123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <div>
- <BasicTable @register="registerTable">
- <template #toolbar>
- <!-- <a-button
- v-power="[RoleEnum.COMPANY_ADMIN, RoleEnum.PLAT_ADMIN]"
- type="primary"
- @click="handleCreate"
- >新增</a-button
- > -->
- </template>
- <template #headerTop v-if="getCheckRole([RoleEnum.COMPANY_ADMIN])">
- <Alert
- :message="`带看权益为 ${surplusSubNum.lookNum} 个、拍摄权益为 ${surplusSubNum.shotNum} 个`"
- type="info"
- />
- </template>
- <template #role="{ record }">
- {{ renderRoleType(record.role) }}
- </template>
- <template #status="{ record }">
- {{ renderStatus(record.status) }}
- </template>
- <template #createTime="{ record }">
- <Time :value="record.createTime" mode="datetime" />
- </template>
- <template #action="{ record }">
- <TableAction
- :actions="[
- {
- label: '查看',
- onClick: handleEdit.bind(null, record),
- },
- {
- color: 'warning',
- label: t('routes.rightsEnterprises.add'),
- onClick: handleOpenModal.bind(null, record),
- },
- ]"
- />
- </template>
- </BasicTable>
- <addModal @register="register" @update="reload" />
- <ProductDrawer @register="registerDrawer" type="rights" @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 { Alert } from 'ant-design-vue';
- import { ListApi, delApi, getNumByStaff } from '/@/api/rightsEnterprises/list';
- import { useDrawer } from '/@/components/Drawer';
- import { useI18n } from '/@/hooks/web/useI18n';
- import ProductDrawer from './productDrawer.vue';
- import { RoleEnum } from '/@/enums/roleEnum';
- import { useGo } from '/@/hooks/web/usePage';
- import addModal from './addModal.vue';
- import { Time } from '/@/components/Time';
- import { useUserStore } from '/@/store/modules/user';
- import { useRouter } from 'vue-router';
- export default defineComponent({
- components: {
- BasicTable,
- TableAction,
- Time,
- Alert,
- addModal,
- ProductDrawer,
- },
- setup() {
- const router = useRouter();
- const [register, { openModal }] = useModal();
- const [registerDrawer, { openDrawer }] = useDrawer();
- const surplusSubNum = ref({
- lookNum: 0,
- shotNum: 0,
- });
- const { createConfirm, createMessage } = useMessage();
- const userStore = useUserStore();
- const { getCheckRole } = userStore;
- const userinfo = computed(() => userStore.getUserInfo);
- const companyId = ref(userinfo.value.companyId);
- const go = useGo();
- const { t } = useI18n();
- console.log('companyId', companyId);
- if (companyId.value) {
- router.replace(`detail/${companyId.value}`);
- }
- onMounted(() => {
- getNumByStaffData();
- });
- const columns: BasicColumn[] = [
- {
- title: 'ID',
- dataIndex: 'companyId',
- fixed: 'left',
- width: 60,
- },
- {
- title: t('routes.staff.deptName'),
- dataIndex: 'companyName',
- width: 160,
- },
- {
- title: t('routes.rightsEnterprises.companyPhone'),
- dataIndex: 'companyPhone',
- width: 80,
- },
- {
- title: t('routes.rightsEnterprises.userPermNum'),
- dataIndex: 'userPermNum',
- width: 130,
- },
- {
- title: t('routes.rightsEnterprises.exUserPermNum'),
- dataIndex: 'exUserPermNum',
- sorter: true,
- width: 130,
- },
- {
- title: t('routes.staff.createTime'),
- dataIndex: 'createTime',
- slots: { customRender: 'createTime' },
- width: 130,
- },
- {
- title: '操作',
- dataIndex: '',
- ifShow: !getCheckRole('tourist'),
- slots: { customRender: 'action' },
- fixed: 'right',
- width: 120,
- },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 100,
- schemas: [
- {
- field: 'fieldTime',
- component: 'RangePicker',
- label: t('routes.rightsEnterprises.timeField'),
- colProps: {
- span: 8,
- },
- },
- ],
- };
- const [registerTable, { reload }] = useTable({
- title: t('routes.rightsEnterprises.menuList'),
- api: ListApi,
- columns: columns,
- useSearchForm: true,
- formConfig: searchForm,
- showTableSetting: true,
- tableSetting: { fullScreen: true },
- showIndexColumn: true,
- rowKey: 'id',
- pagination: { pageSize: 20 },
- beforeFetch: (T) => {
- return {
- limit: T.limit,
- page: T.page,
- startTime: T.fieldTime?.[0],
- endTime: T.fieldTime?.[1],
- };
- },
- 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) {
- console.log('Received', record);
- openModal(true, record);
- }
- function getNumByStaffData() {
- getNumByStaff({}).then((res) => {
- surplusSubNum.value.lookNum = res.lookNum;
- surplusSubNum.value.shotNum = res.shotNum;
- });
- }
- function handleEdit(record) {
- // router.push(`detail/${record.companyId}`);
- openDrawer(true, {
- record,
- isUpdate: true,
- });
- }
- function handDelconfirm(record) {
- createConfirm({
- iconType: 'warning',
- title: '警告',
- content: `此操作将对${record.userName}进行删除, 是否继续?`,
- onOk: async () => {
- await delApi({ userId: record.id });
- reload();
- },
- });
- }
- return {
- registerTable,
- createMessage,
- handDelconfirm,
- t,
- reload,
- openModal,
- go,
- renderRoleType,
- renderStatus,
- handleOpenModal,
- handleEdit,
- register,
- uploadApi: uploadApi as any,
- RoleEnum,
- surplusSubNum,
- getCheckRole,
- getNumByStaffData,
- registerDrawer,
- };
- },
- });
- </script>
|