zenglf
2023-10-25 4b62098fb4528e3f38df4265e1e2ec081664d4b4
src/views/eam/modules/equipmentCalibrationOrder/EquipmentCalibrationOrderModal.vue
@@ -1,78 +1,79 @@
<template>
  <a-modal
    :title="title"
    :width="1250"
    :visible="visible"
    :maskClosable="false"
    @ok="handleOk"
    cancelText="关闭"
    @cancel="handleCancel"
    :confirmLoading="confirmLoading"
    :title='title'
    :width='1250'
    :visible='visible'
    :maskClosable='false'
    @ok='handleOk'
    cancelText='关闭'
    @cancel='handleCancel'
    :confirmLoading='confirmLoading'
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row :gutter="24">
          <a-col :span="12">
    <a-spin :spinning='confirmLoading'>
      <a-form :form='form'>
        <a-row :gutter='24'>
          <a-col :span='12'>
            <a-form-item
              label="工单号"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label='工单号'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
            >
              <a-input
                allow-clear
                :disabled="codeDisable"
                :disabled='codeDisable'
                :placeholder="disableSubmit?'':'请输入工单号编码'"
                v-decorator="['num', validatorRules.num ]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
          <a-col :span='12'>
            <a-form-item
              label="检定方式"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label='检定方式'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
            >
              <j-dict-select-tag
                allow-clear
                :disabled="disableSubmit"
                :disabled='disableSubmit'
                :placeholder="disableSubmit?'':'请选择检定方式'"
                :triggerChange="true"
                dictCode="calibration_type"
                :triggerChange='true'
                dictCode='calibration_type'
                v-decorator="['calibrationType', validatorRules.calibrationType]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
        <a-row :gutter='24'>
          <a-col :span='12'>
            <a-form-item
              label="设备"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label='设备'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
            >
              <a-input-search
                :disabled="disableSubmit"
                placeholder="请选择设备"
                :disabled='disableSubmit'
                placeholder='请选择设备'
                enter-button
                @search="onEquipmentList()"
                :read-only="true"
                @search='onEquipmentList()'
                :read-only='true'
                v-decorator="['equipmentName', validatorRules.equipmentName]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
          <a-col :span='12'>
            <a-form-item
              label="判断依据"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label='判断依据'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
            >
              <j-dict-select-tag
                allow-clear
                :disabled="disableSubmit"
                :read-only='true'
                :disabled='disableSubmit'
                :placeholder="disableSubmit?'':'请选择判断依据'"
                :triggerChange="true"
                dictCode="management_mode"
                :triggerChange='true'
                dictCode='management_mode'
                v-decorator="['managementMode', validatorRules.managementMode]"
              />
            </a-form-item>
@@ -80,48 +81,48 @@
        </a-row>
        <a-row
          hidden
          :gutter="24"
          :gutter='24'
        >
          <a-col :span="12">
          <a-col :span='12'>
            <a-form-item
              label="设备Id"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label='设备Id'
              :labelCol='labelCol'
              :wrapperCol='wrapperCol'
            >
              <a-input
                allow-clear
                :disabled="true"
                :disabled='true'
                :placeholder="disableSubmit?'':'请输入设备编码/名称/型号'"
                v-decorator="['equipmentId', validatorRules.equipmentId ]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
        <a-row :gutter='24'>
          <a-col :span='24'>
            <a-form-item
              :labelCol="{span:3}"
              :wrapperCol="{span:21}"
              label="备注"
              :labelCol='{span:3}'
              :wrapperCol='{span:21}'
              label='备注'
            >
              <a-textarea
                allow-clear
                :disabled="disableSubmit"
                :disabled='disableSubmit'
                :placeholder="disableSubmit?'':'请输入备注'"
                v-decorator="['remark', validatorRules.remark]"
              />
            </a-form-item>
          </a-col>
          <a-col :span="24">
          <a-col :span='24'>
            <a-form-item
              :labelCol="{span:3}"
              :wrapperCol="{span:21}"
              label="精度参数模板ID"
              :labelCol='{span:3}'
              :wrapperCol='{span:21}'
              label='精度参数模板ID'
              hidden
            >
              <a-textarea
                allow-clear
                :disabled="disableSubmit"
                :disabled='disableSubmit'
                :placeholder="disableSubmit?'':'请输入精度参数模板ID'"
                v-decorator="['calibrationOrderUda1', validatorRules.calibrationOrderUda1]"
              />
