CreatScanCheckTaskModal.vue 5.67 KB
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-table ref="table" rowKey="id" size="middle" :columns="columns" :dataSource="dataSource" :pagination="ipagination">
      <span slot="action" slot-scope="text, record">
        <a-input-number placeholder="" v-model="record.shipmentQty" :value="text" />
      </span>
    </a-table>
  </j-modal>
</template>

<script>
import {getZoneList, scanCheckInventoryDetail, selectPickPort} from '@/api/api'
import {getAction} from "@api/manage";

export default {
  name: 'CreatScanCheckTaskModal',
  components: {},
  data() {
    return {
      title: '操作',
      width: 1400,
      portList: [],
      inventoryDetailList: [],
      dataSource: [],
      ipagination: {
        current: 1,
        pageSize: 20,
        pageSizeOptions: ['20', '50', '100'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      querySource: {},
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
        {
          title: '容器编码',
          dataIndex: 'containerCode',
          align: 'center',
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          align: 'center',
          width: 124
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center',
          width: 96
        },
        {
          title: '物料名称',
          dataIndex: 'materialSpec',
          align: 'center',
          width: 96
        },
        {
          title: '库存状态',
          align: 'center',
          dataIndex: 'inventoryStatus_dictText',
          scopedSlots: {customRender: 'inventoryStatus_dictText'}
        },
        {
          title: '批次',
          dataIndex: 'project',
          align: 'center'
        },
        {
          title: '托号',
          dataIndex: 'batch',
          align: 'center'
        },
        {
          title: '卷号',
          dataIndex: 'batch',
          align: 'center'
        },
        {
          title: '叠片',
          align: "center",
          dataIndex: 'userdef4'
        },
        {
          title: '铁损',
          align: "center",
          dataIndex: 'userdef5'
        },
        {
          title: '励磁',
          align: "center",
          dataIndex: 'userdef6'
        },
        {
          title: '极差',
          align: "center",
          dataIndex: 'userdef7'
        },
        {
          title: '均厚',
          align: "center",
          dataIndex: 'userdef8'
        },
        {
          title: '产线',
          align: "center",
          dataIndex: 'userdef11'
        },
        {
          title: '等级',
          align: "center",
          dataIndex: 'userdef12'
        },
        {
          title: '包装方式',
          align: "center",
          dataIndex: 'userdef13_dictText'
        },
        {
          title: '客户标签',
          align: "center",
          dataIndex: 'userdef14_dictText'
        },
        {
          title: '发货类型',
          align: "center",
          dataIndex: 'userdef10'
        },
        {
          title: '库存数量',
          dataIndex: 'qty',
          align: 'center',
          width: 80
        },
        {
          title: '出库数量',
          dataIndex: 'shipmentQty',
          align: 'center',
          key: 'action',
          scopedSlots: { customRender: 'action' }
        },
      ],
      url: {
        pageByMainIds: "/inventory/inventoryDetail/pageByMainIds",
      },
      // 选择用户查询条件配置
      selectUserQueryConfig: [],
      confirmLoading: false,
      validatorRules: {

      }
    }
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  watch: {
    dataSource: {
      handler(newDataSource) {
        newDataSource.forEach(record => {
          record.shipmentQty = record.qty;
        });
      },
      deep: true
    }
  },
  methods: {
    add() {
      this.edit(this.modelDefault)
    },
    edit(record) {
      this.visible = true
      this.model.containerCode = record[0].containerCode
      this.inventoryDetailList = record
      this.searchInventoryDetailList();
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    },
    searchInventoryDetailList() {
      let params = {
        inventoryHeaderIds:""
      };
      this.inventoryDetailList.forEach(x=>{
        params.inventoryHeaderIds+=  + x.inventoryHeaderId + ","
      })
      params.pageNo = this.ipagination.current;
      params.pageSize = this.ipagination.pageSize;
      getAction(this.url.pageByMainIds, params).then((res) => {
        this.dataSource = res.result.records
        this.inventoryDetailList = res.result.records
      })
    },
    handleOk() {
      if (this.model.outPortCode === '') {
        this.$message.warning('请选择出库口')
      }
      scanCheckInventoryDetail(this.inventoryDetailList).then(res => {
        if (res.success) {
          this.$message.success(res.message)
          this.$emit('ok')
        } else {
          this.$message.error(res.message)
        }
      })
      this.$emit('ok', this.model.outPortCode)
      this.close()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>