123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <template>
- <div class="p-4">
- <BasicTable @register="registerTable">
- <template #toolbar>
- <a-button
- type="primary"
- @click="handleCreate"
- v-if="getCheckPerm('application-add')"
- >新增</a-button
- >
- </template>
- <!-- , -->
- <template #action="{ record }">
- <TableAction
- :actions="[
- {
- label: '删除',
- ifShow: getCheckPerm('application-delete'),
- color: 'error',
- onClick:handDelconfirm.bind(null, record),
- },
- ]"
- />
- </template>
- </BasicTable>
- <DetailsModal @register="registerDetail" @ok="reload" />
- <!--<DelListModal @register="registerDelList" @reload="reload" /> -->
- </div>
- </template>
- <script lang="ts">
- import { defineComponent, computed, onMounted, ref, } from 'vue';
- import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { useModal } from '/@/components/Modal';
- import { uploadApi } from '/@/api/sys/upload';
- import DetailsModal from './detailsModal.vue';
- import { buryPointList, buryPointDlt } from '/@/api/statistics/index';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { RoleEnum } from '/@/enums/roleEnum';
- import { useGo } from '/@/hooks/web/usePage';
- import { Time } from '/@/components/Time';
- import { useUserStore } from '/@/store/modules/user';
- import { usePermissionStore } from '/@/store/modules/permission';
- export default defineComponent({
- components: {
- BasicTable,
- TableAction,
- Time,
- DetailsModal,
- // DelListModal,
- },
- setup() {
- const [register, { openModal }] = useModal();
- const surplusSubNum = ref({
- lookNum: 0,
- shotNum: 0,
- });
- const [registerDetail, { openModal: openDetaileModal }] = useModal();
- const [registerDelList, { openModal: openDelListeModal }] = useModal();
- const { createConfirm, createMessage } = useMessage();
- const permissionStore = usePermissionStore();
- const { getCheckPerm } = permissionStore;
- const userStore = useUserStore();
- // const { getCheckRole } = userStore;
- const roleList = computed(() => userStore.getRoleList);
- console.log('getRoleList', roleList);
- const go = useGo();
- const { t } = useI18n();
- onMounted(() => {
- // getNumByStaffData();
- });
- const columns: BasicColumn[] = [
- {
- title: '应用名称',
- dataIndex: 'applicationName',
- },
- {
- title: '应用key',
- dataIndex: 'applicationKey',
- },
- {
- title: '操作',
- align: 'center',
- dataIndex: '',
- flag:'ACTION',
- // ifShow: !getCheckRole('tourist'),
- slots: { customRender: 'action' },
- fixed: 'right',
- width: 150,
- },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 100,
- autoSubmitOnEnter:true,
- schemas: [
- {
- field: 'applicationName',
- label: '应用名称',
- component: 'Input',
- componentProps: {
- maxLength: 15,
- },
- colProps: {
- xl: 6,
- xxl: 6,
- },
- },
- ],
- };
- const [registerTable, { reload }] = useTable({
- title: '应用列表',
- api: buryPointList,
- columns: columns,
- useSearchForm: true,
- formConfig: searchForm,
- showTableSetting: true,
- tableSetting: { fullScreen: true },
- showIndexColumn: false,
- rowKey: 'id',
- fetchSetting: {
- pageField: 'pageNum',
- sizeField: 'pageSize',
- listField: 'list',
- totalField: 'total',
- },
- pagination: { pageSize: 20 },
- afterFetch: (T) => {
- return T;
- },
- bordered: true,
- sortFn: (sortInfo) => {
- let order = sortInfo.order && sortInfo.order.replace('end', '');
- return { ...sortInfo, sidx: sortInfo.field, order: order };
- },
- });
- function renderRoleType(type: number): string {
- switch (type) {
- case 0:
- return t('routes.staff.roleType.0');
- case 1:
- return t('routes.staff.roleType.1');
- default:
- return '';
- }
- }
- function renderStatus(type: number): string {
- switch (type) {
- case 1:
- return t('common.normal');
- case 0:
- return t('common.unNormal');
- default:
- return '';
- }
- }
- function handleOpenModal(record: Recordable) {
- openModal(true, record);
- }
- function handleCreate() {
- // if (
- // getCheckRole([RoleEnum.COMPANY_ADMIN]) &&
- // surplusSubNum.value.lookNum == 0 &&
- // surplusSubNum.value.shotNum == 0
- // ) {
- // return createMessage.error('新增失败,可添加员工数量为0个');
- // }
- openDetaileModal(true, {});
- }
- function handleEdit(record: Recordable) {
- openDetaileModal(true, {
- ...record,
- phone:record.userName,
- });
- }
- function handDelconfirm(record) {
- createConfirm({
- iconType: 'warning',
- title: '警告',
- content: `此操作将对${record.applicationName}进行删除, 是否继续?`,
- onOk: async () => {
- await buryPointDlt({ id: record.id });
- reload();
- createMessage.success(t('common.optSuccess'));
- },
- });
- }
- return {
- registerTable,
- registerDetail,
- registerDelList,
- openDelListeModal,
- createMessage,
- handDelconfirm,
- t,
- reload,
- go,
- renderRoleType,
- renderStatus,
- handleCreate,
- handleOpenModal,
- register,
- handleEdit,
- uploadApi: uploadApi as any,
- RoleEnum,
- surplusSubNum,
- getCheckPerm,
- };
- },
- });
- </script>
|