|
@@ -0,0 +1,288 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <BasicTable @register="registerTable">
|
|
|
+ <template #toolbar>
|
|
|
+ <a-button
|
|
|
+ v-power="[RoleEnum.COMPANY_ADMIN, RoleEnum.PLAT_ADMIN]"
|
|
|
+ type="primary"
|
|
|
+ @click="handleOpenModal"
|
|
|
+ >
|
|
|
+ 新增</a-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ <template #status="{ record }">
|
|
|
+ {{ renderStatus(record.state) }}
|
|
|
+ </template>
|
|
|
+ <template #createTime="{ record, field }">
|
|
|
+ <Time v-if="record[field]" :value="record[field]" mode="date" />
|
|
|
+ </template>
|
|
|
+ <!-- onClick: handleOpenModal.bind(null, record),
|
|
|
+ ifShow: record.state == 0 && !!record.userId,
|
|
|
+ ifShow: !!record.userId,
|
|
|
+ -->
|
|
|
+ <template #action="{ record }">
|
|
|
+ <TableAction
|
|
|
+ :actions="[
|
|
|
+ {
|
|
|
+ label: '授权',
|
|
|
+ ifShow: !record.snCode,
|
|
|
+ onClick: handleDelete.bind(null, record),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '解绑',
|
|
|
+ color: 'error',
|
|
|
+ ifShow: !!record.snCode,
|
|
|
+ onClick: handleUpBind.bind(null, record),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ <addCameraModal @register="register" @update="reload" />
|
|
|
+ <BindModal @register="registerDelList" @update="reload" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { defineComponent, computed, onMounted, ref, watch, reactive } 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 BindModal from './cameraBind.vue';
|
|
|
+ import addCameraModal from './addCameraModal.vue';
|
|
|
+ import { cameraDetailList, unbindCamera } from '/@/api/rightsEnterprises/list';
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
|
|
|
+ import { RoleEnum } from '/@/enums/roleEnum';
|
|
|
+ import { useGo } from '/@/hooks/web/usePage';
|
|
|
+ import { Time } from '/@/components/Time';
|
|
|
+ import { useUserStore } from '/@/store/modules/user';
|
|
|
+ export default defineComponent({
|
|
|
+ name: 'StaffList',
|
|
|
+ components: {
|
|
|
+ BasicTable,
|
|
|
+ TableAction,
|
|
|
+ Time,
|
|
|
+ BindModal,
|
|
|
+ addCameraModal,
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ companyInfo: {
|
|
|
+ type: Object,
|
|
|
+ default: function () {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ setup(props) {
|
|
|
+ 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 userStore = useUserStore();
|
|
|
+ const { getCheckRole } = userStore;
|
|
|
+ const userinfo = computed(() => userStore.getUserInfo);
|
|
|
+ const modelRef = reactive({
|
|
|
+ companyId: userinfo.value.companyId,
|
|
|
+ companyName: '0',
|
|
|
+ companyPhone: '',
|
|
|
+ });
|
|
|
+ const go = useGo();
|
|
|
+ const { t } = useI18n();
|
|
|
+ watch(
|
|
|
+ () => props.companyInfo,
|
|
|
+ (newProps) => {
|
|
|
+ modelRef.companyId = newProps.companyId;
|
|
|
+ modelRef.companyName = newProps.companyName;
|
|
|
+ modelRef.companyPhone = newProps.companyPhone;
|
|
|
+ console.log('companyInfo', modelRef);
|
|
|
+ reload();
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ );
|
|
|
+ onMounted(() => {
|
|
|
+ getNumByStaffData();
|
|
|
+ });
|
|
|
+
|
|
|
+ const columns: BasicColumn[] = [
|
|
|
+ {
|
|
|
+ title: '相机权益ID',
|
|
|
+ dataIndex: 'id',
|
|
|
+ fixed: 'left',
|
|
|
+ width: 50,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('routes.rightsEnterprises.snCode'),
|
|
|
+ dataIndex: 'snCode',
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('routes.rightsEnterprises.cameraIncrementTypeName'),
|
|
|
+ dataIndex: 'cameraIncrementTypeName',
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('routes.rightsEnterprises.companyName'),
|
|
|
+ dataIndex: 'companyName',
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('routes.rightsEnterprises.companyPhone'),
|
|
|
+ dataIndex: 'companyPhone',
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('routes.rightsEnterprises.purchaseTime'),
|
|
|
+ dataIndex: 'createTime',
|
|
|
+ // slots: { customRender: 'createTime' },
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: t('routes.rightsEnterprises.expirationTime'),
|
|
|
+ dataIndex: 'incrementEndTime',
|
|
|
+ // slots: { customRender: 'createTime' },
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: '',
|
|
|
+ ifShow: !getCheckRole('tourist'),
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ fixed: 'right',
|
|
|
+ width: 60,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const searchForm: Partial<FormProps> = {
|
|
|
+ labelWidth: 100,
|
|
|
+ schemas: [
|
|
|
+ {
|
|
|
+ field: 'staffName',
|
|
|
+ label: t('routes.rightsEnterprises.staffName'),
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ maxLength: 15,
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ span: 8,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'staffPhone',
|
|
|
+ label: t('routes.corporation.phone'),
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ maxLength: 15,
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ span: 8,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ const [registerTable, { reload }] = useTable({
|
|
|
+ title: t('routes.rightsEnterprises.staffList'),
|
|
|
+ api: cameraDetailList,
|
|
|
+ columns: columns,
|
|
|
+ useSearchForm: true,
|
|
|
+ formConfig: searchForm,
|
|
|
+ showTableSetting: true,
|
|
|
+ tableSetting: { fullScreen: true },
|
|
|
+ showIndexColumn: true,
|
|
|
+ rowKey: 'id',
|
|
|
+ pagination: { pageSize: 20 },
|
|
|
+ searchInfo: modelRef,
|
|
|
+ afterFetch: (T) => {
|
|
|
+ getNumByStaffData();
|
|
|
+ return T;
|
|
|
+ },
|
|
|
+ bordered: true,
|
|
|
+ sortFn: (sortInfo) => {
|
|
|
+ let order = sortInfo.order && sortInfo.order.replace('end', '');
|
|
|
+ return { ...sortInfo, sidx: sortInfo.field, order: order };
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ function renderStatus(type: number): string {
|
|
|
+ switch (type) {
|
|
|
+ // case 0:
|
|
|
+ // return t('routes.rightsEnterprises.state.0');
|
|
|
+ // case 1:
|
|
|
+ // return t('routes.rightsEnterprises.state.1');
|
|
|
+ case 2:
|
|
|
+ return t('routes.rightsEnterprises.state.2');
|
|
|
+ default:
|
|
|
+ return t('routes.rightsEnterprises.state.9');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function handleOpenModal() {
|
|
|
+ openModal(true, modelRef);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ function getNumByStaffData() {
|
|
|
+ // getNumByStaff({}).then((res) => {
|
|
|
+ // surplusSubNum.value.lookNum = res.lookNum;
|
|
|
+ // surplusSubNum.value.shotNum = res.shotNum;
|
|
|
+ // });
|
|
|
+ }
|
|
|
+ async function handleDelete(record) {
|
|
|
+ return openDelListeModal(true, {
|
|
|
+ ...record,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ function handleUpBind(record) {
|
|
|
+ createConfirm({
|
|
|
+ iconType: 'warning',
|
|
|
+ title: '温馨提醒',
|
|
|
+ content: `是否确定解绑相机?`,
|
|
|
+ onOk: async () => {
|
|
|
+ await unbindCamera({ id: record.id });
|
|
|
+ reload();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ registerTable,
|
|
|
+ registerDetail,
|
|
|
+ registerDelList,
|
|
|
+ openDelListeModal,
|
|
|
+ createMessage,
|
|
|
+ modelRef,
|
|
|
+ handleUpBind,
|
|
|
+ t,
|
|
|
+ reload,
|
|
|
+ go,
|
|
|
+ renderStatus,
|
|
|
+ handleCreate,
|
|
|
+ handleOpenModal,
|
|
|
+ register,
|
|
|
+ handleEdit,
|
|
|
+ handleDelete,
|
|
|
+ uploadApi: uploadApi as any,
|
|
|
+ RoleEnum,
|
|
|
+ surplusSubNum,
|
|
|
+ getCheckRole,
|
|
|
+ getNumByStaffData,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+</script>
|