From 74448f9a9f1f8cb779023db3ea9eda762fc6ad0a Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期五, 28 二月 2025 14:29:42 +0800 Subject: [PATCH] 维修工接单、维修 --- eims-ui/apps/web-antd/src/views/eims/repair-res/index.vue | 73 ++++++++++++++++++++++++++++++++---- 1 files changed, 64 insertions(+), 9 deletions(-) diff --git a/eims-ui/apps/web-antd/src/views/eims/repair-res/index.vue b/eims-ui/apps/web-antd/src/views/eims/repair-res/index.vue index d4f5852..b2b4668 100644 --- a/eims-ui/apps/web-antd/src/views/eims/repair-res/index.vue +++ b/eims-ui/apps/web-antd/src/views/eims/repair-res/index.vue @@ -1,22 +1,25 @@ <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 { 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'; 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; @@ -74,11 +77,16 @@ 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; + } } }); @@ -94,6 +102,27 @@ 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'])); + +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>) { @@ -119,6 +148,15 @@ 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 () => { @@ -195,8 +233,8 @@ <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"> @@ -211,14 +249,30 @@ > {{ $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> @@ -230,6 +284,7 @@ </Space> </template> </BasicTable> + <RepairRecord :res-id="resId" class="h-1/3" table-title="缁翠慨璁板綍" /> </div> <RepairResDrawer @reload="tableApi.query()" /> </Page> -- Gitblit v1.9.3