hyingbo
11 小时以前 e0e111d15a3f3995799b8b480c162c619ec897aa
src/views/eam/repair/modules/EamMajorPartialRepairForm.vue
@@ -28,18 +28,19 @@
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicant">
              <j-search-select-tag  placeholder="请选择申请人" v-model="model.applicant" dict="sys_user,realname, username, del_flag=0 and status=1"/>
              <j-search-select-tag disabled placeholder="请选择申请人" v-model="model.applicant" dict="sys_user,realname, username, del_flag=0 and status=1"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="申请车间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicantProduction">
              <a-tree-select v-model="model.applicantProduction"
                             style="width: 100%"
                             :tree-data="treeData"
                             :tree-data="treeDataAlias"
                             :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                             placeholder="请选择申请车间"
                             allow-clear
                             tree-default-expand-all
                             @change="handleWorkShopChange"
              >
              </a-tree-select>
            </a-form-model-item>
@@ -74,7 +75,7 @@
              <a-input v-model="model.applicantReason" placeholder="请输入申请原因"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
          <a-col :span="8" v-if="disabled">
            <a-form-model-item label="责任人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="responsiblePerson">
              <j-search-select-tag  placeholder="请选择责任人" v-model="model.responsiblePerson" dict="sys_user,realname, username, del_flag=0 and status=1"/>
            </a-form-model-item>
@@ -120,6 +121,8 @@
import { getAction, httpAction } from '@/api/manage'
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
export default {
    name: 'EamMajorPartialRepairForm',
@@ -137,6 +140,7 @@
    data () {
      return {
        model: {},
        treeDataAlias: [],
        labelCol: {
          xs: { span: 24 },
          sm: { span: 7 },
@@ -154,7 +158,7 @@
          planStartDate: { required: true, message: '请选择计划开始日期!' },
          planEndDate: { required: true, message: '请选择计划结束日期!' },
          applicantReason: { required: true, message: '请输入申请原因!' },
          responsiblePerson: { required: true, message: '请输入责任人!' },
          // responsiblePerson: { required: true, message: '请输入责任人!' },
          faultDescription: { required: true, message: '请输入故障描述!' }
        },
        treeData: [],
@@ -169,6 +173,7 @@
          queryById: "/eam/eamMajorPartialRepair/queryById",
          queryDetailList: "/eam/eamMajorPartialRepairDetail/list",
          queryEquipmentList: "/eam/equipment/asyncLoadEquipment",
          queryEquipmentByProductionList: "/eam/equipment/asyncLoadEquipmentByProduction",
          loadWorkShopOptions:'/mdc/mdcProduction/loadProductionTreeOptions'
        }
      }
@@ -233,16 +238,71 @@
        getAction(this.url.loadWorkShopOptions).then(res => {
          if (res.success) {
            this.treeData = [...res.result]
            this.treeDataAlias = this.deepCopyAndModify(res.result)
          }else {
            that.$message.warning(res.message)
          }
        })
      },
      handleWorkShopChange(productionId) {
        this.detail.dataSource = []
        if (productionId) {
          this.getEquipmentList(productionId);
        } else {
          this.equipmentOptions = [];
        }
      },
      getEquipmentList(productionId) {
        //加载车间选择树
        getAction(this.url.queryEquipmentByProductionList, {productionId: productionId}).then((res) => {
          if (res.success) {
            this.equipmentOptions = res.result.map(item => {
              return {
                label: item.text,
                value: item.value
              }
            })
          }
        })
      },
      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;
      },
      add () {
        this.edit(this.modelDefault)
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.model = Object.assign({
          applicant: Vue.ls.get(USER_INFO).username
        }, record);
        console.log("this.model", this.model)
        this.visible = true
        if (this.model.id) {
          getAction(this.url.queryDetailList, { repairId: this.model.id }).then((res) => {