submitWarehouse.vue 5.42 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="projectCode" 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="workCode" disabled=""></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="仓库" prop="remark">
              <!--              <a-input v-model="model.userdef3" placeholder="请输入班组"></a-input>-->
              <j-dict-select-tag placeholder="请选择头状态" v-model="warehouse" dictCode="warehouse"/>
            </a-form-model-item>
          </a-col>

          <a-col :xl="8" :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 {JVXETypes} from '@/components/jeecg/JVxeTable'
import {getWoDetailListByIds, productPickShipment} from '@/api/api'

export default {
  name: "submitWarehouse",
  components: {},
  props: {
    mainId: {
      type: String,
      required: false,
      default: ''
    }
  },
  data() {
    return {
      title: "操作",
      width: 1600,
      visible: false,
      loading: false,
      remark: '',
      workCode: '',
      warehouse: '',
      userdef3: '',
      projectCode: '',
      ids: '',
      columns: [
        {
          title: '项次',
          key: 'sfbaseq',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '上阶料号',
          key: 'sfba001',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: 'bom料号',
          key: 'sfba005',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '发料料号',
          key: 'sfba006',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '应发总数量',
          key: 'sfba013',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },

        {
          title: '已发数量',
          key: 'yfsl',
          type: JVXETypes.normal,
          width: '180px',
          fixed: 'left',
          defaultValue: 'normal-new',
        },
        {
          title: '领料数量',
          key: 'llsl',
          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,
      }
      getWoDetailListByIds(params).then((res) => {
        this.dataSource = res.result;
      })
    },
    add() {
      this.edit(this.modelDefault);
    },
    edit(ids, workCode, projectCode) {
      this.workCode = workCode
      this.projectCode = projectCode
      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.xlqty > row.qty - row.ylqty) {
            //   this.$message.error("物料:" + row.materialCode + "超出bom定额用量");
            //   return false;
            // }
            row.reamrk = this.remark;
            row.warehouse = this.warehouse;
          });
          productPickShipment(values).then((res) => {
            if (res.success) {
              this.$message.success(res.message);
            } else {
              this.$message.error(res.message);
            }
            this.visible = false;
          })
        }
      })


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


  }
}
</script>