createaVisit.vue
22.9 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
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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<template>
<view class="container">
<Navbar :title="title" canBack></Navbar>
<u-form labelPosition="left" :model="model" :rules="rules" ref="uForm">
<view class="usuallyCard padding margin-sm">
<view class="text-lg padding-tb">
基本信息
</view>
<view class="padding-lr-sm">
<!-- 日期选择 -->
<view class="" v-for="(item,index) in basisData" :key="index">
<u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom
v-if="item.type === 'date'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<u-icon slot="right" name="calendar" size="20" @click="handleDateTime(item)"></u-icon>
</u-form-item>
<!-- 输入类型 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom
v-if="item.type === 'input'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabledColor="#fff"
border="none"></u-input>
<view class="" style="width: 40rpx;height: 40rpx;"></view>
</u-form-item>
<!-- 选择类型 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom
v-if="item.type === 'select'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<u-icon slot="right" name="arrow-down" size="20" @click="handleSelect(item)"></u-icon>
</u-form-item>
</view>
</view>
</view>
<view class="usuallyCard padding margin-sm">
<view class="text-lg padding-tb">
拜访信息
</view>
<view class="padding-lr-sm">
<view class="" v-for="(item,index) in visitData" :key="index">
<!-- 单选 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="70%" borderBottom
v-if="item.type === 'radio'">
<u-radio-group activeColor="#EA5504" placement="row" v-model="model[item.key]">
<u-radio class="margin-right" name="是">是</u-radio>
<u-radio name="否">否</u-radio>
</u-radio-group>
</u-form-item>
<!-- 日期 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom
v-if="item.type === 'date'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<u-icon slot="right" name="calendar" size="20" @click="calendarShow = true"></u-icon>
</u-form-item>
<!-- 输入 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom
v-if="item.type === 'input'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabledColor="#fff"
border="none"></u-input>
<view class="" style="width: 40rpx;height: 40rpx;"></view>
</u-form-item>
<!-- 选择 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom
v-if="item.type === 'select'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<u-icon slot="right" name="arrow-down" size="20" @click="handleSelect(item)"></u-icon>
</u-form-item>
<!-- 文件 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="75%" borderBottom
v-if="item.type === 'file'">
<u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="10"
width="100rpx" height="100rpx"></u-upload>
</u-form-item>
</view>
</view>
</view>
<view class="usuallyCard padding margin-sm">
<view class="text-lg padding-tb">
决策人信息
</view>
<view class="padding-lr-sm">
<view class="" v-for="(item,index) in decisionMakersData" :key="index">
<!-- 单选 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="70%" borderBottom
v-if="item.type === 'radio'">
<u-radio-group activeColor="#EA5504" placement="row" v-model="model[item.key]">
<u-radio class="margin-right" name="是">是</u-radio>
<u-radio name="否">否</u-radio>
</u-radio-group>
</u-form-item>
<!-- 输入 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="120" borderBottom
v-if="item.type === 'input'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabledColor="#fff"
border="none"></u-input>
<view class="" style="width: 40rpx;height: 40rpx;"></view>
</u-form-item>
<!-- 选择 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="120" borderBottom
v-if="item.type === 'select'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<u-icon slot="right" name="arrow-down" size="20" @click="handleSelect(item)"></u-icon>
</u-form-item>
</view>
</view>
</view>
<view class="usuallyCard padding margin-sm">
<view class="text-lg padding-tb">
收费信息
</view>
<view class="padding-lr-sm">
<view class="" v-for="(item,index) in chargeData" :key="index">
<!-- 单选 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="70%" borderBottom
v-if="item.type === 'radio'">
<u-radio-group activeColor="#EA5504" placement="row" v-model="model.bf">
<u-radio class="margin-right" name="是">是</u-radio>
<u-radio name="否">否</u-radio>
</u-radio-group>
</u-form-item>
<!-- 输入 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="120" borderBottom
v-if="item.type === 'input'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabledColor="#fff"
border="none"></u-input>
<view class="" style="width: 40rpx;height: 40rpx;"></view>
</u-form-item>
<!-- 选择 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="120" borderBottom
v-if="item.type === 'select'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<u-icon slot="right" name="arrow-down" size="20" @click="handleSelect(item)"></u-icon>
</u-form-item>
</view>
</view>
</view>
<view class="usuallyCard padding margin-sm">
<view class="text-lg padding-tb">
其他信息
</view>
<view class="padding-lr-sm">
<view class="" v-for="(item,index) in otherData" :key="index">
<!-- 输入 -->
<u-form-item :required="item.required" :label="item.label" labelWidth="120" borderBottom
v-if="item.type === 'input'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabledColor="#fff"
border="none"></u-input>
<view class="" style="width: 40rpx;height: 40rpx;"></view>
</u-form-item>
<!-- 附件 -->
<view class="" v-if="item.type === 'attachment'">
<u-form-item :required="item.required" :label="item.label" labelWidth="120" borderBottom
v-if="item.type === 'attachment'">
<u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled
disabledColor="#fff" border="none"></u-input>
<view slot="right" class="text-blue" @click="uploadAttachment">上传附件</view>
</u-form-item>
<view class="bg-gray">
<view class="flex justify-between">
<view class="padding" v-for="(item,index) in attachmentList" :key="index">
{{item.fileName}}
</view>
<view class="">
查看
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</u-form>
<view class="fixedBtnCss" @click="handleConfirm">
<u-button shape="circle" color="#CF000D">立即发起</u-button>
</view>
<u-picker :show="pickerShow" ref="uPicker" closeOnClickOverlay :columns="columns" @cancel="pickerShow = false"
@close="pickerShow = false" keyName="label" @confirm="confirm" @change="changeHandler"></u-picker>
<u-datetime-picker :show="datetimeShow" v-model="dataTimeValue" @confirm="dateConfirm"
mode="datetime"></u-datetime-picker>
</view>
</template>
<script>
import chargeFile from '@/api/chargeFile'
import config from '@/common/config.js'
import {
getCurrentFiscalYear,
getCompanyCascader
} from '@/api/charge.js'
export default {
components: {},
props: {
},
data() {
return {
title: "创建拜访/收费",
model: {
fiscalYear: "",
jobNature: "",
},
copyModel: {},
rules: {},
pickerShow: false,
datetimeShow: false,
dataTimeValue: Number(new Date()),
columns: [],
regionName: [],
groupName: [],
companyName: [],
companyCode: [],
currentName: "", //弹窗后赋值name
companyOption: [],
fileList: [],
attachmentList:[],
// 基本信息
basisData: [{
label: '财年',
placeholder: "请选择财年",
type: "date",
required: true,
key: "fiscalYear"
}, {
label: '收费人员',
placeholder: "请输入",
type: "input",
required: true,
key: "billingPersonName"
}, {
label: '兼职/全职',
placeholder: "请选择",
type: "select",
dict: "sys_mc_job_nature",
key: "jobNature",
required: true
}, {
label: '入户时间',
placeholder: "请选择",
type: "date",
required: true,
key: "entryTime"
}, {
label: '区域',
placeholder: "请选择",
type: "select",
required: true,
key: "regionName"
},
{
label: '集团',
placeholder: "请选择",
type: "select",
required: true,
key: "groupName"
},
{
label: '公司',
placeholder: "请选择",
type: "select",
required: true,
key: "companyName"
}, {
label: '村(小区)',
placeholder: "请选择",
type: "select",
required: true,
key: "vlgOrCmty"
}, {
label: '户名',
placeholder: "请选择",
type: "select",
required: true,
key: "userName",
}, {
label: '联系电话',
placeholder: "请输入",
type: "input",
required: true,
key: "userPhone"
}, {
label: '省/市/区/街道',
placeholder: "请输入",
type: "input",
required: true,
key: 'address'
}, {
label: '详细地址',
placeholder: "请输入",
type: "input",
required: true,
key: "userDetailedAddress"
}],
// 拜访信息
visitData: [{
label: '本次是否拜访',
type: "radio",
required: true,
key: "isVisited",
}, {
label: '是否有意向',
// placeholder: "请选择",
required: true,
type: "radio",
key: "isIntent"
}, {
label: '房屋情况',
placeholder: "请选择",
required: true,
type: "select",
key: "houseCondition",
dict: "sys_mc_visit_house"
}, {
label: '现用做饭能源',
placeholder: "请选择",
required: true,
type: "select",
key: "currentCookingEnergy",
dict: "sys_mc_visit_energy"
}, {
label: '现用取暖能源',
placeholder: "请选择",
type: "select",
key: "currentHeatingEnergy",
dict: "sys_mc_visit_energy"
}, {
label: '家庭人口情况',
placeholder: "请选择",
type: "select",
key: "familyMembers",
dict: "sys_mc_visit_members"
}, {
label: '电冰箱',
placeholder: "请选择",
type: "select",
key: "fridgeStatus",
dict: 'sys_mc_visit_appliance_status'
}, {
label: '空调',
placeholder: "请选择",
type: "select",
key: "acStatus",
dict: 'sys_mc_visit_appliance_status'
}, {
label: '电视',
placeholder: "请选择",
type: "select",
key: "tvStatus",
dict: 'sys_mc_visit_appliance_status'
}, {
label: '洗衣机',
placeholder: "请选择",
type: "select",
key: "washerStatus",
dict: 'sys_mc_visit_appliance_status'
}, {
label: '热水器',
placeholder: "请选择",
type: "select",
key: "waterHeaterStatus",
dict: 'sys_mc_visit_appliance_status'
}, {
label: '光伏',
placeholder: "请选择",
type: "select",
key: "pvSystemStatus",
dict: 'sys_mc_visit_appliance_status'
}, {
label: '当前地址',
placeholder: "请输入",
type: "input",
key: "visitDetailedAddress"
}, {
label: '上传图片',
placeholder: "请选择",
type: "file",
key: 'fieldPhotoFile'
}],
// 决策人信息
decisionMakersData: [{
label: '是否获取决策人信息',
type: "radio",
required: true,
key: "hasDm"
}, {
label: '决策人年龄',
placeholder: "请输入",
required: true,
type: "input",
key: "dmAge"
}, {
label: '决策人收入来源',
placeholder: "请选择",
required: true,
type: "select",
key: "dmIncomeSrc",
dict: 'sys_mc_visit_dm_income'
}, {
label: '决策人联系方式',
placeholder: "请输入",
required: true,
type: "input",
key: "dmPhone"
}],
// 收费信息
chargeData: [{
label: '本次是否收费',
type: "radio",
required: true,
key: "isCharged"
}, {
label: '用户编号',
placeholder: "请输入",
required: true,
type: "input",
key: "userCode"
}, {
label: '身份证号',
placeholder: "请输入",
required: true,
type: "input",
key: "userIdCard"
}, {
label: '票据单号',
placeholder: "请输入",
required: true,
type: "input",
key: "invoiceNo"
}, {
label: '收费金额',
placeholder: "请输入",
required: true,
type: "input",
key: "chargeAmt"
}, {
label: '缴费方式',
placeholder: "请选择",
required: true,
type: "select",
key: "paymentMeth",
dict: 'sys_mc_payment_meth',
}, {
label: '收费类型',
placeholder: "请选择",
required: true,
type: "select",
key: "chargeType",
dict: "sys_mc_charge_type"
}],
// 其他信息
otherData: [{
label: '备注',
placeholder: "请输入",
type: "input",
key: 'remark'
}, {
label: '附件',
type: "attachment",
key: "attachmentFile"
}, ]
}
},
computed: {
},
onLoad() {
this.init()
},
methods: {
async init() {
console.log(this.$store);
// 查询财年
await this.getCurrentFiscalYear()
await this.getCompanyCascader()
this.model.billingPersonName = uni.getStorageSync("nickName");
},
async getCurrentFiscalYear() {
this.model.fiscalYear = (await getCurrentFiscalYear()).data;
console.log("当前财年", this.model.fiscalYear);
},
async getCompanyCascader() {
this.companyOption = (await getCompanyCascader()).data;
console.log("当前公司类", this.companyOption);
},
// 选择弹出层
handleSelect(item) {
console.log(item);
if (item.key === 'companyCode') {
this.companyOption.forEach(item1 => {
// console.log(111,item1);
this.regionName.push(item1);
item1.children.forEach(item2 => {
// console.log(222,item2);
this.groupName.push(item2);
item2.children.forEach(item3 => {
// console.log(333,item3);
this.companyName.push(item3);
});
});
});
// console.log("data1", data1);
// console.log("data2", data2);
// console.log("data3", data3);
this.columns = [this.regionName, this.groupName, this.companyName];
console.log("数据", this.columns);
} else {
let dict = item.dict;
let dictArr = this.getDictDatas(dict);
this.currentName = item.key;
this.columns = [dictArr];
}
this.pickerShow = true;
console.log(this.columns);
// console.log("字典数组", dictArr);
},
// 选择弹出层确认
confirm(e) {
console.log("确认", e);
this.model[this.currentName] = e.value[0].value;
this.pickerShow = false;
},
// 选择时间弹出层
handleDateTime(item) {
this.currentName = item.key;
this.datetimeShow = true;
console.log(item);
},
// 时间弹出层确认
dateConfirm(e) {
let time = this.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
console.log("选择时间", time);
this.model[this.currentName] = time;
this.datetimeShow = false;
},
changeHandler(e) {
console.log(e);
const {
columnIndex,
value,
values, // values为当前变化列的数组内容
index,
// 微信小程序无法将picker实例传出来,只能通过ref操作
picker = this.$refs.uPicker
} = e
// 当第一列值发生变化时,变化第二列(后一列)对应的选项
// if (columnIndex === 0) {
// // picker为选择器this实例,变化第二列对应的选项
// picker.setColumnValues(1, this.groupName[index])
// }
},
// 删除图片
deletePic(event) {
this.fileList.splice(event.index, 1)
},
// 新增图片
async afterRead(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
let fileListLen = this.fileList.length
lists.map((item) => {
this.fileList.push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this.fileList[fileListLen]
this.fileList.splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
uuid: result.uuid,
url: result
}))
fileListLen++
}
console.log(this.fileList);
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: `${config.baseUrl}/schsf/mcFile/upload`,
filePath: url,
name: 'file',
header: {
Authorization: "Bearer " + uni.getStorageSync('ACCESS_TOKEN')
},
success: (res) => {
console.log("上传结果", res);
setTimeout(() => {
if (res.statusCode === 200) {
let data = JSON.parse(res.data);
console.log("上传data", data.data[0]);
resolve(data.data[0])
}
}, 500)
}
});
})
},
async uploadAttachment() {
console.log("上传附件");
uni.chooseFile({
count: 1, //默认100
extension:['.doc','.xlsx','.docx'],
success:async (res)=> {
let tempUrl = res.tempFilePaths[0]
console.log(res);
const result = await chargeFile.uploadFile(tempUrl);
this.attachmentList.push(result);
console.log(result);
}
});
},
// 重构提交数据,不影响表单数据
copyMethods() {
this.copyModel.fieldPhotoFile = this.fileList.map(item => item.uuid).join(",");
},
// 发起拜访
handleConfirm() {
this.copyModel = this.model;
this.copyMethods();
console.log('提交数据', JSON.parse(JSON.stringify(this.copyModel)));
this.$modal.confirm('确认发起当前这条记录?', '温馨提示').then(() => {
console.log('确定');
}).catch(() => {
console.log("取消");
});
}
}
}
</script>
<style lang="scss" scoped>
.container {
padding-bottom: 100rpx;
background: #F2F4F3;
}
/deep/.u-input__content__field-wrapper__field {
margin-right: 20rpx;
}
/deep/.u-upload__button {
margin: 0;
}
.fixedBtnCss {
position: fixed;
bottom: 0;
height: 100rpx;
width: 100%;
padding: 10rpx;
background: #fff;
}
</style>