浏览代码

物资信息修改规格之后多出来的逗号问题修复

pm 3 月之前
父节点
当前提交
3cd869660b
共有 2 个文件被更改,包括 29 次插入27 次删除
  1. 20 18
      src/views/mes/material/materialinformation/index.vue
  2. 9 9
      src/views/mes/material/typeofmaterial/index.vue

+ 20 - 18
src/views/mes/material/materialinformation/index.vue

@@ -927,29 +927,30 @@ export default {
     },
     // 选择属性值
     selectValue(propertyId, recordId) {
-      // 如果当前选中值和之前选中的相同,直接切换选中状态
       if (this.selectedValues[propertyId] === recordId) {
         this.selectedValues[propertyId] = null;
       } else {
         this.$set(this.selectedValues, propertyId, recordId);
       }
-      // 生成 JSON 格式的数据
-      const selectionJson = Object.entries(this.selectedValues).map(
-        ([propertyId, recordId]) => {
-          const property = this.PropertyList.find(
-            (p) => p.propertyId === propertyId
-          );
-          const value = this.PropertyValueList.find(
-            (v) => v.recordId === recordId
-          );
-          return {
-            propertyId,
-            recordId,
-            valueName: value ? value.valueName : "",
-            propertyName: property ? property.propertyName : "",
-          };
-        }
-      );
+
+      const selectionJson = Object.entries(this.selectedValues)
+        .map(([propertyId, recordId]) => {
+          if (!recordId) return null;
+          const property = this.PropertyList.find(p => p.propertyId === propertyId);
+          const value = this.PropertyValueList.find(v => v.recordId === recordId);
+
+          if (property && value) {
+            return {
+              propertyId,
+              recordId,
+              valueName: value.valueName,
+              propertyName: property.propertyName,
+            };
+          }
+          return null;
+        })
+        .filter(Boolean);
+
       this.form.properties = JSON.stringify(selectionJson);
       console.log(selectionJson, "生成的属性值json");
     },
@@ -1097,6 +1098,7 @@ export default {
             this.form.expirationDate = this.formatDateExpirationDate(
               this.form.expirationDate
             );
+            console.log(this.form,'修改传递的参数');
             updateMaterials(this.form).then((response) => {
               console.log(response, "修改返回");
               this.$modal.msgSuccess("修改成功");

+ 9 - 9
src/views/mes/material/typeofmaterial/index.vue

@@ -192,15 +192,15 @@
     <!-- 添加或修改设备类型对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="120px">
-        <el-form-item label="父类型" prop="parentId">
-          <treeselect
-            v-model="form.parentId"
-            :options="machinerytypeOptions"
-            :normalizer="normalizer"
-            placeholder="请选择父类型"
-            style="width: 318px"
-          />
-        </el-form-item>
+<!--        <el-form-item label="父类型" prop="parentId">-->
+<!--          <treeselect-->
+<!--            v-model="form.parentId"-->
+<!--            :options="machinerytypeOptions"-->
+<!--            :normalizer="normalizer"-->
+<!--            placeholder="请选择父类型"-->
+<!--            style="width: 318px"-->
+<!--          />-->
+<!--        </el-form-item>-->
         <el-row>
           <el-col :span="17">
             <el-form-item label="物资类型编码" prop="materialsTypeCode">