| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { onMounted, ref } 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 { Modal, Popconfirm, Space } from 'ant-design-vue'; |
| | | |
| | | import { useVbenVxeGrid, vxeCheckboxChecked, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; |
| | | import { delRepairRes, listRepairRes, repairResExport } from '#/api/eims/repair-res'; |
| | | import { delRepairRes, listRepairRes, repairResExport, updateRepairRes } 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 RepairRecord from '../repair-record/index.vue'; |
| | |
| | | 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'])); |
| | | |
| | | function weixiu(row: any) { |
| | | return (isSuperAdmin.value || row.resUser === userId) && row.status === REPAIR_RES_STATUS.YIJIEDAN; |
| | | } |
| | | |
| | | function wancheng(row: any) { |
| | | return (isSuperAdmin.value || row.resUser === userId) && row.status === REPAIR_RES_STATUS.WEIXIU; |
| | | } |
| | | |
| | | async function handleRepairStatus(record: Recordable<any>, status: string) { |
| | | record.status = status; |
| | | handleConfirm(record); |
| | | } |
| | | |
| | | async function handleDelete(row: Recordable<any>) { |
| | | await delRepairRes(row.id); |
| | | await tableApi.query(); |
| | |
| | | commonDownloadExcel(repairResExport, '维修工单记录', tableApi.formApi.form.values, { |
| | | fieldMappingTime: formOptions.fieldMappingTime |
| | | }); |
| | | } |
| | | |
| | | async function handleConfirm(data: any) { |
| | | try { |
| | | await updateRepairRes(data); |
| | | } catch (error) { |
| | | console.error(error); |
| | | } finally { |
| | | } |
| | | } |
| | | |
| | | onMounted(async () => { |
| | |
| | | > |
| | | {{ $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="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> |