Merge remote-tracking branch 'origin/0.8.X' into 0.8.X

This commit is contained in:
2025-07-25 11:27:42 +08:00
8 changed files with 747 additions and 4 deletions

View File

@@ -56,6 +56,7 @@
"quill": "1.3.7",
"screenfull": "5.0.2",
"sortablejs": "1.10.2",
"vditor": "^3.11.1",
"vue": "2.6.12",
"vue-count-to": "1.0.13",
"vue-cropper": "0.5.5",

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询产品销售话术列表
export function listProductSalesScript(query) {
return request({
url: '/klp/productSalesScript/list',
method: 'get',
params: query
})
}
// 查询产品销售话术详细
export function getProductSalesScript(scriptId) {
return request({
url: '/klp/productSalesScript/' + scriptId,
method: 'get'
})
}
// 新增产品销售话术
export function addProductSalesScript(data) {
return request({
url: '/klp/productSalesScript',
method: 'post',
data: data
})
}
// 修改产品销售话术
export function updateProductSalesScript(data) {
return request({
url: '/klp/productSalesScript',
method: 'put',
data: data
})
}
// 删除产品销售话术
export function delProductSalesScript(scriptId) {
return request({
url: '/klp/productSalesScript/' + scriptId,
method: 'delete'
})
}

View File

@@ -0,0 +1,55 @@
<template>
<div id="vditor" style="min-height: 192px;"></div>
</template>
<script>
import Vditor from 'vditor'
import 'vditor/dist/index.css'
export default {
name: 'VditorEditor',
props: {
value: {
type: String,
default: ''
}
},
data() {
return {
vditor: null
}
},
mounted() {
this.vditor = new Vditor('vditor', {
value: this.value,
height: 360,
toolbarConfig: {
pin: true,
},
cache: {
enable: false,
},
after: () => {
this.vditor.setValue(this.value || '')
},
input: (val) => {
this.$emit('input', val)
}
})
},
watch: {
value(val) {
if (this.vditor && val !== this.vditor.getValue()) {
this.vditor.setValue(val || '')
}
}
}
}
</script>
<style scoped>
#vditor {
border: 1px solid #e4e7ed;
border-radius: 4px;
}
</style>

View File

