From fd0e324bc94f411ac774f081f5952066c7f7557c Mon Sep 17 00:00:00 2001 From: my_ong <429426262@qq.com> Date: Wed, 5 Mar 2025 23:45:19 +0800 Subject: [PATCH] =?UTF-8?q?tada:=20:tada:=20=E6=96=B0=E5=A2=9E=E7=9B=98?= =?UTF-8?q?=E7=82=B9=E6=8A=BD=E5=B1=89=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=8C=E5=BE=85=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/material/api.d.ts | 3 + src/views/stock/stocktaking/form.ts | 25 +++++++- .../stock/stocktaking/stocktaking-page.vue | 64 +++++++++++++------ vite.config.ts | 4 +- 4 files changed, 70 insertions(+), 26 deletions(-) diff --git a/src/api/material/api.d.ts b/src/api/material/api.d.ts index a8656fe..8872bd5 100644 --- a/src/api/material/api.d.ts +++ b/src/api/material/api.d.ts @@ -146,6 +146,9 @@ declare namespace material { /** 物料ids */ ids?: Array + /** 物料类型 */ + types?: Array + /** 审核意见 */ reviewRemark?: string diff --git a/src/views/stock/stocktaking/form.ts b/src/views/stock/stocktaking/form.ts index 7e4d4d0..86d9192 100644 --- a/src/views/stock/stocktaking/form.ts +++ b/src/views/stock/stocktaking/form.ts @@ -1,4 +1,5 @@ import { FormItem, FormConfig } from '@/components/form-render/form-render-types' +import { TreeDataNode } from 'ant-design-vue/es/vc-tree-select/interface' export const config: FormConfig = { layout: 'horizontal', @@ -17,6 +18,7 @@ export const formItems = ( materialOptions: Array<{ value: string | undefined; label: string | undefined }>, required: boolean, persons: Array<{ value: string | undefined; label: string | undefined }>, + types: Array, ): FormItem[] => [ { group: 'form', @@ -32,14 +34,30 @@ export const formItems = ( size: 'default', optionType: 'button', buttonStyle: 'solid', - defaultValue: 'ALL', + defaultValue: 'SCAN', options: [ - { value: 'ALL', label: '全部盘点' }, - { value: 'PARTIAL', label: '部分盘点' }, + { value: 'SCAN', label: '扫码盘点' }, + { value: 'PARTIAL', label: '人工盘点' }, ], }, rules: [], }, + { + type: 'tree-select', + group: 'form', + config: { + label: '物料类型选择', + name: 'types', + required: true, + }, + properties: { + size: 'default', + placeholder: '请选择物料类型', + multiple: true, + treeData: types, + }, + rules: [], + }, { group: 'form', type: 'select', @@ -49,6 +67,7 @@ export const formItems = ( hasFeedback: false, label: '物料选择', name: 'ids', + required: true, }, properties: { size: 'default', diff --git a/src/views/stock/stocktaking/stocktaking-page.vue b/src/views/stock/stocktaking/stocktaking-page.vue index adb69c0..7f345ab 100644 --- a/src/views/stock/stocktaking/stocktaking-page.vue +++ b/src/views/stock/stocktaking/stocktaking-page.vue @@ -78,7 +78,6 @@ v-model="applyForm" :form-items="items" :config="formConfig" - :disabled-fields="disabledFields" title="扫码盘点" @ok="doSave" /> @@ -121,6 +120,7 @@ import { useUserStore } from '@/stores/user' import scanForm from '../component/scan-form.vue' import resultForm from './result-form.vue' + import { TreeDataNode } from 'ant-design-vue/es/vc-tree-select/interface' const searchKey = ref('') const userStore = useUserStore() @@ -135,6 +135,7 @@ applyDate: dayjs() + '', confirm: false, reviewResult: 'WAIT_SCAN', + types: [], }) const msg = ref() const totalValue = ref(0) // 盘点总值 @@ -147,14 +148,6 @@ const materialList = ref>([]) const personList = ref>([]) const required = ref(true) - api.materialApi.material.all({}, (data) => { - materialList.value = data.map((item) => { - return { - value: item?.id + '', - label: item?.name, - } - }) - }) api.aclApi.user.all((data) => { personList.value = data.map((item) => { return { @@ -164,19 +157,48 @@ }) }) - //是否必填 - const disabledFields = computed(() => { - return applyForm.value?.auditType === 'ALL' ? ['ids'] : [] - }) + // //是否必填 + // const disabledFields = computed(() => { + // return applyForm.value?.auditType === 'ALL' ? ['ids'] : [] + // }) - // 监听盘点类型是否时部分盘点,部分盘点时必填 - watch(applyForm, () => { - if (applyForm.value && applyForm.value.auditType === 'ALL') { - required.value = false - } else { - required.value = true - } + // 监听选择类型后查询物料 + watch( + applyForm, + () => { + if (applyForm.value && applyForm.value.types && applyForm.value.types.length > 0) { + getMaterialList() + } + }, + { + immediate: true, + deep: true, + }, + ) + + // 物料类型树 + const types = ref>([]) + api.materialApi.type.trees((data) => { + types.value = children(data) }) + const children = (res: Array): Array => { + return res.map((areaTree) => ({ + label: areaTree.label, + value: areaTree.value, + children: areaTree.children ? children(areaTree.children) : [], + key: areaTree.value, + })) + } + const getMaterialList = async () => { + await api.materialApi.material.all({ type: '' }, (data) => { + materialList.value = data.map((item) => { + return { + value: item?.id + '', + label: item?.name, + } + }) + }) + } //抽屉组件 const formDrawer = ref() @@ -186,7 +208,7 @@ //表单配置 const items = computed(() => { //required 参数未生效 - return formItems(materialList.value, required.value, personList.value) + return formItems(materialList.value, required.value, personList.value, types.value) }) // 加载数据的方法 const loadData = async (page = 1, size = 10) => { diff --git a/vite.config.ts b/vite.config.ts index 3b82e6b..8974332 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -59,8 +59,8 @@ export default defineConfig(({ mode }) => { open: true, proxy: { '/api': { - // target: 'https://ims.riemann.tech/api/', - target: 'http://127.0.0.1:8888', + target: 'https://ims.riemann.tech/api/', + // target: 'http://127.0.0.1:8888', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), },