PbomForm.vue 5.57 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']"    disabled></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="24">
            <a-form-item label="物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['pno']" placeholder="请输入物料编码"  disabled></a-input>
              <a-input v-decorator="['projectNo']" placeholder="请输入物料编码"  style="display:none"></a-input>
              <a-input v-decorator="['uuid']"  style="display:none"></a-input>
            </a-form-item>
          </a-col>
<!--          <a-col :span="24">-->
<!--            <a-form-item label="自制计划项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['name']" placeholder="请输入项目名称"  ></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" style="text-align: center" class="table-page-search-submitButtons">
            <a-button type="primary" @click="submitForm" icon="check-circle">提 交</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:'',
      pbom_status:'',
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
      },
      searchOptions:[{
        text:"外协",
        value:"外协"
      },{
        text:"自制",
        value:"自制"
      },{
        text:"外购",
        value:"外购"
      }],
      url: {
        list:"1",
        add: "/pbom_type/pbomType/sendPbom",
        edit: "/pbom_type/pbomType/produceSendPbom",
        queryById: "/pbom_type/pbomType/queryById"
      }
    }
  },
  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 () {

  },
  methods: {
    add () {
      this.edit({});
    },
    edit (pno,workNo,flag,projectNo,pbom_status,uuid,projectName) {
      if (flag<1){
        this.$message.warning("请先查询出bom信息");
        return false;
      }
      this.pbom_status=pbom_status;
      if(pno==''){
        this.$message.warning("请至少勾选一条记录");
        return false;
      }
      this.visible = true;
      this.$nextTick(() => {
        this.form.setFieldsValue({
          workNo:workNo,
          pno:pno,
          projectNo:projectNo,
          uuid:uuid,
          projectName:projectName
        })
      })
    },
    handleCancel(){
      this.form.setFieldsValue({
        name:'',
        code:''
      })
      this.visible = false
    },

    submitForm () {
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (this.pbom_status=='1'){
            httpurl+=this.url.edit;
          }else{
            httpurl+=this.url.add;
          }
          method = 'post';
          let formData = Object.assign(this.model, values);
          httpAction(httpurl,formData,method).then((res)=>{
            if(res.success){
              that.$message.success(res.message);
              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>