@@ -126,7 +126,7 @@ export default {
description: '订单审核与发货管理',
icon: 'fas fa-clipboard-check',
bgColor: 'bg-green-500',
link: '/wms/order'
link: '/shop/order'
},
{
title: '人员管理',
@@ -140,7 +140,7 @@ export default {
description: '订单数据可视化分析',
icon: 'fas fa-chart-line',
bgColor: 'bg-purple-500',
link: '/wms/order/dashboard'
link: '/shop/order/dashboard'
},
{
title: '出库入库',

View File

@@ -241,7 +241,7 @@ export default {
});
},
goDashboard() {
this.$router.push('/wms/order/dashboard');
this.$router.push('/shop/order/dashboard');
},
/** 推荐采购计划确认 */
handleRecommendConfirm(data) {

View File

@@ -0,0 +1,365 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<div class="waterfall-list">
<div v-for="item in productSalesScriptList" :key="item.scriptId" class="waterfall-item">
<el-card shadow="hover">
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;">
<div>
<strong>{{ item.scriptTitle }}</strong>
<span style="margin-left: 8px; color: #999;">({{ item.featurePoint }})</span>
</div>
<div>
<el-tag v-if="item.isEnabled == 1 || item.isEnabled === '1'" type="success">启用</el-tag>
<el-tag v-else type="info">禁用</el-tag>
</div>
</div>
<div style="margin: 8px 0; color: #666; word-break: break-all;">{{ item.scriptContent }}</div>
<div style="font-size: 13px; color: #888;">产品ID: {{ item.productName }} ({{ item.productCode }})</div>
<div style="font-size: 13px; color: #888;">备注: {{ item.remark }}</div>
<div style="margin-top: 12px; text-align: right;">
<el-button size="mini" type="primary" icon="el-icon-edit" @click="handleUpdate(item)">修改</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(item)">删除</el-button>
</div>
</el-card>
</div>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改产品销售话术对话框 -->
<el-dialog :title="title" :visible.sync="open" :width="dialogWidth" :top="dialogTop" append-to-body custom-class="responsive-dialog">
<el-form ref="form" :model="form" :rules="rules" label-width="110px" label-position="top" style="padding: 0 8px;">
<el-row :gutter="12">
<el-col :xs="24" :sm="12">
<el-form-item label="关联产品" prop="productId">
<ProductSelect v-model="form.productId" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12">
<el-form-item label="话术标题/场景" prop="scriptTitle">
<el-input v-model="form.scriptTitle" placeholder="请输入话术标题/场景" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="话术内容" prop="scriptContent">
<VditorEditor v-model="form.scriptContent" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="12">
<el-col :xs="24" :sm="12">
<el-form-item label="产品特性/亮点" prop="featurePoint">
<el-input v-model="form.featurePoint" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align:right;">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProductSalesScript, getProductSalesScript, delProductSalesScript, addProductSalesScript, updateProductSalesScript } from "@/api/wms/productSalesScript";
import ProductSelect from '@/components/KLPService/ProductSelect';
import VditorEditor from '@/components/VditorEditor.vue';
export default {
name: "ProductSalesScript",
components: { ProductSelect, VditorEditor },
data() {
return {
dialogWidth: '900px',
dialogTop: '5vh',
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 产品销售话术表格数据
productSalesScriptList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
productId: undefined,
scriptTitle: undefined,
scriptContent: undefined,
featurePoint: undefined,
isEnabled: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
productId: [
{ required: true, message: "关联产品ID不能为空", trigger: "blur" }
],
scriptTitle: [
{ required: true, message: "话术标题/场景不能为空", trigger: "blur" }
],
scriptContent: [
{ required: true, message: "话术内容不能为空", trigger: "blur" }
],
featurePoint: [
{ required: true, message: "产品特性/亮点不能为空", trigger: "blur" }
],
isEnabled: [
{ required: true, message: "是否启用不能为空", trigger: "blur" }
],
remark: [
{ required: true, message: "备注不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
this.setDialogResponsive();
window.addEventListener('resize', this.setDialogResponsive);
},
beforeDestroy() {
window.removeEventListener('resize', this.setDialogResponsive);
},
methods: {
setDialogResponsive() {
if (window.innerWidth < 600) {
this.dialogWidth = '100vw';
this.dialogTop = '0';
} else {
this.dialogWidth = '900px';
this.dialogTop = '5vh';
}
},
/** 查询产品销售话术列表 */
getList() {
this.loading = true;
listProductSalesScript(this.queryParams).then(response => {
this.productSalesScriptList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
scriptId: undefined,
productId: undefined,
scriptTitle: undefined,
scriptContent: undefined,
featurePoint: undefined,
isEnabled: undefined,
delFlag: undefined,
remark: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.scriptId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加产品销售话术";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const scriptId = row.scriptId || this.ids
getProductSalesScript(scriptId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改产品销售话术";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.scriptId != null) {
updateProductSalesScript(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addProductSalesScript(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const scriptIds = row.scriptId || this.ids;
this.$modal.confirm('是否确认删除产品销售话术编号为"' + scriptIds + '"的数据项?').then(() => {
this.loading = true;
return delProductSalesScript(scriptIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/productSalesScript/export', {
...this.queryParams
}, `productSalesScript_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.waterfall-list {
column-count: 3;
column-gap: 16px;
width: 100%;
}
.waterfall-item {
break-inside: avoid;
margin-bottom: 16px;
width: 100%;
display: inline-block;
}
@media (max-width: 1200px) {
.waterfall-list {
column-count: 2;
}
}
@media (max-width: 800px) {
.waterfall-list {
column-count: 1;
}
}
@media (max-width: 600px) {
.waterfall-list {
column-count: 1;
padding: 0 2px;
}
.waterfall-item {
margin-bottom: 8px;
}
.responsive-dialog {
padding: 0 !important;
width: 100vw !important;
max-width: 100vw !important;
top: 0 !important;
left: 0 !important;
margin: 0 !important;
border-radius: 0 !important;
}
.el-dialog__body {
padding: 8px !important;
}
}
</style>

View File

@@ -0,0 +1,259 @@
<template>
<div>
<div class="chart-header">
<el-radio-group v-model="groupMode" @change="updateChart">
<el-radio-button label="warehouse">按仓库汇总</el-radio-button>
<el-radio-button label="item">按物品汇总</el-radio-button>
</el-radio-group>
</div>
<div ref="chartContainer" style="width: 100%; height: 600px;"></div>
</div>
</template>
<script>
import * as echarts from 'echarts';
import { listStock } from "@/api/wms/stock";
import { listWarehouse } from "@/api/wms/warehouse";
export default {
name: "StockBox",
data() {
return {
chart: null,
stockData: [],
warehouseData: [],
groupMode: 'warehouse', // 默认按仓库汇总
warehouseTreeData: []
};
},
mounted() {
this.initChart();
this.loadData();
},
methods: {
initChart() {
if (this.chart) {
this.chart.dispose();
}
this.chart = echarts.init(this.$refs.chartContainer);
window.addEventListener('resize', this.handleResize);
},
handleResize() {
this.chart && this.chart.resize();
},
async loadData() {
try {
// 并行加载仓库结构和库存数据
const [warehouseRes, stockRes] = await Promise.all([
listWarehouse(),
listStock({ pageNum: 1, pageSize: 9999 })
]);
this.warehouseTreeData = this.handleTree(warehouseRes.data, 'warehouseId', 'parentId');
this.stockData = stockRes.rows;
this.updateChart();
} catch (error) {
console.error('加载数据失败:', error);
}
},
// 处理树结构
handleTree(data, id, parentId) {
const cloneData = JSON.parse(JSON.stringify(data));
return cloneData.filter(father => {
const branchArr = cloneData.filter(child => father[id] === child[parentId]);
if (branchArr.length > 0) father.children = branchArr;
return father[parentId] === 0 || father[parentId] === null;
});
},
updateChart() {
let treeData;
if (this.groupMode === 'warehouse') {
treeData = this.getWarehouseTreeData();
} else {
treeData = this.getItemTreeData();
}
const option = {
tooltip: {
formatter: (params) => {
const data = params.data;
if (data.stockInfo) {
return this.formatTooltip(data);
}
return `${params.name}<br/>总数量: ${params.value || 0}`;
}
},
series: [{
type: 'treemap',
data: treeData.children,
label: {
show: true,
formatter: (params) => {
const data = params.data;
if (data.stockInfo) {
return `${params.name}\n${params.value}${data.stockInfo.unit || ''}`;
}
return `${params.name}\n${params.value || ''}`;
}
},
breadcrumb: {
show: true
},
roam: false,
levels: [
{
itemStyle: {
borderColor: '#555',
borderWidth: 4,
gapWidth: 4
}
},
{
itemStyle: {
borderColor: '#777',
borderWidth: 2,
gapWidth: 2
}
}
]
}]
};
this.chart && this.chart.setOption(option);
},
getWarehouseTreeData() {
const buildWarehouseTree = (warehouseNode) => {
const stocks = this.stockData.filter(stock => stock.warehouseId === warehouseNode.warehouseId);
const children = [];
let totalQuantity = 0;
// 处理当前仓库的库存
stocks.forEach(stock => {
const quantity = Number(stock.quantity) || 0;
totalQuantity += quantity;
children.push({
name: this.getItemName(stock),
value: quantity,
stockInfo: {
itemType: stock.itemType,
itemCode: stock.itemCode,
unit: stock.unit,
batchNo: stock.batchNo
}
});
});
// 处理子仓库
if (warehouseNode.children && warehouseNode.children.length > 0) {
warehouseNode.children.forEach(child => {
const childNode = buildWarehouseTree(child);
if (childNode.value > 0) {
children.push(childNode);
totalQuantity += childNode.value;
}
});
}
return {
name: warehouseNode.warehouseName,
value: totalQuantity,
children: children.length > 0 ? children : undefined
};
};
return {
name: '库存总览',
children: this.warehouseTreeData.map(warehouse => buildWarehouseTree(warehouse))
};
},
getItemTreeData() {
// 按物品类型和物品分组
const itemGroups = {};
this.stockData.forEach(stock => {
const itemType = this.getItemTypeName(stock.itemType);
if (!itemGroups[itemType]) {
itemGroups[itemType] = {};
}
const itemKey = stock.itemId + '_' + stock.itemName;
if (!itemGroups[itemType][itemKey]) {
itemGroups[itemType][itemKey] = {
name: stock.itemName,
value: 0,
children: []
};
}
const quantity = Number(stock.quantity) || 0;
itemGroups[itemType][itemKey].value += quantity;
itemGroups[itemType][itemKey].children.push({
name: this.getWarehouseName(stock.warehouseId),
value: quantity,
stockInfo: {
itemType: stock.itemType,
itemCode: stock.itemCode,
unit: stock.unit,
batchNo: stock.batchNo
}
});
});
return {
name: '库存总览',
children: Object.entries(itemGroups).map(([type, items]) => ({
name: type,
children: Object.values(items)
}))
};
},
formatTooltip(data) {
const stockInfo = data.stockInfo;
return `${data.name}<br/>
数量: ${data.value} ${stockInfo.unit || ''}<br/>
类型: ${this.getItemTypeName(stockInfo.itemType)}<br/>
编号: ${stockInfo.itemCode || '无'}<br/>
批次: ${stockInfo.batchNo || '无'}`;
},
getItemTypeName(type) {
const typeMap = {
raw_material: '原材料',
product: '产品',
};
return typeMap[type] || type;
},
getItemName(stock) {
return stock.itemName || `${this.getItemTypeName(stock.itemType)}-${stock.itemCode}`;
},
getWarehouseName(warehouseId) {
const findWarehouse = (warehouses) => {
for (const warehouse of warehouses) {
if (warehouse.warehouseId === warehouseId) {
return warehouse.warehouseName;
}
if (warehouse.children) {
const name = findWarehouse(warehouse.children);
if (name) return name;
}
}
return null;
};
return findWarehouse(this.warehouseTreeData) || '未知仓库';
},
refresh() {
this.loadData();
}
},
beforeDestroy() {
window.removeEventListener('resize', this.handleResize);
if (this.chart) {
this.chart.dispose();
this.chart = null;
}
}
};
</script>
<style scoped>
</style>

View File

@@ -51,6 +51,9 @@
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['wms:stock:export']">导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-data-analysis" size="mini" @click="showStockBox">库存分析</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@@ -81,6 +84,11 @@
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 库存分析对话框 -->
<el-dialog title="库存统计" :visible.sync="stockBoxVisible" width="80%" append-to-body destroy-on-close>
<stock-box ref="stockBoxChart" />
</el-dialog>
<!-- 添加或修改库存对话框保持不变 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
@@ -128,6 +136,7 @@ import { listWarehouse } from "@/api/wms/warehouse";
import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
import ProductSelect from "@/components/KLPService/ProductSelect";
import WarehouseSelect from "@/components/WarehouseSelect";
import StockBox from './box';
export default {
name: "Stock",
@@ -135,10 +144,13 @@ export default {
components: {
WarehouseSelect,
RawMaterialSelect,
ProductSelect
ProductSelect,
StockBox
},
data() {
return {
// 库存分析对话框显示状态
stockBoxVisible: false,
// 按钮loading
buttonLoading: false,
// 遮罩层
@@ -340,6 +352,13 @@ export default {
this.download('wms/stock/export', {
...this.queryParams
}, `stock_${new Date().getTime()}.xlsx`)
},
/** 显示库存分析图表 */
showStockBox() {
this.stockBoxVisible = true;
this.$nextTick(() => {
this.$refs.stockBoxChart && this.$refs.stockBoxChart.refresh();
});
}
}
};