From 6ee935ccb60c6497569e0da75b38fb7e162c954e Mon Sep 17 00:00:00 2001 From: re-JZzzz Date: Mon, 29 Sep 2025 20:09:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BE=9B=E5=BA=94=E5=95=86=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=B9=B6=E4=BC=98=E5=8C=96=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(出入库管理): 添加产品ID字段并调整默认单据类型 fix(备品配件): 修正库存数量输入类型为数字并移除调试日志 feat(文件上传): 支持后端文件格式转换并暴露清空方法 style(库存管理): 调整单据类型默认值及表单字段顺序 perf(采购计划): 优化供应商选择及文件上传处理逻辑 --- src/api/wuziguanli/caigouPlan/types.ts | 13 ++- src/api/wuziguanli/churuku/types.ts | 13 +++ src/components/FileUpload/index.vue | 76 +++++++++---- .../components/detailInfo.vue | 2 +- .../inventoryManagement.vue | 39 ++++--- .../materialManagement/procurementPlan.vue | 100 +++++++++++------- src/views/materialManagement/spareParts.vue | 7 +- 7 files changed, 172 insertions(+), 78 deletions(-) diff --git a/src/api/wuziguanli/caigouPlan/types.ts b/src/api/wuziguanli/caigouPlan/types.ts index 4085c5c..47f53b7 100644 --- a/src/api/wuziguanli/caigouPlan/types.ts +++ b/src/api/wuziguanli/caigouPlan/types.ts @@ -182,6 +182,10 @@ export interface CaigouPlanVO { * 申请原因 */ reason?: string; + /** + * 供应商名称 + */ + gonyingshangName?: string; } @@ -368,7 +372,10 @@ export interface CaigouPlanForm extends BaseEntity { * 申请原因 */ reason?: string; - + /** + * 供应商名称 + */ + gonyingshangName?: string; } export interface CaigouPlanQuery extends PageQuery { @@ -556,6 +563,10 @@ export interface CaigouPlanQuery extends PageQuery { * 申请原因 */ reason?: string; + /** + * 供应商名称 + */ + gonyingshangName?: string; } diff --git a/src/api/wuziguanli/churuku/types.ts b/src/api/wuziguanli/churuku/types.ts index d901e94..4457dc5 100644 --- a/src/api/wuziguanli/churuku/types.ts +++ b/src/api/wuziguanli/churuku/types.ts @@ -55,6 +55,10 @@ export interface ChurukudanVO { * 产品名称 */ chanpinName?: string; + /** + * 产品id + */ + chanpinId?: string | number; } export interface ChurukudanForm extends BaseEntity { @@ -114,6 +118,11 @@ export interface ChurukudanForm extends BaseEntity { * 产品名称 */ chanpinName?: string; + /** + * 产品id + */ + chanpinId?: string | number; + } export interface ChurukudanQuery extends PageQuery { @@ -158,6 +167,10 @@ export interface ChurukudanQuery extends PageQuery { * 结束日期 */ endDate?: string; + /** + * 产品id + */ + chanpinId?: string | number; /** * 日期范围参数 */ diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 13093ec..e480c89 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -1,5 +1,16 @@ @@ -55,7 +55,7 @@ import { propTypes } from '@/utils/propTypes'; import { delOss, listByIds } from '@/api/system/oss'; import { globalHeaders } from '@/utils/request'; - +import { ref } from 'vue'; const props = defineProps({ modelValue: { type: [String, Object, Array], @@ -89,6 +89,16 @@ const showTip = computed(() => props.isShowTip && (props.fileType || props.fileS const fileUploadRef = ref(); +// 暴露方法给父组件 +defineExpose({ + // 清空所有文件 + clearAllFiles: () => { + fileList.value = []; + emit('update:modelValue', ''); + emit('update:fileList', []); + } +}); + // 监听 fileType 变化,更新 fileAccept const fileAccept = computed(() => props.fileType.map((type) => `.${type}`).join(',')); @@ -100,18 +110,28 @@ watch( let temp = 1; // 首先将值转为数组 let list: any[] = []; + if (Array.isArray(val)) { - list = val; + // 如果是数组,检查第一个元素的格式 + if (val.length > 0 && val[0].fileName && val[0].fileId && val[0].fileUrl) { + // 处理后端返回的格式 [{fileName,fileId,fileUrl}] + list = val.map(item => ({ + name: item.fileName, + url: item.fileUrl, + ossId: item.fileId + })); + } else { + // 处理组件内部格式 [{name,url,ossId}] + list = val; + } } else { + // 处理字符串格式(逗号分隔的ossId) const res = await listByIds(val); list = res.data.map((oss) => { - return { - name: oss.originalName, - url: oss.url, - ossId: oss.ossId - }; + return { name: oss.originalName, url: oss.url, ossId: oss.ossId }; }); } + // 然后将数组转为对象数组 fileList.value = list.map((item) => { item = { name: item.name, url: item.url, ossId: item.ossId }; @@ -190,7 +210,15 @@ const handleDelete = (index: number) => { const ossId = fileList.value[index].ossId; delOss(ossId); fileList.value.splice(index, 1); - emit('update:modelValue', listToString(fileList.value)); + + // 转换为后端需要的格式 [{fileName,fileId,fileUrl}] + const formattedList = fileList.value.map(file => ({ + fileName: file.name, + fileId: file.ossId, + fileUrl: file.url + })); + + emit('update:modelValue', formattedList); }; // 上传结束处理 @@ -199,7 +227,15 @@ const uploadedSuccessfully = () => { fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value); uploadList.value = []; number.value = 0; - emit('update:modelValue', listToString(fileList.value)); + + // 转换为后端需要的格式 [{fileName,fileId,fileUrl}] + const formattedList = fileList.value.map(file => ({ + fileName: file.name, + fileId: file.ossId, + fileUrl: file.url + })); + + emit('update:modelValue', formattedList); emit('update:fileList', fileList.value); proxy?.$modal.closeLoading(); } diff --git a/src/views/materialManagement/components/detailInfo.vue b/src/views/materialManagement/components/detailInfo.vue index a2f6c91..45d996e 100644 --- a/src/views/materialManagement/components/detailInfo.vue +++ b/src/views/materialManagement/components/detailInfo.vue @@ -15,7 +15,7 @@ - {{ props.detailInfo.gonyingshangId }} + {{ props.detailInfo.gonyingshangName }} {{ props.detailInfo.chuhuoTime }} diff --git a/src/views/materialManagement/inventoryManagement.vue b/src/views/materialManagement/inventoryManagement.vue index 971442a..3c2f301 100644 --- a/src/views/materialManagement/inventoryManagement.vue +++ b/src/views/materialManagement/inventoryManagement.vue @@ -8,8 +8,8 @@
单据列表
- +
@@ -129,9 +129,6 @@ :value="dict.value"> - - - - @@ -154,7 +151,7 @@ - +