lightChange.vue
12.2 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<!-- 短课程 - 轻改业务(表格与逻辑与延保业务对齐,仅业务类型筛选不同) -->
<template>
<div>
<d2-table ref="lightTable"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="searchFormSearch"
:table-params="tableParams">
<template #merchantName="scope">
<div>
<template v-if="
scope.scope.merchantName
&& scope.scope.merchantName.split(',').length > 1
">
<span>
{{
scope.scope.merchantName.split(",").slice(0, 1).join("")
}}
</span>
<el-popover placement="top"
trigger="hover"
width="fit-content">
<div :class="{
serverHeight: scope.scope.merchantName.split(',').length >= 10,
}">
<div v-for="(item, index) in scope.scope.merchantName.split(',')"
:key="index">
{{ item }}
</div>
</div>
<template #reference>
<span class="more-info">
...({{ scope.scope.merchantName.split(",").length }})
</span>
</template>
</el-popover>
</template>
<template v-else>
<span>
{{
scope.scope.merchantName ? scope.scope.merchantName : "--"
}}
</span>
</template>
</div>
</template>
<template #tagNamesHtml="scope">
<div>
<template v-if="scope.scope.tagNames">
<el-tooltip :content="scope.scope.tagNames"
placement="top"
effect="dark">
<span class="two-line-ellipsis">
{{ scope.scope.tagNames }}
</span>
</el-tooltip>
</template>
<template v-else>
<span>-</span>
</template>
</div>
</template>
<template #taskStatusHtml="scope">
<div class="taskStatus">
<div class="spot"
:class="[
scope.scope.taskStatus === 0 ? 'orgenSpot' : 'ashSpot',
]">
</div>
<!-- 完成状态,0-进行中,1-已结束 -->
<div>{{ ["进行中", "已结束"][scope.scope.taskStatus] }}</div>
<div v-if="scope.scope.taskStatus === 0">
({{
scope.scope.progress
}}%)
</div>
</div>
</template>
<template #penalty="scope">
<div>
<!-- 是否启用处罚 0-否 1-是 -->
<el-switch active-value="1"
inactive-value="0"
:value="penaltySwitchValue(scope.scope)"
:disabled="!canModifyPenaltySwitch(scope.scope)"
@change="handlePenalty(scope.scope)">
</el-switch>
</div>
</template>
<template #auth-button="scope">
<div>
<span style="margin-right: 10px">
<el-button size="small"
type="text"
@click="handleDetail(scope.scope)">
查看
</el-button>
</span>
</div>
</template>
</d2-table>
<ShortLightDetail v-if="detailVisible"
:short-info="shortInfo"
:short-visible.sync="detailVisible"
@dialogClose="closeDetailDialog" />
</div>
</template>
<script>
import { getLightChangePage, switchLightChange } from "@api/serviceCentre";
import dayjs from "dayjs";
import { mapActions, mapState } from "vuex";
import {
punishStatusOpt,
punishTypeOpt,
taskStatusOpt,
} from "@/common/constants.js";
import { deepClone, Util } from "@/common/util";
import shortLightDetail from "./components/shortLightDetail.vue";
export default {
name: "ShortCourseLightChange",
components: {
ShortLightDetail: shortLightDetail,
},
props: {
filterForm: {
type: Object,
required: true,
},
},
data() {
return {
shortInfo: {},
searchFormSearch: {},
getListApi: getLightChangePage,
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: { width: "150px" },
tableColumns: [
{
label: "员工姓名",
prop: "staffName",
width: "150",
},
{
label: "手机号码",
prop: "staffPhone",
width: "150",
},
{
label: "门店名称",
addHtml: "merchantName",
width: "150",
},
// {
// label: "归属业务",
// prop: "businessSceneTypeName",
// width: "120px",
// },
{
label: "战败客户明细",
prop: "defeatCustomerNames",
width: "200px",
formatter: (row) => {
const raw = row.defeatCustomerNames;
if (raw == null || raw === "") {
return "-";
}
const names = String(raw)
.split(",")
.map(s => s.trim())
.filter(Boolean);
if (names.length === 0) {
return "-";
}
if (names.length === 1) {
return names[0];
}
return `${names[0]}等${names.length}人`;
},
},
// {
// label: "能力短板维度",
// prop: "tagNames",
// width: "200px",
// },
{
label: "能力短板维度",
prop: "tagNames",
addHtml: "tagNamesHtml",
width: "300",
},
{
label: "复盘日期",
prop: "checkDate",
width: "150",
},
// {
// label: "战败数量",
// prop: "recordingInfoCount",
// width: "120",
// },
{
label: "完成情况",
prop: "taskStatus",
addHtml: "taskStatusHtml",
width: "120px",
},
{
label: "完成时间",
prop: "completeTime",
width: "150",
formatter: (cellValue) => {
return cellValue.completeTime
? Util.dateFormate(
cellValue.completeTime,
"YYYY-MM-DD HH:mm:ss",
)
: "-";
},
},
{
label: "处罚方式",
prop: "punishType",
width: "100px",
formatter: (cellValue) => {
// 惩罚方式 0-无惩罚 1-限制录单
return (
this.baseData.punishTypeOpt.find(
item => item.confId === cellValue.punishType,
)?.confValue || "-"
);
},
},
{
label: "处罚状态",
prop: "punishStatus",
width: "120px",
formatter: (cellValue) => {
// 惩罚状态 1-未触发 2-处罚中 3-已结束 4-已解除
return this.baseData.punishStatusOpt.find(
item => item.confId === cellValue.punishStatus,
)?.confValue;
},
className: (cellValue) => {
return {
1: "orgenSpot",
2: "redSpot",
3: "ashSpot",
4: "ashSpot",
}[cellValue.punishStatus];
},
},
{
label: "处罚启停",
prop: "penalty",
addHtml: "penalty",
},
],
},
baseData: {
punishTypeOpt: deepClone(punishTypeOpt),
taskStatusOpt: deepClone(taskStatusOpt),
punishStatusOpt: deepClone(punishStatusOpt),
businessSceneTypeNameOpt: [
{ confId: "轻改", confValue: "轻改" },
{ confId: "延保", confValue: "延保" },
{ confId: "权益", confValue: "权益" },
],
},
detailVisible: false,
};
},
computed: {
...mapState({
dowloadList: state => state.d2admin.user.dowloadList,
}),
},
methods: {
...mapActions("d2admin/user", ["actionSetDownloadList"]),
refreshTable(first = true, second = true) {
this.$refs.lightTable
&& this.$refs.lightTable.refreshTable(first, second);
},
// taskStatus = 1 && completeTime 为空 && punishType = 1 满足三个条件方可修改处罚开关;否则开关展示为 0
canModifyPenaltySwitch(row) {
const taskStatusOk = Number(row?.taskStatus) === 1;
const completeTimeEmpty
= row?.completeTime === null
|| row?.completeTime === undefined
|| row?.completeTime === "";
const punishTypeOk = Number(row?.punishType) === 1;
return taskStatusOk && completeTimeEmpty && punishTypeOk;
},
penaltySwitchValue(row) {
if (this.canModifyPenaltySwitch(row)) {
return String(row?.punishFlag ?? 0);
}
return "0";
},
handlePenalty(row) {
if (!this.canModifyPenaltySwitch(row)) {
this.$message.warning("当前任务不允许修改处罚开关");
return;
}
const { id, punishFlag } = row;
const punishFlagTemp = punishFlag === 1 ? 0 : 1;
switchLightChange({
id,
punishFlag: punishFlagTemp,
}).then(() => {
this.notice.okTips();
// 处罚开关切换后仅刷新当前页数据,不重置分页到第一页
this.refreshTable(false, false);
});
},
async handleExport() {
try {
const params = await this.beforeSearchFn(2); // type = 2 表示导出 获取导出传参
params.currentPage = 1;
params.method = "dj.api.smartcarlife.servicecenter.short.course.task.page.export";
const list = [
...this.dowloadList,
{
name: "短课程配置",
exportParam: JSON.stringify(params),
status: "waiting",
timeid: new Date().getTime(),
},
];
this.actionSetDownloadList({ list, type: "dowloadList" });
} catch (err) {
console.log(err);
}
},
beforeSearchFn(type = 1) {
return new Promise((resolve, reject) => {
this.searchFormSearch = deepClone(this.filterForm);
// this.searchFormSearch.businessSceneTypeName = "轻改";
if (this.searchFormSearch.checkTime.length) {
this.searchFormSearch.checkStartTime
= Util.dateFormate(this.searchFormSearch.checkTime[0], "YYYY-MM-DD")
+ " 00:00:00";
this.searchFormSearch.checkEndTime
= Util.dateFormate(this.searchFormSearch.checkTime[1], "YYYY-MM-DD")
+ " 23:59:59";
const date1 = dayjs(this.searchFormSearch.checkStartTime);
const date2 = dayjs(this.searchFormSearch.checkEndTime);
const day = date2.diff(date1, "day") + 1;
if (day > 31) {
this.$message.error(
`${
type === 1 ? "查询" : "导出"
}的时间跨度最大为31天,请重新选择日期范围`,
);
reject(new Error("date_range_too_large"));
return;
}
}
if (this.searchFormSearch.finishTime.length) {
this.searchFormSearch.finishStartTime = Util.dateFormate(
this.searchFormSearch.finishTime[0],
"YYYY-MM-DD HH:mm:ss",
);
this.searchFormSearch.finishEndTime
= Util.dateFormate(
this.searchFormSearch.finishTime[1],
"YYYY-MM-DD",
) + " 23:59:59";
}
delete this.searchFormSearch.finishTime;
delete this.searchFormSearch.checkTime;
resolve(this.searchFormSearch);
});
},
handleDetail(row) {
this.shortInfo = row;
this.detailVisible = true;
},
closeDetailDialog() {
this.detailVisible = false;
},
},
};
</script>
<style lang="scss" scoped>
.taskStatus {
display: flex;
align-items: center;
justify-content: center;
}
.two-line-ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: normal;
}
</style>