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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<template>
<div class="customer-follow">
<el-dialog append-to-body :title="$t('客户跟进')" :visible.sync="customerFollow.dialogVisible" :before-close="customerFollowClose" width="1200px">
<el-form class="custom-form-1" ref="customerFollowForm" :model="form" label-width="120px">
<el-row :gutter="10">
<el-col :span="8">
<el-form-item :label="$t('编号')" prop="number">
<el-input v-model="form.number" :placeholder="$t('请输入编号')" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('跟进状态')">
<el-select v-model="form.status" :placeholder="$t('请选择')" disabled>
<el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('客户编号')">
<el-input v-model="form.customerNumber" :placeholder="$t('请输入客户编号')" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('跟进类型')" required>
<el-select v-model="form.followType" clearable :placeholder="$t('请选择')" @change="handleFollowType" :disabled="isView || !!offerId">
<el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_TYPE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" v-if="form.followType == 2">
<el-form-item :label="$t('报价单')" required prop="offerId">
<el-input :value="form.offerNumber" readonly>
<el-button slot="append" icon="el-icon-search" @click="CustomerFollowSelectOffer = true" v-if="!(isView || offerId)"></el-button>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('跟进时间')" required>
<el-date-picker v-model="form.followTime" clearable type="datetime" :placeholder="$t('请选择')" :disabled="isView" />
</el-form-item>
</el-col>
<el-col :span="8" v-if="customerId">
<el-form-item :label="$t('联系人')" required>
<el-select v-model="form.contactId" clearable :placeholder="$t('请选择')" :disabled="isView" @change="changeContactUser">
<el-option v-for="(item, index) in customerContactsList" :key="index" :label="item.name" :value="item.id"> </el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" v-else>
<el-form-item :label="$t('联系人')" required>
<div class="contact">
<el-input v-model="form.contactName" :value="form.customerContactsId" placeholder="" disabled />
<img src="@/assets/svg/contacts.svg" class="phonebook" @click="ChooseContactDialog = true" />
</div>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('联系方式')">
<el-input v-model="form.contactPhone" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('客户经理')" required>
<el-select v-model="form.followUserId" clearable :placeholder="$t('请选择')" :disabled="isView">
<el-option v-for="item in serviceUserList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('跟进方式')" required>
<dict-selector ref="dictMethod" v-model="form.followMethod" clearable :disabled="isView" :type="DICT_TYPE.CUSTOMER_FOLLOWUP_METHOD"></dict-selector>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('上一级跟进单')" prop="parentNumber">
<el-input v-model="form.parentNumber" :placeholder="$t('请输入上一级跟进单')" disabled />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('跟进结果')" prop="followMethod">
<el-select v-model="form.resultType" clearable :placeholder="$t('请选择')" :disabled="isView">
<el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_RESULT_TYPE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :label="$t('目的')" prop="purpose">
<el-input type="textarea" :rows="3" v-model="form.purpose" :placeholder="$t('请输入目的')" maxlength="200" show-word-limit :disabled="isView" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :label="$t('跟进情况')">
<el-input rows="3" class="text_style" type="textarea" v-model="form.feedback" maxlength="500" show-word-limit :disabled="isView" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :label="$t('附件')" prop="attatchment">
<FileUpload :limit="5" :isShowTip="true" v-model="form.attatchment" :fileType="fileType" :disabled="isView" />
</el-form-item>
</el-col>
<el-col :span="13">
<el-form-item :label="$t('下次跟进时间')">
<el-date-picker v-model="form.nextTime" type="datetime" :placeholder="$t('请选择')" :disabled="isView" @change="changeNextTime"> </el-date-picker>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :label="$t('下一步计划')" prop="nextPlan">
<el-input type="textarea" :rows="3" v-model="form.nextPlan" :placeholder="$t('请输入下一步计划')" maxlength="500" show-word-limit :disabled="isView" />
</el-form-item>
</el-col>
<el-col :span="24" v-if="isView">
<el-form-item>
<div style="text-align: right">
<!-- <el-button size="mini" icon="el-icon-collection" type="primary" @click="$emit('handleCustomerFollowAdd', form)" v-has-permi="['ecw:customer:follow-add-plan']">{{ $t("增加计划") }} </el-button>-->
<el-button size="mini" type="text" icon="el-icon-collection" @click="handleUpdate(form, true)" v-has-permi="['ecw:customer:follow-add-plan']">{{ $t("增加计划") }} </el-button>
</div>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('创建人')" prop="founder">
<el-select v-model="form.creatorName" disabled :placeholder="$t('请选择')">
<el-option v-for="item in allSimplList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('创建时间')" prop="createTime">
<el-date-picker v-model="form.createTime" type="datetime" disabled :placeholder="$t('请选择')"> </el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('最后更新人')">
<el-select v-model="form.updaterName" disabled>
<el-option v-for="item in allSimplList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('最后更新时间')">
<el-date-picker v-model="form.updateTime" type="datetime" disabled :placeholder="$t('请选择')"> </el-date-picker>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" v-if="isView">
<el-button type="warning" @click="customerFollowClose">{{ $t("关 闭") }}</el-button>
</div>
<div slot="footer" class="dialog-footer" v-else>
<el-button type="warning" @click="goBack">{{ $t("返 回") }}</el-button>
<el-button type="primary" @click="customerFollowSubmit(0)">{{ $t("保 存") }}</el-button>
<el-button type="success" @click="customerFollowSubmit(1)">{{ $t("提交结果") }}</el-button>
</div>
</el-dialog>
<choose-contact-dialog v-if="ChooseContactDialog" :type="2" @choose="changeAllContactUser" @close="ChooseContactDialog = false" />
<CustomerFollowSelectOffer v-if="CustomerFollowSelectOffer" :customer-id="customerId" ref="customerFollowSelectOffer" @select="selectOffer" @close="CustomerFollowSelectOffer = false" />
</div>
</template>
<style lang="scss" scoped>
.contact {
display: flex;
align-items: center;
justify-content: center;
img.phonebook {
width: 30px;
height: 30px;
margin-left: 10px;
cursor: pointer;
}
}
</style>
<script>
import { createCustomerFollow, getCustomerFollowPage, getCustomerFollowPage2, addCustomerFollow, getCustomerFollowList, editCustomerFollow, getFollowupNewNumber } from "@/api/ecw/customerFollow"
import { getCustomerContactsSelect } from "@/api/ecw/customerContacts"
import { getOfferPage, getOfferNumber } from "@/api/ecw/offer"
import { DICT_TYPE, getDictDataLabel } from "@/utils/dict"
import { getCustomerContactsListByCustomer } from "@/api/ecw/customerContacts"
import { listAllSimpl, listServiceUser, listSimpleUsers } from "@/api/system/user"
import { parseTime } from "@/utils/ruoyi"
import FileUpload from "@/components/FileUpload/fileUpload"
import { formatDate } from "@/utils/index"
import ChooseContactDialog from "@/components/ChooseContactDialog"
import CustomerFollowSelectOffer from "./customerFollowSelectOffer"
export default {
/**
* 客户跟进
* 客户投诉跟进
*/
name: "CustomerFollow",
props: {
/**
* 如果是客户投诉跟进,则id为客户投诉id;如果是客户跟进,则id为客户id
*/
offerId: Number,
customerId: Number,
customerNumber: String,
customerService: Number
},
components: {
ChooseContactDialog,
CustomerFollowSelectOffer,
FileUpload
},
data() {
return {
CustomerFollowSelectOffer: false,
ChooseContactDialog: false,
fileType: ["doc", "xls", "ppt", "txt", "pdf", "png", "jpg", "jpeg"],
DICT_TYPE,
getDictDataLabel,
parseTime,
customerFollowList: [],
serviceUserList: [],
customerContactsList: [],
customerFollow: {
dialogVisible: false,
form: {
followType: 3
}
},
offerDialogVisible: true,
form: {
offerId: undefined
},
pageNo: 1,
pageSize: 10,
total: 10,
allSimplList: [],
pickerOptions: {
disabledDate(time) {
return time.getTime() <= Date.now()
}
},
followTime: [],
nextTime: [],
queryParams: {
pageNo: 1,
pageSize: 10
},
offerList: [],
offerTotal: 0,
isView: false
}
},
computed: {
isChinese() {
return this.$i18n.locale === "zh_CN"
}
},
created() {
listServiceUser().then((r) => {
this.serviceUserList = r.data
})
listAllSimpl().then((r) => {
this.allSimplList = r.data
})
},
watch: {
"form.offerId"(v) {
if (v) {
getOfferNumber(v).then((r) => {
this.form.offerNumber = r.data
})
} else {
this.form.offerNumber = ""
}
}
},
methods: {
selectOffer(offerId) {
this.form.offerId = offerId
},
init() {
if (this.form.customerId) {
getCustomerContactsListByCustomer({
customerId: this.form.customerId
}).then((r) => {
this.customerContactsList = r.data
})
} else {
getCustomerContactsSelect().then((res) => {
this.customerContactsList = res.data.list.map((item) => {
return {
name: item.contactsName,
id: item.customerContactsId,
customerId: item.customerId,
phoneNew: item.phoneNew,
areaCode: item.areaCode,
customerNumber: item.customerNumber
}
})
})
}
},
changeAllContactUser(item) {
console.log(item)
if (item) {
this.form.contactId = item.customerContactsId
this.form.contactName = item.contactsName
this.form.customerId = item.customerId
this.form.contactPhone = "+" + item.areaCode + item.phoneNew
if (item.customerService) this.form.followUserId = item.customerService
if (item.customerNumber) this.form.customerNumber = item.customerNumber
} else {
this.form.contactId = null
this.form.contactName = null
this.form.contactPhone = null
}
this.ChooseContactDialog = false
},
changeContactUser(val) {
if (val) {
for (const item of this.customerContactsList) {
if (item.id == val) {
this.form.contactId = item.id
this.form.contactName = item.name
this.form.customerId = item.customerId
this.form.contactPhone = "+" + item.areaCode + item.phoneNew
if (item.customerService) this.form.followUserId = item.customerService
if (item.customerNumber) this.form.customerNumber = item.customerNumber
break
}
}
} else {
this.form.contactName = null
this.form.contactPhone = null
}
},
getOfferList() {
getOfferPage(this.queryParams).then((response) => {
this.offerList = response.data.list
this.offerTotal = response.data.total
})
},
handleFollowType(val) {
console.log(val)
if (val == 2) {
} else {
this.form.offerId = undefined
}
},
reset() {
this.form = {
attatchment: undefined,
contactId: undefined,
contactName: undefined,
contactPhone: undefined,
customerId: this.customerId,
customerNumber: this.customerNumber,
feedback: undefined,
followMethod: undefined,
followTime: new Date().getTime(),
followType: this.offerId ? 2 : undefined,
followUserId: this.customerService,
nextPlan: undefined,
nextTime: undefined,
number: undefined,
offerId: this.offerId,
offerNumber: undefined,
parentId: undefined,
parentNumber: undefined,
purpose: undefined,
resultType: undefined,
status: undefined,
creatorName: this.$store.getters.userId,
createTime: new Date().getTime(),
updaterName: this.$store.getters.userId,
updateTime: new Date().getTime()
}
},
changeNextTime(val) {
if (val) {
const curTime = new Date().getTime()
const valTime = new Date(val).getTime()
if (curTime > valTime) {
this.form.nextTime = null
this.$modal.msgError(this.$t("不能小于当前时间"))
}
}
},
customerFollowSubmit(status) {
console.log(this.form)
this.$refs["customerFollowForm"].validate((valid) => {
if (!valid) {
return
}
if (!this.form.followType) {
this.$modal.msgError(this.$t("请选择跟进类型"))
return
}
if (!this.form.followTime) {
this.$modal.msgError(this.$t("请选择跟进时间"))
return
}
if (!this.form.contactName) {
this.$modal.msgError(this.$t("请选择联系人"))
return
}
if (!this.form.followUserId) {
this.$modal.msgError(this.$t("请选择客户经理"))
return
}
if (!this.form.followMethod) {
this.$modal.msgError(this.$t("请选择跟进方式"))
return
}
if (!this.form.offerId && this.form.followType == 2) {
this.$modal.msgError(this.$t("请选择报价单"))
return
}
if (status === 0) {
this.saveSubmitData(status)
} else {
this.$confirm(this.$t("提交后无法修改"), this.$t("提示"), {
confirmButtonText: this.$t("确定"),
cancelButtonText: this.$t("取消"),
type: "warning"
}).then(() => {
this.saveSubmitData(status)
})
}
})
},
saveSubmitData(status) {
let func = this.form.id ? editCustomerFollow : addCustomerFollow
func({
...this.form,
followTime: this.form.followTime ? formatDate(this.form.followTime) : undefined,
nextTime: this.form.nextTime ? formatDate(this.form.nextTime) : undefined,
status
}).then((r) => {
this.$message.success(this.$t("操作成功"))
this.$emit("refresh")
this.customerFollowClose()
})
},
goBack() {
this.$confirm(this.$t("是否确认不保存信息"), this.$t("提示"), {
confirmButtonText: this.$t("确定"),
cancelButtonText: this.$t("取消"),
type: "warning"
}).then(() => {
this.customerFollowClose()
})
},
customerFollowClose() {
this.customerFollow.dialogVisible = false
this.$emit("close")
},
handleView(row) {
this.form = row
this.isView = this.form.status === 1
this.customerFollow.dialogVisible = true
},
async handleAdd() {
this.isView = false
this.customerFollow.dialogVisible = true
this.reset()
let r = await getFollowupNewNumber()
console.log(r)
this.form.customerId = this.customerId
this.form.number = r.data.number
this.form.numberId = r.data.numberId
this.form.numberVersion = r.data.numberVersion
this.form.status = 0
this.init()
},
async handleUpdate(row, flag) {
this.isView = false
this.customerFollow.dialogVisible = true
if (!flag) {
this.form = row
} else {
let r = await getFollowupNewNumber()
console.log(r)
this.form = {
...row,
id: null,
parentNumber: row.number,
followTime: row.nextTime,
nextTime: "",
number: r.data.number,
numberId: r.data.numberId,
numberVersion: r.data.numberVersion,
nextPlan: "",
status: 0
}
}
this.init()
}
}
}
</script>
<style scoped>
.text_style {
white-space: pre-wrap;
}
</style>