ProductionOrderFinishModal.vue 11.6 KB
<template>
  <j-modal
    :title="title"
    :width="1400"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">
    <a-row :gutter="24">
      <a-col :span="24">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" class="j-inline-form" >
            <a-row :gutter="24">
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="物料序列号">
                  <a-input placeholder="物料序列号" v-model="queryParam.sn"></a-input>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <div style="height: 340px">
          <a-table
            ref="table"
            rowKey="id"
            size="middle"
            bordered
            class="j-table-force-nowrap"
            :scroll="{x:true}"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="false">


          </a-table>
        </div>
      </a-col>
    </a-row>
  </j-modal>
</template>

<script>

// import CycleCountDetailForm from './CycleCountDetailForm'
import JSelectBizQueryItem from "@comp/jeecgbiz/JButtonBizComponent/JSelectBizQueryItem";
import {JeecgListMixin} from "@/mixins/JeecgListMixin";
import {
  getCompanyList,
  getZoneList,
  createCycleCountDetailByInventory,
  getInventoryFromShipmentDetail,
  ajaxGetDictItems, combination, finishProduction, reViewProduction
} from '@api/api'
import {getAction} from "@api/manage";

export default {
  name: 'ProductionOrderFinishModal',
  mixins: [JeecgListMixin],
  components: {
    JSelectBizQueryItem,
    // CycleCountDetailForm
  },
  data() {
    return {
      title: '',
      loading: true,
      visible: false,
      disableSubmit: false,
      cycleCountHeader: {},
      productionHeaderId: {},
      combineParam: {},
      invStatus:[],
      queryParam: {},
      shipQty: {},
      rowKey: 'id',
      selectedRowKeys: [],
      selectedRows: [],
      selectedRowIds: [],
      columns: [
        {title: '详情ID', align: 'center', dataIndex: 'id'},
        {title: '物料编码', align: 'center', dataIndex: 'materialCode'},
        {title: '序列号', align: 'center', dataIndex: 'sn'},
        {title: '数量', align: 'center', dataIndex: 'qty'},
        {title: '配盘数量', align: 'center', dataIndex: 'taskQty'},
        {title: '可出数量', align: 'center', dataIndex: 'shipmentQty'},
      ],
      detailColumns: [
        {title: '货主', align: "center", dataIndex: 'companyCode', scopedSlots: {customRender: 'companyCode'}},
        {title: '库位编码', align: "center", dataIndex: 'locationCode'},
        {title: '容器编码', align: "center", dataIndex: 'containerCode'},
        {title: '物料编码', align: "center", dataIndex: 'materialCode'},
        {title: '物料名称', align: "center", dataIndex: 'materialName'},
        {title: '库存数量', align: "center", dataIndex: 'qty'},
        {title: '锁定数量', align: "center", dataIndex: 'taskQty'},
        {
          title: '库存状态',
          dataIndex: 'inventoryStatus',
          align: 'center',
          scopedSlots: {customRender: 'inventoryStatus'}
        },
        {title: '批次', align: "center", dataIndex: 'batch'},
        {title: '入库日期', align: "center", dataIndex: 'receiptDate'},
        {
          title: '出库数量',
          dataIndex: 'action',
          align: 'center',
          key: 'action',
          scopedSlots: {customRender: 'action'}
        },
        {
          title: '操作',
          dataIndex: 'action2',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action2' }
        }
      ],
      selectedTable: {
        pagination: false,
        scroll: {y: 235},
        columns: [
          {title: '库位编码', align: 'center', width: '70%', dataIndex: 'locationCode'},
          {title: '操作', dataIndex: 'action', align: 'center', width: 60, scopedSlots: {customRender: 'action'},}
        ],
        dataSource: [],
      },
      dataSource: [],
      detailDataSource: [],
      url: {
        list: '/shipment/productionOrderHeader/listProductionOrderDetailByMainId',
        pageByMainIds: "/inventory/productionOrderHeader/pageByMainIds"
      },
      zoneList: [],
      companyList: [],
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '100'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      detailIpagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '100'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      }
    }
  },
  methods: {
    searchReset() {
      Object.keys(this.queryParam).forEach(key => {
        this.queryParam[key] = ''
      })
      this.selectedRowKeys = []
      this.selectedRows = []
      this.selectedRowIds = []
      this.selectedTable.dataSource = []
      this.detailDataSource = []
      this.detailIpagination.total = 0
      // this.loadData(1)
      this.dataSearch(this.productionHeaderId);
    },
    edit(record) {
      this.productionHeaderId = record;
      console.log("this.productionHeaderId:" + this.productionHeaderId);
      this.search(this.productionHeaderId);
    },
    search() {
      this.dataSearch();
      // 点击查询清空列表选中行
      // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    dataSearch(arg){
      //加载数据 若传入参数1则加载第一页的内容
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      this.selectedRowKeys = []
      this.selectionRows = []
      this.detailDataSource = []
      this.queryParam.headerId = this.productionHeaderId;
      this.queryParam.sn = "";
      var params = this.getQueryParams();//查询条件
      params.headerId = this.productionHeaderId;
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records || res.result;
          if (res.result.total) {
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },

    solutionInvStatus(value) {
      var actions = []
      Object.keys(this.invStatus).some(key => {
        if (this.invStatus[key].value == '' + value) {
          actions.push(this.invStatus[key].text)
          return true
        }
      })
      return actions.join('')
    },
    handleOk() {
      this.finishProduction();
      this.$emit('ok');
      this.close();
    },
    finishProduction() {
      this.loading = true;
      finishProduction(this.queryParam).then((res) => {
        if (res.success) {
          this.$message.success(res.message);
          this.$emit('ok');
        } else {
          this.$message.warning(res.message)
        }
        this.loading = false;
      })
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys;
      // 解决翻页后 selectionRows 没记录上一页的问题
      if (selectedRowKeys.length === selectionRows.length) {
        this.selectionRows = selectionRows;
      } else {
        this.selectionRows = selectedRowKeys.map(key => (
          this.selectionRows.find(row => row.id === key) || selectionRows.find(row => row.id === key)
        ))
      }
      this.selectedTable.dataSource = this.selectionRows;
      this.selectedRowIds = this.selectionRows.map(x => x.id)
      this.searchShipment();
    },
    clickThenSelect(record,index) {
      return {
        on: {
          click: () => {
            this.selectIndex=index
            this.onSelectChange(record.id.toString().split(','), [record]);
          }
        }
      }
    },
    combine(record) {
      const that = this
      that.querySource = record
      this.combineParam.shipmentDetailID =  this.selectionRows[0].id
      this.combineParam.inventoryDetailID = record.id
      this.combineParam.shipQty = record.shipQty
      combination(this.combineParam).then(res => {
        if (res.success) {
          // this.model = res.result;
          this.$message.success(res.message)
          this.searchShipment()
          // this.refreshHeader();
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    handleDetailTableChange(pagination, filters, sorter) {
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field;
        this.isorter.order = "ascend" === sorter.order ? "asc" : "desc"
      }
      this.detailIpagination = pagination;
      this.searchShipment();
    },
    searchShipment() {
      let id = this.selectionRows[0].id;
      console.log("searchShipment" + id);
      let params = {
        id: id
      }
      getInventoryFromShipmentDetail(params).then(res => {
        if (res.success) {
          this.detailDataSource = res.result;
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    loadDetailDataSource(pageCurrent) {
      if (pageCurrent && typeof pageCurrent == 'number') {
        this.detailIpagination.current =  pageCurrent;
      }
      this.loading = true;
      let params = {
        inventoryHeaderIds: this.selectedRowIds.join(","),
        pageNo:  this.detailIpagination.current,
        pageSize: this.detailIpagination.pageSize
      }

      getAction(this.url.pageByMainIds, params).then((res) => {
        if (res.success) {
          this.detailDataSource = res.result ? res.result.records : null;
          if (res.result && res.result.total) {
            this.detailIpagination.total = res.result.total;
          } else {
            this.detailIpagination.total = 0;
          }
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    close() {
      // this.searchReset()
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
    loadForm() {
      getZoneList().then(res => {
        if (res.success) {
          this.zoneList = res.result
        }
      })
      getCompanyList().then(res => {
        if (res.success) {
          this.companyList = res.result
        }
      })
      ajaxGetDictItems('inventory_status').then((res) => {
        if (res.success) {
          this.invStatus = res.result
        }
      })
    },
    solutionZoneCode(value) {
      let actions = []
      Object.keys(this.zoneList).some(key => {
        if (this.zoneList[key].code === '' + value) {
          actions.push(this.zoneList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    solutionCompany(value) {
      let actions = []
      Object.keys(this.companyList).some(key => {
        if (this.companyList[key].code === '' + value) {
          actions.push(this.companyList[key].name)
          return true
        }
      })
      return actions.join('')
    },
    getStatusColor(status) {
      return 'blue';
    },
  },
  created() {
    this.loadForm();
  }
}
</script>

<style lang="less" scoped>
</style>