MaterialTaskModal.vue 6.7 KB
<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel">

    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="model">
        <!-- 主表单区域 -->
        <a-row class="form-row" :gutter="24">
          <a-col :lg="8">
            <a-form-model-item label="托盘号" :rules="[{ required: true, message: '请输入托盘号!' }]">
              <a-input placeholder="请输入托盘号" v-model="quickMainModel.containerCode"/>
            </a-form-model-item>
          </a-col>
          <a-col :lg="10">
            <a-form-model-item label="入库口">
              <a-input placeholder="请输入入库口" v-model="quickMainModel.fromPort"/>
              <!--              <j-search-select-tag
                              placeholder="请选择入库口"
                              v-model="quickMainModel.toPort"
                              dict="port,name,code,type='5'"
                              :pageSize="5"
                              :async="true">
                            </j-search-select-tag>-->
            </a-form-model-item>
          </a-col>
        </a-row>
        <!-- 子表单区域 -->
        <a-tabs defaultActiveKey="1">
          <a-tab-pane v-if="showType === 'qty'" tab="物料信息" key="1">
            <div>
              <a-row type="flex" style="margin-bottom:10px" :gutter="24">
                <a-col :span="12">物料编码</a-col>
                <a-col :span="8">数量</a-col>
                <!--              <a-col :span="4">操作</a-col>-->
              </a-row>
              <a-row type="flex" style="margin-bottom:-20px" :gutter="24"
                     v-for="(item, index) in quickMainModel.receiptEntityList" :key="index">
                <a-col style="display: none">
                  <a-form-model-item>
                    <a-input placeholder="id" v-model="item.id"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item>
                    <j-search-select-tag
                      placeholder="请选择"
                      v-model="item.materialCode"
                      :dict="'material,name,code'"
                      :pageSize="2"
                      :async="true">
                    </j-search-select-tag>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item>
                    <a-input :max="240" placeholder="数量" v-model="item.qty"/>
                  </a-form-model-item>
                </a-col>
              </a-row>
              <!--            <a-button type="dashed" style="width: 100%;margin-top: 10px" @click="addRowCustom"><a-icon type="plus"/>添加物料信息</a-button>-->
            </div>
          </a-tab-pane>
          <a-tab-pane v-if="showType === 'layer'" tab="物料信息" key="2">
            <div>
              <a-row type="flex" style="margin-bottom:10px" :gutter="24">
                <a-col :span="12">物料编码</a-col>
                <a-col :span="8">层数</a-col>
              </a-row>
              <a-row type="flex" style="margin-bottom:-20px" :gutter="24"
                     v-for="(item, index) in quickMainModel.receiptEntityList" :key="index">
                <a-col style="display: none">
                  <a-form-model-item>
                    <a-input placeholder="id" v-model="item.id"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item>
                    <j-search-select-tag
                      placeholder="请选择"
                      v-model="item.materialCode"
                      :dict="'material,name,code'"
                      :pageSize="4"
                      :async="true">
                    </j-search-select-tag>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item>
                    <a-input :max="16" placeholder="有料层数" v-model="item.layerUse"/>
                  </a-form-model-item>
                </a-col>
              </a-row>
            </div>
          </a-tab-pane>
        </a-tabs>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>

import JEditableTable from '@/components/jeecg/JEditableTable'
import {quickReceipt, quickYLHK} from '@/api/api'
import JDate from '@/components/jeecg/JDate'
import JSelectMultiCanUseContainer from "@/components/jeecgbiz/JSelectMultiCanUseContainer";

export default {
  name: 'MaterialTaskModal',
  components: {
    JDate, JEditableTable, JSelectMultiCanUseContainer
  },
  data() {
    return {
      title: '快速入库',
      visible: false,
      confirmLoading: false,
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 4}
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 24}
      },
      activeKey: '1',
      quickMainModel: {
        receiptEntityList: [{}],
      },
      showType: "qty",
      sceneType: "jt",
      // 客户信息
      url: {
        add: '/test/jeecgOrderMain/add',
        edit: '/test/jeecgOrderMain/edit',
      }
    }
  },
  created() {
  },
  methods: {
    handleOk() {
      this.validateFields()
    },
    handleCancel() {
      this.visible = false
    },
    edit(record) {
      this.visible = true
      this.activeKey = '1'
      this.quickMainModel = Object.assign({
        receiptEntityList: [{}]
      }, record);
    },
    /** 触发表单验证 */
    validateFields() {
      // 触发表单验证
      this.$refs.form.validate(valid => {
        //alert(JSON.stringify(this.quickMainModel));
        this.receipt(this.quickMainModel);
      })
    },
    receipt(record) {
      this.confirmLoading = true
      this.model = Object.assign({}, record);
      if (this.sceneType === 'jt') {
        quickYLHK(this.model).then((res) => {
          this.loading = false;
          if (res.success) {
            this.$message.success(res.message);
            this.$emit('ok');
            this.visible = false
          } else {
            this.$message.error(res.message);
          }
          this.confirmLoading = false
        });
      } else {
        quickReceipt(this.model).then((res) => {
          this.loading = false;
          if (res.success) {
            this.$message.success(res.message);
            this.$emit('ok');
            this.visible = false
          } else {
            this.$message.error(res.message);
          }
          this.confirmLoading = false
        });
      }

    },
  }
}
</script>