|
@@ -26,8 +26,8 @@
|
|
|
|
|
|
<!-- 发货状态列插槽 -->
|
|
|
<template slot="shipmentStatus" slot-scope="{row}">
|
|
|
- <el-tag :type="getStatusType(row.shipmentStatus)">
|
|
|
- {{ getStatusText(row.shipmentStatus) }}
|
|
|
+ <el-tag :type="getShipmentStatusType(row.shipmentStatus)">
|
|
|
+ {{ getShipmentStatusLabel(row.shipmentStatus) }}
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
|
|
@@ -103,8 +103,8 @@
|
|
|
|
|
|
<!-- 异常状态列插槽 -->
|
|
|
<template slot="isException" slot-scope="{row}">
|
|
|
- <el-tag :type="row.isException ? 'danger' : 'success'">
|
|
|
- {{ row.isException ? '异常' : '正常' }}
|
|
|
+ <el-tag :type="getExceptionStatusType(row.isException)">
|
|
|
+ {{ getExceptionStatusLabel(row.isException) }}
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</avue-crud>
|
|
@@ -114,37 +114,64 @@
|
|
|
|
|
|
<script>
|
|
|
import { getOrderShipmentList, getShipmentItemList, getShipmentTrackingList } from '@/api/shipment'
|
|
|
+import {
|
|
|
+ SHIPMENT_STATUS_OPTIONS,
|
|
|
+ getShipmentStatusLabel,
|
|
|
+ getShipmentStatusType,
|
|
|
+ getTrackingStatusType,
|
|
|
+ getExceptionStatusLabel,
|
|
|
+ getExceptionStatusType
|
|
|
+} from '@/constants/shipment'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
|
|
|
+/**
|
|
|
+ * 发货状态查询组件
|
|
|
+ * @description 提供发货单状态查询、明细查看、物流跟踪等功能
|
|
|
+ */
|
|
|
export default {
|
|
|
name: 'ShipmentStatusQuery',
|
|
|
+
|
|
|
data() {
|
|
|
return {
|
|
|
+ /** @type {Record<string, any>} 表单数据 */
|
|
|
form: {},
|
|
|
+ /** @type {Record<string, any>} 查询参数 */
|
|
|
query: {},
|
|
|
+ /** @type {boolean} 加载状态 */
|
|
|
loading: true,
|
|
|
+ /** @type {{pageSize: number, currentPage: number, total: number}} 分页信息 */
|
|
|
page: {
|
|
|
pageSize: 10,
|
|
|
currentPage: 1,
|
|
|
total: 0
|
|
|
},
|
|
|
+ /** @type {Array<Record<string, any>>} 表格数据 */
|
|
|
data: [],
|
|
|
|
|
|
// 明细相关
|
|
|
+ /** @type {boolean} 明细对话框显示状态 */
|
|
|
detailDialogVisible: false,
|
|
|
+ /** @type {boolean} 明细加载状态 */
|
|
|
detailLoading: false,
|
|
|
+ /** @type {Array<Record<string, any>>} 明细数据 */
|
|
|
detailData: [],
|
|
|
+ /** @type {{pageSize: number, currentPage: number, total: number}} 明细分页信息 */
|
|
|
detailPage: {
|
|
|
pageSize: 10,
|
|
|
currentPage: 1,
|
|
|
total: 0
|
|
|
},
|
|
|
+ /** @type {Record<string, any>|null} 当前选中的发货单 */
|
|
|
currentShipment: null,
|
|
|
|
|
|
// 跟踪相关
|
|
|
+ /** @type {boolean} 跟踪对话框显示状态 */
|
|
|
trackingDialogVisible: false,
|
|
|
+ /** @type {boolean} 跟踪加载状态 */
|
|
|
trackingLoading: false,
|
|
|
+ /** @type {Array<Record<string, any>>} 跟踪数据 */
|
|
|
trackingData: [],
|
|
|
+ /** @type {{pageSize: number, currentPage: number, total: number}} 跟踪分页信息 */
|
|
|
trackingPage: {
|
|
|
pageSize: 10,
|
|
|
currentPage: 1,
|
|
@@ -152,6 +179,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 主表配置
|
|
|
+ /** @type {Record<string, any>} 主表配置 */
|
|
|
option: {
|
|
|
height: 'auto',
|
|
|
calcHeight: 30,
|
|
@@ -210,13 +238,7 @@ export default {
|
|
|
slot: true,
|
|
|
search: true,
|
|
|
type: 'select',
|
|
|
- dicData: [
|
|
|
- { label: '待发货', value: 1 },
|
|
|
- { label: '已发货', value: 2 },
|
|
|
- { label: '运输中', value: 3 },
|
|
|
- { label: '已送达', value: 4 },
|
|
|
- { label: '已签收', value: 5 }
|
|
|
- ],
|
|
|
+ dicData: SHIPMENT_STATUS_OPTIONS,
|
|
|
width: 100
|
|
|
},
|
|
|
{
|
|
@@ -249,98 +271,7 @@ export default {
|
|
|
]
|
|
|
},
|
|
|
|
|
|
- // 明细表配置
|
|
|
- detailOption: {
|
|
|
- height: 400,
|
|
|
- tip: false,
|
|
|
- border: true,
|
|
|
- index: true,
|
|
|
- menu: false,
|
|
|
- addBtn: false,
|
|
|
- column: [
|
|
|
- {
|
|
|
- label: '物料编码',
|
|
|
- prop: 'itemCode',
|
|
|
- width: 120
|
|
|
- },
|
|
|
- {
|
|
|
- label: '物料名称',
|
|
|
- prop: 'itemName',
|
|
|
- width: 150
|
|
|
- },
|
|
|
- {
|
|
|
- label: '规格',
|
|
|
- prop: 'specs',
|
|
|
- width: 120
|
|
|
- },
|
|
|
- {
|
|
|
- label: '发货数量',
|
|
|
- prop: 'shippedQuantity',
|
|
|
- width: 100
|
|
|
- },
|
|
|
- {
|
|
|
- label: '包装号',
|
|
|
- prop: 'packageNo',
|
|
|
- width: 120
|
|
|
- },
|
|
|
- {
|
|
|
- label: '批次号',
|
|
|
- prop: 'batchNo',
|
|
|
- width: 120
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
-
|
|
|
- // 跟踪表配置
|
|
|
- trackingOption: {
|
|
|
- height: 400,
|
|
|
- tip: false,
|
|
|
- border: true,
|
|
|
- index: true,
|
|
|
- menu: false,
|
|
|
- addBtn: false,
|
|
|
- column: [
|
|
|
- {
|
|
|
- label: '运单号',
|
|
|
- prop: 'trackingNo',
|
|
|
- width: 150
|
|
|
- },
|
|
|
- {
|
|
|
- label: '跟踪状态',
|
|
|
- prop: 'trackingStatus',
|
|
|
- slot: true,
|
|
|
- width: 100
|
|
|
- },
|
|
|
- {
|
|
|
- label: '位置',
|
|
|
- prop: 'location',
|
|
|
- width: 200
|
|
|
- },
|
|
|
- {
|
|
|
- label: '事件时间',
|
|
|
- prop: 'eventTime',
|
|
|
- type: 'datetime',
|
|
|
- format: 'YYYY-MM-DD HH:mm:ss',
|
|
|
- width: 160
|
|
|
- },
|
|
|
- {
|
|
|
- label: '事件描述',
|
|
|
- prop: 'eventDesc',
|
|
|
- width: 250
|
|
|
- },
|
|
|
- {
|
|
|
- label: '异常状态',
|
|
|
- prop: 'isException',
|
|
|
- slot: true,
|
|
|
- width: 100
|
|
|
- },
|
|
|
- {
|
|
|
- label: '异常类型',
|
|
|
- prop: 'exceptionType',
|
|
|
- width: 120
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ // ... existing code ...
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -353,60 +284,40 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- // 获取发货状态类型
|
|
|
- getStatusType(status) {
|
|
|
- const statusMap = {
|
|
|
- 1: 'info', // 待发货
|
|
|
- 2: 'warning', // 已发货
|
|
|
- 3: 'primary', // 运输中
|
|
|
- 4: 'success', // 已送达
|
|
|
- 5: 'success' // 已签收
|
|
|
- }
|
|
|
- return statusMap[status] || 'info'
|
|
|
- },
|
|
|
-
|
|
|
- // 获取发货状态文本
|
|
|
- getStatusText(status) {
|
|
|
- const statusMap = {
|
|
|
- 1: '待发货',
|
|
|
- 2: '已发货',
|
|
|
- 3: '运输中',
|
|
|
- 4: '已送达',
|
|
|
- 5: '已签收'
|
|
|
- }
|
|
|
- return statusMap[status] || '未知'
|
|
|
- },
|
|
|
-
|
|
|
- // 获取跟踪状态类型
|
|
|
- getTrackingStatusType(status) {
|
|
|
- if (status.includes('运输中') || status.includes('在途')) {
|
|
|
- return 'primary'
|
|
|
- } else if (status.includes('已送达') || status.includes('已签收')) {
|
|
|
- return 'success'
|
|
|
- } else if (status.includes('异常') || status.includes('延误')) {
|
|
|
- return 'danger'
|
|
|
- }
|
|
|
- return 'info'
|
|
|
- },
|
|
|
-
|
|
|
- // 加载数据
|
|
|
- onLoad() {
|
|
|
+ // 导入的工具函数
|
|
|
+ getShipmentStatusLabel,
|
|
|
+ getShipmentStatusType,
|
|
|
+ getTrackingStatusType,
|
|
|
+ getExceptionStatusLabel,
|
|
|
+ getExceptionStatusType,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加载数据
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async onLoad() {
|
|
|
this.loading = true
|
|
|
- getOrderShipmentList({
|
|
|
- ...this.query,
|
|
|
- current: this.page.currentPage,
|
|
|
- size: this.page.pageSize
|
|
|
- }).then(res => {
|
|
|
+ try {
|
|
|
+ const res = await getOrderShipmentList({
|
|
|
+ ...this.query,
|
|
|
+ current: this.page.currentPage,
|
|
|
+ size: this.page.pageSize
|
|
|
+ })
|
|
|
const data = res.data.data
|
|
|
this.data = data.records
|
|
|
this.page.total = data.total
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载发货数据失败:', error)
|
|
|
+ } finally {
|
|
|
this.loading = false
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- // 搜索
|
|
|
+ /**
|
|
|
+ * 搜索
|
|
|
+ * @param {Record<string, any>} params - 搜索参数
|
|
|
+ * @param {Function} done - 完成回调
|
|
|
+ */
|
|
|
searchChange(params, done) {
|
|
|
this.query = params
|
|
|
this.page.currentPage = 1
|
|
@@ -414,97 +325,140 @@ export default {
|
|
|
done()
|
|
|
},
|
|
|
|
|
|
- // 重置搜索
|
|
|
+ /**
|
|
|
+ * 重置搜索
|
|
|
+ */
|
|
|
searchReset() {
|
|
|
this.query = {}
|
|
|
this.page.currentPage = 1
|
|
|
this.onLoad()
|
|
|
},
|
|
|
|
|
|
- // 分页大小改变
|
|
|
+ /**
|
|
|
+ * 分页大小改变
|
|
|
+ * @param {number} pageSize - 页面大小
|
|
|
+ */
|
|
|
sizeChange(pageSize) {
|
|
|
this.page.pageSize = pageSize
|
|
|
this.onLoad()
|
|
|
},
|
|
|
|
|
|
- // 当前页改变
|
|
|
+ /**
|
|
|
+ * 当前页改变
|
|
|
+ * @param {number} currentPage - 当前页
|
|
|
+ */
|
|
|
currentChange(currentPage) {
|
|
|
this.page.currentPage = currentPage
|
|
|
this.onLoad()
|
|
|
},
|
|
|
|
|
|
- // 行点击
|
|
|
+ /**
|
|
|
+ * 行点击
|
|
|
+ * @param {Record<string, any>} row - 行数据
|
|
|
+ * @param {Record<string, any>} column - 列信息
|
|
|
+ * @param {Event} event - 事件对象
|
|
|
+ */
|
|
|
rowClick(row, column, event) {
|
|
|
this.viewDetails(row)
|
|
|
},
|
|
|
|
|
|
- // 查看明细
|
|
|
+ /**
|
|
|
+ * 查看明细
|
|
|
+ * @param {Record<string, any>} row - 行数据
|
|
|
+ */
|
|
|
viewDetails(row) {
|
|
|
this.currentShipment = row
|
|
|
this.detailDialogVisible = true
|
|
|
this.loadShipmentDetails(row.shipmentNo)
|
|
|
},
|
|
|
|
|
|
- // 加载发货明细
|
|
|
- loadShipmentDetails(shipmentNo) {
|
|
|
+ /**
|
|
|
+ * 加载发货明细
|
|
|
+ * @param {string} shipmentNo - 发货单号
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async loadShipmentDetails(shipmentNo) {
|
|
|
this.detailLoading = true
|
|
|
- getShipmentItemList({
|
|
|
- shipmentNo: shipmentNo,
|
|
|
- current: this.detailPage.currentPage,
|
|
|
- size: this.detailPage.pageSize
|
|
|
- }).then(res => {
|
|
|
+ try {
|
|
|
+ const res = await getShipmentItemList({
|
|
|
+ shipmentNo: shipmentNo,
|
|
|
+ current: this.detailPage.currentPage,
|
|
|
+ size: this.detailPage.pageSize
|
|
|
+ })
|
|
|
const data = res.data.data
|
|
|
this.detailData = data.records
|
|
|
this.detailPage.total = data.total
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载发货明细失败:', error)
|
|
|
+ } finally {
|
|
|
this.detailLoading = false
|
|
|
- }).catch(() => {
|
|
|
- this.detailLoading = false
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- // 明细分页大小改变
|
|
|
+ /**
|
|
|
+ * 明细分页大小改变
|
|
|
+ * @param {number} pageSize - 页面大小
|
|
|
+ */
|
|
|
detailSizeChange(pageSize) {
|
|
|
this.detailPage.pageSize = pageSize
|
|
|
this.loadShipmentDetails(this.currentShipment.shipmentNo)
|
|
|
},
|
|
|
|
|
|
- // 明细当前页改变
|
|
|
+ /**
|
|
|
+ * 明细当前页改变
|
|
|
+ * @param {number} currentPage - 当前页
|
|
|
+ */
|
|
|
detailCurrentChange(currentPage) {
|
|
|
this.detailPage.currentPage = currentPage
|
|
|
this.loadShipmentDetails(this.currentShipment.shipmentNo)
|
|
|
},
|
|
|
|
|
|
- // 查看物流跟踪
|
|
|
+ /**
|
|
|
+ * 查看物流跟踪
|
|
|
+ * @param {Record<string, any>} row - 行数据
|
|
|
+ */
|
|
|
viewTracking(row) {
|
|
|
this.currentShipment = row
|
|
|
this.trackingDialogVisible = true
|
|
|
this.loadTrackingInfo(row.shipmentNo)
|
|
|
},
|
|
|
|
|
|
- // 加载物流跟踪信息
|
|
|
- loadTrackingInfo(shipmentNo) {
|
|
|
+ /**
|
|
|
+ * 加载物流跟踪信息
|
|
|
+ * @param {string} shipmentNo - 发货单号
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async loadTrackingInfo(shipmentNo) {
|
|
|
this.trackingLoading = true
|
|
|
- getShipmentTrackingList({
|
|
|
- shipmentNo: shipmentNo,
|
|
|
- current: this.trackingPage.currentPage,
|
|
|
- size: this.trackingPage.pageSize
|
|
|
- }).then(res => {
|
|
|
+ try {
|
|
|
+ const res = await getShipmentTrackingList({
|
|
|
+ shipmentNo: shipmentNo,
|
|
|
+ current: this.trackingPage.currentPage,
|
|
|
+ size: this.trackingPage.pageSize
|
|
|
+ })
|
|
|
const data = res.data.data
|
|
|
this.trackingData = data.records
|
|
|
this.trackingPage.total = data.total
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载物流跟踪信息失败:', error)
|
|
|
+ } finally {
|
|
|
this.trackingLoading = false
|
|
|
- }).catch(() => {
|
|
|
- this.trackingLoading = false
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- // 跟踪分页大小改变
|
|
|
+ /**
|
|
|
+ * 跟踪分页大小改变
|
|
|
+ * @param {number} pageSize - 页面大小
|
|
|
+ */
|
|
|
trackingSizeChange(pageSize) {
|
|
|
this.trackingPage.pageSize = pageSize
|
|
|
this.loadTrackingInfo(this.currentShipment.shipmentNo)
|
|
|
},
|
|
|
|
|
|
- // 跟踪当前页改变
|
|
|
+ /**
|
|
|
+ * 跟踪当前页改变
|
|
|
+ * @param {number} currentPage - 当前页
|
|
|
+ */
|
|
|
trackingCurrentChange(currentPage) {
|
|
|
this.trackingPage.currentPage = currentPage
|
|
|
this.loadTrackingInfo(this.currentShipment.shipmentNo)
|