zhangherong
2025-03-06 0b22c1255437bc6f0170355dad2a35172e0eddfd
src/views/eam/modules/projectMaintenanceOrder/ProjectMaintenanceOrderForm.vue
@@ -2,20 +2,47 @@
  <a-spin :spinning='confirmLoading'>
    <j-form-container :disabled='formDisabled'>
      <!-- 主表单区域 -->
      <a-form-model ref='form' :model='model' :rules='validatorRules' slot='detail'>
      <a-form-model
        ref='form'
        :model='model'
        :rules='validatorRules'
        slot='detail'
      >
        <a-row>
          <a-col :span='12'>
            <a-form-model-item label='计划单编号' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='num'>
              <a-input v-model='model.num' placeholder='请输入计划单编号'></a-input>
            <a-form-model-item
              label='计划单编号'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              prop='num'
            >
              <a-input
                v-model='model.num'
                placeholder='请输入计划单编号'
              ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span='12'>
            <a-form-model-item label='计划名称' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='计划名称'>
              <a-input v-model='model.name' rows='4' placeholder='请输入计划名称' />
            <a-form-model-item
              label='计划名称'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              prop='计划名称'
            >
              <a-input
                v-model='model.name'
                rows='4'
                placeholder='请输入计划名称'
              />
            </a-form-model-item>
          </a-col>
          <a-col :span='12'>
            <a-form-model-item label='计划开始日期' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='planStartTime'>
            <a-form-model-item
              label='计划开始日期'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              prop='planStartTime'
            >
              <j-date
                placeholder='请选择计划开始日期'
                v-model='model.planStartTime'
@@ -26,7 +53,12 @@
            </a-form-model-item>
          </a-col>
          <a-col :span='12'>
            <a-form-model-item label='计划结束日期' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='planEndTime'>
            <a-form-model-item
              label='计划结束日期'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              prop='planEndTime'
            >
              <j-date
                placeholder='请选择计划结束日期'
                v-model='model.planEndTime'
@@ -59,16 +91,27 @@
            </a-form-model-item>
          </a-col> -->
          <a-col :span='12'>
            <a-form-model-item label='附件' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='annex'>
              <j-image-upload
                :isMultiple="false"
                v-model="model.annex"
              ></j-image-upload>
            <a-form-model-item
              label='附件'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              prop='annex'
            >
            <j-upload :returnUrl= "false" :isMultiple="false"  v-model="model.file" ></j-upload>
            </a-form-model-item>
          </a-col>
          <a-col :span='12'>
            <a-form-model-item label='备注' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='remark'>
              <a-textarea v-model='model.remark' rows='4' placeholder='请输入备注' />
            <a-form-model-item
              label='备注'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
              prop='remark'
            >
              <a-textarea
                v-model='model.remark'
                rows='4'
                placeholder='请输入备注'
              />
            </a-form-model-item>
          </a-col>
@@ -76,39 +119,68 @@
      </a-form-model>
    </j-form-container>
    <!-- 子表单区域 -->
    <a-tabs v-model='activeKey' @change='handleChangeTabs'>
      <a-tab-pane tab='项目性维修明细' :key='refKeys[0]' :forceRender='true'>
        <j-vxe-table keep-source :ref='refKeys[0]' :loading='projectMaintenanceOrderDetailTable.loading'
                     :columns='projectMaintenanceOrderDetailTable.columns'
                     :dataSource='projectMaintenanceOrderDetailTable.dataSource'
                     :maxHeight='300'
                     :disabled='formDisabled' :rowNumber='true' :rowSelection='true' :toolbar='true'
                     :toolbarConfig='toolbarConfig'
                     :linkage-config='linkageConfig'>
    <a-tabs
      v-model='activeKey'
      @change='handleChangeTabs'
    >
      <a-tab-pane
        tab='项目性维修明细'
        :key='refKeys[0]'
        :forceRender='true'
      >
        <j-vxe-table
          keep-source
          :ref='refKeys[0]'
          :loading='projectMaintenanceOrderDetailTable.loading'
          :columns='projectMaintenanceOrderDetailTable.columns'
          :dataSource='projectMaintenanceOrderDetailTable.dataSource'
          :maxHeight='400'
          :disabled='formDisabled'
          :rowNumber='true'
          :rowSelection='true'
          :alwaysEdit='true'
          :toolbar='true'
          :bordered='true'
          :toolbarConfig='toolbarConfig'
          :linkage-config='linkageConfig'
        >
          <template slot='toolbarPrefix'>
            <a-button type='primary' @click='selectEquipmentList' :disabled='formDisabled'>选择设备
            <a-button
              type='primary'
              @click='selectEquipmentList'
              :disabled='formDisabled'
            >选择设备
            </a-button>
          </template>
          <template v-slot:supplierId='props'>
            <a-select v-model='props.row.supplierId' :options='supplierVoList'
                      style='width: 100%'
                      placeholder='请选择'
                      @change='(e) => handleChange(e, props.row)' />
            <a-select
              v-model='props.row.supplierId'
              :options='supplierVoList'
              style='width: 100%'
              placeholder='请选择'
              @change='(e) => handleChange(e, props.row)'
            />
          </template>
          <template v-slot:teamId='props'>
            <a-select v-model='props.row.teamId' :options='teamVoList'
                      style='width: 100%'
                      placeholder='请选择'
                      @change='(e) => handleChange(e, props.row)' />
            <a-select
              v-model='props.row.teamId'
              :options='teamVoList'
              style='width: 100%'
              placeholder='请选择'
              @change='(e) => handleChange(e, props.row)'
            />
          </template>
          <template v-slot:userId='props'>
            <a-select v-model='props.row.userId' :options='userVoList'
                      style='width: 100%'
                      placeholder='请选择'
                      @change='(e) => handleChange(e, props.row)' />
            <a-select
              v-model='props.row.userId'
              :options='userVoList'
              style='width: 100%'
              placeholder='请选择'
              @change='(e) => handleChange(e, props.row)'
            />
            <!-- <a-select
                  placeholder="请选择责任人"
                  allowClear
