QualityTestModal.vue 4.81 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="action1" slot-scope="text, record">
        <a-input-number :min="0" placeholder="" v-model="record.goodQty" :value="text"/>
      </span>

      <span slot="action2" slot-scope="text, record">
        <a-input-number :min="0" placeholder="" v-model="record.badQty" :value="text"/>
      </span>

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

    </a-table>


  </j-modal>
</template>

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

export default {
  name: 'QualityTestModal',
  components: {},
  data() {
    return {
      title: '操作',
      width: 800,
      portList: [],
      inventoryDetailList: [],
      invStatus: [],
      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',
          scopedSlots: {customRender: 'inventoryStatus'},
          align: 'center',
          width: 96
        },
        // {
        //   title: '批次',
        //   dataIndex: 'batch',
        //   align: 'center'
        // },
        {
          title: '系统数量',
          dataIndex: 'qty',
          align: 'center',
          width: 80
        },
        {
          title: '合格数量',
          dataIndex: 'goodQty',
          align: 'center',
          key: 'goodQty',
          scopedSlots: {customRender: 'action1'}
        },
        {
          title: '不合格数量',
          dataIndex: 'badQty',
          align: 'center',
          key: 'badQty',
          scopedSlots: {customRender: 'action2'}
        },
      ],
      url: {
        pageByMainIds: "/inventory/inventoryDetail/pageByMainIds",
      },
      // 选择用户查询条件配置
      selectUserQueryConfig: [],
      confirmLoading: false,
      validatorRules: {
        outPortCode: [{required: true, message: '请选择出库口!'}]
      }
    }
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
    this.loadFrom();
  },
  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) {
      const that = this
      getInventoryListByContainer(record).then(res => {
        that.dataSource = res.result
      })
    },
    loadFrom() {
      ajaxGetDictItems('inventory_status').then((res) => {
        if (res.success) {
          this.invStatus = res.result
        }
      });
    },
    handleOk() {
      qualityConfirm(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()
    },
    solutionInvStatus(value) {
      var actions = []
      console.log("solutionInvStatus  value:" + value);
      Object.keys(this.invStatus).some(key => {
        if (this.invStatus[key].value == '' + value) {
          actions.push(this.invStatus[key].text)
          console.log("solutionInvStatus  text:" + this.invStatus[key].text);
          return true
        }
      })
      return actions.join('')
    },
    getStatusColor(status) {
      const colors = {
        'good ': 'green',
        'defective': 'red',
        'discussed': 'grey',
        'scrap': 'purple',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
  }
}
</script>