zhangherong
2 天以前 e94aec6475d51aea1a349485f2a45442b5321d30
src/views/eam/equipment/modules/EamEquipmentModal.vue
@@ -85,30 +85,6 @@
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="6">
            <a-form-model-item prop="equipmentWeight" label="重量">
              <a-input :placeholder="disableSubmit?'':'请输入重量'" v-model="model.equipmentWeight" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item prop="equipmentPort" label="设备端口">
              <a-input :placeholder="disableSubmit?'':'请输入设备端口'" v-model="model.equipmentPort" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item prop="coordinateNum" label="坐标数量">
              <a-input-number :placeholder="disableSubmit?'':'请输入坐标数量'" v-model="model.coordinateNum" style="width: 100%" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item prop="assetStatus" label="资产状态">
              <j-dict-select-tag dict-code="asset_status" v-model="model.assetStatus"
                                 disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 出厂信息
        </a-divider>
@@ -166,12 +142,12 @@
            <a-form-model-item prop="orgId" label="使用车间">
              <a-tree-select v-model="model.orgId"
                             style="width: 100%"
                             :tree-data="treeData"
                             :tree-data="treeDataAlias"
                             :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                             placeholder="请选择使用车间"
                             allow-clear
                             tree-default-expand-all
                             :disabled="editable || disableSubmit"
                             :disabled="disableSubmit"
                >
              </a-tree-select>
            </a-form-model-item>
@@ -211,13 +187,9 @@
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item prop="processParametersFlag" label="有无工艺参数">
              <lx-switch checked-children='有' un-checked-children='无' v-model="model.processParametersFlag" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item prop="precisionParametersFlag" label="有无精度参数">
              <lx-switch checked-children='有' un-checked-children='无' v-model="model.precisionParametersFlag" :disabled="disableSubmit"/>
            <a-form-model-item prop="assetStatus" label="资产状态">
              <j-dict-select-tag dict-code="asset_status" v-model="model.assetStatus"
                                 disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
@@ -284,7 +256,7 @@
          { required: true, message: '请选择出厂日期' }
        ],
        acceptanceCheckDate: [
          { required: true, message: '请选择验收日期' }
          { required: false, message: '请选择验收日期' }
        ],
        technologyStatus: [
          { required: true, message: '请选择技术状态' }
@@ -305,6 +277,7 @@
        loadProductionOptions:'/mdc/mdcProduction/loadProductionTreeOptions'
      },
      treeData: [],
      treeDataAlias: [],
    }
  },
  created() {
@@ -366,11 +339,43 @@
      getAction(this.url.loadProductionOptions).then(res => {
        if (res.success) {
          this.treeData = [...res.result]
          this.treeDataAlias = this.deepCopyAndModify(res.result)
        }else {
          that.$message.warning(res.message)
        }
      })
    },
    deepCopyAndModify(arr) {
      // 如果当前元素不是数组或对象,直接返回
      if (!Array.isArray(arr) && typeof arr !== 'object' || arr === null || arr.length === 0) {
        return arr;
      }
      // 如果是数组,创建一个新数组并递归处理每个元素
      if (Array.isArray(arr)) {
        const newArray = [];
        for (let i = 0; i < arr.length; i++) {
          newArray.push(this.deepCopyAndModify(arr[i]));
        }
        return newArray;
      }
      // 如果是对象,创建一个新对象并递归处理每个属性
      const newObj = {};
      for (const key in arr) {
        if (arr.hasOwnProperty(key)) {
          if(key === 'selectable') {
            newObj[key] = true;
          } else if(key === 'children') {
            newObj[key] = this.deepCopyAndModify(arr[key]);
          }else {
            newObj[key] = arr[key];
          }
        }
      }
      return newObj;
    },
  }
}
</script>