Ver código fonte

feat: 产品属性配置化

wuzh 18 horas atrás
pai
commit
a7a8fd4083
1 arquivos alterados com 23 adições e 13 exclusões
  1. 23 13
      src/views/material/product/detail.vue

+ 23 - 13
src/views/material/product/detail.vue

@@ -1152,6 +1152,14 @@
         }
       });
 
+      parameterGetByCode({
+        code: 'component_attribute'
+      }).then((res) => {
+        this.lbjtList = this.parseComponentAttributeOptions(
+          res?.name || res?.value
+        );
+      });
+
       //新增
 
       this.$set(
@@ -1648,20 +1656,22 @@
       //   });
       //   console.log('produceTypeList',this.produceTypeList);
       // },
-      // // 属性类型字典
-      // async getLbjtListList(code) {
-      //   let { data: res } = await getByCode(code);
-      //   console.log('res----', res);
+      parseComponentAttributeOptions(value) {
+        if (!value) {
+          return [];
+        }
 
-      //   this.lbjtList = res.map((item) => {
-      //     let values = Object.keys(item);
-      //     return {
-      //       value: Number(values[0]),
-      //       label: item[values[0]]
-      //     };
-      //   });
-      //   console.log('lbjtList',this.lbjtList);
-      // },
+        const options = [];
+        const optionRegExp = /(\d+)\s*[::]\s*([^;;))]+)/g;
+        let match;
+        while ((match = optionRegExp.exec(String(value))) !== null) {
+          options.push({
+            value: Number(match[1]),
+            label: match[2].trim()
+          });
+        }
+        return options;
+      },
       async getDictList(code) {
         let { data: res } = await getByCode(code);