|
|
@@ -43,7 +43,7 @@
|
|
|
<el-radio-button label="商品" >商品</el-radio-button>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="主体名称" prop="mainId">
|
|
|
+ <el-form-item :label="queryParams.mainType === '店铺'?'主体名称':'商品名称'" prop="mainId">
|
|
|
<el-select
|
|
|
v-model="queryParams.mainId"
|
|
|
filterable
|
|
|
@@ -115,7 +115,12 @@
|
|
|
<el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column label="日志编号" align="center" prop="operId" />
|
|
|
- <el-table-column label="主体名称" align="center" prop="mainName"/>
|
|
|
+ <el-table-column :label="queryParams.mainType === '店铺'?'主体名称':'商品名称'" align="center" prop="mainName">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <span v-if="scope.row.mainName !== null">{{scope.row.mainName}}</span>
|
|
|
+ <span v-else>{{extractMainNames(scope.row)}}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="系统模块" align="center" prop="title" />
|
|
|
<el-table-column label="操作类型" align="center" prop="businessType">
|
|
|
<template slot-scope="scope">
|
|
|
@@ -202,9 +207,11 @@
|
|
|
|
|
|
<script>
|
|
|
import { list, exportOperlog, getMains } from '@/api/hisStore/operlog'
|
|
|
+import Template from '@/views/his/complaint/template.vue'
|
|
|
|
|
|
export default {
|
|
|
name: "Operlog",
|
|
|
+ components: { Template },
|
|
|
data() {
|
|
|
return {
|
|
|
|
|
|
@@ -337,7 +344,59 @@ export default {
|
|
|
this.download(response.msg);
|
|
|
this.exportLoading = false;
|
|
|
}).catch(() => {});
|
|
|
- }
|
|
|
+ },
|
|
|
+ extractMainNames(row) {
|
|
|
+ let jsonResult= row.jsonResult;
|
|
|
+ if(this.queryParams.mainType === '店铺'){
|
|
|
+ if (!jsonResult) return '暂无名称';
|
|
|
+
|
|
|
+ const resultStr = typeof jsonResult === 'object'
|
|
|
+ ? JSON.stringify(jsonResult)
|
|
|
+ : jsonResult;
|
|
|
+ const keyword = this.queryParams.mainType === '店铺' ? '删除店铺:' : '删除商品:';
|
|
|
+ const reg = new RegExp(`${keyword}([^/]+)`, 'g'); // 动态拼接正则
|
|
|
+ const names = [];
|
|
|
+ let match;
|
|
|
+
|
|
|
+ while ((match = reg.exec(resultStr)) !== null) {
|
|
|
+ names.push(match[1].trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ return names.length > 0 ? names.join('、') : `暂无${this.queryParams.mainType}名称`;
|
|
|
+ }else {
|
|
|
+ if (!jsonResult) return '暂无删除的商品名称';
|
|
|
+
|
|
|
+ const resultStr = typeof jsonResult === 'object'
|
|
|
+ ? JSON.stringify(jsonResult)
|
|
|
+ : jsonResult.trim();
|
|
|
+ const productNameReg = /删除商品名称:([^/-]+?)(?=-删除|\/|$)/g;
|
|
|
+ const deletedProductNames = [];
|
|
|
+ let match;
|
|
|
+
|
|
|
+ while ((match = productNameReg.exec(resultStr)) !== null) {
|
|
|
+ const productName = match[1].trim();
|
|
|
+ if (productName) deletedProductNames.push(productName);
|
|
|
+ }
|
|
|
+ return deletedProductNames.length
|
|
|
+ ? deletedProductNames.join('、')
|
|
|
+ : this.extractNames(row.operParam);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ extractNames(value) {
|
|
|
+ if (!value || typeof value !== 'string') {
|
|
|
+ console.warn('传入的不是有效 JSON 字符串:', value);
|
|
|
+ return '暂无商品名称';
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ const trimmedValue = value.trim();
|
|
|
+ const productObj = JSON.parse(trimmedValue);
|
|
|
+ return productObj.productName || '暂无商品名称';
|
|
|
+ } catch (error) {
|
|
|
+ console.error('JSON 解析失败,原始值:', value, '错误信息:', error);
|
|
|
+ return '暂无商品';
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|