CycleCountModal.vue 3.82 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="false">
      <span slot="action" slot-scope="text, record">
        <a-input-number :min="0" placeholder="" v-model="record.countedQty" :value="text"/>
      </span>

      <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus">
          <a-tag :key="inventoryStatus" :color="getStatusColor(inventoryStatus)">
            {{ inventoryStatus }}
          </a-tag>
        </span>

    </a-table>


  </j-modal>
</template>

<script>
import {
  cycleCountConfirm,
  getInventoryListByContainer,
  listCycleDetailChildByDetailId,
  selectPickPort,
  shipmentInventoryDetail
} from '@api/api'
import {getAction} from "@api/manage";

export default {
  name: 'CycleCountModal',
  components: {},
  data() {
    return {
      title: '操作',
      width: 800,
      portList: [],
      inventoryDetailList: [],
      dataSource: [],
      querySource: {},
      visible: false,
      model: {
        outPortCode: null
      },
      labelCol: {
        xs: {span: 24},
        sm: {span: 5}
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16}
      },
      columns: [
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          align: 'center',
          width: 124
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
          align: 'center',
          width: 96
        },
        {
          title: '库存状态',
          dataIndex: 'inventoryStatus',
          align: 'center',
          width: 96,
          scopedSlots: {customRender: 'inventoryStatus'}
        },
        {
          title: '批次',
          dataIndex: 'batch',
          align: 'center'
        },
        {
          title: '系统数量',
          dataIndex: 'qty',
          align: 'center',
          width: 80
        },
        {
          title: '实盘数量',
          dataIndex: 'countedQty',
          align: 'center',
          key: 'countedQty',
          scopedSlots: {customRender: 'action'}
        },
      ],
      url: {
        pageByMainIds: "/inventory/inventoryDetail/pageByMainIds",
      },
      // 选择用户查询条件配置
      selectUserQueryConfig: [],
      confirmLoading: false,
      validatorRules: {
        outPortCode: [{required: true, message: '请选择出库口!'}]
      }
    }
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    add() {
      this.edit(this.modelDefault)
    },
    edit(record) {
      this.visible = true
      this.searchCycle(record);
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    },
    searchCycle(record) {
      console.log("searchCycle  " + record);
      const that = this
      getInventoryListByContainer(record).then(res => {
        that.dataSource = res.result
      })
    },
    handleOk() {
      cycleCountConfirm(this.dataSource).then(res => {
        if (res.success) {
          this.$message.success(res.message)
          this.$emit('ok')
          this.close()
        } else {
          this.visible = false;
          this.$message.error(res.message)
        }
      })
      /*this.$emit('ok', this.model.outPortCode)
      this.close()*/
    },
    handleCancel() {
      this.close()
    },
    getStatusColor(status) {
      const colors = {
        '良品': 'green',
        '次品': 'red',
        '待确认': 'grey',
        '报废品': 'purple',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
  }
}
</script>