feat(钢卷管理): 添加长度字段支持及相关功能

refactor(订单管理): 重构订单状态显示及操作记录功能

fix(权限控制): 移除导出订单明细的权限校验

perf(钢卷操作): 使用策略模式重构钢卷操作逻辑
This commit is contained in:
砂糖
2025-12-29 16:22:18 +08:00
parent 9b8c5ab80b
commit 825a967f7b
13 changed files with 344 additions and 170 deletions

View File

@@ -1,116 +1,169 @@
import request from '@/utils/request'
import { addOrder, updateOrder } from '@/api/crm/order'
import { addOrderItem, updateOrderItem } from '@/api/crm/orderItem'
import { addOrderOperationTrace } from '@/api/crm/orderOperationTrace'
/**
* 查询销售报表汇总数据
*/
export function getSummary(query) {
return request({
url: '/crm/salesReport/summary',
method: 'get',
params: query
})
// 需要被记录的操作
const ORDER_ACTIONS = {
createPreOrder: 'createPreOrder',
updatePreOrder: 'updatePreOrder',
approvePreOrder: 'approvePreOrder',
createOrder: 'createOrder',
updateOrder: 'updateOrder',
createOrderdetail: 'createOrderdetail',
updateOrderdetail: 'updateOrderdetail',
}
/**
* 分页查询销售报表订单明细
*/
export function getOrderDetails(query) {
return request({
url: '/crm/salesReport/orderDetails',
method: 'get',
params: query
})
const actions = {
// 创建预订单
createPreOrder: {
type: 'createPreOrder',
name: '创建预订单',
description: '创建一个预订单',
// 预订单的相关信息
async handler(payload) {
const { data: order } = await addOrder({
...payload,
})
if (order.orderId) {
addOrderOperationTrace({
orderId: order.orderId,
operationType: ORDER_ACTIONS.createPreOrder,
newStatus: order.orderId,
operationContent: JSON.stringify(payload)
})
}
return order
}
},
// 修改预订单
updatePreOrder: {
type: 'updatePreOrder',
name: '修改预订单',
description: '修改预订单的相关信息',
// 预订单的相关信息
async handler(payload) {
await updateOrder({
...payload,
})
addOrderOperationTrace({
orderId: payload.orderId,
operationType: ORDER_ACTIONS.updatePreOrder,
newStatus: payload.orderId,
operationContent: JSON.stringify(payload)
})
return payload
}
},
// 创建订单明细
createOrderdetail: {
type: 'createOrderdetail',
name: '创建订单明细',
description: '创建订单明细的相关信息',
// 订单明细的相关信息
async handler(payload) {
const { data: orderItem } = await addOrderItem({
...payload,
})
if (orderItem.orderItemId) {
addOrderOperationTrace({
orderId: orderItem.orderId,
operationType: ORDER_ACTIONS.createOrderdetail,
newStatus: payload.orderItemId,
operationContent: JSON.stringify(payload)
})
}
return orderItem
}
},
// 修改订单明细
updateOrderdetail: {
type: 'updateOrderdetail',
name: '修改订单明细',
description: '修改订单明细的相关信息',
// 订单明细的相关信息
async handler(payload) {
await updateOrderItem({
...payload,
})
addOrderOperationTrace({
orderId: payload.orderId,
operationType: ORDER_ACTIONS.updateOrderdetail,
newStatus: payload.orderItemId,
operationContent: JSON.stringify(payload)
})
return payload
}
},
// 预订单审批为正式订单
approvePreOrder: {
type: 'approvePreOrder',
name: '审批预订单',
description: '审批预订单为正式订单',
// 预订单的相关信息
async handler(payload) {
await updateOrder({
...payload,
})
if (payload.orderId) {
addOrderOperationTrace({
orderId: payload.orderId,
operationType: ORDER_ACTIONS.approvePreOrder,
newStatus: payload.orderId,
operationContent: JSON.stringify(payload)
})
}
return payload
}
},
// 直接创建正式订单
createOrder: {
type: 'createOrder',
name: '创建正式订单',
description: '直接创建一个正式订单',
// 正式订单的相关信息
async handler(payload) {
const { data: order } = await addOrder({
...payload,
})
if (order.orderId) {
addOrderOperationTrace({
orderId: order.orderId,
operationType: ORDER_ACTIONS.createOrder,
newStatus: order.orderId,
operationContent: JSON.stringify(payload)
})
}
return order
}
},
// 正式订单修改
updateOrder: {
type: 'updateOrder',
name: '修改正式订单',
description: '修改正式订单的相关信息',
// 正式订单的相关信息
async handler(payload) {
await updateOrder({
...payload,
})
if (payload.orderId) {
addOrderOperationTrace({
orderId: payload.orderId,
operationType: ORDER_ACTIONS.updateOrder,
newStatus: payload.orderId,
operationContent: JSON.stringify(payload)
})
}
return payload
}
}
}
/**
* 查询完整销售报表数据
*/
export function getFullSalesReport(query) {
return request({
url: '/crm/salesReport/fullReport',
method: 'get',
params: query
})
}
/**
* 查询销售员统计数据
*/
export function getSalesmanStats(query) {
return request({
url: '/crm/salesReport/salesmanStats',
method: 'get',
params: query
})
}
/**
* 查询客户等级统计数据
*/
export function getCustomerLevelStats(query) {
return request({
url: '/crm/salesReport/customerLevelStats',
method: 'get',
params: query
})
}
/**
* 查询行业统计数据
*/
export function getIndustryStats(query) {
return request({
url: '/crm/salesReport/industryStats',
method: 'get',
params: query
})
}
/**
* 导出销售报表订单明细
*/
export function exportOrderDetails(query) {
return request({
url: '/crm/salesReport/exportOrderDetails',
method: 'post',
data: query,
// 导出文件需指定响应类型可选根据项目ExcelUtil配置调整
responseType: 'blob'
})
}
/**
* 导出销售员统计数据
*/
export function exportSalesmanStats(query) {
return request({
url: '/crm/salesReport/exportSalesmanStats',
method: 'post',
data: query,
responseType: 'blob'
})
}
/**
* 导出客户等级统计数据
*/
export function exportCustomerLevelStats(query) {
return request({
url: '/crm/salesReport/exportCustomerLevelStats',
method: 'post',
data: query,
responseType: 'blob'
})
}
/**
* 导出行业统计数据
*/
export function exportIndustryStats(query) {
return request({
url: '/crm/salesReport/exportIndustryStats',
method: 'post',
data: query,
responseType: 'blob'
})
export {
ORDER_ACTIONS,
actions,
}

View File

@@ -76,14 +76,15 @@
<span>{{ parseTime(scope.row.deliveryDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="preOrderStatus">
<el-table-column label="状态" align="center" prop="orderType">
<template slot-scope="scope">
<span v-if="scope.row.preOrderStatus === 0">审核</span>
<span v-else-if="scope.row.preOrderStatus === 1">已审核</span>
<span v-else-if="scope.row.preOrderStatus === 2">已取消</span>
<span v-if="scope.row.orderType === 0" class="text-primary">审核</span>
<span v-else-if="scope.row.orderType === 1">已审核</span>
<span v-else>未知状态</span>
</template>
</el-table-column>
<el-table-column label="销售员" align="center" prop="createBy" />
<el-table-column label="销售员" align="center" prop="createTime" />
<!-- <el-table-column label="审核人" align="center" prop="auditUser" />
<el-table-column label="审核时间" align="center" prop="auditTime" width="180">
<template slot-scope="scope">
@@ -202,7 +203,7 @@ export default {
pageNum: 1,
pageSize: 10,
orderCode: undefined,
orderType: ORDER_TYPE['预订单'],
// orderType: ORDER_TYPE['预订单'],
customerId: undefined,
orderAmount: undefined,
salesman: undefined,

View File

@@ -95,7 +95,6 @@
type="success"
icon="el-icon-download"
@click="exportOrderDetails"
v-hasPermi="['crm:salesReport:export']"
>
导出订单明细
</el-button>

View File

@@ -110,6 +110,11 @@
<el-input v-model="form.netWeight" placeholder="请输入净重" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="长度" prop="length">
<el-input v-model="form.length" placeholder="请输入长度" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />

View File

@@ -229,6 +229,7 @@ import ProductSelect from "@/components/KLPService/ProductSelect";
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
import { Pagination } from 'element-ui';
import { listDeliveryPlan } from '@/api/wms/deliveryPlan'
import handleCoil, { COIL_ACTIONS } from '../js/coilActions'
// 键值为[400, 500), 不包含在字典中但后续可以加入的特殊操作这类操作录入后会立刻完成例如入库401和发货402
@@ -354,26 +355,16 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
addMaterialCoil(this.form).then(response => {
addPendingAction({
// 计划ID 对应 warehouseId warehouseId字段并不是仓库ID而是一个根据操作类型自适应的查询字段
warehouseId: this.form.planId,
actionType: 401,
currentCoilNo: this.form.currentCoilNo,
sourceType: 'manual',
coilId: response.data.coilId,
priority: 0,
remark: this.form.remark,
actionStatus: 0,
}).then(res => {
handleCoil(COIL_ACTIONS.RECEIVE, this.form, this.form.planId)
.then(res => {
this.$modal.msgSuccess("入库成功");
this.$refs.form.resetFields();
this.getList()
})
}).finally(() => {
this.buttonLoading = false;
});
}).finally(() => {
this.buttonLoading = false;
});
}
});
})
},
// 打开收货弹窗
@@ -394,20 +385,13 @@ export default {
this.$modal.confirm("收货后刚钢卷会进入库存并占用所选的实际库区,是否继续?").then(() => {
this.buttonLoading = true;
// 更新操作记录状态 actionStatus: 2
updatePendingAction({
...this.receiptForm,
actionStatus: 2,
}).then(_ => {
this.$message.success("确认收货成功");
this.getList()
}).finally(() => {
this.buttonLoading = false;
});
// 更新钢卷状态为当前钢卷; dataType: 1
updateMaterialCoilSimple({
...this.coilInfo,
dataType: 1,
})
handleCoil(COIL_ACTIONS.STORE, this.coilInfo, this.receiptForm)
.then(_ => {
this.$message.success("确认收货成功");
this.getList()
}).finally(() => {
this.buttonLoading = false;
});
})
},
// 取消操作

View File

@@ -0,0 +1,79 @@
import { addMaterialCoil, updateMaterialCoil, updateMaterialCoilSimple } from "@/api/wms/coil"
import { addPendingAction, updatePendingAction } from '@/api/wms/pendingAction';
export const COIL_ACTIONS = {
RECEIVE: 'RECEIVE', // 收货与入库的区别在于,收货相当于计划入库,不管是否已到货都执行这个操作,计划收货也是收获
STORE: 'STORE', // 入库相当于实际收货与入库
CORRECTION: 'CORRECTION',
PROCESSING: 'PROCESSING',
MERGE: 'MERGE',
SPLIT: 'SPLIT',
PACK: 'PACK',
DELIVER: 'DELIVER',
MOVE: 'MOVE',
EDIT: 'EDIT', // 对应“根据库位码编辑钢卷信息”
ALLOCATE: 'ALLOCATE'
}
export const actions = Object.values(COIL_ACTIONS)
export const actionStrategies = {
RECEIVE: {
type: COIL_ACTIONS.RECEIVE,
name: '计划钢卷收货',
description: '计划钢卷收货,不管是否已到货都执行这个操作,计划收货也是收货',
handler: async (coil, planId) => {
// 收货逻辑创建一个dataType为10的钢卷和一个待操作记录
const response = await addMaterialCoil({
...coil,
dataType: 10,
})
await addPendingAction({
// 计划ID 对应 warehouseId warehouseId字段并不是仓库ID而是一个根据操作类型自适应的查询字段
warehouseId: planId,
actionType: 401,
currentCoilNo: coil.currentCoilNo,
sourceType: 'manual',
coilId: response.data.coilId,
priority: 0,
remark: coil.remark,
actionStatus: 0,
})
return response.data.coilId
}
},
STORE: {
type: COIL_ACTIONS.STORE,
name: '实际钢卷入库',
description: '实际钢卷入库,只有在已到货的情况下才执行这个操作',
handler: async (coil, action) => {
// 更新操作记录状态 actionStatus: 2
// 并行执行更新操作记录和更新钢卷状态
await Promise.all([
updatePendingAction({
...action,
actionStatus: 2,
}),
updateMaterialCoilSimple({
...coil,
dataType: 1,
})
])
return true
}
},
}
const handleCoil = (action, ...args) => {
const strategy = actionStrategies[action]
if (strategy && strategy.handler) {
return strategy.handler(...args)
} else {
console.error(`No strategy found for action: ${action}`)
}
}
export default handleCoil

View File

@@ -182,6 +182,12 @@
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="长度(m)">
<el-input v-model.number="targetCoil.length" placeholder="请输入长度" type="number" step="0.01"
:disabled="readonly">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="逻辑库区">
<WarehouseSelect
v-model="targetCoil.warehouseId"
@@ -257,7 +263,8 @@ export default {
qualityStatus: '',
packagingRequirement: '',
packingStatus: '',
trimmingRequirement: ''
trimmingRequirement: '',
length: null,
},
buttonLoading: false,
loading: false,
@@ -359,6 +366,9 @@ export default {
materialName: '',
productName: '',
specification: '',
grossWeight: null,
netWeight: null,
length: null,
bomItems: []
},
{
@@ -372,6 +382,9 @@ export default {
materialName: '',
productName: '',
specification: '',
grossWeight: null,
netWeight: null,
length: null,
bomItems: []
}
];
@@ -400,6 +413,9 @@ export default {
productName: data.productName || (data.product ? data.product.productName : ''),
specification: data.rawMaterial?.specification || data.product?.specification || '',
bomItems: data.bomItemList || [],
grossWeight: data.grossWeight || null,
netWeight: data.netWeight || null,
length: data.length || null,
},
{
coilId: null,
@@ -412,7 +428,10 @@ export default {
materialName: '',
productName: '',
specification: '',
bomItems: []
bomItems: [],
grossWeight: null,
netWeight: null,
length: null,
}
];
@@ -488,6 +507,9 @@ export default {
materialName: data.materialName || (data.rawMaterial ? data.rawMaterial.rawMaterialName : ''),
productName: data.productName || (data.product ? data.product.productName : ''),
specification: data.rawMaterial?.specification || data.product?.specification || '',
grossWeight: data.grossWeight || null,
netWeight: data.netWeight || null,
length: data.length || null,
bomItems: data.bomItemList || [],
actionId: pending.actionId // 保存待操作ID用于后续完成操作
});
@@ -662,6 +684,9 @@ export default {
materialName: coil.materialName || '',
productName: coil.productName || '',
specification: coil.rawMaterial?.specification || coil.product?.specification || '',
grossWeight: coil.grossWeight || null,
netWeight: coil.netWeight || null,
length: coil.length || null,
bomItems: coil.bomItemList || []
});

