OutsourcingInModal.vue 6.57 KB
<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
    wrapClassName="ant-modal-cust-warp"
    style="top:5%;height: 85%;overflow-y: hidden">

    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="物料编码">
          <a-input placeholder="请输入物料编码" disabled="false" v-decorator="['materialCode']" />
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="名称">
          <a-input placeholder="请输入名称" disabled="false" v-decorator="[ 'materialName' ]" />
        </a-form-item>

          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="规格">
            <a-input placeholder="请输入规格" v-decorator="[ 'spec' ]" />
          </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="单位">
          <a-input placeholder="请输入单位"   v-decorator="[ 'unit' ]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="数量">
          <a-input placeholder="请输入数量"   v-decorator="[ 'qty' ]" />
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="采购单号">
          <a-input  disabled="false" v-decorator="['code']" />
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="状态">
          <a-select
            v-model="status" disabled="false"
          >
            <a-select-option v-for="item in statusList" :key="item.value" :value="item.value">{{ item.text }}</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="供应商">
          <a-input placeholder="请输入供应商"   v-decorator="['supplier']" />
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="联系人">
          <a-input placeholder="请输入联系人"   v-decorator="['contact']" />
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="联系方式">
          <a-input placeholder="请输入联系方式"   v-decorator="['phone']" />
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="初次计划完成时间" >
          <a-date-picker
            v-decorator="['planEndTime']" disabled="false"
            type="date"
          />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="变更计划完成时间">
          <a-date-picker
            v-decorator="['changePlanEndTime']"
            type="date"
          />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="实际结束时间">
          <a-date-picker disabled="false"
            v-decorator="['actualEndTime']"
            type="date"
          />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import {ajaxGetDictItems,editOutsourcing} from '../../../api/api'
export default {
  name: 'OutsourcingInModal',
  data () {
    return {
      title:"操作",
      visible: false,
      model: {},
      designType: '',
      wipType: '',
      method: '',
      categories: '',
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
      methodList: {},
      wipTypeList: {},
      designTypeList: {},
      categoryList: {},
      statusList:[],
      status:''
    }
    this.status = this.model.status
  },
  computed() {

  },
  created() {
    this.loadBaseData();
  },
  methods: {
    loadBaseData() {
      ajaxGetDictItems('outsourcing_status').then((res)=> {
        if (res.success) {
          this.statusList = res.result
        }
      })
    },
    add () {
      this.edit({});
    },
    edit (record) {
      this.form.resetFields();
      this.model = Object.assign({}, record);
      this.visible = true;
      this.$nextTick(() => {
        this.form.setFieldsValue({
          materialCode: this.model.materialCode,
          materialName: this.model.materialName,
          brand: this.model.brand,
          spec: this.model.spec,
          unit: this.model.unit,
          planStartTime: this.model.planStartTime,
          planEndTime: this.model.planEndTime,
          actualStartTime: this.model.actualStartTime,
          actualEndTime: this.model.actualEndTime,
          contact: this.model.contact,
          status: this.model.status,
          changePlanEndTime:this.model.changePlanEndTime,
          code:this.model.code,
          qty:this.model.qty
        })
      });
      this.status = this.model.status
    },
    close () {
      this.$emit('close');
      this.visible = false;
    },
    handleOk () {
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let formData = Object.assign(this.model, values);
          editOutsourcing(formData).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()
    },
    validateRoleCode(rule, value, callback){
      if(/[\u4E00-\u9FA5]/g.test(value)){
        callback("角色编码不可输入汉字!");
      }else{
        var params = {
          tableName: "sys_role",
          fieldName: "role_code",
          fieldVal: value,
          dataId: this.model.id,
        };
        duplicateCheck(params).then((res)=>{
          if(res.success){
            callback();
          }else{
            callback(res.message);
          }
        });
      }
    }

  }
}
</script>

<style scoped>

</style>