AgvTaskDetailList.vue 3.37 KB
<template>
  <div>
    <a-table
      ref="table"
      size="middle"
      :scroll="{x:true}"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange">

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

    </a-table>
  </div>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'

export default {
  name: 'AgvTaskDetailList',
  mixins: [JeecgListMixin],
  props: {
    shipmentCode: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      description: 'AGV任务详情',
      // 表头
      columns: [
        {
          title: '任务ID',
          align: "center",
          dataIndex: 'id',
          sorter: true,
        },
        {
          title: '起始点位',
          align: "center",
          dataIndex: 'fromPort'
        },
        {
          title: '目标点位',
          align: "center",
          dataIndex: 'toPort'
        },
        {
          title: '托盘号',
          align: "center",
          dataIndex: 'containerCode'
        },
        {
          title: '小车编号',
          align: "center",
          dataIndex: 'carno'
        },
        {
          title: '任务状态',
          align: "center",
          dataIndex: 'status_dictText',
          scopedSlots: { customRender: 'status_dictText' }
        },
        {
          title: '创建时间',
          align: "center",
          dataIndex: 'createTime'
        }
      ],
      url: {
        list: "/task/agvTask/list",
      },
      dictOptions: {},
    }
  },
  watch: {
    shipmentCode: {
      handler(newVal) {
        console.log('shipmentCode changed:', newVal)
        if (newVal) {
          this.loadData()
        } else {
          this.dataSource = []
        }
      },
      immediate: true
    }
  },
  methods: {
    getStatusColor(status) {
      const colors = {
        '生成任务': 'green',
        '下发任务': 'blue',
        '开始执行': 'orange',
        '取货完成': 'purple',
        '任务完成': 'grey',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
    getQueryParams() {
      var param = Object.assign({}, this.queryParam, this.isorter);
      if (this.shipmentCode) {
        param.shipmentCode = this.shipmentCode;
      }
      return param;
    },
    loadData(arg) {
      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;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total;
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false;
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>