View File

@@ -82,7 +82,7 @@
</div>
<div class="info-grid-item label-cell">参考长度</div>
<div class="info-grid-item value-cell">
<input type="text" class="nob" :value="content.referenceLength || ''" />
<input type="text" class="nob" :value="content.length || ''" />
</div>
<!-- 第八行生产日期跨3列 -->
@@ -137,6 +137,7 @@ export default {
grossWeight: '',
netWeight: '7080',
referenceLength: '320',
length: '320',
productionDate: '2025-03-19',
// 底部信息字段
address: '唐山市滦州市茨榆坨工业区',

View File

@@ -90,6 +90,7 @@
</template>
</el-table-column>
<el-table-column v-if="showAbnormal" label="异常数量" align="center" prop="abnormalCount"></el-table-column>
<el-table-column label="长度 (米)" align="center" prop="length" v-if="showLength" />
<el-table-column label="更新时间" align="center" prop="updateTime" />
<el-table-column label="发货时间" align="center" v-if="showExportTime" prop="exportTime" />
<el-table-column label="更新人" align="center" prop="updateByName" />
@@ -206,6 +207,9 @@
<el-form-item label="净重" prop="netWeight">
<el-input v-model="form.netWeight" placeholder="请输入净重" />
</el-form-item>
<el-form-item label="长度" prop="length" v-if="showLength">
<el-input v-model="form.length" placeholder="请输入长度" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
@@ -311,6 +315,10 @@ export default {
type: Boolean,
default: false,
},
showLength: {
type: Boolean,
default: false,
},
},
data() {
return {

View File

@@ -1,5 +1,10 @@
<template>
<BasePage :qrcode="qrcode" :querys="querys" :labelType="labelType" :showStatus="showStatus" :hideType="hideType" />
<BasePage :qrcode="qrcode"
:querys="querys"
:labelType="labelType"
:showStatus="showStatus"
:hideType="hideType"
:showLength="showLength" />
</template>
<script>
@@ -21,6 +26,7 @@ export default {
labelType: '3',
showStatus: true,
hideType: true,
showLength: true,
}
}
}

