newsOrderPart.vue 9.2 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/3">
            <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/3">
            <a-form-item label="物料编码:" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['cno']" placeholder="请输入物料编码" disabled></a-input>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="采购"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose" v-model="visibleCheck"/>
            </a-form-item>
          </a-col>

          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="到货"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose2" v-model="visibleCheck2"/>
            </a-form-item>
          </a-col>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="入库"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose3" v-model="visibleCheck3"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="领料"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose4" v-model="visibleCheck4"/>
            </a-form-item>
          </a-col>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="制作"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose5" v-model="visibleCheck5"/>
            </a-form-item>
          </a-col>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="工艺"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose6" v-model="visibleCheck6"/>
            </a-form-item>
          </a-col>
        </a-row>

        <a-row>
          <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),
      excludeFlag: "",
      visibleCheck: false,
      excludeFlag2: "",
      visibleCheck2: false,
      excludeFlag3: "",
      visibleCheck3: false,
      excludeFlag4: "",
      visibleCheck4: false,
      excludeFlag5: "",
      visibleCheck5: false,
      excludeFlag6: "",
      visibleCheck6: false,
      model: {},
      no: '',
      flag: false,
      flag2: false,
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      confirmLoading: false,
      validatorRules: {},
      searchOptions: [{
        text: "外协",
        value: "外协"
      }, {
        text: "自制",
        value: "自制"
      }, {
        text: "外购",
        value: "外购"
      }, {
        text: "工序外协",
        value: "工序外协"
      }],
      url: {
        list: "1",
        add: "/news/userNewsOrder/add",
        edit: "/pbom_type/pbomType/edit",
        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() {
    //如果是流程中表单,则需要加载流程表单data
    this.showFlowData();
  },
  methods: {
    add() {
      this.edit({});
    },
    edit(record, workNo) {
      this.visible = true;
      this.form.resetFields();
      this.no = record.cno;
      this.model = Object.assign({}, record);
      this.visible = true;
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, 'cno', 'uuid', 'f04', 'code'))
        this.form.setFieldsValue({
          workNo: workNo
        })
      })
      if (record.purchase == '1') {
        this.visibleCheck = true
      } else {
        this.visibleCheck = false
      }
      if (record.arrival == '1') {
        this.visibleCheck2 = true
      } else {
        this.visibleCheck2 = false
      }
      if (record.warehousing == '1') {
        this.visibleCheck3 = true
      } else {
        this.visibleCheck3 = false
      }
      if (record.picking == '1') {
        this.visibleCheck4 = true
      } else {
        this.visibleCheck4 = false
      }
      if (record.make == '1') {
        this.visibleCheck5 = true
      } else {
        this.visibleCheck5 = false
      }
      if (record.craft == '1') {
        this.visibleCheck6 = true
      } else {
        this.visibleCheck6 = false
      }
    },
    handleCancel() {
      this.visible = false
    },

    onChose(checked) {
      if (checked) {
        this.excludeFlag = 1
        this.visibleCheck = true
      } else {
        this.excludeFlag = 0
        this.visibleCheck = false
      }
    },

    onChose2(checked) {
      if (checked) {
        this.excludeFlag2 = 1
        this.visibleCheck2 = true
      } else {
        this.excludeFlag2 = 0
        this.visibleCheck2 = false
      }
    },

    onChose3(checked) {
      if (checked) {
        this.excludeFlag3 = 1
        this.visibleCheck3 = true
      } else {
        this.excludeFlag3 = 0
        this.visibleCheck3 = false
      }
    },

    onChose4(checked) {
      if (checked) {
        this.excludeFlag4 = 1
        this.visibleCheck4 = true
      } else {
        this.excludeFlag4 = 0
        this.visibleCheck4 = false
      }
    },

    onChose5(checked) {
      if (checked) {
        this.excludeFlag5 = 1
        this.visibleCheck5 = true
      } else {
        this.excludeFlag5 = 0
        this.visibleCheck5 = false
      }
    },

    onChose6(checked) {
      if (checked) {
        this.excludeFlag6 = 1
        this.visibleCheck6 = true
      } else {
        this.excludeFlag6 = 0
        this.visibleCheck6 = 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);
          formData.no = this.no
          formData.purchase = this.excludeFlag
          formData.arrival = this.excludeFlag2
          formData.warehousing = this.excludeFlag3
          formData.picking = this.excludeFlag4
          formData.make = this.excludeFlag5
          formData.craft = this.excludeFlag6
          httpAction(httpurl, formData, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              this.visible = false
              that.$emit('ok');
              that.$emit('fatherMethod', '');

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

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