SchedulerDetailModal.vue 8.49 KB
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row>
<!--          <a-col :span="24">-->
<!--            <a-form-item label="图号" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['drawingNo', { rules: [{ required: true, message: '请输入图号' }] }]" placeholder="请输入图号" ></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="父图号" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['parentDrawingNo']" placeholder="请输入父图号" ></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['name', { rules: [{ required: true, message: '请输入名称' }] }]" placeholder="请输入名称" ></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="型号规格" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['spec']" placeholder="请输入型号规格" ></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="准备工时" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['readyTime']" placeholder="请输入准备工时" ></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="操作工时" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['technologyTime']" placeholder="请输入操作工时" ></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="数量" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['qty', { rules: [{ required: true, message: '请输入数量' }] }]" placeholder="请输入数量" style="width: 100%" />-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-item label="长度" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['length']" placeholder="请输入长度" style="width: 100%" />-->
<!--            </a-form-item>-->
<!--          </a-col>-->

          <a-col :span="24">
            <a-form-model-item label="工艺" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <j-search-select-tag
                placeholder="请选择工艺"
                v-decorator="['technology']"
                dict="technology,name,code,type='ljgy'"
                :pageSize="30"
                :async="true">
              </j-search-select-tag>
            </a-form-model-item>
          </a-col>

<!--          <a-col :span="24">-->
<!--            <a-form-item label="下图日期/预期完成日期" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-date placeholder="请选择下图日期/预期完成日期" v-decorator="['preDate']" :trigger-change="true" style="width: 100%" />-->
<!--            </a-form-item>-->
<!--          </a-col>-->
        </a-row>
      </a-form>
    </a-spin>
  </j-modal>
</template>

<script>

  import {getTechnologyType, getTechnology} from '@/api/api'
  import pick from 'lodash.pick'
  import {addDetail, editDetail, addFromDetail} from '@/api/schedulerApi'
  // import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: "SchedulerDetailModal",
    components: {
    },
    props:{
      mainId:{
        type:String,
        required:false,
        default:''
      }
    },
    data () {
      let technologyTypeList
      let technologyList
      let technologyTypeModal
      let technologyModal
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/scheduler/schedulerHeader/addSchedulerDetail",
          edit: "/scheduler/schedulerHeader/editSchedulerDetail",
        },
        technologyTypeList,
        technologyList,
        technologyTypeModal,
        technologyModal
      }
    },
    created () {
      this.getTechnologyType()
      this.getTechnologyList()
    },
    methods: {
      handleProvinceChange(value) {
        this.getTechnologyList(value)
      },
      add () {
        this.edit({});
      },
      addForm (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.model.id = null;
        this.model.userDef3 = 1;
        this.visible = true;
        this.technologyModal = record.technology;
        this.technologyTypeModal = record.technologyType;
        this.getTechnologyList(record.technologyType)
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model, 'id', 'drawingNo', 'parentDrawingNo', 'name', 'spec', 'qty','length','weight','readyTime','technologyTime','technology', 'preDate','sequence','completeDate','delayReason', 'completeBy'))
        })
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.technologyModal = record.technology;
        this.technologyTypeModal = record.technologyType;
        this.getTechnologyList(record.technologyType)
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model, 'technology'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            values.drawingNo = (values.drawingNo || '').trim()
            values.name = (values.name || '').trim()
            values.parentDrawingNo = (values.parentDrawingNo || '').trim()
            let formData = Object.assign(this.model, values);
            formData['headerId'] = this.mainId
            // formData['technology'] = this.technologyModal
            // formData['technologyType'] = this.technologyTypeModal
            let obj
            if(!this.model.id) {
              if (this.model.userDef3 == 1) {
                obj = addFromDetail(formData)
              } else {
                obj = addDetail(formData)
              }
            }else{
              obj = editDetail(formData)
            }
            obj.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()
            })
          }
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'headerId','drawingNo','name','qty','length','weight','readyTime','technologyTime','technology','preDate','weldTechnology','weldBy','weldDate','machiningTechnology','machiningBy','machiningDate','paintTechnology','paintBy','paintDate','completedDate','delayReason'))
      },
      getTechnologyType() {
        const that = this;
        let obj = getTechnologyType();
        obj.then((res) => {
          if (res.success) {
            that.technologyTypeList = res.result;
          } else {
            that.$message.warning(res.message);
          }
        })
      },
      getTechnologyList(val) {
        const that = this;
        let obj = getTechnology({val});
        obj.then((res) => {
          if (res.success) {
            that.technologyList = res.result;
          } else {
            that.$message.warning(res.message);
          }
        })
      }
    }
  }
</script>