View File

@@ -163,6 +163,12 @@
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="长度(m)" required>
<el-input v-model.number="item.length" placeholder="请输入长度" type="number" step="0.01"
:disabled="readonly">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="逻辑库区" required>
<WarehouseSelect
v-model="item.warehouseId"
@@ -248,7 +254,8 @@ export default {
grossWeight: null,
netWeight: null,
warehouseId: null,
actualWarehouseId: null
actualWarehouseId: null,
length: null,
}
],
loading: false,
@@ -467,6 +474,7 @@ export default {
productName: coil.productName || '',
grossWeight: coil.grossWeight,
netWeight: coil.netWeight,
length: coil.length,
bomItems: coil.bomItemList || coil.bomItems || []
};
this.$message.success('母卷选择成功');
@@ -492,6 +500,7 @@ export default {
productName: data.productName || (data.product ? data.product.productName : ''),
grossWeight: data.grossWeight,
netWeight: data.netWeight,
length: data.length,
bomItems: data.bomItemList || data.bomItems || []
};
}
@@ -525,6 +534,7 @@ export default {
itemId: null,
grossWeight: null,
netWeight: null,
length: null,
warehouseId: null,
actualWarehouseId: null,
qualityStatus: '',

View File

@@ -158,6 +158,13 @@
</el-input>
</el-form-item>
<el-form-item label="长度(m)" prop="length">
<el-input v-model.number="updateForm.length" placeholder="请输入长度" type="number" step="0.01"
:disabled="readonly">
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="逻辑库区" prop="warehouseId">
<WarehouseSelect
v-model="updateForm.warehouseId"
@@ -264,7 +271,8 @@ export default {
warehouseId: null,
nextWarehouseName: '',
status: 0,
remark: ''
remark: '',
length: null,
},
// 更新表单
updateForm: {
@@ -281,7 +289,8 @@ export default {
qualityStatus: '',
packagingRequirement: '',
packingStatus: '',
trimmingRequirement: ''
trimmingRequirement: '',
length: null,
},
rules: {
currentCoilNo: [
@@ -597,6 +606,7 @@ export default {
grossWeight: parseFloat(this.currentInfo.grossWeight) || null,
netWeight: parseFloat(this.currentInfo.netWeight) || null,
warehouseId: this.currentInfo.warehouseId,
length: parseFloat(this.currentInfo.length) || null,
remark: this.currentInfo.remark
};

View File

@@ -148,6 +148,7 @@ import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect
import CoilNo from "@/components/KLPService/Renderer/CoilNo.vue";
import Printer from "../components/Printer.vue";
import { getConfigKey } from '@/api/system/config'
import handleCoil, { COIL_ACTIONS } from "@/views/wms/coil/js/coilActions.js";
export default {
name: "DeliveryWaybill",
@@ -440,22 +441,14 @@ export default {
// 二次确认
this.$modal.confirm("收货后刚钢卷会进入库存并占用所选的实际库区,是否继续?").then(() => {
this.buttonLoading = true;
// 更新操作记录状态 actionStatus: 2
updatePendingAction({
...this.receiptForm,
actionStatus: 2,
}).then(_ => {
this.$message.success("确认收货成功");
this.getList()
this.receiptModalVisible = false;
}).finally(() => {
this.buttonLoading = false;
});
// 更新钢卷状态为当前钢卷; dataType: 1
updateMaterialCoilSimple({
...this.coilInfo,
dataType: 1,
})
handleCoil(COIL_ACTIONS.STORE, this.coilInfo, this.receiptForm)
.then(_ => {
this.$message.success("确认收货成功");
this.getList()
this.receiptModalVisible = false;
}).finally(() => {
this.buttonLoading = false;
});
})
},
// 取消操作