@@ -130,36 +131,37 @@
        </a-row>
      </a-form>
    </a-spin>
    <a-table
      ref="table"
      bordered
      size="middle"
      rowKey='id'
      :columns="columns"
      :pagination="ipagination"
      :loading="loading"
      :dataSource="dataSource"
      @change="handleTableChange"
    <a-table v-show='false'
             ref='table'
             bordered
             size='middle'
             rowKey='id'
             :columns='columns'
             :pagination='ipagination'
             :loading='loading'
             :dataSource='dataSource'
             @change='handleTableChange'
    >
    </a-table>
    <template slot="footer">
    <template slot='footer'>
      <a-button
        :style="{marginRight: '8px'}"
        @click="handleCancel()"
        @click='handleCancel()'
      >
        关闭
      </a-button>
      <a-button
        @click="handleOk()"
        type="primary"
        :loading="confirmLoading"
      >确定</a-button>
        @click='handleOk()'
        type='primary'
        :loading='confirmLoading'
      >确定
      </a-button>
    </template>
    <equipment-list
      ref="EquipmentList"
      ref='EquipmentList'
      @sendEquipmentRecord='sendEquipmentRecord'
    ></equipment-list>
  </a-modal>
@@ -177,189 +179,216 @@
import Vue from 'vue'
export default {
  name: "EquipmentCalibrationOrderModal",
  mixins:[JeecgListMixin],
  name: 'EquipmentCalibrationOrderModal',
  mixins: [JeecgListMixin],
  components: {
    JMultiSelectTag,
    Tooltip,
    EquipmentList
  },
  data() {
    return {
      columns: [
          {
            title: '#',
            dataIndex:'sort',
            width:100,
            align:"center",
          },
          {
            title:'检验项目名称',
            align:"center",
            dataIndex: 'precisionParametersName',
            width:300
          },
          {
            title:'位置',
            align:"center",
            dataIndex: 'precisionParametersUda1',
            width:300
          },
          {
            title:'允差(mm)',
            align:"center",
            dataIndex: 'tolerance',
            width:300
          },
        {
          title: '#',
          dataIndex: 'sort',
          width: 100,
          align: 'center'
        },
        {
          title: '检验项目名称',
          align: 'center',
          dataIndex: 'precisionParametersName',
          width: 300
        },
        {
          title: '位置',
          align: 'center',
          dataIndex: 'precisionParametersUda1',
          width: 300
        },
        {
          title: '允差(mm)',
          align: 'center',
          dataIndex: 'tolerance',
          width: 300
        }
      ],
      title: "操作",
      precisionParametersTemplateId:'',
      title: '操作',
      precisionParametersTemplateId: '',
      visible: false,
      disableSubmit: false,
      codeDisable: true,
      dataSource: [],
      model: {},
      num:"",
      model: { 'management_mode': 'report', 'calibration_type': 'self' },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 },
        sm: { span: 18 }
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {
        num: {
          rules: [
            { required: true, message: '请输入工单编码!' },
            { required: true, message: '请输入工单编码!' }
          ]
        },
        calibrationType: {
          rules: [
            { required: true, message: '请选择检定方式!' },
            { required: true, message: '请选择检定方式!' }
          ]
        },
        managementMode: {
          rules: [
            { required: true, message: '请选择判定依据!' },
            { required: true, message: '请选择判定依据!' }
          ]
        },
        equipmentName: {
          rules: [
            { required: true, message: '请选择设备!' },
            { required: true, message: '请选择设备!' }
          ]
        },
        }
      },
      url: {
        add: "/eam/calibrationOrder/addNew",
        edit: "/eam/calibrationOrder/editNew",
        list: "/eam/precisionParametersTemplateDetail/listByPrecisionParametersTemplateId",
      },
        add: '/eam/calibrationOrder/addNew',
        edit: '/eam/calibrationOrder/editNew',
        list: '/eam/precisionParametersTemplateDetail/listByPrecisionParametersTemplateId',
        getNum: '/eam/sysIdentity/getNumNew',
      }
    }
  },
  created() {
    // this.initNum()
  },
  methods: {
    // 初始化技术状态鉴定工单号
    // initNum(){
    //   getAction(this.url.getNum, { type: 'CalibrationOrder', length: '4' }).then((res) => {
    //     if (res.success) {
    //       this.num = res.message
    //     }
    //   })
    // },
    add() {
      this.precisionParametersTemplateId='-1';
      this.edit({})
      this.precisionParametersTemplateId = '-1'
      getAction(this.url.getNum, { type: 'CalibrationOrder', length: '4' }).then((res) => {
        if (res.success) {
          this.num = res.message
        }
      })
      // 新增时候设置鉴定类型为自检、 判定依据为报告
      this.edit({ "num":this.num,'calibrationType': 'self', 'managementMode': 'report' })
    },
    edit(record) {
      let that = this;
      this.form.resetFields();
      this.model = Object.assign({}, record);
      this.visible = true;
      let that = this
      this.form.resetFields()
      this.model = Object.assign({}, record)
      this.visible = true
      this.maintenanceCycles = record.maintenanceCycles
      if (record.precisionParameterList != undefined) {
        this.dataSource = record.precisionParameterList;
        this.dataSource = record.precisionParameterList
      }
      that.$nextTick(() => {
        that.form.setFieldsValue(pick(that.model, 'num', 'equipmentName', 'equipmentId', 'calibrationType', 'managementMode'));
      });
        that.form.setFieldsValue(pick(that.model, 'num', 'equipmentName', 'equipmentId', 'calibrationType', 'managementMode'))
      })
      if (record.id) {
        this.codeDisable = true;
        this.codeDisable = true
      } else {
        this.codeDisable = false;
        this.codeDisable = false
      }
    },
    close() {
      this.$emit('close');
      this.visible = false;
      this.$emit('close')
      this.visible = false
    },
    handleCancel() {
      this.close();
      this.close()
    },
    handleOk() {
      const that = this;
      const that = this
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let formData = Object.assign(this.model, values);
          let obj;
          that.confirmLoading = true
          let formData = Object.assign(this.model, values)
          let obj
          if (!this.model.id) {
            obj = postAction(this.url.add, formData);
            obj = postAction(this.url.add, formData)
          } else {
            obj = requestPut(this.url.edit, formData, { id: this.model.id });
            obj = requestPut(this.url.edit, formData, { id: this.model.id })
          }
          obj.then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
              that.$message.success(res.message)
              that.$emit('ok')
            } else {
              that.$message.warning(res.message);
              that.$message.warning(res.message)
            }
          }).finally(() => {
            that.confirmLoading = false;
            that.close();
            that.confirmLoading = false
            that.close()
          })
        }
      })
    },
    onEquipmentList() {
      this.$refs.EquipmentList.list();
      this.$refs.EquipmentList.title = "选择设备信息";
      this.$refs.EquipmentList.list()
      this.$refs.EquipmentList.title = '选择设备信息'
    },
    sendEquipmentRecord(data) {
      this.dataSource = [];
      let record = data.record;
      this.form.setFieldsValue({calibrationOrderUda1:record.precisionParametersTemplateId,equipmentId: record.id, equipmentName: record.num + "/" + record.name + "/" + record.model });
      this.precisionParametersTemplateId = record.precisionParametersTemplateId;
      this.dataSource = []
      let record = data.record
      this.form.setFieldsValue({
        calibrationOrderUda1: record.precisionParametersTemplateId,
        equipmentId: record.id,
        equipmentName: record.num + '/' + record.name + '/' + record.model
      })
      this.precisionParametersTemplateId = record.precisionParametersTemplateId
    },
    clearList(){
        this.dataSource=[]
        this.selectedRowKeys=[]
        this.ipagination.current = 1
    },
  },
  watch:{
        precisionParametersTemplateId:{
        immediate: true,
        handler(val) {
          if(!this.precisionParametersTemplateId){
            this.clearList()
          }else{
            this.queryParam['precisionParametersTemplateId'] = val;
            this.queryParam['delFlag'] = 0;
            this.loadData(1);
          }
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }
  }
  ,
  watch: {
    precisionParametersTemplateId: {
      immediate: true,
      handler(val) {
        if (!this.precisionParametersTemplateId) {
          this.clearList()
        } else {
          this.queryParam['precisionParametersTemplateId'] = val
          this.queryParam['delFlag'] = 0
          this.loadData(1)
        }
      }
    },
    }
  }
}
</script>
<style lang="less" scoped>
<style lang='less' scoped>
/deep/ .frozenRowClass {
  color: #c9c9c9;
}
.fontweight {
  font-weight: bold;
}
.ant-btn {
  padding: 0 10px;
  margin-left: 3px;