AgvInventoryDetailModal.vue 9.66 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" v-if="vehicleStatus === 0">
      <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="请扫描序列号,添加库存" ref="inputSn" v-model="sn" @change="snChangeEvent"></a-input>
            </a-form-item>
          </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>

        <span slot="action" slot-scope="text, record">
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a v-has="'agvInventory:remove'">删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
  </j-modal>
</template>

<script>

import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getCompanyList} from '@/api/api'
import {simpleDebounce} from "@/utils/util";
import {deleteAction, getAction} from "@api/manage";

export default {
  name: 'AgvInventoryDetailModal',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    containerCode: {
      type: String,
      default: '',
      required: false
    },
    vehicleCode: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    containerCode: {
      immediate: true,
      handler(val) {
        if (!this.containerCode) {
          this.clearList()
        } else {
          this.queryParam['containerCode'] = val
          this.loadData(1)
        }
      }
    },
    vehicleCode: {
      immediate: true,
      handler(val) {
        if (!this.vehicleCode) {
          this.clearList()
        } else {
          this.queryParam['vehicleCode'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      description: 'AGV库存弹窗',
      disableMixinCreated: true,
      title: "AGV库存",
      width: "80%",
      visible: false,
      vehicleStatus: null,
      queryParam: {},
      sn: null,
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      confirmLoading: false,
      companyList: [],
      columns: [
        {
          title: '小车',
          align: 'center',
          dataIndex: 'vehicleCode'
        },
        {
          title: '容器编码',
          align: 'center',
          dataIndex: 'containerCode'
        },
        {
          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: 'batch'
        },
        {
          title: '序列号',
          align: "center",
          dataIndex: 'sn'
        },
        {
          title: '订单号',
          align: 'center',
          dataIndex: 'workOrder'
        },
        {
          title: '领料单号',
          align: 'center',
          dataIndex: 'referCode'
        },
        {
          title: '上游行号',
          align: 'center',
          dataIndex: 'referLineNum'
        },
        {
          title: '车间号',
          align: 'center',
          dataIndex: 'finr'
        },
        {
          title: '工位号',
          align: 'center',
          dataIndex: 'station'
        },
        {
          title: '工序号',
          align: 'center',
          dataIndex: 'processNumber'
        },
        {
          title: '加工部件',
          align: 'center',
          dataIndex: 'processParts'
        },
        {
          title: '加工部件图号',
          align: 'center',
          dataIndex: 'figureNumber'
        },
        {
          title: '拣配人',
          align: "center",
          dataIndex: 'picker'
        },
        {
          title: '拣配时间',
          align: "center",
          dataIndex: 'pickTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: {customRender: 'action'}
        },
      ],
      url: {
        list: '/agv/listInventoryDetail',
        delete: '/agv/removeInventory',
        queryByShipmentSn: '/agv/queryByShipmentSn',
        pickByShipmentSn: '/agv/pickByShipmentSn',
      },
    }
  },
  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.sn = null
      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
    },
    snChangeEvent: simpleDebounce(function () {
      if (this.sn === undefined || this.sn === '') {
        return
      }
      let that = this;
      getAction(that.url.pickByShipmentSn, {
        sn: this.sn,
        containerCode: this.queryParam.containerCode,
        vehicleCode: this.queryParam.vehicleCode
      }).then(res => {
        that.$refs.inputSn.focus();
        if (res.success) {
          that.loadData()
          that.$message.success(res.message);
          this.$emit('dataSearch');
        } else {
          that.$message.warning(res.message);
        }
      }).finally(() => {
        that.sn = null;
        that.confirmLoading = false;
      })
    }, 500),
    handleDelete(id) {
      if (!this.url.delete) {
        this.$message.error("请设置url.delete属性!")
        return
      }
      let that = this;
      deleteAction(that.url.delete, {id: id}).then((res) => {
        if (res.success) {
          //重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message);
          that.loadData();
          this.$emit('dataSearch');
        } else {
          that.$message.warning(res.message);
        }
      })
    },
    loadData() {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      let params = this.getQueryParams()
      this.loading = true
      params['sn'] = ''
      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>