@@ -124,8 +196,11 @@
        </j-vxe-table>
      </a-tab-pane>
    </a-tabs>
    <equipment-select-modal @selectionRows='selectionRows' :equipmentStatus="['2', '3']"
                            ref='EquipmentSelectModal'></equipment-select-modal>
    <equipment-select-modal
      @selectionRows='selectionRows'
      :equipmentStatus="['2', '3']"
      ref='EquipmentSelectModal'
    ></equipment-select-modal>
  </a-spin>
</template>
@@ -137,10 +212,10 @@
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import { JVXETypes } from '@comp/jeecg/JVxeTable'
import { getRefPromise, VALIDATE_FAILED } from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
import JFormContainer from '@/components/jeecg/JFormContainer'
import { getAction } from '@api/manage'
import { VALIDATE_FAILED, getRefPromise, validateFormAndTables,validateFormModelAndTables} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
export default {
  name: 'ProjectMaintenanceOrderForm',
@@ -222,7 +297,8 @@
            title: '任务编码',
            key: 'taskNum',
            type: JVXETypes.input,
            width: '120px',
            width: '180px',
            align: "center",
            fixed: 'left',
            validateRules: [
              {
@@ -231,32 +307,25 @@
              }]
          },
          {
            title: '设备编码',
            title: '统一编码',
            key: 'equipmentNum',
            type: JVXETypes.normal,
            width: '120px',
            // placeholder: '请输入${title}',
            width: '140px',
            align: "center",
            fixed: 'left'
          },
          {
            title: '资产编码',
            key: 'assetNumber',
            type: JVXETypes.normal,
            width: '120px',
            fixed: 'left',
            defaultValue: ''
          },
          {
            title: '委外单位',
            title: '外委单位',
            key: 'supplierId',
            type: JVXETypes.slot,
            disabled: true,
            width: '100px',
            width: '140px',
            align: "center",
            slotName: 'supplierId',
            defaultValue: ''
          },
          {
            title: '委外单位',
            title: '外委单位',
            key: 'supplierId',
            type: JVXETypes.hidden
          },
@@ -270,7 +339,8 @@
                required: true, // 必填
                message: '请输入${title}' // 显示的文本
              }],
            width: '100px',
            width: '140px',
            align: "center",
            defaultValue: ''
          },
          // {
@@ -294,8 +364,8 @@
            key: 'equipmentName',
            type: JVXETypes.normal,
            disabled: true,
            width: '120px',
            width: '140px',
            align: "center",
            defaultValue: ''
          },
          {
@@ -303,7 +373,8 @@
            key: 'model',
            type: JVXETypes.normal,
            disabled: true,
            width: '120px',
            width: '140px',
            align: "center",
            defaultValue: ''
          },
          {
@@ -311,7 +382,8 @@
            key: 'specification',
            type: JVXETypes.normal,
            disabled: true,
            width: '120px',
            width: '140px',
            align: "center",
            placeholder: '请输入${title}',
            defaultValue: ''
          },
@@ -320,7 +392,8 @@
            key: 'equipmentStatus_dictText',
            type: JVXETypes.normal,
            disabled: true,
            width: '100px',
            width: '140px',
            align: "center",
            // placeholder: '请输入${title}',
            defaultValue: ''
          },
