AgvInventoryDetailModal.vue 6.98 KB
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    :ok-button-props="{ style: { display: 'none' } }"
    @cancel="handleCancel"
    cancelText="关闭">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{ x: true }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
         <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
          <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
            {{ inventoryStatus_dictText }}
          </a-tag>
        </span>

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

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

        <span slot="companyCode" slot-scope="companyCode">
          <a-tag :key="companyCode" color="blue">
            {{ solutionCompany(companyCode) }}
          </a-tag>
        </span>
      </a-table>
    </div>
  </j-modal>
</template>

<script>

import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getCompanyList} from '@/api/api'

export default {
  name: 'AgvInventoryDetailModal',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    containerCode: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    containerCode: {
      immediate: true,
      handler(val) {
        if (!this.containerCode) {
          this.clearList()
        } else {
          this.queryParam['containerCode'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      description: 'AGV库存弹窗',
      disableMixinCreated: true,
      title: "AGV库存",
      width: 1600,
      visible: false,
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      confirmLoading: false,
      companyList: [],
      // 表头
      columns: [
        {
          title: '库存详情ID',
          align: 'center',
          dataIndex: 'id'
        },
        {
          title: '货主',
          align: 'center',
          dataIndex: 'companyCode',
          key: 'companyCode',
          scopedSlots: {customRender: 'companyCode'}
        },
        // {
        //   title: '库区',
        //   align: "center",
        //   dataIndex: 'zoneCode'
        // },
        {
          title: '容器编码',
          align: 'center',
          dataIndex: 'containerCode'
        },
        {
          title: '容器状态',
          align: "center",
          dataIndex: 'containerStatus_dictText',
          scopedSlots: {customRender: 'containerStatus_dictText'}
        },
        {
          title: '库位编码',
          align: 'center',
          dataIndex: 'locationCode'
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName'
        },
        {
          title: '物料规格',
          align: 'center',
          dataIndex: 'materialSpec'
        },
        {
          title: '物料单位',
          align: 'center',
          dataIndex: 'materialUnit'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'qty'
        },
        {
          title: '任务锁定数量',
          align: 'center',
          dataIndex: 'taskQty'
        },
        {
          title: '托盘填充度',
          align: 'center',
          dataIndex: 'fillDensity',
          customRender: text => {
            return text == null ? '' : text + '%'
          }
        },
        {
          title: '库存状态',
          align: 'center',
          dataIndex: 'inventoryStatus_dictText',
          scopedSlots: {customRender: 'inventoryStatus_dictText'}
        },
        {
          title: '可用状态',
          align: 'center',
          dataIndex: 'enable_dictText',
          scopedSlots: {customRender: 'enable_dictText'}
        },
        {
          title: '批次',
          align: 'center',
          dataIndex: 'batch'
        },
        {
          title: '序列号',
          align: "center",
          dataIndex: 'sn'
        },
        {
          title: '入库日期',
          align: 'center',
          dataIndex: 'receiptDate'
        },
        {
          title: '库龄(天)',
          align: 'center',
          dataIndex: 'inventoryAge'
        },
        {
          title: '创建人',
          align: 'center',
          dataIndex: 'createBy'
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '更新人',
          align: 'center',
          dataIndex: 'updateBy'
        },
        {
          title: '更新日期',
          align: 'center',
          dataIndex: 'updateTime'
        }
      ],
      url: {
        list: '/inventory/inventoryHeader/listInventoryDetailByMainId',
      },
      dictOptions: {
        containerStatus: []
      }
    }
  },
  created() {
    this.loadFrom();
    this.loadData(1);
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.containerCode}`
    }
  },
  methods: {
    handleCancel() {
      this.close()
    },
    getStatusColor(status) {
      const colors = {
        '空闲': 'green',
        '有货': 'purple',
        '满盘': 'blue',
        '良品': 'green',
        '报废品': 'purple',
        '待确认	': 'grey',
        '次品': 'red',
        '锁定': 'red',
        "冻结": "red",
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
    close() {
      //this.$emit('close');
      this.visible = false;
    },
    loadFrom() {
      getCompanyList().then(res => {
        if (res.success) {
          this.companyList = res.result
        }
      })
    },
    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('')
    },
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>