index.vue
3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<template>
<d2-container v-loading="pageLoading" class="customer-group-rel-page">
<div class="page-content">
<CustomerBasicInfoCard :basic-info="groupData.basicInfo"
:customer-row="customerRow" />
<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 size="medium"
type="primary"
@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>