Prechádzať zdrojové kódy

feat(product): 扩展选项加载功能支持额外字段映射

- 修改 loadOptions 函数增加 extraKeys 参数用于指定额外字段
- 实现动态字段映射逻辑支持多个属性同时提取
- 更新 store 选项加载调用传入 storeTypeId 和 storeTypeName 字段
- 优化选项数据结构适配多字段存储需求
fugui001 2 dní pred
rodič
commit
ff7ca0857b
1 zmenil súbory, kde vykonal 17 pridanie a 8 odobranie
  1. 17 8
      src/views/system/physical/product/index.vue

+ 17 - 8
src/views/system/physical/product/index.vue

@@ -101,9 +101,9 @@
             <el-option v-for="item in itemOptionsStore" :key="item.id" :label="item.label" :value="item.id" />
           </el-select>
         </el-form-item>
-        <el-form-item label="服务类型" prop="typeId">
+<!--        <el-form-item label="服务类型" prop="typeId">
           <el-input v-model="form.typeId" placeholder="请输入服务类型" disabled />
-        </el-form-item>
+        </el-form-item>-->
         <el-form-item label="服务类型" prop="">
           <el-input v-model="form.storeTypeName" placeholder="请输入服务类型" disabled />
         </el-form-item>
@@ -437,14 +437,23 @@ const handleExport = () => {
 const itemOptionsType = ref<{ id: number; label: string }[]>([]);
 const itemOptionsStore = ref<{ id: number; label: string; storeTypeName?: string; storeTypeId?: string }[]>([]);
 
-const loadOptions = async (apiFunc: () => Promise<any>, targetRef: any, labelKey: string = 'serviceName') => {
+// ... existing code ...
+const loadOptions = async (apiFunc: () => Promise<any>, targetRef: any, labelKey: string = 'serviceName', extraKeys?: string[]) => {
   try {
     const res = await apiFunc();
     if (res.code === 200) {
-      targetRef.value = (res.data as unknown as any[]).map((item) => ({
-        id: item.id,
-        label: item[labelKey]
-      }));
+      targetRef.value = (res.data as unknown as any[]).map((item) => {
+        const result: any = {
+          id: item.id,
+          label: item[labelKey]
+        };
+        if (extraKeys) {
+          extraKeys.forEach((key) => {
+            result[key] = item[key];
+          });
+        }
+        return result;
+      });
     } else {
       alert('加载失败:' + res.msg);
     }
@@ -454,7 +463,7 @@ const loadOptions = async (apiFunc: () => Promise<any>, targetRef: any, labelKey
 };
 
 const loadItemStructuresOptions = () => loadOptions(selectAllPhysicalTagsSelList, itemOptionsType);
-const loadStoreOptions = () => loadOptions(selectPhysicalStoreSelList, itemOptionsStore, 'name');
+const loadStoreOptions = () => loadOptions(selectPhysicalStoreSelList, itemOptionsStore, 'name', ['storeTypeId', 'storeTypeName']);
 onMounted(() => {
   getList();
   loadItemStructuresOptions();