hyingbo
昨天 ff1f734e5f37cdd004f6c8bf88a2917737e1ff08
src/views/eam/dispose/modules/EamEquipmentLeanOutModal.vue
@@ -24,7 +24,7 @@
          <a-tree-select v-model="model.leanDepartId"
                         :disabled="disableSubmit"
                         style="width: 100%"
                         :tree-data="treeData"
                         :tree-data="treeDataAlias"
                         :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                         placeholder="请选择借入车间"
                         allow-clear
@@ -67,6 +67,7 @@
        },
        confirmLoading: false,
        treeData: [],
        treeDataAlias: [],
        validatorRules:{
          equipmentId: [
            { required: true, message: '请选择设备!' }
@@ -147,12 +148,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>