From 609b918b24e8dbbe75bf2eaef7a532308d83a708 Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期三, 16 四月 2025 10:06:47 +0800 Subject: [PATCH] 完成备件模块 --- eims-ui/apps/web-antd/src/views/eims/spare-in/spare-in-drawer.vue | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 108 insertions(+), 2 deletions(-) diff --git a/eims-ui/apps/web-antd/src/views/eims/spare-in/spare-in-drawer.vue b/eims-ui/apps/web-antd/src/views/eims/spare-in/spare-in-drawer.vue index 263c7ac..919183e 100644 --- a/eims-ui/apps/web-antd/src/views/eims/spare-in/spare-in-drawer.vue +++ b/eims-ui/apps/web-antd/src/views/eims/spare-in/spare-in-drawer.vue @@ -1,7 +1,7 @@ <script setup lang="ts"> import { computed, ref } from 'vue'; -import { useVbenDrawer } from '@vben/common-ui'; +import { useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; import { addFullName, cloneDeep, getPopupContainer } from '@vben/utils'; @@ -11,7 +11,72 @@ import { drawerSchema } from './data'; import CodeInput from '#/views/eims/components/code-input.vue'; +import spareModal from '#/views/eims/components/spare-modal.vue'; +import SelectSpareTable from '#/views/eims/spare-out/select-spare-table.vue'; +import { message } from 'ant-design-vue'; +import type { VxeGridProps } from '#/adapter/vxe-table'; +import { renderDict } from '#/utils/render'; +import { DictEnum } from '@vben/constants'; +/** + * 鍑哄簱鍗曢�夋嫨鐨勫浠舵暟鎹� + */ +const outSpareList = ref([]); +const selectSpareTable = ref(); +const outCol: VxeGridProps['columns'] = [ + { + field: 'action', + slots: { default: 'action' }, + title: '鍒犻櫎', + width: 60 + }, + { + title: '澶囦欢鍚嶇О', + field: 'name', + width: 180 + }, + { + title: '澶囦欢缂栫爜', + field: 'code', + width: 120 + }, + { + title: '澶囦欢鍨嬪彿', + field: 'modelNo', + width: 100 + }, + { + title: '璁¢噺鍗曚綅', + field: 'unit', + slots: { + default: ({ row }) => { + if (!row.unit || row.unit === '') { + return ''; + } + return renderDict(row.unit, DictEnum.EIMS_SPARE_UNIT); + } + }, + width: 80 + }, + { + title: '瀹為檯搴撳瓨', + field: 'actualStock', + width: 100 + }, + { + title: '鏁伴噺', + field: 'quantity', + editRender: { + name: 'input' + }, + width: 80 + }, + { + title: '鍙傝�冧环', + field: 'referPrice', + width: 90 + } +]; const emit = defineEmits<{ reload: [] }>(); const isUpdate = ref(false); @@ -39,6 +104,7 @@ if (!isOpen) { return null; } + outSpareList.value = []; drawerApi.drawerLoading(true); const { id } = drawerApi.getData() as { id?: number | string }; isUpdate.value = !!id; @@ -48,6 +114,10 @@ if (isUpdate.value && id) { const record = await getSpareInout(id); await formApi.setValues(record); + outSpareList.value = record?.spareList; + if (isUpdate.value && record.chargeDept) { + await setupUserOptions(record.chargeDept); + } } drawerApi.drawerLoading(false); @@ -127,7 +197,15 @@ if (!valid) { return; } + const selectSpareList = selectSpareTable.value.tableData(); + // 妫�娴嬫槸鍚﹁緭鍏ュ嚭搴撴暟閲� + const eList = selectSpareList.filter((item: any) => !item.quantity || item.quantity <= 0); + if (selectSpareList.length<= 0 || eList.length > 0) { + message.error('鍏ュ簱鏁伴噺涓虹┖锛岃妫�鏌ワ紒'); + return false; + } const data = cloneDeep(await formApi.getValues()); + data.spareList = selectSpareList; await (isUpdate.value ? updateSpareInout(data) : addSpareInout(data)); emit('reload'); await handleCancel(); @@ -142,14 +220,42 @@ drawerApi.close(); await formApi.resetForm(); } + +// 澶囦欢modal +const [SpareModal, spareModalApi] = useVbenModal({ + connectedComponent: spareModal, + draggable: true, + title: '閫夋嫨澶囦欢' +}); + +function handleSpareModal() { + spareModalApi.setData({}); + spareModalApi.open(); +} + +/** + * 閫夋嫨鐨勫浠� + * @param spareList + */ +function selectSpare(spareList: any) { + outSpareList.value = spareList; +} </script> <template> - <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[600px]"> + <BasicDrawer :close-on-click-modal="false" :title="title" class="w-[1000px]"> <BasicForm> <template #orderCode="slotProps"> <CodeInput v-bind="slotProps" :disabled="isUpdate" prefix="RK" /> </template> + <template #openSpare="slotProps"> + <a-button type="primary" v-bind="slotProps" :disabled="isUpdate" @click.stop="handleSpareModal">娣诲姞澶囦欢</a-button> + </template> + <template #outSpareList> + <SelectSpareTable ref="selectSpareTable" :columns="outCol" :data="outSpareList" :is-update="isUpdate" /> + </template> </BasicForm> + + <SpareModal class="w-[1200px]" @update-select="selectSpare" /> </BasicDrawer> </template> -- Gitblit v1.9.3