zhaowei
5 天以前 48d85187a16a313c5244a830862db5e672e6997d
src/views/eam/technical/modules/EamTechnicalStatusEvaluationOrderChangeModal.vue
@@ -1,162 +1,140 @@
<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
  <j-modal :title="title" :width="1300" :visible="visible" :confirmLoading="confirmLoading" switchFullscreen
           @ok="handleOk" @cancel="handleCancel" cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag" label="删除标记">
          <a-input-number v-model="model.delFlag"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderId" label="工单ID">
          <a-input placeholder="请输入工单ID" v-model="model.orderId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="changeOrderNum" label="变更单号">
          <a-input placeholder="请输入变更单号" v-model="model.changeOrderNum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applicant" label="申请人">
          <a-input placeholder="请输入申请人" v-model="model.applicant" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryOrgCode" label="申请部门">
          <a-input placeholder="请输入申请部门" v-model="model.factoryOrgCode" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyDate" label="申请日期">
          <a-input placeholder="请输入申请日期" v-model="model.applyDate" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="changeStatus" label="变更状态;待提交、待主管审核、待部门确认、待保障部确认、已作废、已完成">
          <a-input placeholder="请输入变更状态;待提交、待主管审核、待部门确认、待保障部确认、已作废、已完成" v-model="model.changeStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyReason" label="变更原因;生产任务急无法停机、设备故障正处于维修状态、设备已报废、设备大修、搬迁、改造">
          <a-input placeholder="请输入变更原因;生产任务急无法停机、设备故障正处于维修状态、设备已报废、设备大修、搬迁、改造" v-model="model.applyReason" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deferredMaintenanceDate" label="变更鉴定日期">
          <a-input placeholder="请输入变更鉴定日期" v-model="model.deferredMaintenanceDate" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentManagerSignature" label="主管领导签字">
          <a-input placeholder="请输入主管领导签字" v-model="model.equipmentManagerSignature" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentManagerSignatureTime" label="主管领导签字时间">
          <a-input placeholder="请输入主管领导签字时间" v-model="model.equipmentManagerSignatureTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="departManagerSignature" label="部门领导签字;根据变更原因类型区分不同的人审批">
          <a-input placeholder="请输入部门领导签字;根据变更原因类型区分不同的人审批" v-model="model.departManagerSignature" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="departManagerSignatureTime" label="部门领导签字时间">
          <a-input placeholder="请输入部门领导签字时间" v-model="model.departManagerSignatureTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="departManagerComment" label="部门领导意见">
          <a-input placeholder="请输入部门领导意见" v-model="model.departManagerComment" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionSupportSignature" label="生产保障部领导签字">
          <a-input placeholder="请输入生产保障部领导签字" v-model="model.productionSupportSignature" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionSupportSignatureTime" label="生产保障部领导签字时间">
          <a-input placeholder="请输入生产保障部领导签字时间" v-model="model.productionSupportSignatureTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionSupportComment" label="生产保障部领导意见">
          <a-input placeholder="请输入生产保障部领导意见" v-model="model.productionSupportComment" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hfCode" label="HF编码">
          <a-input placeholder="请输入HF编码" v-model="model.hfCode" />
        </a-form-model-item>
      <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-row>
          <a-col :span="8">
            <a-form-model-item label="工单号">
              <a-input placeholder="选择设备后自动带出" disabled v-model="model.orderId"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="变更单号">
              <a-input placeholder="系统自动生成" disabled v-model="model.changeOrderNum"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="统一编码">
              <technical-status-equipment-select placeholder="请输入统一编码或名称搜索" v-model="model.equipmentId" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="deferredEvaluationDate" label="变更鉴定日期">
              <a-date-picker v-model="model.deferredEvaluationDate" value-format="YYYY-MM-DD" style="width: 100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="applyReason" label="变更原因">
              <j-dict-select-tag v-model="model.applyReason" placeholder="请选择变更原因"
                                 dict-code="technical_status_evaluation_order_change_reason"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="{span:2}" :wrapperCol="{span:21}">
              <a-textarea v-model="model.remark" placeholder="请输入备注"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"
  import { postAction } from '@/api/manage'
  import TechnicalStatusEquipmentSelect from '../../equipment/modules/TechnicalStatusEquipmentSelect'
  export default {
    name: "EamTechnicalStatusEvaluationOrderChangeModal",
    data () {
    name: 'EamTechnicalStatusEvaluationOrderChangeModal',
    components: { TechnicalStatusEquipmentSelect },
    data() {
      return {
        title:"操作",
        title: '操作',
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
          sm: { span: 15 }
        },
        confirmLoading: false,
        validatorRules:{
        validatorRules: {
          deferredEvaluationDate: [{ required: true, message: '请选择日期', trigger: 'change' }],
          applyReason: [{ required: true, message: '请选择变更原因', trigger: 'change' }]
        },
        url: {
          add: "/eam/eamTechnicalStatusEvaluationOrderChange/add",
          edit: "/eam/eamTechnicalStatusEvaluationOrderChange/edit",
        },
          add: '/eam/eamTechnicalStatusEvaluationOrderChange/add',
          edit: '/eam/eamTechnicalStatusEvaluationOrderChange/edit'
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      add({ id, equipmentId }) {
        this.model = Object.assign({ orderId: id, equipmentId })
        this.visible = true
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      edit(record) {
        this.model = Object.assign({}, record)
        this.visible = true
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
      handleOk() {
        const that = this
        // 触发表单验证
         this.$refs.form.validate(valid => {
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            that.confirmLoading = true
            let httpUrl
            if (!that.model.id) {
              httpUrl = that.url.add
            } else {
              httpUrl = that.url.edit
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
            postAction(httpUrl, that.model)
              .then((res) => {
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  if (!that.model.id) {
                    that.$router.push('/eam/technical/order/change')
                    return
                  }
                  that.close()
                  that.$emit('ok')
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that.confirmLoading = false
              })
          } else {
            return false
          }
        })
      },
      handleCancel () {
      handleCancel() {
        this.close()
      },
      close() {
        this.$emit('close')
        this.visible = false
        this.$refs.form.clearValidate()
      }
    }
  }
</script>
<style lang="less" scoped>
</style>
</script>