This commit is contained in:
雷欧(林平凡)
2025-08-15 18:01:05 +08:00
parent 5f2fbe3412
commit 5508c72442
11 changed files with 916 additions and 174 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div class="app-container">
<!-- 数据统计卡片 -->
<el-row :gutter="20" class="mb20" v-if="statistics">
<!-- <el-row :gutter="20" class="mb20" v-if="statistics">
<el-col :span="6">
<el-card shadow="hover">
<div class="statistics-card">
@@ -20,7 +20,7 @@
</el-col>
</el-row>
</el-row> -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="消息内容" prop="content">
@@ -33,12 +33,6 @@
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:xbmessage:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:xbmessage:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:xbmessage:remove']">删除</el-button>
</el-col>
@@ -48,28 +42,51 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="xbmessageList" @selection-change="handleSelectionChange" row-key="id" :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table v-loading="loading" :data="xbmessageList" @selection-change="handleSelectionChange" @row-click="handleRowClick" highlight-current-row>
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="首行" prop="firstLine" :show-overflow-tooltip="true" min-width="260" />
<el-table-column label="首个商品" prop="firstSkuName" :show-overflow-tooltip="true" min-width="220" />
<el-table-column label="首价" prop="firstPrice" width="120" align="center" />
<el-table-column label="商品数" width="100" align="center">
<el-table-column label="首行" prop="firstLine" :show-overflow-tooltip="true" min-width="180">
<template slot-scope="scope">
<el-tag v-if="scope.row.children && scope.row.children.length > 0" type="success" size="mini">
{{ scope.row.children.length }}
<span>{{ decodeUnicode(scope.row.firstLine) }}</span>
</template>
</el-table-column>
<el-table-column label="线报商品" prop="firstSkuName" :show-overflow-tooltip="true" min-width="480">
<template slot-scope="scope">
<span>{{ decodeUnicode(scope.row.firstSkuName) }}</span>
</template>
</el-table-column>
<el-table-column label="线报价格" prop="firstPrice" width="100" align="center" />
<el-table-column label="线报商品数" width="80" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.childrenCount > 0" type="success" size="mini">
{{ scope.row.childrenCount }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="店铺信息" width="200" align="left">
<template slot-scope="scope">
<div v-if="scope.row.children && scope.row.children.length > 0">
<span v-html="parseOwner(scope.row.children[0].owner)"></span>-
<span v-if="scope.row.children[0].jsonShopInfo">{{ decodeUnicode(getJsonValue(scope.row.children[0].jsonShopInfo, 'shopName')) || '-' }}</span>
<span v-else>-</span>
</div>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="线报群" prop="fromWxid" width="240" align="center">
<template slot-scope="scope">
<span>{{ getGroupName(scope.row.fromWxid) || scope.row.fromWxid || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="线报时间" prop="createDate" width="180" align="center">
<template slot-scope="scope">
<span>{{ scope.row.createDate ? parseTime(scope.row.createDate) : '-' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-info" @click="showMessageDetail(scope.row)">详情</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:xbmessage:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:xbmessage:remove']">删除</el-button>
</template>
</el-table-column>
@@ -83,50 +100,42 @@
@pagination="getList"
/>
<!-- 添加或修改消息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="消息类型" prop="type">
<el-input v-model="form.type" placeholder="请输入消息类型" />
</el-form-item>
<el-form-item label="消息内容" prop="content">
<el-input v-model="form.content" type="textarea" placeholder="请输入消息内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 子消息详情对话框 -->
<el-dialog title="子消息详情" :visible.sync="childDetailVisible" width="900px" append-to-body>
<el-dialog title="商品详情" :visible.sync="childDetailVisible" width="1200px" append-to-body>
<div v-if="currentChild">
<el-descriptions :column="2" border>
<el-descriptions-item label="ID">{{ currentChild.id }}</el-descriptions-item>
<el-descriptions-item label="商品名称">{{ currentChild.skuName || '-' }}</el-descriptions-item>
<el-descriptions-item label="店铺名称">{{ decodeUnicode(getJsonValue(currentChild.jsonQueryResult, 'shopInfo.shopName')) || '-' }}</el-descriptions-item>
<el-descriptions-item label="商品名称">{{ decodeUnicode(currentChild.skuName) || '-' }}</el-descriptions-item>
<el-descriptions-item label="价格">{{ currentChild.firstPrice ? `¥${currentChild.firstPrice}` : '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ currentChild.createDate ? parseTime(currentChild.createDate) : '-' }}</el-descriptions-item>
<el-descriptions-item label="SPUID">{{ currentChild.spuid || '-' }}</el-descriptions-item>
<el-descriptions-item label="所有者">{{ currentChild.owner || '-' }}</el-descriptions-item>
<el-descriptions-item label="所有者"></el-descriptions-item>
</el-descriptions>
<!-- 商品查询结果 -->
<div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
<h4>商品查询结果</h4>
<el-descriptions :column="1" border>
<el-descriptions-item label="品牌">{{ getJsonValue(currentChild.jsonQueryResult, 'brandName') || '-' }}</el-descriptions-item>
<el-descriptions-item label="分类">{{ getCategoryPath(currentChild.jsonQueryResult) || '-' }}</el-descriptions-item>
<el-descriptions-item label="评论数">{{ getJsonValue(currentChild.jsonQueryResult, 'comments') || '-' }}</el-descriptions-item>
<el-descriptions-item label="好评率">{{ getJsonValue(currentChild.jsonQueryResult, 'goodCommentsShare') ? `${getJsonValue(currentChild.jsonQueryResult, 'goodCommentsShare')}%` : '-' }}</el-descriptions-item>
<el-descriptions-item label="30天订单数">{{ getJsonValue(currentChild.jsonQueryResult, 'inOrderCount30Days') || '-' }}</el-descriptions-item>
<el-descriptions-item label="是否热门">{{ getJsonValue(currentChild.jsonQueryResult, 'isHot') ? '是' : '否' }}</el-descriptions-item>
<el-descriptions-item label="是否京东自营">{{ getJsonValue(currentChild.jsonQueryResult, 'isJdSale') ? '是' : '否' }}</el-descriptions-item>
<!-- 佣金信息 -->
<div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
<h4>佣金信息</h4>
<el-descriptions :column="2" border>
<el-descriptions-item label="佣金">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commission') ? `¥${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commission')}` : '-' }}</el-descriptions-item>
<el-descriptions-item label="佣金比例">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commissionShare') ? `${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commissionShare')}%` : '-' }}</el-descriptions-item>
<el-descriptions-item label="券佣金">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.couponCommission') ? `¥${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.couponCommission')}` : '-' }}</el-descriptions-item>
<el-descriptions-item label="PLUS佣金比例">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.plusCommissionShare') ? `${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.plusCommissionShare')}%` : '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<!-- 商品查询结果 -->
<!-- <div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
<h4>商品查询结果</h4>
<el-descriptions :column="1" border>
<el-descriptions-item label="品牌">{{ decodeUnicode(getJsonValue(currentChild.jsonQueryResult, 'brandName')) || '-' }}</el-descriptions-item>
<el-descriptions-item label="分类">{{ decodeUnicode(getCategoryPath(currentChild.jsonQueryResult)) || '-' }}</el-descriptions-item>
<el-descriptions-item label="评论数">{{ getJsonValue(currentChild.jsonQueryResult, 'comments') || '-' }}</el-descriptions-item>
<el-descriptions-item label="好评率">{{ getJsonValue(currentChild.jsonQueryResult, 'goodCommentsShare') ? `${getJsonValue(currentChild.jsonQueryResult, 'goodCommentsShare')}%` : '-' }}</el-descriptions-item>
<el-descriptions-item label="30天订单数">{{ getJsonValue(currentChild.jsonQueryResult, 'inOrderCount30Days') || '-' }}</el-descriptions-item>
<el-descriptions-item label="是否热门">{{ getJsonValue(currentChild.jsonQueryResult, 'isHot') ? '是' : '否' }}</el-descriptions-item>
<el-descriptions-item label="是否京东自营">{{ getJsonValue(currentChild.jsonQueryResult, 'isJdSale') ? '是' : '否' }}</el-descriptions-item>
</el-descriptions>
</div> -->
<!-- 价格信息 -->
<div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
@@ -139,27 +148,17 @@
</el-descriptions>
</div>
<!-- 佣金信息 -->
<div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
<h4>佣金信息</h4>
<el-descriptions :column="2" border>
<el-descriptions-item label="佣金">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commission') ? `¥${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commission')}` : '-' }}</el-descriptions-item>
<el-descriptions-item label="佣金比例">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commissionShare') ? `${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.commissionShare')}%` : '-' }}</el-descriptions-item>
<el-descriptions-item label="券佣金">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.couponCommission') ? `¥${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.couponCommission')}` : '-' }}</el-descriptions-item>
<el-descriptions-item label="PLUS佣金比例">{{ getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.plusCommissionShare') ? `${getJsonValue(currentChild.jsonQueryResult, 'commissionInfo.plusCommissionShare')}%` : '-' }}</el-descriptions-item>
</el-descriptions>
</div>
<!-- 店铺信息 -->
<div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
<!-- <div v-if="currentChild.jsonQueryResult" style="margin-top: 20px;">
<h4>店铺信息</h4>
<el-descriptions :column="2" border>
<el-descriptions-item label="店铺ID">{{ getJsonValue(currentChild.jsonQueryResult, 'shopInfo.shopId') || '-' }}</el-descriptions-item>
<el-descriptions-item label="店铺名称">{{ getJsonValue(currentChild.jsonQueryResult, 'shopInfo.shopName') || '-' }}</el-descriptions-item>
<el-descriptions-item label="店铺等级">{{ getJsonValue(currentChild.jsonQueryResult, 'shopInfo.shopLevel') || '-' }}</el-descriptions-item>
<el-descriptions-item label="店铺标签">{{ getJsonValue(currentChild.jsonQueryResult, 'shopInfo.shopLabel') || '-' }}</el-descriptions-item>
<el-descriptions-item label="店铺标签">{{ decodeUnicode(getJsonValue(currentChild.jsonQueryResult, 'shopInfo.shopLabel')) || '-' }}</el-descriptions-item>
</el-descriptions>
</div>
</div> -->
<!-- 优惠券信息 -->
<div v-if="currentChild.jsonCouponList && currentChild.jsonCouponList !== '[]'" style="margin-top: 20px;">
@@ -202,42 +201,66 @@
</el-dialog>
<!-- 消息详情对话框 -->
<el-dialog title="消息详情" :visible.sync="messageDetailVisible" width="900px" append-to-body>
<el-dialog title="消息详情" :visible.sync="messageDetailVisible" width="1600px" append-to-body>
<div v-if="currentMessageDetail">
<el-descriptions :column="2" border>
<el-descriptions-item label="消息ID">{{ currentMessageDetail.id }}</el-descriptions-item>
<el-descriptions :column="3" border>
<el-descriptions-item label="创建时间">{{ currentMessageDetail.createDate ? parseTime(currentMessageDetail.createDate) : '-' }}</el-descriptions-item>
<el-descriptions-item label="来源微信ID">{{ currentMessageDetail.fromWxid || '-' }}</el-descriptions-item>
<el-descriptions-item label="SKUID">{{ currentMessageDetail.skuid || '-' }}</el-descriptions-item>
<el-descriptions-item label="线报群名称">{{ getGroupName(currentMessageDetail.fromWxid) || '-' }}</el-descriptions-item>
<!-- <el-descriptions-item label="SKUID">{{ currentMessageDetail.skuid || '-' }}</el-descriptions-item> -->
</el-descriptions>
<!-- 原始消息内容 -->
<div style="margin-top: 20px;">
<h4>原始消息内容</h4>
<h4 style="font-size: 18px; font-weight: bold; color: #303133;">原始消息内容</h4>
<el-input
type="textarea"
:rows="8"
v-model="currentMessageDetail.tipOriginalMessage"
:value="decodeUnicode(currentMessageDetail.tipOriginalMessage)"
readonly
placeholder="暂无消息内容"
style="font-size: 18px; font-weight: bold;"
class="original-message-content"
/>
</div>
<!-- 子消息列表 -->
<div v-if="currentMessageDetail.children && currentMessageDetail.children.length > 0" style="margin-top: 20px;">
<h4>子消息列表 ({{ currentMessageDetail.children.length }})</h4>
<el-table :data="currentMessageDetail.children" border style="width: 100%" max-height="400">
<el-table-column label="ID" align="center" prop="id" width="80" />
<el-table-column label="商品名称" align="left" prop="skuName" :show-overflow-tooltip="true" min-width="200" />
<el-table-column label="价格" align="center" prop="firstPrice" width="100">
<el-table :data="currentMessageDetail.children" border style="width: 100%" max-height="400" @row-click="handleChildRowClick" highlight-current-row>
<el-table-column label="商品名称" align="left" prop="skuName" :show-overflow-tooltip="true" min-width="250">
<template slot-scope="scope">
<span>{{ decodeUnicode(scope.row.skuName) }}</span>
</template>
</el-table-column>
<el-table-column label="价格" align="center" prop="firstPrice" width="120">
<template slot-scope="scope">
<span v-if="scope.row.firstPrice">¥{{ scope.row.firstPrice }}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="商品详情" align="left" min-width="300">
<el-table-column label="店铺名称" align="center" width="150">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="showChildDetail(scope.row)">查看详情</el-button>
<span v-html="parseOwner(scope.row.owner)"></span>-
<span v-if="scope.row.jsonQueryResult">{{ decodeUnicode(getJsonValue(scope.row.jsonQueryResult, 'shopInfo.shopName')) || '-' }}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="佣金比例" align="center" width="80">
<template slot-scope="scope">
<span v-if="scope.row.jsonQueryResult && getJsonValue(scope.row.jsonQueryResult, 'commissionInfo.commissionShare')">{{ getJsonValue(scope.row.jsonQueryResult, 'commissionInfo.commissionShare') }}%</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="佣金" align="center" width="120">
<template slot-scope="scope">
<span v-if="scope.row.jsonQueryResult && getJsonValue(scope.row.jsonQueryResult, 'commissionInfo.commission')">¥{{ getJsonValue(scope.row.jsonQueryResult, 'commissionInfo.commission') }}</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="100">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-info" @click.stop="showChildDetail(scope.row)">详情</el-button>
</template>
</el-table-column>
</el-table>
@@ -252,7 +275,7 @@
</template>
<script>
import { listXbmessage, getXbmessage, delXbmessage, addXbmessage, updateXbmessage } from "@/api/system/xbmessage";
import { listXbmessage, delXbmessage, getGroupNameOptions } from "@/api/system/xbmessage";
import { parseTime } from "@/utils/ruoyi";
export default {
@@ -263,8 +286,6 @@ export default {
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
@@ -273,29 +294,12 @@ export default {
total: 0,
// 消息表格数据
xbmessageList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
id: null,
type: null,
content: null
},
// 表单参数
form: {},
// 表单校验
rules: {
type: [
{ required: true, message: "消息类型不能为空", trigger: "blur" }
],
content: [
{ required: true, message: "消息内容不能为空", trigger: "blur" }
]
},
// 子消息详情对话框
childDetailVisible: false,
// 当前查看的子消息
@@ -305,11 +309,14 @@ export default {
// 当前查看的消息详情
currentMessageDetail: {},
// 统计数据
statistics: null
statistics: null,
// 群名称选项
groupNameOptions: []
};
},
created() {
this.getList();
this.getGroupNameOptions();
},
methods: {
/** 查询消息列表 */
@@ -325,11 +332,30 @@ export default {
this.processStatistics(response);
});
},
/** 获取群名称选项 */
getGroupNameOptions() {
getGroupNameOptions().then(response => {
this.groupNameOptions = response.data || [];
console.log('群名称选项加载完成:', this.groupNameOptions);
}).catch(error => {
console.error('获取群名称选项失败:', error);
this.groupNameOptions = [];
});
},
/** 根据微信ID获取群名称 */
getGroupName(wxid) {
if (!wxid || !this.groupNameOptions || this.groupNameOptions.length === 0) return null;
const group = this.groupNameOptions.find(item => item.value === wxid);
return group ? group.label : null;
},
/** 归一化列表数据(解决 children 字段结构不同) */
normalizeList(rows) {
if (!Array.isArray(rows)) return [];
return rows.map(parent => {
const normalized = { ...parent };
// 添加childrenCount字段
normalized.childrenCount = Array.isArray(parent.children) ? parent.children.length : 0;
if (Array.isArray(parent.children) && parent.children.length > 0) {
normalized.children = parent.children.map(child => {
// 如果接口已经提供了这些字段直接使用否则从jsonQueryResult中解析
@@ -408,6 +434,41 @@ export default {
return null;
}
},
/** 解析所有者字段 */
parseOwner(owner) {
if (!owner) return '-';
if (owner === 'g') return '<span style="color: #67C23A; font-weight: bold;">自营</span>';
if (owner === 'p') return '<span style="color: #409EFF; font-weight: bold;">POP</span>';
return owner;
},
/** 解码Unicode字符 */
decodeUnicode(str) {
if (!str || typeof str !== 'string') return str;
try {
// 处理 \u 开头的Unicode转义序列
return str.replace(/\\u([0-9a-fA-F]{4})/g, (match, hex) => {
return String.fromCharCode(parseInt(hex, 16));
});
} catch (e) {
return str;
}
},
/** 行点击事件 */
handleRowClick(row, column, event) {
// 如果点击的是操作列,不触发详情
if (column.label === '操作') {
return;
}
this.showMessageDetail(row);
},
/** 子消息行点击事件 */
handleChildRowClick(row, column, event) {
// 如果点击的是操作列,不触发详情
if (column.label === '操作') {
return;
}
this.showChildDetail(row);
},
/** 解析优惠券列表 */
parseCouponList(couponListStr) {
try {
@@ -472,20 +533,6 @@ export default {
};
}
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
type: null,
content: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
@@ -499,50 +546,12 @@ export default {
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加消息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getXbmessage(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改消息";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateXbmessage(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addXbmessage(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除消息编号为"' + ids + '"的数据').then(function() {
this.$modal.confirm('是否确认删除选中的消息数据?').then(function() {
return delXbmessage(ids);
}).then(() => {
this.getList();
@@ -580,4 +589,10 @@ export default {
.mb20 {
margin-bottom: 20px;
}
.original-message-content .el-textarea__inner {
font-size: 18px !important;
font-weight: bold !important;
line-height: 1.6;
}
</style>