| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { onMounted } from 'vue'; |
| | | import { computed, onMounted, ref } from 'vue'; |
| | | |
| | | import { useAccess } from '@vben/access'; |
| | | import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | import { addFullName, getPopupContainer, getVxePopupContainer } from '@vben/utils'; |
| | | |
| | | import { Modal, Popconfirm, Space } from 'ant-design-vue'; |
| | | |
| | | import { useVbenVxeGrid, vxeCheckboxChecked, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; |
| | | import { listRepairRecord } from '#/api/eims/repair-record'; |
| | | import { delRepairRes, listRepairRes, repairResExport } from '#/api/eims/repair-res'; |
| | | import { getDeptTree, userList } from '#/api/system/user'; |
| | | import { REPAIR_RES_STATUS } from '#/constants/dict'; |
| | | import { commonDownloadExcel } from '#/utils/file/download'; |
| | | import BasisSubTable from '#/views/eims/components/basis-sub-table.vue'; |
| | | |
| | | import fbPreviewDrawer from '../repair-fb/fb-preview-drawer.vue'; |
| | | import repairFbDrawer from '../repair-fb/repair-fb-drawer.vue'; |
| | | import { columns as repairRecordCol } from '../repair-record/data'; |
| | | import { columns, querySchema } from './data'; |
| | | import repairResDrawer from './repair-res-drawer.vue'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | |
| | | const userStore = useUserStore(); |
| | | const userId = userStore.userInfo?.userId; |
| | |
| | | id: 'eims-repair-res-index' |
| | | }; |
| | | |
| | | const resId = ref<string>(); |
| | | const [BasicTable, tableApi] = useVbenVxeGrid({ |
| | | formOptions, |
| | | gridOptions, |
| | | gridEvents: { |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) |
| | | sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams), |
| | | cellClick: (e: any) => { |
| | | const { row } = e; |
| | | resId.value = row.id; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | const [RepairResDrawer, repairResDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: repairResDrawer |
| | | }); |
| | | |
| | | const [RepairFbDrawer, repairFbDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: repairFbDrawer |
| | | }); |
| | | |
| | | const [FbPreviewDrawer, fbPreviewDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: fbPreviewDrawer |
| | | }); |
| | | |
| | | function handleAddFb(record: Recordable<any>) { |
| | | repairFbDrawerApi.setData({ resId: record.id, resCode: record.resCode, fbUser: userId, fbDept: deptId }); |
| | | repairFbDrawerApi.open(); |
| | | } |
| | | |
| | | function handleDetailFb(record: Recordable<any>) { |
| | | fbPreviewDrawerApi.setData({ id: record.fbId }); |
| | | fbPreviewDrawerApi.open(); |
| | | } |
| | | |
| | | function handleAdd() { |
| | | repairResDrawerApi.setData({ resUser: userId, resDept: deptId }); |
| | |
| | | async function handleEdit(record: Recordable<any>) { |
| | | repairResDrawerApi.setData({ id: record.id }); |
| | | repairResDrawerApi.open(); |
| | | } |
| | | |
| | | async function handleEditStatus(record: Recordable<any>, status: string) { |
| | | repairResDrawerApi.setData({ id: record.id, action: status, status }); |
| | | repairResDrawerApi.open(); |
| | | } |
| | | |
| | | const { hasAccessByRoles } = useAccess(); |
| | | const isSuperAdmin = computed(() => hasAccessByRoles(['superadmin'])); |
| | | const isLeader = computed(() => hasAccessByRoles(['leader'])); |
| | | |
| | | function pingjiaAdd(row: any) { |
| | | return (isSuperAdmin.value || isLeader.value || row.reqUser === userId) && row.status === REPAIR_RES_STATUS.WANCHENG && !row.fbId; |
| | | } |
| | | |
| | | function pingjiaDetail(row: any) { |
| | | return (isSuperAdmin.value || isLeader.value || row.reqUser === userId) && row.status === REPAIR_RES_STATUS.WANCHENG && row.fbId; |
| | | } |
| | | |
| | | function weixiu(row: any) { |
| | | return (isSuperAdmin.value || isLeader.value || row.resUser === userId) && row.status === REPAIR_RES_STATUS.YIJIEDAN; |
| | | } |
| | | |
| | | function wancheng(row: any) { |
| | | return (isSuperAdmin.value || isLeader.value || row.resUser === userId) && row.status === REPAIR_RES_STATUS.WEIXIU; |
| | | } |
| | | |
| | | async function handleDelete(row: Recordable<any>) { |
| | |
| | | |
| | | <template> |
| | | <Page :auto-content-height="true"> |
| | | <div class="flex h-full gap-[8px]"> |
| | | <BasicTable class="flex-1 overflow-hidden" table-title="维修工单列表"> |
| | | <div class="flex h-full gap-[8px] flex-col"> |
| | | <BasicTable class="h-2/3" table-title="维修工单列表"> |
| | | <template #toolbar-tools> |
| | | <Space> |
| | | <a-button v-access:code="['eims:repairRes:export']" @click="handleDownloadExcel"> |
| | |
| | | > |
| | | {{ $t('pages.common.delete') }} |
| | | </a-button> |
| | | <a-button type="primary" v-access:code="['eims:repairRes:add']" @click="handleAdd"> |
| | | {{ $t('pages.common.add') }} |
| | | </a-button> |
| | | <a-button type="primary" v-access:code="['eims:repairRes:add']" @click="handleAdd"> 接单</a-button> |
| | | </Space> |
| | | </template> |
| | | |
| | | <template #action="{ row }"> |
| | | <Space> |
| | | <ghost-button v-if="pingjiaAdd(row)" class="btn-success" v-access:code="['eims:repairRes:edit']" @click.stop="handleAddFb(row)"> |
| | | 评价 |
| | | </ghost-button> |
| | | <ghost-button v-if="pingjiaDetail(row)" class="btn-success" v-access:code="['eims:repairRes:edit']" @click.stop="handleDetailFb(row)"> |
| | | 阅评 |
| | | </ghost-button> |
| | | <ghost-button |
| | | v-if="weixiu(row)" |
| | | class="btn-success" |
| | | v-access:code="['eims:repairRes:edit']" |
| | | @click.stop="handleEditStatus(row, REPAIR_RES_STATUS.WEIXIU)" |
| | | > |
| | | 维修 |
| | | </ghost-button> |
| | | |
| | | <ghost-button |
| | | v-if="wancheng(row)" |
| | | class="btn-success" |
| | | v-access:code="['eims:repairRes:edit']" |
| | | @click.stop="handleEditStatus(row, REPAIR_RES_STATUS.WANCHENG)" |
| | | > |
| | | 完成 |
| | | </ghost-button> |
| | | |
| | | <ghost-button v-access:code="['eims:repairRes:edit']" @click.stop="handleEdit(row)"> |
| | | {{ $t('pages.common.edit') }} |
| | | </ghost-button> |
| | |
| | | </Space> |
| | | </template> |
| | | </BasicTable> |
| | | <BasisSubTable :columns="repairRecordCol" :list-api="listRepairRecord" :req-value="resId" class="h-1/3" req-key="resId" title="操作记录" /> |
| | | </div> |
| | | <RepairResDrawer @reload="tableApi.query()" /> |
| | | <RepairFbDrawer @reload="tableApi.query()" /> |
| | | <FbPreviewDrawer /> |
| | | </Page> |
| | | </template> |