ShipHeaderPurchaseForm.vue 6.8 KB
<template>
  <a-modal
    :width="modalWidth"
    :style="modalStyle"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    @cancel="handleCancel">
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
    </template>
    <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="['projectName']"   disabled=""></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="工作令" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['workNo']" placeholder="请输入工作令"  disabled=""></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['no']"   disabled="" ></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['name']"  disabled=""  ></a-input>
          </a-form-item>
        </a-col>

        <a-col :span="24">
          <a-form-item label="类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['spare1']"  disabled=""  ></a-input>
          </a-form-item>
        </a-col>

        <a-col :span="24">
          <a-form-item label="数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['num']" disabled=""  ></a-input>
          </a-form-item>
        </a-col>

        <a-col :span="24">
          <a-form-item label="单位" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['unit']" disabled=""   ></a-input>
          </a-form-item>
        </a-col>

        <a-col :span="24">
          <a-form-item label="快递单号" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['code']" placeholder="请输入快递单号"  ></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="收件人" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['recipient']" placeholder="请输入收件人"  ></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['phone']" placeholder="请输入联系电话"  ></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="收件地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['address']" placeholder="请输入地址"  ></a-input>
          </a-form-item>
        </a-col>

        <a-col :span="24">
          <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input v-decorator="['remark']" placeholder="请输入备注"  ></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="到货时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <j-date placeholder="请选择到货时间" v-decorator="['arrivalTime']" :trigger-change="true" style="width: 100%" />
          </a-form-item>
        </a-col>

        <a-col  :span="24" style="text-align: center">
          <a-button type="primary" icon="check-circle" @click="submitForm">提 交</a-button>
        </a-col>
      </a-row>

    </a-form>
    </a-spin>
  </a-modal>
</template>

<script>

import { httpAction} from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import pick from 'lodash.pick'
export default {
  name: 'PbomTypeForm',
  mixins:[JeecgListMixin],
  components: {
  },
  props: {
    //流程表单data
    formData: {
      type: Object,
      default: ()=>{},
      required: false
    },
    //表单模式:true流程表单 false普通表单
    formBpm: {
      type: Boolean,
      default: false,
      required: false
    },
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data () {
    return {
      visible: false,
      modalWidth: '50%',
      modalStyle: { 'top': '20px'},
      form: this.$form.createForm(this),
      model: {},
      f04:'',
      flag:false,
      flag2:false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      url: {
        list:"1",
        add: "/ship/shipHeader/add",
      },
      validatorRules:{

      },

    }
  },
  computed: {
    formDisabled(){
      if(this.formBpm===true){
        if(this.formData.disabled===false){
          return false
        }
        return true
      }
      return this.disabled
    },
    showFlowSubmitButton(){
      if(this.formBpm===true){
        if(this.formData.disabled===false){
          return true
        }
      }
      return false
    },

  },
  created () {
    //如果是流程中表单,则需要加载流程表单data
    this.showFlowData();
  },
  methods: {
    add () {
      this.edit({});
    },
    edit (projectName,workNo,materialCode,materialName,unit,qty,type) {
      if (materialCode==''){
        this.$message.warning("请至少勾选一条记录");
        return false;
      }
      this.visible=true;
      this.form.resetFields();
      this.visible = true;
      this.$nextTick(() => {
        this.form.setFieldsValue({
          workNo:workNo,
          no:materialCode,
          name:materialName,
          unit:unit,
          num:qty,
          spare1:type,
          projectName:projectName
        })
      })
    },
    handleCancel(){
      this.visible = false
    },

    submitForm () {
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          httpurl+=this.url.add;
          method = 'post';
          let formData = Object.assign(this.model, values);
          httpAction(httpurl,formData,method).then((res)=>{
            if(res.success){
              that.$emit('fatherMethod', '');
              that.$message.success(res.message);
              this.visible = false
              that.$emit('ok');

            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }

      })
    },
    popupCallback(row){
      this.form.setFieldsValue(pick(row,'cno','uuid','f04','code'))
    },
  }
}
</script>