Commit ac4b3924 by wangzhihui

Merge branch 'SAAS+V5.8.3' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.8.3_wzh
2 parents b989d504 5ce19c19
import request from "./request";
import RequestMethods from "./request.methods";
/** 查询客户画像 */
export function queryCustomerPortrait(data = {}) {
data.method = "dj.api.customer.profile";
data.id = data.id ?? data.customerId;
return request(data, RequestMethods.POST);
}
/** 查询客户群关联 */
export function queryCustomerGroups(data = {}) {
data.method = "dj.api.customer.groupAssoc";
data.id = data.id ?? data.customerId;
return request(data, RequestMethods.POST);
}
import request from "./request";
import RequestMethods from "./request.methods";
const METHOD_PREFIX = "dj.api.strategy.tag.";
/** 查询标签类别树 */
export function queryTagCategoryTree(data = {}) {
data.method = `${METHOD_PREFIX}category.tree`;
return request(data, RequestMethods.POST);
}
/** 查询可新增子级的分类列表 */
export function queryTagCategoryLeafList(data = {}) {
data.method = `${METHOD_PREFIX}category.leaf.list`;
return request(data, RequestMethods.POST);
}
/** 创建标签类别 */
export function createTagCategory(data = {}) {
data.method = `${METHOD_PREFIX}category.create`;
return request(data, RequestMethods.POST);
}
/** 编辑标签类别 */
export function updateTagCategory(data = {}) {
data.method = `${METHOD_PREFIX}category.update`;
return request(data, RequestMethods.POST);
}
/** 分页查询标签维度列表 */
export function queryTagDimension(data = {}) {
data.method = `${METHOD_PREFIX}dimension.query`;
return request(data, RequestMethods.POST);
}
/** 获取新增维度时可选的分类列表 */
export function queryTagDimensionCategoryOptions(data = {}) {
data.method = `${METHOD_PREFIX}dimension.category.options`;
return request(data, RequestMethods.POST);
}
/**
* 查询标签维度详情
* @param {Object} data categoryId — 参数名沿用后端,实际传维度 ID
*/
export function queryTagDimensionDetail(data = {}) {
data.method = `${METHOD_PREFIX}dimension.detail`;
return request(data, RequestMethods.POST);
}
/** 创建标签维度 */
export function createTagDimension(data = {}) {
data.method = `${METHOD_PREFIX}dimension.create`;
return request(data, RequestMethods.POST);
}
/** 编辑标签维度 */
export function updateTagDimension(data = {}) {
data.method = `${METHOD_PREFIX}dimension.update`;
return request(data, RequestMethods.POST);
}
/** 分页查询枚举值列表 */
export function pageTagEnum(data = {}) {
data.method = `${METHOD_PREFIX}enum.page`;
return request(data, RequestMethods.POST);
}
/** 创建标签枚举值 */
export function createTagEnum(data = {}) {
data.method = `${METHOD_PREFIX}enum.create`;
return request(data, RequestMethods.POST);
}
/** 编辑标签枚举值 */
export function updateTagEnum(data = {}) {
data.method = `${METHOD_PREFIX}enum.update`;
return request(data, RequestMethods.POST);
}
......@@ -237,7 +237,7 @@
v-bind="getItemAttrs(item)"
:disabled="getItemIsDisabled(item)"
v-on="item.listeners ? item.listeners : {}"
@change="item.handleRadioChange ? item.handleRadioChange : () => { }">
@change="handleRadioChange($event, item)">
<el-radio v-for="subItem in item.optionList"
:key="subItem[item.optionId]"
:disabled="getItemIsDisabled(item)"
......@@ -628,6 +628,11 @@ export default {
mounted() { },
methods: {
handleRadioChange(value, item) {
if (item.handleRadioChange) {
item.handleRadioChange(value);
}
},
passwordInputType(item) {
if (item.showPass) {
return this.passwordPlain[item.name] ? "text" : "password";
......
const _import = require("@/libs/util.import." + process.env.NODE_ENV)
export const routerName = {
902: {
path: "/flowManage",
name: "flowManage",
meta: {
title: "流量管理",
authId: "902",
parentId: "1",
cache: false
}
},
90201: {
path: "/customerList",
name: "customerList",
meta: {
title: "客户列表",
authId: "90201",
parentId: "902",
cache: false
},
auth: [
{
authId: "9020101",
parentId: "90201",
label: "导出",
category: "Button",
type: "primary",
handle: "handleExport"
}
],
component: _import("customer/customerList")
},
90202: {
path: "/recordList",
name: "recordList",
meta: {
title: "预录信息",
authId: "90202",
parentId: "902",
cache: false
},
auth: [
{
authId: "9020201",
parentId: "90202",
label: "预录客户",
icon: "plus",
category: "Button",
type: "primary",
handle: "handleAdd",
addRoutePath: [
{
authId: "901",
name: "预录客户",
parentId: "90202"
}
]
},
{
authId: "9020202",
parentId: "90202",
label: "一键导入",
category: "Button",
type: "primary",
handle: "handleImport"
},
{
authId: "9020203",
parentId: "90202",
label: "编辑",
handle: "handleEdit",
addRoutePath: [
{
authId: "901",
name: "预录客户",
parentId: "90202"
}
]
}
],
component: _import("customer/recordList")
},
90203: {
path: "/invitation",
name: "invitation",
meta: {
title: "邀约管理",
authId: "90203",
parentId: "902",
cache: false
},
auth: [
{
authId: "9020301",
parentId: "90203",
label: "再次电联",
handle: "handleMoreCall"
// ruleObj: {
// attr: 'status',
// rule: {
// 0: '上架',
// 1: '下架'
// }
// }
},
{
authId: "9020302",
parentId: "90203",
label: "取消预约",
handle: "handleCancel"
},
{
authId: "9020303",
parentId: "90203",
label: "更新备注",
handle: "handleUpdateRemark"
},
{
authId: "9020304",
parentId: "90203",
label: "修改时间",
handle: "handleChangeTime"
},
{
authId: "9020305",
parentId: "90203",
label: "电联一下",
handle: "handleCall"
},
{
authId: "9020306",
parentId: "90203",
label: "预约时间",
handle: "handleAppoint"
},
{
authId: "9020307",
parentId: "90203",
label: "更新备注",
handle: "handleUpdateRemark"
}
],
component: _import("customer/invitation")
},
901: {
path: "/editCustomer",
name: "editCustomer",
meta: {
title: "预录客户",
authId: "901",
parentId: "90202",
cache: false,
sideHidden: false,
activePath: "/recordList"
},
component: _import("customer/editCustomer")
}
}
// { routerName }
const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = {
902: {
path: "/flowManage",
name: "flowManage",
meta: {
title: "流量管理",
authId: "902",
parentId: "1",
cache: false,
},
},
90201: {
path: "/customerList",
name: "customerList",
meta: {
title: "客户列表",
authId: "90201",
parentId: "902",
cache: false,
},
auth: [
{
authId: "9020101",
parentId: "90201",
label: "导出",
category: "Button",
type: "primary",
handle: "handleExport",
},
{
authId: "9020102",
parentId: "90201",
label: "客户画像",
handle: "handleViewPortrait",
addRoutePath: [
{
authId: "90205",
name: "客户画像",
parentId: "90201",
},
],
},
{
authId: "9020103",
parentId: "90201",
label: "群关联",
handle: "handleViewGroups",
addRoutePath: [
{
authId: "90206",
name: "群关联",
parentId: "90201",
},
],
},
{
authId: "9020104",
parentId: "90201",
label: "订单信息",
handle: "handleViewOrders",
// addRoutePath: [
// {
// authId: "90401",
// name: "订单列表",
// parentId: "904",
// },
// ],
},
],
component: _import("customer/customerList"),
},
90202: {
path: "/recordList",
name: "recordList",
meta: {
title: "预录信息",
authId: "90202",
parentId: "902",
cache: false,
},
auth: [
{
authId: "9020201",
parentId: "90202",
label: "预录客户",
icon: "plus",
category: "Button",
type: "primary",
handle: "handleAdd",
addRoutePath: [
{
authId: "901",
name: "预录客户",
parentId: "90202",
},
],
},
{
authId: "9020202",
parentId: "90202",
label: "一键导入",
category: "Button",
type: "primary",
handle: "handleImport",
},
{
authId: "9020203",
parentId: "90202",
label: "编辑",
handle: "handleEdit",
addRoutePath: [
{
authId: "901",
name: "预录客户",
parentId: "90202",
},
],
},
],
component: _import("customer/recordList"),
},
90203: {
path: "/invitation",
name: "invitation",
meta: {
title: "邀约管理",
authId: "90203",
parentId: "902",
cache: false,
},
auth: [
{
authId: "9020301",
parentId: "90203",
label: "再次电联",
handle: "handleMoreCall",
// ruleObj: {
// attr: 'status',
// rule: {
// 0: '上架',
// 1: '下架'
// }
// }
},
{
authId: "9020302",
parentId: "90203",
label: "取消预约",
handle: "handleCancel",
},
{
authId: "9020303",
parentId: "90203",
label: "更新备注",
handle: "handleUpdateRemark",
},
{
authId: "9020304",
parentId: "90203",
label: "修改时间",
handle: "handleChangeTime",
},
{
authId: "9020305",
parentId: "90203",
label: "电联一下",
handle: "handleCall",
},
{
authId: "9020306",
parentId: "90203",
label: "预约时间",
handle: "handleAppoint",
},
{
authId: "9020307",
parentId: "90203",
label: "更新备注",
handle: "handleUpdateRemark",
},
],
component: _import("customer/invitation"),
},
90205: {
path: "/customerPortrait",
name: "customerPortrait",
meta: {
title: "客户画像",
authId: "90205",
parentId: "90201",
cache: false,
sideHidden: true,
activePath: "/customerList",
},
component: _import("customer/portrait/index"),
},
90206: {
path: "/customerGroupRel",
name: "customerGroupRel",
meta: {
title: "群关联",
authId: "90206",
parentId: "90201",
cache: false,
sideHidden: true,
activePath: "/customerList",
},
component: _import("customer/groupRel/index"),
},
901: {
path: "/editCustomer",
name: "editCustomer",
meta: {
title: "预录客户",
authId: "901",
parentId: "90202",
cache: false,
sideHidden: false,
activePath: "/recordList",
},
component: _import("customer/editCustomer"),
},
};
// { routerName }
const _import = require("@/libs/util.import." + process.env.NODE_ENV)
const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = {
922: {
path: "/marketingManagement",
......@@ -8,7 +8,7 @@ export const routerName = {
authId: "922",
parentId: "1",
cache: false,
}
},
},
92201: {
path: "/marketingActivity",
......@@ -29,12 +29,12 @@ export const routerName = {
type: "primary",
handle: "handleAdd",
addRoutePath: [
{
authId: "92202",
name: "新增活动",
parentId: "92201"
}
]
{
authId: "92202",
name: "新增活动",
parentId: "92201",
},
],
},
{
authId: "9220102",
......@@ -42,14 +42,14 @@ export const routerName = {
label: "查看详情",
handle: "handleDetail",
addRoutePath: [
{
authId: "92203",
name: "订单详情",
parentId: "92201"
}
]
{
authId: "92203",
name: "订单详情",
parentId: "92201",
},
],
},
]
],
},
92202: {
path: "/addMarketingActivity",
......@@ -62,7 +62,7 @@ export const routerName = {
sideHidden: true,
activePath: "/marketingActivity",
},
component: _import("marketingManagement/marketingActivity/addMarketingActivity")
component: _import("marketingManagement/marketingActivity/addMarketingActivity"),
},
92203: {
path: "/viewMarketingActivity",
......@@ -101,7 +101,7 @@ export const routerName = {
authId: "9220106",
parentId: "92203",
label: "恢复",
handle: "handleToggleStatus"
handle: "handleToggleStatus",
},
{
authId: "9220107",
......@@ -119,8 +119,8 @@ export const routerName = {
authId: "9220109",
parentId: "92203",
label: "再次创建",
handle: "handleRecreate"
}
]
}
}
handle: "handleRecreate",
},
],
},
};
const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = {
923: {
path: "/tagManagement",
name: "tagManagementGroup",
meta: {
title: "标签管理",
authId: "923",
parentId: "1",
cache: false,
},
},
92301: {
path: "/tagManagementList",
name: "tagManagement",
meta: {
title: "标签管理",
authId: "92301",
parentId: "923",
cache: false,
},
addRoutePath: [
{
authId: "92302",
name: "维护枚举值",
parentId: "92301",
},
],
auth: [
{
authId: "9230101",
parentId: "92301",
label: "新增子分类",
category: "Button",
type: "primary",
handle: "handleAddCategory",
},
{
authId: "9230102",
parentId: "92301",
label: "新增标签维度",
category: "Button",
type: "primary",
handle: "handleAddDimension",
},
{
authId: "9230103",
parentId: "92301",
label: "编辑",
handle: "handleEditCategory",
},
{
authId: "9230104",
parentId: "92301",
label: "新增枚举",
handle: "handleAddEnum",
},
{
authId: "9230105",
parentId: "92301",
label: "编辑",
handle: "handleEditDimension",
},
{
authId: "9230106",
parentId: "92301",
label: "编辑枚举",
handle: "handleEditEnum",
},
{
authId: "9230108",
parentId: "92301",
label: "维护枚举值",
handle: "handleMaintainEnum",
addRoutePath: [
{
authId: "92302",
name: "维护枚举值",
parentId: "92301",
},
],
},
],
component: _import("tagCustomerManagement/tagManagement/index"),
},
92302: {
path: "/tagEnumMaintain",
name: "tagEnumMaintain",
meta: {
title: "维护枚举值",
authId: "92302",
parentId: "92301",
cache: false,
sideHidden: true,
activePath: "/tagManagementList",
},
auth: [
{
authId: "9230104",
parentId: "92302",
label: "新增枚举值",
category: "Button",
type: "primary",
handle: "handleAddEnum",
},
{
authId: "9230106",
parentId: "92302",
label: "编辑枚举",
handle: "handleEditEnum",
},
],
component: _import("tagCustomerManagement/tagManagement/enumMaintain/index"),
},
};
<template>
<section class="detail-card">
<h3 class="detail-card__title">
基础信息
</h3>
<el-row :gutter="16">
<el-col
v-for="item in fieldList"
:key="item.prop"
class="detail-row"
:span="item.span || 8"
>
<span class="detail-label">{{ item.label }}:</span>
<span class="detail-value">{{ displayInfo[item.prop] || "-" }}</span>
</el-col>
</el-row>
</section>
</template>
<script>
import { CUSTOMER_STATUS_LIST, mapBasicInfoFromRow } from "../utils/customerSnapshot";
export default {
name: "CustomerBasicInfoCard",
props: {
customerRow: {
type: Object,
default: () => ({}),
},
basicInfo: {
type: Object,
default: () => ({}),
},
statusList: {
type: Array,
default: () => CUSTOMER_STATUS_LIST,
},
},
computed: {
displayInfo() {
const fromRow = mapBasicInfoFromRow(this.customerRow, this.statusList);
if (this.basicInfo && Object.keys(this.basicInfo).length) {
return {
...fromRow,
...this.basicInfo,
// 客户分类、客户状态仅来自列表行数据,详情接口不返回
customerCategory: fromRow.customerCategory,
customerStatus: fromRow.customerStatus,
};
}
return fromRow;
},
fieldList() {
return [
{ label: "客户姓名", prop: "customerName" },
{ label: "手机号", prop: "mobile" },
{ label: "客户分类", prop: "customerCategory" },
{ label: "品牌车型", prop: "carModel" },
{ label: "客户状态", prop: "customerStatus" },
{ label: "服务时间", prop: "serviceTime" },
{ label: "备注", prop: "remark", span: 24 },
{ label: "流量来源", prop: "trafficSource" },
{ label: "推荐人", prop: "referrer" },
{ label: "园区店", prop: "parkStore" },
{ label: "转化专员", prop: "conversionStaff" },
{ label: "群关联信息", prop: "groupRelInfo" },
{ label: "创建方式", prop: "createMethod" },
{ label: "创建时间", prop: "createTime" },
{ label: "交车时间", prop: "deliveryTime" },
];
},
},
};
</script>
<style lang="scss" scoped>
.detail-card {
background: #fff;
border-radius: 4px;
padding: 16px 20px 8px;
margin-bottom: 12px;
&__title {
margin: 0 0 16px;
padding-left: 10px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 20px;
}
}
.detail-row {
margin-bottom: 14px;
font-size: 14px;
line-height: 22px;
}
.detail-label {
color: #606266;
}
.detail-value {
color: #303133;
word-break: break-all;
}
</style>
<template>
<d2-container v-loading="pageLoading" class="customer-group-rel-page">
<div class="page-content">
<CustomerBasicInfoCard
:customer-row="customerRow"
:basic-info="groupData.basicInfo"
/>
<section class="detail-card">
<h3 class="detail-card__title">
群关联
</h3>
<div
v-for="item in groupFieldList"
:key="item.prop"
class="field-row"
>
<span class="field-label">{{ item.label }}:</span>
<span class="field-value">{{ displayGroupInfo[item.prop] || "-" }}</span>
</div>
</section>
<div class="footer-actions">
<el-button type="primary" size="medium" @click="handleBack">
返回
</el-button>
</div>
</div>
</d2-container>
</template>
<script>
import { queryCustomerGroups } from "@api/customerDetail";
import CustomerBasicInfoCard from "../components/CustomerBasicInfoCard.vue";
import { loadCustomerSnapshot, mapGroupAssocResponse, resolveCustomerRowFromRoute } from "../utils/customerSnapshot";
export default {
name: "CustomerGroupRel",
components: { CustomerBasicInfoCard },
data() {
return {
pageLoading: false,
customerId: "",
customerRow: {},
groupData: {
basicInfo: {},
groupRelStatus: "",
groupName: "",
groupMemberCustomer: "",
},
};
},
computed: {
groupFieldList() {
return [
{ label: "群关联状态", prop: "groupRelStatus" },
{ label: "群名称", prop: "groupName" },
{ label: "群成员-客户", prop: "groupMemberCustomer" },
];
},
displayGroupInfo() {
return {
groupRelStatus: this.groupData.groupRelStatus || "未关联",
groupName: this.groupData.groupName || "",
groupMemberCustomer: this.groupData.groupMemberCustomer || "",
};
},
},
created() {
this.customerId = this.$route.query.customerId;
if (!this.customerId) {
this.$message.warning("缺少客户参数");
this.$router.back();
return;
}
this.customerRow = resolveCustomerRowFromRoute(
this.$route,
loadCustomerSnapshot()
);
this.loadGroupInfo();
},
methods: {
async loadGroupInfo() {
this.pageLoading = true;
try {
const res = await queryCustomerGroups({
id: this.customerId,
});
this.applyGroupData(mapGroupAssocResponse(res || {}, this.customerRow));
} catch (err) {
this.$message.error(err.message || "加载群关联失败");
this.applyGroupData(mapGroupAssocResponse({}, this.customerRow));
} finally {
this.pageLoading = false;
}
},
applyGroupData(res) {
this.groupData = {
basicInfo: res.basicInfo || {},
groupRelStatus: res.groupRelStatus || "未关联",
groupName: res.groupName || "",
groupMemberCustomer: res.groupMemberCustomer || "",
};
},
handleBack() {
this.$router.push({ name: "customerList" });
},
},
};
</script>
<style lang="scss" scoped>
.customer-group-rel-page {
::v-deep .d2-container-full__body {
padding: 0 !important;
background: #f0f2f5;
}
.page-content {
width: 100%;
box-sizing: border-box;
padding: 12px 20px 32px;
}
.detail-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 16px 20px;
margin-bottom: 12px;
&__title {
margin: 0 0 16px;
padding-left: 10px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 20px;
}
}
.field-row {
display: flex;
align-items: flex-start;
margin-bottom: 14px;
font-size: 14px;
line-height: 22px;
&:last-child {
margin-bottom: 0;
}
}
.field-label {
flex-shrink: 0;
min-width: 110px;
color: #606266;
}
.field-value {
flex: 1;
color: #303133;
word-break: break-all;
}
.footer-actions {
margin-top: 8px;
padding: 16px 0 8px;
text-align: center;
}
}
</style>
<template>
<d2-container v-loading="pageLoading" class="customer-portrait-page">
<div class="page-content">
<CustomerBasicInfoCard
:customer-row="customerRow"
:basic-info="portraitData.basicInfo"
/>
<section class="detail-card">
<h3 class="detail-card__title">
消费力标签({{ consumptionScore }}分)
</h3>
<template v-if="consumptionDimensions.length">
<div
v-for="(dimension, index) in consumptionDimensions"
:key="`consumption-${index}`"
class="field-row"
>
<span class="field-label">{{ dimension.dimensionName }}:</span>
<div class="tag-list">
<template v-if="dimension.tags.length">
<el-tag
v-for="(tag, tagIndex) in dimension.tags"
:key="`consumption-tag-${index}-${tagIndex}`"
size="small"
class="tag-item"
>
{{ tag }}
</el-tag>
</template>
<span v-else class="empty-text">-</span>
</div>
</div>
</template>
<div v-else class="field-row">
<span class="empty-text">-</span>
</div>
</section>
<section class="detail-card">
<h3 class="detail-card__title">
产品标签({{ productScore }}分)
</h3>
<template v-if="productDimensions.length">
<div
v-for="(dimension, index) in productDimensions"
:key="`product-${index}`"
class="field-row"
>
<span class="field-label">{{ dimension.dimensionName }}:</span>
<div class="tag-list">
<template v-if="dimension.tags.length">
<el-tag
v-for="(tag, tagIndex) in dimension.tags"
:key="`product-tag-${index}-${tagIndex}`"
size="small"
class="tag-item"
>
{{ tag }}
</el-tag>
</template>
<span v-else class="empty-text">-</span>
</div>
</div>
</template>
<div v-else class="field-row">
<span class="empty-text">-</span>
</div>
</section>
<section class="detail-card">
<h3 class="detail-card__title">
行为标签({{ behaviorScore }}分)
</h3>
<el-table
:data="behaviorTagList"
border
size="small"
class="behavior-table"
>
<el-table-column
label="序号"
type="index"
width="60"
align="center"
/>
<el-table-column
label="标签维度"
prop="dimensionName"
min-width="200"
align="center"
/>
<el-table-column
label="枚举值"
min-width="120"
align="center"
>
<template slot-scope="scope">
<el-tag
v-if="scope.row.enumName"
size="small"
class="tag-item"
>
{{ scope.row.enumName }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column
label="依据"
prop="basis"
min-width="320"
align="left"
>
<template slot-scope="scope">
<span class="basis-text">{{ scope.row.basis || "-" }}</span>
</template>
</el-table-column>
</el-table>
</section>
<div class="footer-actions">
<el-button type="primary" size="medium" @click="handleBack">
返回
</el-button>
</div>
</div>
</d2-container>
</template>
<script>
import { queryCustomerPortrait } from "@api/customerDetail";
import CustomerBasicInfoCard from "../components/CustomerBasicInfoCard.vue";
import {
loadCustomerSnapshot,
mapProfileResponse,
resolveCustomerRowFromRoute,
} from "../utils/customerSnapshot";
export default {
name: "CustomerPortrait",
components: { CustomerBasicInfoCard },
data() {
return {
pageLoading: false,
customerId: "",
customerRow: {},
portraitData: {
basicInfo: {},
consumptionScore: 0,
consumptionDimensions: [],
productScore: 0,
productDimensions: [],
behaviorScore: 0,
behaviorTagList: [],
},
};
},
computed: {
consumptionScore() {
return this.portraitData.consumptionScore || 0;
},
productScore() {
return this.portraitData.productScore || 0;
},
behaviorScore() {
return this.portraitData.behaviorScore || 0;
},
consumptionDimensions() {
return this.portraitData.consumptionDimensions || [];
},
productDimensions() {
return this.portraitData.productDimensions || [];
},
behaviorTagList() {
return this.portraitData.behaviorTagList || [];
},
},
created() {
this.customerId = this.$route.query.customerId;
if (!this.customerId) {
this.$message.warning("缺少客户参数");
this.$router.back();
return;
}
this.customerRow = resolveCustomerRowFromRoute(
this.$route,
loadCustomerSnapshot()
);
this.loadPortrait();
},
methods: {
async loadPortrait() {
this.pageLoading = true;
try {
const res = await queryCustomerPortrait({
id: this.customerId,
});
this.applyPortraitData(
mapProfileResponse(res || {}, this.customerRow)
);
} catch (err) {
this.$message.error(err.message || "加载客户画像失败");
this.applyPortraitData(
mapProfileResponse({}, this.customerRow)
);
} finally {
this.pageLoading = false;
}
},
applyPortraitData(res) {
this.portraitData = {
basicInfo: res.basicInfo || {},
consumptionScore: res.consumptionScore || 0,
consumptionDimensions: res.consumptionDimensions || [],
productScore: res.productScore || 0,
productDimensions: res.productDimensions || [],
behaviorScore: res.behaviorScore || 0,
behaviorTagList: res.behaviorTagList || [],
};
},
handleBack() {
this.$router.push({ name: "customerList" });
},
},
};
</script>
<style lang="scss" scoped>
.customer-portrait-page {
::v-deep .d2-container-full__body {
padding: 0 !important;
background: #f0f2f5;
}
.page-content {
width: 100%;
box-sizing: border-box;
padding: 12px 20px 32px;
}
.detail-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 16px 20px;
margin-bottom: 12px;
&__title {
margin: 0 0 16px;
padding-left: 10px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 20px;
}
}
.field-row {
display: flex;
align-items: flex-start;
margin-bottom: 12px;
font-size: 14px;
line-height: 22px;
&:last-child {
margin-bottom: 0;
}
}
.field-label {
flex-shrink: 0;
min-width: 90px;
color: #606266;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
flex: 1;
}
.tag-item {
background: #ecf5ff;
border-color: #d9ecff;
color: #409eff;
&--plain {
background: #f4f4f5;
border-color: #e9e9eb;
color: #909399;
}
}
.empty-text {
color: #909399;
}
.behavior-table {
width: 100%;
}
.basis-text {
display: inline-block;
word-break: break-all;
white-space: pre-wrap;
line-height: 20px;
color: #606266;
}
.footer-actions {
margin-top: 8px;
padding: 16px 0 8px;
text-align: center;
}
}
</style>
const SNAPSHOT_KEY = "customerDetailSnapshot";
export const CUSTOMER_STATUS_LIST = [
{ confId: 1, confLabel: "待跟进" },
{ confId: 2, confLabel: "已升级" },
{ confId: 3, confLabel: "战败" },
{ confId: 4, confLabel: "已退款" },
];
export function saveCustomerSnapshot(row) {
if (!row) {
return;
}
try {
sessionStorage.setItem(SNAPSHOT_KEY, JSON.stringify(row));
} catch (err) {
// ignore quota errors
}
}
export function loadCustomerSnapshot() {
try {
const raw = sessionStorage.getItem(SNAPSHOT_KEY);
return raw ? JSON.parse(raw) : {};
} catch (err) {
return {};
}
}
/** 合并列表行快照与路由参数,客户分类仅来自列表数据 */
export function resolveCustomerRowFromRoute(route = {}, snapshotRow = {}) {
const row = { ...snapshotRow };
if (route.query && route.query.customerClass) {
row.customerClass = route.query.customerClass;
}
if (route.query && route.query.customerStatus !== undefined && route.query.customerStatus !== "") {
row.customerStatus = route.query.customerStatus;
}
return row;
}
function formatDateValue(value) {
if (!value) {
return "";
}
return new Date(value).toLocaleDateString();
}
export function formatCarModel(row = {}) {
const carModel = (row.carModel || "").trim();
if (carModel) {
return carModel;
}
const parts = [row.carBrand, row.carSeriesName, row.carTypeName]
.map((item) => (item || "").trim())
.filter(Boolean);
return parts.length ? parts.join("-") : "";
}
export function formatCarModelForList(row = {}) {
const value = formatCarModel(row);
return value || "";
}
export function formatListPhone(row = {}) {
return row.customerPhone || row.mobile || row.phone || row.phoneNumber || "";
}
export function formatCustomerClass(row = {}) {
const customerClass = row.customerClass || row.customerCategory;
if (!customerClass) {
return "";
}
const normalized = String(customerClass).trim().toUpperCase();
if (normalized === "A" || normalized === "A类") {
return "A类";
}
if (normalized === "B" || normalized === "B类") {
return "B类";
}
if (normalized === "C" || normalized === "C类") {
return "C类";
}
return String(customerClass);
}
export function formatGroupStatus(row = {}) {
if (row.groupStatus === true || row.groupStatus === "已关联") {
return "已关联";
}
return "未关联";
}
export function formatDeliveryTime(row = {}) {
const time = row.deliveryDate
|| row.deliveryTime
|| row.buyTimeStr
|| (row.order && row.order.installUpgradeTime);
return formatDateValue(time);
}
export function formatRecorder(row = {}) {
return row.userName || row.advanceUserName || row.createdBy || "";
}
export function formatReferrer(row = {}) {
return row.referrerName
|| row.employeeName
|| (row.order && row.order.employeeName)
|| "";
}
export function formatCustomerStatus(row = {}, statusList = CUSTOMER_STATUS_LIST) {
const customerStatus = row.customerStatus;
if (customerStatus == null || customerStatus === "") {
return "-";
}
const matched = statusList.find((item) => Number(item.confId) === Number(customerStatus));
return matched ? matched.confLabel : "-";
}
export function formatServiceTime(row = {}) {
const time = row.order && row.order.installUpgradeTime;
if (!time) {
return "-";
}
return new Date(time).toLocaleDateString();
}
export function formatRemark(row = {}) {
if (!row.order) {
return "无";
}
if (row.order.upgradeFlag === "N") {
return row.order.customer
? (row.order.customer.refusalReason || "无")
: "无";
}
return row.order.remark || "无";
}
export function formatSource(row = {}) {
const source = row.order ? row.order.source : row.source;
if (source === 3) {
return "现场升级";
}
if (source === 5) {
return "核销抵扣";
}
return "系统录入";
}
export function formatCreateTime(row = {}) {
if (!row.createdDate) {
return "";
}
return formatDateValue(row.createdDate);
}
export function mapBasicInfoFromRow(row = {}, statusList = CUSTOMER_STATUS_LIST) {
const deliveryTime = formatDeliveryTime(row);
const referrer = formatReferrer(row);
const recorder = formatRecorder(row);
return {
customerName: row.customerName || "-",
mobile: formatListPhone(row) || "-",
customerCategory: formatCustomerClass(row) || "-",
carModel: formatCarModel(row) || "-",
customerStatus: formatCustomerStatus(row, statusList),
serviceTime: formatServiceTime(row),
remark: formatRemark(row),
trafficSource: row.merchantName || "-",
referrer: referrer || "-",
parkStore: row.yqMerchantName || "-",
conversionStaff: (row.order && row.order.sellerName) || "-",
groupRelInfo: formatGroupStatus(row),
createMethod: formatSource(row),
createTime: formatCreateTime(row) || "-",
deliveryTime: deliveryTime || "-",
recorder: recorder || "-",
};
}
function buildProfileCarModel(res = {}) {
const carModel = (res.carModel || "").trim();
if (carModel) {
return carModel;
}
const parts = [res.carBrand, res.carSeriesName]
.map((item) => (item || "").trim())
.filter(Boolean);
return parts.length ? parts.join("-") : "";
}
export function mapProfileResponse(res = {}, snapshotRow = {}) {
const snapshotBasic = mapBasicInfoFromRow(snapshotRow);
const deliveryTime = res.deliveryDate
? formatDateValue(res.deliveryDate)
: snapshotBasic.deliveryTime;
const basicInfo = {
...snapshotBasic,
customerName: res.customerName || snapshotBasic.customerName,
mobile: res.customerPhone || snapshotBasic.mobile,
carModel: buildProfileCarModel(res) || snapshotBasic.carModel,
trafficSource: res.merchantName || snapshotBasic.trafficSource,
deliveryTime: deliveryTime || "-",
// 客户分类、客户状态仅来自列表接口,详情接口不返回
customerCategory: snapshotBasic.customerCategory,
customerStatus: snapshotBasic.customerStatus,
};
const consumptionTag = res.consumptionTag || {};
// 接口字段名与 categoryName 语义对调:产品数据在 behaviorTag,行为数据在 productTag
const apiProductTag = res.behaviorTag || {};
const apiBehaviorTag = res.productTag || {};
const consumptionDimensions = (consumptionTag.dimensions || []).map((dimension) => ({
dimensionName: dimension.dimensionName || "-",
tags: (dimension.enumValues || []).map((item) => item.enumName).filter(Boolean),
}));
const productDimensions = (apiProductTag.dimensions || []).map((dimension) => ({
dimensionName: dimension.dimensionName || "-",
tags: (dimension.enumValues || []).map((item) => item.enumName).filter(Boolean),
}));
const behaviorTagList = [];
const behaviorCategory = apiBehaviorTag.categoryName || "行为标签";
(apiBehaviorTag.dealEnumValues || []).forEach((item) => {
behaviorTagList.push({
dimensionName: behaviorCategory,
enumName: item.enumName || "",
basis: item.scoreBasis || "",
});
});
(apiBehaviorTag.noDealEnumValues || []).forEach((item) => {
behaviorTagList.push({
dimensionName: behaviorCategory,
enumName: item.enumName || "",
basis: item.scoreBasis || "",
});
});
return {
basicInfo,
consumptionScore: consumptionTag.totalScore || 0,
consumptionDimensions,
productScore: apiProductTag.totalScore || 0,
productDimensions,
behaviorScore: apiBehaviorTag.totalScore || 0,
behaviorTagList,
};
}
export function mapGroupAssocResponse(res = {}, snapshotRow = {}) {
const snapshotBasic = mapBasicInfoFromRow(snapshotRow);
const groupRelStatus = res.groupStatus || "未关联";
const basicInfo = {
...snapshotBasic,
customerName: res.customerName || snapshotBasic.customerName,
mobile: res.customerPhone || snapshotBasic.mobile,
// 客户分类、客户状态仅来自列表接口,详情接口不返回
customerCategory: snapshotBasic.customerCategory,
customerStatus: snapshotBasic.customerStatus,
// 接口返回后同步基础信息中的群关联状态
groupRelInfo: groupRelStatus,
};
return {
basicInfo,
groupRelStatus,
groupName: res.qwGroupName || "",
groupMemberCustomer: res.wxName || "",
};
}
......@@ -101,6 +101,16 @@ import multipleMixin from "./multipleMixin";
export default {
name: "MultipleRecording",
mixins: [multipleMixin],
props: {
/**
* biz: 业务类型
* 1.延保 2.轻改 3.权益 4.二手车
*/
biz: {
type: Number,
default: 1,
},
},
data() {
return {
dialogConfig: {
......@@ -183,6 +193,14 @@ export default {
mounted() {
},
methods: {
beforeSearchFn() {
// 1.延保 2.轻改 3.权益 4.二手车 延保和权益都传1
return new Promise((resolve) => {
this.searchFormSearch = this.getParams();
this.searchFormSearch.businessType = this.biz == 3 ? 1 : this.biz;
resolve();
});
},
getParams() {
let params = this.deepClone(this.searchForm);
if (params.receptionDate) {
......
......@@ -149,6 +149,7 @@
@dialogClose="staffTag1Visible = false">
</MultipleStaff>
<MultipleRecording ref="recordingTagRef"
:biz="biz"
:choose-data="formData.recordingList"
:visible="recordingTagVisible"
@choose="formatMultipleList($event, 'recordingList')"
......
......@@ -462,6 +462,11 @@ export default {
type: [Number, String],
default: undefined,
},
/** 客户列表跳转带入的姓名/手机号筛选 */
customerFilter: {
type: Object,
default: null,
},
},
components: {
ChooseRuleDialog: chooseRuleDialog,
......@@ -529,6 +534,14 @@ export default {
keyFn: this.keyDowmGetList,
},
{
label: "手机号",
name: "customerPhone",
type: "input",
isClear: true,
maxlength: 11,
keyFn: this.keyDowmGetList,
},
{
label: "订单编号",
name: "orderCode",
type: "input",
......@@ -764,6 +777,7 @@ export default {
status: "",
upgradeFinishFlag: "",
customerName: "",
customerPhone: "",
yqMerchantIds: "",
merchantId: "",
orderTime: "",
......@@ -979,6 +993,18 @@ export default {
},
},
watch: {
customerFilter: {
handler(val) {
if (!val || (!val.customerName && !val.customerPhone)) {
return;
}
this.searchForm.customerName = val.customerName || "";
this.searchForm.customerPhone = val.customerPhone || "";
this.page.pageNum = 1;
this.handleSearch();
},
immediate: true,
},
updateRefesh(val) {
// console.log('val', val)
if (val == true) {
......@@ -1060,8 +1086,12 @@ export default {
this.signRefundFlag = true; // 是否有标记退款权限
}
this.getBaseData();
this.getList();
this.getOrderCount();
const hasCustomerFilter = this.customerFilter
&& (this.customerFilter.customerName || this.customerFilter.customerPhone);
if (!hasCustomerFilter) {
this.getList();
this.getOrderCount();
}
this.getProvinceList();
// 获取全部类目
getAllCategory({ pageSize: 9999, currentPage: 1 }).then((res) => {
......@@ -1145,6 +1175,7 @@ export default {
status: "",
upgradeFinishFlag: "",
customerName: "",
customerPhone: "",
yqMerchantIds: "",
merchantId: "",
orderTime: "",
......
......@@ -220,6 +220,13 @@ export default {
if (this.tabName === "carDamage" && this.carDamageRightsNavPreset) {
base.rightsNavPreset = this.carDamageRightsNavPreset
}
const { customerName, customerPhone } = this.$route.query
if (customerName || customerPhone) {
base.customerFilter = {
customerName: customerName || "",
customerPhone: customerPhone || "",
}
}
return base
}
},
......
<template>
<glsk-form-dialog v-if="visible"
default-width="320px"
dialog-width="520px"
label-width="100px"
:base-data="baseData"
:dialog-config="dialogConfig"
:edit-data="editData"
:edit-form-data="editFormData"
:form-rules="formRules"
:select-visible="visible"
@handleClose="$emit('update:visible', false)"
@handleConfirm="handleConfirm" />
</template>
<script>
import { createTagCategory, updateTagCategory } from "@api/tagManagement";
export default {
name: "CategoryFormDialog",
props: {
visible: {
type: Boolean,
default: false,
},
mode: {
type: String,
default: "add",
},
categoryData: {
type: Object,
default: () => ({}),
},
parentOptions: {
type: Array,
default: () => [],
},
defaultParentId: {
type: [Number, String],
default: "",
},
},
data() {
return {
editData: {
id: "",
categoryName: "",
parentId: "",
},
baseData: {
parentOptions: [],
},
formRules: {
categoryName: [
{ required: true, message: "请输入类别名称" },
{ max: 20, message: "类别名称不能超过20个字符" },
],
parentId: [
{ required: true, message: "请选择上级类别" },
],
},
};
},
computed: {
isEdit() {
return this.mode === "edit";
},
dialogConfig() {
return {
title: this.isEdit ? "编辑标签分类" : "新增标签类别",
okText: "保存",
};
},
editFormData() {
const fields = [
{
label: "类别名称",
name: "categoryName",
type: "input",
placeholder: "请输入类别名称",
maxlength: 20,
isClear: true,
},
];
if (!this.isEdit) {
fields.unshift({
label: "上级类别",
name: "parentId",
type: "select",
placeholder: "请选择上级类别",
filterable: true,
optionsName: "parentOptions",
optionId: "id",
optionLabel: "fullPath",
optionList: [],
});
}
return fields;
},
},
watch: {
visible(val) {
if (val) {
this.initForm();
}
},
parentOptions: {
handler(val) {
this.baseData.parentOptions = (val || []).map(item => ({
...item,
fullPath: item.fullPath || item.categoryName,
}));
},
immediate: true,
deep: true,
},
},
methods: {
initForm() {
if (this.isEdit) {
const row = this.categoryData || {};
this.editData = {
id: row.id,
categoryName: row.categoryName || "",
parentId: row.parentId,
};
} else {
this.editData = {
id: "",
categoryName: "",
parentId: this.defaultParentId || "",
};
}
},
async handleConfirm() {
try {
const payload = {
categoryName: (this.editData.categoryName || "").trim(),
};
if (this.isEdit) {
payload.id = this.editData.id;
await updateTagCategory(payload);
this.$message.success("编辑成功");
} else {
payload.parentId = this.editData.parentId || 0;
await createTagCategory(payload);
this.$message.success("新增成功");
}
this.$emit("update:visible", false);
this.$emit("success");
} catch (err) {
// this.$message.error(err.message || "操作失败");
}
},
},
};
</script>
<template>
<div class="category-nav">
<div class="nav-search">
<el-input v-model="keyword"
placeholder="请输入标签名称"
size="small"
clearable
@keyup.enter.native="handleSearch" />
<el-button size="small"
type="primary"
@click="handleSearch">
搜索
</el-button>
</div>
<div class="nav-list">
<div class="nav-item"
:class="{ active: isAllActive }"
@click="selectAll">
全部
</div>
<template v-for="item in displayList">
<div :key="`l1-${item.id}`" class="nav-group">
<div class="nav-item level-1"
:class="{ active: isActive(item) }"
@click="selectCategory(item)">
<span v-if="hasChildren(item)"
class="expand-icon"
@click.stop="toggleExpand(item.id)">
<i :class="expandedMap[item.id] ? 'el-icon-arrow-down' : 'el-icon-arrow-right'" />
</span>
<span class="nav-label">{{ item.categoryName }}</span>
<i v-if="Number(item.canAddChild) === 1"
class="el-icon-plus action-icon"
title="新增标签类别"
@click.stop="$emit('add-child', item)" />
</div>
<template v-if="hasChildren(item) && expandedMap[item.id]">
<div v-for="child in item.children"
:key="child.id"
class="nav-item level-2"
:class="{ active: isActive(child) }"
@click="selectCategory(child)">
<span class="nav-label">{{ child.categoryName }}</span>
<i v-if="Number(child.canEdit) === 1"
class="el-icon-edit action-icon"
title="编辑"
@click.stop="$emit('edit', child)" />
</div>
</template>
</div>
</template>
</div>
</div>
</template>
<script>
export default {
name: "CategoryNav",
props: {
list: {
type: Array,
default: () => [],
},
currentId: {
type: [Number, String],
default: "",
},
},
data() {
return {
keyword: "",
filterKeyword: "",
expandedMap: {},
};
},
computed: {
isAllActive() {
return this.currentId === "" || this.currentId == null;
},
displayList() {
const kw = (this.filterKeyword || "").trim().toLowerCase();
if (!kw) {
return this.list || [];
}
return (this.list || [])
.map((item) => {
const matchParent = (item.categoryName || "").toLowerCase().includes(kw);
const children = (item.children || []).filter(child =>
(child.categoryName || "").toLowerCase().includes(kw),
);
if (matchParent || children.length) {
return {
...item,
children: matchParent ? item.children || [] : children,
};
}
return null;
})
.filter(Boolean);
},
},
watch: {
list: {
handler(val) {
(val || []).forEach((item) => {
if (this.hasChildren(item) && this.expandedMap[item.id] === undefined) {
this.$set(this.expandedMap, item.id, true);
}
});
},
immediate: true,
deep: true,
},
},
methods: {
hasChildren(item) {
return Array.isArray(item.children) && item.children.length > 0;
},
isActive(item) {
return String(this.currentId) === String(item.id);
},
handleSearch() {
this.filterKeyword = this.keyword;
},
selectAll() {
this.$emit("select", { id: "", categoryName: "全部" });
},
selectCategory(item) {
this.$emit("select", item);
},
toggleExpand(id) {
this.$set(this.expandedMap, id, !this.expandedMap[id]);
},
},
};
</script>
<style lang="scss" scoped>
.category-nav {
width: 228px;
height: 100%;
background: #fff;
display: flex;
flex-direction: column;
box-sizing: border-box;
.nav-search {
display: flex;
align-items: center;
padding: 12px 10px;
gap: 8px;
.el-input {
flex: 1;
}
}
.nav-list {
flex: 1;
overflow: auto;
padding: 0 0 12px;
}
.nav-item {
position: relative;
display: flex;
align-items: center;
min-height: 40px;
padding: 0 12px 0 16px;
font-size: 14px;
color: #303133;
cursor: pointer;
transition: background 0.2s;
&:hover {
background: #f5f7fa;
}
&.active {
background: #e6f4ff;
color: #409eff;
border-left: 3px solid #409eff;
padding-left: 13px;
}
&.level-2 {
padding-left: 36px;
&.active {
padding-left: 33px;
}
}
.expand-icon {
width: 16px;
margin-right: 4px;
color: #909399;
flex-shrink: 0;
}
.nav-label {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.action-icon {
flex-shrink: 0;
margin-left: 8px;
font-size: 14px;
color: #909399;
&:hover {
color: #409eff;
}
}
}
}
</style>
<template>
<glsk-form-dialog
v-if="visible"
:selectVisible="visible"
:dialogConfig="dialogConfig"
label-width="120px"
dialog-width="520px"
defaultWidth="320px"
:formRules="formRules"
:editData="editData"
:editFormData="editFormData"
:baseData="baseData"
@handleClose="$emit('update:visible', false)"
@handleConfirm="handleConfirm"
/>
</template>
<script>
import {
createTagDimension,
updateTagDimension,
queryTagDimensionDetail,
} from "@api/tagManagement";
export default {
name: "DimensionFormDialog",
props: {
visible: {
type: Boolean,
default: false,
},
mode: {
type: String,
default: "add",
},
dimensionData: {
type: Object,
default: () => ({}),
},
categoryOptions: {
type: Array,
default: () => [],
},
defaultCategoryId: {
type: [Number, String],
default: "",
},
},
data() {
return {
editData: {
id: "",
dimensionName: "",
categoryId: "",
},
baseData: {
categoryOptions: [],
},
formRules: {
dimensionName: [
{ required: true, message: "请输入标签维度", trigger: "blur" },
{ max: 20, message: "标签维度不能超过20个字符", trigger: "blur" },
],
categoryId: [
{ required: true, message: "请选择所属标签类别", trigger: "change" },
],
},
};
},
computed: {
isEdit() {
return this.mode === "edit";
},
nameReadonly() {
return this.isEdit && Number(this.dimensionData.canEdit) === 0;
},
categoryReadonly() {
return this.isEdit;
},
dialogConfig() {
return {
title: this.isEdit ? "编辑标签维度" : "新增标签维度",
okText: "保存",
};
},
editFormData() {
return [
{
label: "所属标签类别",
name: "categoryId",
type: "select",
placeholder: "请选择所属标签类别",
filterable: true,
optionsName: "categoryOptions",
optionId: "value",
optionLabel: "fullPath",
optionList: [],
disabled: this.categoryReadonly,
isDisabled: this.categoryReadonly,
},
{
label: "标签维度",
name: "dimensionName",
type: "input",
placeholder: "请输入标签维度",
maxlength: 20,
isClear: true,
disabled: this.nameReadonly,
isDisabled: this.nameReadonly,
},
];
},
},
watch: {
visible(val) {
if (val) {
this.initForm();
}
},
categoryOptions: {
handler(val) {
this.baseData.categoryOptions = val || [];
},
immediate: true,
deep: true,
},
},
methods: {
async initForm() {
if (this.isEdit) {
try {
const detail = await queryTagDimensionDetail({
categoryId: this.dimensionData.id,
});
this.editData = {
id: detail.id,
dimensionName: detail.dimensionName || "",
categoryId: detail.categoryId,
};
} catch (err) {
this.$message.error(err.message || "获取维度详情失败");
const row = this.dimensionData || {};
this.editData = {
id: row.id,
dimensionName: row.dimensionName || "",
categoryId: row.categoryId,
};
}
} else {
this.editData = {
id: "",
dimensionName: "",
categoryId: this.defaultCategoryId || "",
};
}
},
async handleConfirm() {
if (this.isEdit && Number(this.dimensionData.canEdit) === 0) {
this.$message.warning("该维度不可编辑");
return;
}
try {
if (this.isEdit) {
const payload = { id: this.editData.id };
if (!this.nameReadonly) {
payload.dimensionName = (this.editData.dimensionName || "").trim();
}
await updateTagDimension(payload);
this.$message.success("编辑成功");
} else {
await createTagDimension({
categoryId: this.editData.categoryId,
dimensionName: (this.editData.dimensionName || "").trim(),
});
this.$message.success("新增成功");
}
this.$emit("update:visible", false);
this.$emit("success");
} catch (err) {
this.$message.error(err.message || "操作失败");
}
},
},
};
</script>
<template>
<div class="enum-form-dialog">
<glsk-form-dialog
v-if="visible"
:selectVisible="visible"
:dialogConfig="dialogConfig"
label-width="130px"
dialog-width="520px"
defaultWidth="320px"
:formRules="formRules"
:editData="editData"
:editFormData="editFormData"
@handleClose="$emit('update:visible', false)"
@handleConfirm="handleConfirm"
/>
</div>
</template>
<script>
import {
createTagEnum,
pageTagEnum,
updateTagEnum,
} from "@api/tagManagement";
export default {
name: "EnumFormDialog",
props: {
visible: {
type: Boolean,
default: false,
},
mode: {
type: String,
default: "add",
},
enumData: {
type: Object,
default: () => ({}),
},
dimensionData: {
type: Object,
default: () => ({}),
},
},
data() {
return {
editData: {
id: "",
dimensionId: "",
enumName: "",
score: "",
remark: "",
},
existingEnumList: [],
};
},
computed: {
isEdit() {
return this.mode === "edit";
},
enumNameReadonly() {
return this.isEdit && Number(this.enumData.enumNameCanEdit) === 0;
},
scoreReadonly() {
return this.isEdit && Number(this.enumData.scoreCanEdit) === 0;
},
dialogConfig() {
return {
title: this.isEdit ? "编辑枚举值" : "新增枚举值",
okText: "确定",
};
},
formRules() {
return {
enumName: [
{ validator: this.validateEnumNameRule, trigger: ["blur", "change"] },
],
score: [
{ validator: this.validateScoreRule, trigger: ["blur", "change"] },
],
};
},
editFormData() {
return [
{
label: "标签枚举值名称",
name: "enumName",
type: "input",
placeholder: "请输入",
maxlength: 20,
showLimit: true,
isClear: true,
disabled: this.enumNameReadonly,
isDisabled: this.enumNameReadonly,
},
{
label: "命中客户分",
name: "score",
type: "input",
placeholder: "请输入0~100的整数",
maxlength: 3,
isClear: true,
disabled: this.scoreReadonly,
isDisabled: this.scoreReadonly,
inputFn: this.handleScoreInput,
},
{
label: "枚举值描述",
name: "remark",
type: "textarea",
placeholder: "请输入",
maxlength: 500,
showLimit: true,
rows: 4,
isClear: true,
},
];
},
},
watch: {
visible(val) {
if (val) {
this.initForm();
}
},
},
methods: {
async initForm() {
if (this.isEdit) {
const row = this.enumData || {};
this.editData = {
id: row.id,
dimensionId: row.dimensionId,
enumName: row.enumName || "",
score: row.score != null && row.score !== "" ? String(row.score) : "",
remark: row.remark || "",
};
} else {
const dim = this.dimensionData || {};
this.editData = {
id: "",
dimensionId: dim.id,
enumName: "",
score: "",
remark: "",
};
}
await this.loadExistingEnumList();
},
async loadExistingEnumList() {
const dimensionId = this.editData.dimensionId;
if (!dimensionId) {
this.existingEnumList = [];
return;
}
try {
const res = await pageTagEnum({
dimensionId,
pageNum: 1,
pageSize: 9999,
});
this.existingEnumList = res?.list || [];
} catch (err) {
this.existingEnumList = [];
}
},
handleScoreInput(val) {
if (this.scoreReadonly) {
return;
}
const digits = String(val || "").replace(/\D/g, "");
if (!digits) {
this.editData.score = "";
return;
}
let num = Number.parseInt(digits, 10);
if (num > 100) {
num = 100;
}
this.editData.score = String(num);
},
validateEnumNameRule(rule, value, callback) {
if (this.enumNameReadonly) {
callback();
return;
}
const name = (value || "").trim();
if (!name) {
callback(new Error("请输入标签枚举值名称"));
return;
}
if (name.length > 20) {
callback(new Error("标签枚举值名称不能超过20个字符"));
return;
}
const isDuplicate = this.existingEnumList.some((item) => {
const itemName = (item.enumName || "").trim();
if (itemName !== name) {
return false;
}
if (this.isEdit && item.id === this.editData.id) {
return false;
}
return true;
});
if (isDuplicate) {
callback(new Error("同一维度下枚举值名称不可重复"));
return;
}
callback();
},
validateScoreRule(rule, value, callback) {
if (this.scoreReadonly) {
callback();
return;
}
if (value === "" || value == null) {
callback(new Error("请输入命中客户分"));
return;
}
const num = Number(value);
if (!Number.isInteger(num) || num < 0 || num > 100) {
callback(new Error("命中客户分须为0~100的整数"));
return;
}
callback();
},
async handleConfirm() {
try {
const payload = {
remark: this.editData.remark || undefined,
};
if (this.isEdit) {
payload.id = this.editData.id;
if (!this.enumNameReadonly) {
payload.enumName = (this.editData.enumName || "").trim();
}
if (!this.scoreReadonly && this.editData.score !== "") {
payload.score = Number(this.editData.score);
}
await updateTagEnum(payload);
this.$message.success("编辑成功");
} else {
payload.dimensionId = this.editData.dimensionId;
payload.enumName = (this.editData.enumName || "").trim();
payload.score = Number(this.editData.score);
await createTagEnum(payload);
this.$message.success("新增成功");
}
this.$emit("update:visible", false);
this.$emit("success");
} catch (err) {
this.$message.error(err.message || "操作失败");
}
},
},
};
</script>
<style lang="scss" scoped>
.enum-form-dialog {
::v-deep .el-textarea .el-input__count {
right: 10px !important;
bottom: 5px !important;
}
}
</style>
<template>
<d2-container v-loading="pageLoading" class="tag-enum-maintain-page">
<div class="page-breadcrumb">
<template v-for="(seg, index) in breadcrumbSegments">
<span v-if="index > 0"
:key="`sep-${index}`"
class="sep">
/
</span>
<span :key="`seg-${index}`" class="crumb-text">{{ seg }}</span>
</template>
</div>
<div class="d2-container-content">
<d2-table-header :left-span="0">
<el-button size="small"
type="primary"
@click="handleAddEnum">
新增枚举值
</el-button>
</d2-table-header>
<d2-table ref="enumTable"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="searchForm"
:table-params="tableParams">
<template #auth-button="scope">
<el-button v-if="canShowEnumEdit(scope.scope)"
size="mini"
type="text"
@click="handleEditEnum(scope.scope)">
编辑
</el-button>
</template>
</d2-table>
</div>
<EnumFormDialog :dimension-data="dimensionDetail"
:enum-data="currentEnum"
:mode="enumFormMode"
:visible.sync="enumFormVisible"
@success="handleEnumFormSuccess" />
</d2-container>
</template>
<script>
import {
pageTagEnum,
queryTagDimensionDetail,
} from "@api/tagManagement";
import EnumFormDialog from "../components/EnumFormDialog.vue";
export default {
name: "TagEnumMaintain",
components: { EnumFormDialog },
data() {
return {
pageLoading: false,
dimensionId: "",
dimensionDetail: {},
searchForm: {},
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: true,
tableColumns: [
{ label: "枚举值", prop: "enumName", minWidth: 200 },
{ label: "命中客户分", prop: "score", width: 120 },
],
},
enumFormVisible: false,
enumFormMode: "add",
currentEnum: {},
};
},
computed: {
breadcrumbSegments() {
const segments = ["标签管理"];
const path = (this.dimensionDetail.categoryFullPath || "").trim();
if (path) {
path.split("/").forEach((part) => {
const text = (part || "").trim();
if (text)
segments.push(text);
});
}
const dimName = (this.dimensionDetail.dimensionName || "").trim();
if (dimName) {
segments.push(dimName);
}
return segments;
},
},
created() {
this.dimensionId = this.$route.query.dimensionId;
if (!this.dimensionId) {
this.$message.warning("缺少维度参数");
this.$router.back();
return;
}
this.loadDimensionDetail();
},
methods: {
beforeSearchFn() {
return Promise.resolve();
},
getListApi(params) {
return pageTagEnum({
dimensionId: this.dimensionId,
pageNum: params.currentPage || 1,
pageSize: params.pageSize || 10,
});
},
async loadDimensionDetail() {
this.pageLoading = true;
try {
const detail = await queryTagDimensionDetail({
categoryId: this.dimensionId,
});
this.dimensionDetail = detail || {};
} catch (err) {
this.$message.error(err.message || "加载维度信息失败");
this.$router.back();
} finally {
this.pageLoading = false;
}
},
refreshTable() {
if (this.$refs.enumTable) {
this.$refs.enumTable.refreshTable();
}
},
canShowEnumEdit(row) {
if (!row) {
return false;
}
if (Number(row.canEdit) === 0) {
return false;
}
const hasFlags = (row.canEdit != null && row.canEdit !== "")
|| (row.enumNameCanEdit != null && row.enumNameCanEdit !== "")
|| (row.scoreCanEdit != null && row.scoreCanEdit !== "");
if (!hasFlags) {
return true;
}
if (row.canEdit != null && row.canEdit !== "") {
return Number(row.canEdit) === 1;
}
return (
Number(row.enumNameCanEdit) === 1
|| Number(row.scoreCanEdit) === 1
);
},
handleAddEnum() {
this.enumFormMode = "add";
this.currentEnum = {};
this.enumFormVisible = true;
},
handleEditEnum(row) {
if (!this.canShowEnumEdit(row)) {
this.$message.warning("该枚举值不可编辑");
return;
}
this.enumFormMode = "edit";
this.currentEnum = { ...row };
this.enumFormVisible = true;
},
handleEnumFormSuccess() {
this.refreshTable();
},
},
};
</script>
<style lang="scss" scoped>
.tag-enum-maintain-page {
.page-breadcrumb {
padding: 16px 20px 0;
font-size: 14px;
color: #606266;
line-height: 22px;
.sep {
margin: 0 8px;
color: #c0c4cc;
}
.crumb-text:last-child {
color: #303133;
}
}
.d2-container-content {
padding: 16px 20px;
}
}
</style>
<template>
<d2-container class="tag-management-page">
<div class="tag-management-layout">
<div v-loading="treeLoading" class="left-pane">
<CategoryNav :current-id="selectedCategoryId"
:list="categoryTree"
@add-child="handleTreeAddChild"
@edit="handleEditCategory"
@select="handleCategorySelect" />
</div>
<div class="main-pane">
<div class="search-card">
<d2-search ref="showSearch"
class="show-search"
label-width="90px"
:form-data="showFormData"
:search-form="searchForm" />
<div class="up-btns">
<el-button :id="tableParams.btnId"
size="small"
type="primary">
查询
</el-button>
<el-button size="small" @click="handleReset">
重置
</el-button>
</div>
</div>
<div class="table-card">
<d2-table-header :left-span="0">
<auth-button category="Button" :show-btn-ids="['9230102']" />
</d2-table-header>
<d2-table ref="dimensionTable"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="searchForm"
:table-params="tableParams">
<template #enumTags="scope">
<div class="enum-tags-cell">
<template v-if="scope.scope.enums && scope.scope.enums.length">
<el-tag v-for="item in scope.scope.enums"
:key="item.id || item.enumName"
class="enum-tag"
size="small">
{{ item.enumName }}
</el-tag>
</template>
<span v-else>-</span>
</div>
</template>
<template #auth-button="scope">
<span v-if="Number(scope.scope.canEdit) === 1" class="op-btn">
<auth-button :data="scope.scope" :show-btn-ids="['9230105']" />
</span>
<span class="op-btn">
<auth-button :data="scope.scope"
:show-btn-ids="['9230108']" />
</span>
</template>
</d2-table>
</div>
</div>
</div>
<CategoryFormDialog :category-data="currentCategory"
:default-parent-id="defaultParentId"
:mode="categoryDialogMode"
:parent-options="categoryLeafOptions"
:visible.sync="categoryDialogVisible"
@success="handleCategorySuccess" />
<DimensionFormDialog :category-options="dimensionCategoryOptions"
:default-category-id="selectedCategoryId"
:dimension-data="currentDimension"
:mode="dimensionDialogMode"
:visible.sync="dimensionDialogVisible"
@success="handleDimensionSuccess" />
</d2-container>
</template>
<script>
import {
queryTagCategoryLeafList,
queryTagCategoryTree,
queryTagDimension,
queryTagDimensionCategoryOptions,
} from "@api/tagManagement";
import CategoryFormDialog from "./components/CategoryFormDialog.vue";
import CategoryNav from "./components/CategoryNav.vue";
import DimensionFormDialog from "./components/DimensionFormDialog.vue";
export default {
name: "TagManagement",
components: {
CategoryNav,
CategoryFormDialog,
DimensionFormDialog,
},
data() {
return {
treeLoading: false,
categoryTree: [],
categoryLeafOptions: [],
dimensionCategoryOptions: [],
selectedCategoryId: "",
selectedCategory: null,
searchForm: {
dimensionName: "",
enumName: "",
},
showFormData: [
{
label: "标签维度",
name: "dimensionName",
type: "input",
placeholder: "请输入标签维度",
maxlength: 20,
isClear: true,
},
{
label: "枚举值",
name: "enumName",
type: "input",
placeholder: "请输入枚举值",
maxlength: 20,
isClear: true,
},
],
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: true,
tableColumns: [
{ label: "所属类别", prop: "categoryFullPath", minWidth: 140 },
{ label: "标签维度", prop: "dimensionName", minWidth: 120 },
{ label: "枚举值", addHtml: "enumTags", minWidth: 280 },
],
},
categoryDialogVisible: false,
categoryDialogMode: "add",
currentCategory: {},
defaultParentId: "",
dimensionDialogVisible: false,
dimensionDialogMode: "add",
currentDimension: {},
};
},
created() {
this.loadCategoryTree();
this.loadCategoryLeafOptions();
this.loadDimensionCategoryOptions();
},
methods: {
beforeSearchFn() {
return Promise.resolve();
},
getListApi(params) {
const payload = {
dimensionName: (params.dimensionName || "").trim() || undefined,
enumName: (params.enumName || "").trim() || undefined,
pageNum: params.currentPage || 1,
pageSize: params.pageSize || 10,
};
if (this.selectedCategoryId !== "" && this.selectedCategoryId != null) {
payload.categoryId = this.selectedCategoryId;
}
return queryTagDimension(payload);
},
async loadCategoryTree() {
this.treeLoading = true;
try {
const res = await queryTagCategoryTree();
this.categoryTree = res || [];
} catch (err) {
this.$message.error(err.message || "加载分类树失败");
} finally {
this.treeLoading = false;
}
},
async loadCategoryLeafOptions() {
try {
const res = await queryTagCategoryLeafList();
this.categoryLeafOptions = res || [];
} catch (err) {
this.$message.error(err.message || "加载可新增子级分类失败");
}
},
async loadDimensionCategoryOptions() {
try {
const res = await queryTagDimensionCategoryOptions();
this.dimensionCategoryOptions = res || [];
} catch (err) {
this.$message.error(err.message || "加载维度分类选项失败");
}
},
handleCategorySelect(data) {
this.selectedCategory = data;
this.selectedCategoryId = data.id === "" || data.id == null ? "" : data.id;
if (this.$refs.dimensionTable) {
this.$refs.dimensionTable.refreshTable(false, true);
}
},
handleReset() {
this.searchForm = {
dimensionName: "",
enumName: "",
};
if (this.$refs.dimensionTable) {
this.$refs.dimensionTable.refreshTable(false, true);
}
},
refreshTable() {
if (this.$refs.dimensionTable) {
this.$refs.dimensionTable.refreshTable();
}
},
handleAddCategory() {
this.categoryDialogMode = "add";
this.currentCategory = {};
this.defaultParentId
= this.selectedCategory && Number(this.selectedCategory.canAddChild) === 1
? this.selectedCategory.id
: "";
this.categoryDialogVisible = true;
},
handleTreeAddChild(data) {
this.categoryDialogMode = "add";
this.currentCategory = {};
this.defaultParentId = data.id;
this.categoryDialogVisible = true;
},
handleEditCategory(data) {
if (Number(data.canEdit) !== 1) {
this.$message.warning("该分类不可编辑");
return;
}
this.categoryDialogMode = "edit";
this.currentCategory = { ...data };
this.categoryDialogVisible = true;
},
handleAddDimension() {
this.dimensionDialogMode = "add";
this.currentDimension = {};
this.dimensionDialogVisible = true;
},
handleEditDimension(row) {
if (Number(row.canEdit) !== 1) {
this.$message.warning("该维度不可编辑");
return;
}
this.dimensionDialogMode = "edit";
this.currentDimension = { ...row };
this.dimensionDialogVisible = true;
},
handleMaintainEnum(row) {
this.$router.push({
name: "tagEnumMaintain",
query: { dimensionId: row.id },
});
},
handleCategorySuccess() {
this.loadCategoryTree();
this.loadCategoryLeafOptions();
this.loadDimensionCategoryOptions();
},
handleDimensionSuccess() {
this.refreshTable();
this.loadCategoryTree();
this.loadDimensionCategoryOptions();
},
},
};
</script>
<style lang="scss" scoped>
.tag-management-page {
::v-deep .d2-container-full__body {
padding: 0 !important;
}
}
.tag-management-layout {
display: flex;
height: calc(100vh - 160px);
min-height: 500px;
background: #f5f7fa;
.left-pane {
flex-shrink: 0;
height: 100%;
}
.main-pane {
flex: 1;
overflow: auto;
padding: 12px;
background: transparent;
.search-card {
background: #fff;
padding: 16px 20px 12px;
margin-bottom: 12px;
border-radius: 4px;
.up-btns {
margin-top: 8px;
}
}
.table-card {
background: #fff;
padding: 16px 20px;
border-radius: 4px;
::v-deep .table-header {
margin-bottom: 12px;
}
}
}
}
.enum-tags-cell {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: flex-start;
gap: 4px;
max-width: 100%;
padding: 4px 20px;
.enum-tag {
height: auto;
white-space: normal;
word-break: break-all;
background: #e6f4ff;
border-color: #b3d8ff;
color: #409eff;
vertical-align: middle;
}
}
.op-btn {
margin-right: 8px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!