@@ -330,7 +403,8 @@
            key: 'technologyStatus_dictText',
            type: JVXETypes.normal,
            disabled: true,
            width: '100px',
            width: '140px',
            align: "center",
            defaultValue: ''
          },
          {
@@ -338,12 +412,12 @@
            key: 'itemName',
            type: JVXETypes.input,
            placeholder: '请输入${title}',
            width: '100px',
            validateRules: [
              {
                required: true, // 必填
                message: '请输入${title}' // 显示的文本
              }],
            width: '240px',
            validateRules: [{
              required: true, // 必填
              message: '请输入${title}' // 显示的文本
            }],
            align: "center",
            defaultValue: ''
          },
          {
@@ -352,7 +426,8 @@
            type: JVXETypes.select,
            dictCode: 'urgency',
            placeholder: '请输入${title}',
            width: '100px',
            width: '140px',
            align: "center",
            defaultValue: ''
          },
          {
@@ -363,6 +438,7 @@
            width: '150px',
            placeholder: '请输入${title}',
            defaultValue: '',
            align: "center",
            slotName: 'teamId'
          },
          {
@@ -370,36 +446,36 @@
            key: 'teamId',
            type: JVXETypes.hidden
          },
          {
            title: '责任人',
            key: 'userId',
            type: JVXETypes.slot,
            disabled: true,
            width: '100px',
            width: '160px',
            placeholder: '请输入${title}',
            defaultValue: '',
            align: "center",
            slotName: 'userId'
          },
          {
            title: '责任人',
            key: 'userId',
            type: JVXETypes.hidden
          },
          {
            title: '计划开始时间',
            key: 'planStartTime',
            type: JVXETypes.datetime,
            width: '120px',
            width: '140px',
            align: "center",
            placeholder: '请输入${title}',
            defaultValue: ''
          }, {
            title: '计划完成时间',
            key: 'planEndTime',
            type: JVXETypes.datetime,
            width: '120px',
            width: '140px',
            align: "center",
            placeholder: '请输入${title}',
            defaultValue: ''
          },
@@ -431,7 +507,7 @@
        projectMaintenanceOrderDetail: {
          list: '/eam/projectMaintenanceOrder/queryProjectMaintenanceOrderDetailByMainId'
        },
        queryUserByTeamId:'/base/team/queryUserByTeamId'
        queryUserByTeamId: '/base/team/queryUserByTeamId'
      }
    }
  },
@@ -454,6 +530,32 @@
    this.getUser();
  },
  methods: {
    handleOk() {
      this.model['annex'] = this.model.file[0].filePath;
      /** 触发表单验证 */
      this.getAllTable().then(tables => {
        /** 一次性验证主表和所有的次表 */
        return validateFormModelAndTables(this.$refs.form,this.model, tables)
      }).then(allValues => {
        /** 一次性验证一对一的所有子表 */
        return this.validateSubForm(allValues)
      }).then(allValues => {
        if (typeof this.classifyIntoFormData !== 'function') {
          throw this.throwNotFunction('classifyIntoFormData')
        }
        let formData = this.classifyIntoFormData(allValues)
        // 发起请求
        return this.request(formData)
      }).catch(e => {
        if (e.error === VALIDATE_FAILED) {
          // 如果有未通过表单验证的子表,就自动跳转到它所在的tab
          this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
        } else {
          console.error(e)
        }
      })
    },
    getSuppler() {
      getAction(this.url.supplierVoList).then((res) => {
@@ -500,14 +602,14 @@
        this.$set(data, 'userId', data.userId)
      })
    },
    getUserVoList(val){
      getAction(this.url.queryUserByTeamId,{teamId:val}).then(res=>{
        if(res.success){
    getUserVoList(val) {
      getAction(this.url.queryUserByTeamId, { teamId: val }).then(res => {
        if (res.success) {
          this.userVoList = res.result
        }
        else{
        else {
          this.$message.error(res.message);
       }
        }
      })
    },
    handleVerify(parent) {
@@ -554,7 +656,7 @@
            supplierVoList: this.supplierVoList,
            userVoList: this.userVoList,
            teamVoList: this.teamVoList,
            userId:data[i].userId
            userId: data[i].userId
          }
        }
@@ -573,6 +675,7 @@
    /** 调用完edit()方法之后会自动调用此方法 */
    editAfter() {
      this.$nextTick(() => {
        this.model.file = this.model.annex;
      })
      // 加载子表数据
      if (this.model.id) {
@@ -582,7 +685,7 @@
    },
    //校验所有一对一子表表单
    validateSubForm(allValues) {
      if(this.$refs.projectMaintenanceOrderDetail.getTableData().length == 0){
      if (this.$refs.projectMaintenanceOrderDetail.getTableData().length == 0) {
        this.$message.warning("请添加维修明细!")
        return
      }