AgvInventoryDetailModal.vue 10.5 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 class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <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-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button id="search" type="primary" @click="snChangeEvent()" icon="search">添加</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <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'
import {simpleDebounce} from "@/utils/util";
import {getAction} from "@api/manage";

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: {},
      queryParam:{},
      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: 'zoneCode'
        },
        {
          title: '小车',
          align: 'center',
          dataIndex: 'vehicleCode'
        },
        {
          title: '工单号',
          align: 'center',
          dataIndex: 'workOrder'
        },
        {
          title: '工位号',
          align: 'center',
          dataIndex: 'station'
        },
        {
          title: '目标点位',
          align: 'center',
          dataIndex: 'agvPortCode'
        },
        // {
        //   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: '/agv/listInventoryDetail',
      },
      dictOptions: {
        containerStatus: []
      }
    }
  },
  created() {
    this.loadFrom();
    this.loadData();
  },
  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() {
      console.log('fsdfsdfsd')
      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
    },
    snChangeEvent: simpleDebounce(function (record) {

      console.log(queryParam.sn)
      if (record.sn == null || record.sn === '') {
        return
      }
      let that = this;
      getAction(that.url.flatReceiveGetMaterialInfoBySn, {sn: record.sn})
        .then(res => {
          if (res.success) {
            let result = res.result
            if (result.code !== record.materialCode) {
              that.$message.warning("该序列号对应的入库物料 " + result.code + " 与单据明细物料 " + record.materialCode + " 不一致")
              record.sn = null;
              return;
            }
            record.taskQty = result.qty;
            record.sn = result.sn;
            that.$message.success(res.message);
          } else {
            that.$message.warning(res.message);
            record.sn = null;
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    }, 500),
    loadData() {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      // if (arg === 1) {
      //   this.ipagination.current = 1
      // }
      var params = this.getQueryParams() //查询条件
      this.loading = true
      console.log(params)
      getAction(this.url.list, params)
        .then(res => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
            //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>