submitWarehouse.vue 4.69 KB
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
    okText="提交生产领料单"
  >

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" >
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="计划号">
              <a-input placeholder="请输入备注" v-model="referCode" disabled=""></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="备注">
              <a-input placeholder="请输入备注" v-model="remark"></a-input>
            </a-form-item>
          </a-col>


        </a-row>
      </a-form>
    </div>

    <j-vxe-table
      ref="vTable"
      :columns="columns"
      :dataSource="dataSource"
      :rowNumber="true"
      :rowSelection="true"
      :maxHeight="400"
    />

  </j-modal>
</template>

<script>

import { httpAction } from '@/api/manage'
import {JVXETypes} from '@/components/jeecg/JVxeTable'
import moment from "moment";
import {randomNumber, randomUUID} from '@/utils/util'
import {productPickShipment,getBomListByIds} from '@/api/api'
export default {
  name: "submitWarehouse",
  components: {
  },
  props:{
    mainId:{
      type:String,
      required:false,
      default:''
    }
  },
  data () {
    return {
      title:"操作",
      width:1500,
      visible: false,
      loading: false,
      remark: '',
      referCode:'',
      ids: '',
      columns: [
        {
          title: '零件名称',
          key: 'partsName',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '关联物料',
          key: 'materialCode',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '规格',
          key: 'spec',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '尺寸',
          key: 'shapeSize',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },

        {
          title: '总量',
          key: 'totalWeight',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '待领',
          key: 'tjWeight',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '需领',
          key: 'xlWeight',
          type: JVXETypes.inputNumber,
          width: '200px',
          validateRules: [{required: true, message: '${title}不能为空'}]
        }
      ],
      dataSource: [],
      model:{
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },

      confirmLoading: false,
      validatorRules: {
      },
      url: {
        add: "/product_model/productModel/addBom",
        edit: "/product_model/productModel/editBom",
      }

    }
  },
  created () {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model));
  },
  methods: {
    loadFrom() {
      let params = {
        'id': this.ids,
      }
      getBomListByIds(params).then((res) => {
        this.dataSource=res.result;
      })
    },
    add () {
      this.edit(this.modelDefault);
    },
    edit (ids,planNumber) {
      this.referCode=planNumber
      this.ids=ids;
      this.visible = true;
      this.loadFrom();

    },
    close () {
      this.$emit('close');
      this.visible = false;
      this.$refs.form.clearValidate();
    },

    handleOk () {
      this.$refs.vTable.validateTable().then(errMap => {
        if (!errMap) {
          const values = this.$refs.vTable.getTableData()
          values.forEach(row => {
            if(row.xlWeight>row.totalWeight-row.tjWeight){
              this.$message.error("物料:"+row.materialCode+"超出bom定额用量");
              return false;
            };
            row.referCode = this.referCode;
            row.version = this.remark;
          });
          productPickShipment(values).then((res) => {
              this.$message.success(res.message);
          })
        }
      })


    },
    handleCancel () {
      this.close()
    },


  }
}
</script>