Commit 7dec0b9a237546a4166c7f81a7ed646e1ab24b08
1 parent
db7f33e1
Exists in
charge
feat:拜访上传文件
Showing
6 changed files
with
228 additions
and
59 deletions
Show diff stats
api/charge.js
... | ... | @@ -14,7 +14,7 @@ export const addMcVisit = data => http.post('/schsf/mcVisit/add',data) |
14 | 14 | export const editMcVisit = data => http.post('/schsf/mcVisit/edit',data) |
15 | 15 | /* 作废拜访 */ |
16 | 16 | export const cancelMcVisit = data => http.post('/schsf/mcVisit/cancel',data) |
17 | -/* 查询小区下拉树 */ | |
17 | +/* 查询项目公司下拉树 */ | |
18 | 18 | export const getCompanyCascader = params => http.get('/schsf/mcBasicCmty/companyCascader', { params }) |
19 | 19 | /* 查询小区 */ |
20 | 20 | export const getVlgOrCmty = params => http.get('/schsf/mcBasicCmty/vlgOrCmty', { params }) | ... | ... |
api/chargeFile.js
1 | 1 | //请求工具参考https://ext.dcloud.net.cn/plugin?id=392 |
2 | -import request from '@/utils/request.js' | |
3 | 2 | import config from '@/common/config.js' |
4 | 3 | |
5 | 4 | |
... | ... | @@ -9,36 +8,38 @@ export function uploadFile(url) { |
9 | 8 | let a = uni.uploadFile({ |
10 | 9 | url: `${config.baseUrl}/schsf/mcFile/upload`, |
11 | 10 | filePath: url, |
12 | - name: 'files', | |
11 | + name: 'file', | |
13 | 12 | formData: {}, |
14 | 13 | header: { |
15 | 14 | Authorization: "Bearer " + uni.getStorageSync('ACCESS_TOKEN') |
16 | 15 | }, |
17 | 16 | success: (res) => { |
18 | 17 | if (res.statusCode === 200) { |
19 | - const data = JSON.parse(res.data) | |
18 | + console.log(res); | |
19 | + const data = JSON.parse(res.data); | |
20 | + console.log(data); | |
20 | 21 | // console.log('上传成功,返回解析数据', data) |
21 | - let uuid = uni.$u.guid(13) | |
22 | - let tempData = { | |
23 | - status:"success", | |
24 | - name: data.fileName, | |
25 | - size: data.size, | |
26 | - percentage: 100, | |
27 | - uid: uuid, | |
28 | - raw: { | |
29 | - uid: uuid | |
30 | - }, | |
31 | - response: { | |
32 | - success: true, | |
33 | - fileId: data.fileId, | |
34 | - fileName:data.fileName, | |
35 | - size: data.size, | |
36 | - username: '超级管理员' | |
37 | - } | |
38 | - } | |
22 | + // let uuid = uni.$u.guid(13) | |
23 | + // let tempData = { | |
24 | + // status:"success", | |
25 | + // name: data.fileName, | |
26 | + // size: data.size, | |
27 | + // percentage: 100, | |
28 | + // uid: uuid, | |
29 | + // raw: { | |
30 | + // uid: uuid | |
31 | + // }, | |
32 | + // response: { | |
33 | + // success: true, | |
34 | + // fileId: data.fileId, | |
35 | + // fileName:data.fileName, | |
36 | + // size: data.size, | |
37 | + // username: '超级管理员' | |
38 | + // } | |
39 | + // } | |
39 | 40 | // let FileJson = JSON.stringify(tempData); |
40 | - console.log("返回文件数据Json",tempData); | |
41 | - resolve(tempData) | |
41 | + // console.log("返回文件数据Json",data.data[0]); | |
42 | + resolve(data.data[0]) | |
42 | 43 | } else { |
43 | 44 | reject() |
44 | 45 | } | ... | ... |
api/user.js
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | const { http } = uni.$u |
3 | 3 | |
4 | 4 | //获取用户信息 |
5 | -export const getUserInfo = params => http.get('/member/user/get', params) | |
5 | +// export const getUserInfo = params => http.get('/member/user/get', params) | |
6 | 6 | //修改用户头像 |
7 | 7 | export const updateAvatar = filePath => |
8 | 8 | http.upload('/member/user/update-avatar', { | ... | ... |
common/config.js
1 | 1 | module.exports = { |
2 | 2 | //后端接口地址 |
3 | 3 | // baseUrl: 'http://10.11.38.240:9001', //内网开发环境 |
4 | - baseUrl: 'http://192.168.0.8:8001', //内网开发环境 | |
4 | + // baseUrl: 'http://192.168.0.8:8001', //内网开发环境 | |
5 | + baseUrl: 'http://hqpnzc.natappfree.cc', //内网穿透开发环境 | |
5 | 6 | // baseUrl: 'http://172.17.56.37:18082/api', //测试环境 |
6 | 7 | // baseUrl: 'http://172.17.56.16:18082/api', //ip正式环境 |
7 | 8 | // baseUrl: 'https://scdcapp.chinagasholdings.com/api', //域名正式环境 | ... | ... |
pages/charge/visitsAndFees/createaVisit.vue
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | v-if="item.type === 'date'"> |
14 | 14 | <u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled |
15 | 15 | disabledColor="#fff" border="none"></u-input> |
16 | - <u-icon slot="right" name="calendar" size="20"></u-icon> | |
16 | + <u-icon slot="right" name="calendar" size="20" @click="handleDateTime(item)"></u-icon> | |
17 | 17 | </u-form-item> |
18 | 18 | <!-- 输入类型 --> |
19 | 19 | <u-form-item :required="item.required" :label="item.label" labelWidth="100" borderBottom |
... | ... | @@ -71,7 +71,8 @@ |
71 | 71 | <!-- 文件 --> |
72 | 72 | <u-form-item :required="item.required" :label="item.label" labelWidth="75%" borderBottom |
73 | 73 | v-if="item.type === 'file'"> |
74 | - <u-upload width="100rpx" height="100rpx"></u-upload> | |
74 | + <u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="10" | |
75 | + width="100rpx" height="100rpx"></u-upload> | |
75 | 76 | </u-form-item> |
76 | 77 | </view> |
77 | 78 | </view> |
... | ... | @@ -160,10 +161,17 @@ |
160 | 161 | v-if="item.type === 'attachment'"> |
161 | 162 | <u-input v-model="model[item.key]" inputAlign="right" :placeholder="item.placeholder" disabled |
162 | 163 | disabledColor="#fff" border="none"></u-input> |
163 | - <view slot="right" class="text-blue">上传附件</view> | |
164 | + <view slot="right" class="text-blue" @click="uploadAttachment">上传附件</view> | |
164 | 165 | </u-form-item> |
165 | 166 | <view class="bg-gray"> |
166 | - 上传内容 | |
167 | + <view class="flex justify-between"> | |
168 | + <view class="padding" v-for="(item,index) in attachmentList" :key="index"> | |
169 | + {{item.fileName}} | |
170 | + </view> | |
171 | + <view class=""> | |
172 | + 查看 | |
173 | + </view> | |
174 | + </view> | |
167 | 175 | </view> |
168 | 176 | </view> |
169 | 177 | </view> |
... | ... | @@ -174,14 +182,20 @@ |
174 | 182 | <u-button shape="circle" color="#CF000D">立即发起</u-button> |
175 | 183 | </view> |
176 | 184 | |
177 | - <u-picker :show="pickerShow" closeOnClickOverlay :columns="columns" @cancel="pickerShow = false" | |
178 | - @close="pickerShow = false" keyName="label" @confirm="confirm"></u-picker> | |
185 | + <u-picker :show="pickerShow" ref="uPicker" closeOnClickOverlay :columns="columns" @cancel="pickerShow = false" | |
186 | + @close="pickerShow = false" keyName="label" @confirm="confirm" @change="changeHandler"></u-picker> | |
187 | + | |
188 | + <u-datetime-picker :show="datetimeShow" v-model="dataTimeValue" @confirm="dateConfirm" | |
189 | + mode="datetime"></u-datetime-picker> | |
179 | 190 | </view> |
180 | 191 | </template> |
181 | 192 | |
182 | 193 | <script> |
194 | + import chargeFile from '@/api/chargeFile' | |
195 | + import config from '@/common/config.js' | |
183 | 196 | import { |
184 | - getCurrentFiscalYear | |
197 | + getCurrentFiscalYear, | |
198 | + getCompanyCascader | |
185 | 199 | } from '@/api/charge.js' |
186 | 200 | export default { |
187 | 201 | components: {}, |
... | ... | @@ -195,10 +209,20 @@ |
195 | 209 | fiscalYear: "", |
196 | 210 | jobNature: "", |
197 | 211 | }, |
212 | + copyModel: {}, | |
198 | 213 | rules: {}, |
199 | 214 | pickerShow: false, |
215 | + datetimeShow: false, | |
216 | + dataTimeValue: Number(new Date()), | |
200 | 217 | columns: [], |
218 | + regionName: [], | |
219 | + groupName: [], | |
220 | + companyName: [], | |
221 | + companyCode: [], | |
201 | 222 | currentName: "", //弹窗后赋值name |
223 | + companyOption: [], | |
224 | + fileList: [], | |
225 | + attachmentList:[], | |
202 | 226 | // 基本信息 |
203 | 227 | basisData: [{ |
204 | 228 | label: '财年', |
... | ... | @@ -226,11 +250,25 @@ |
226 | 250 | required: true, |
227 | 251 | key: "entryTime" |
228 | 252 | }, { |
229 | - label: '项目公司/部门', | |
253 | + label: '区域', | |
230 | 254 | placeholder: "请选择", |
231 | 255 | type: "select", |
232 | 256 | required: true, |
233 | - key: "companyCode" | |
257 | + key: "regionName" | |
258 | + }, | |
259 | + { | |
260 | + label: '集团', | |
261 | + placeholder: "请选择", | |
262 | + type: "select", | |
263 | + required: true, | |
264 | + key: "groupName" | |
265 | + }, | |
266 | + { | |
267 | + label: '公司', | |
268 | + placeholder: "请选择", | |
269 | + type: "select", | |
270 | + required: true, | |
271 | + key: "companyName" | |
234 | 272 | }, { |
235 | 273 | label: '村(小区)', |
236 | 274 | placeholder: "请选择", |
... | ... | @@ -280,62 +318,62 @@ |
280 | 318 | required: true, |
281 | 319 | type: "select", |
282 | 320 | key: "houseCondition", |
283 | - dict:"sys_mc_visit_house" | |
321 | + dict: "sys_mc_visit_house" | |
284 | 322 | }, { |
285 | 323 | label: '现用做饭能源', |
286 | 324 | placeholder: "请选择", |
287 | 325 | required: true, |
288 | 326 | type: "select", |
289 | 327 | key: "currentCookingEnergy", |
290 | - dict:"sys_mc_visit_energy" | |
328 | + dict: "sys_mc_visit_energy" | |
291 | 329 | }, { |
292 | 330 | label: '现用取暖能源', |
293 | 331 | placeholder: "请选择", |
294 | 332 | type: "select", |
295 | 333 | key: "currentHeatingEnergy", |
296 | - dict:"sys_mc_visit_energy" | |
334 | + dict: "sys_mc_visit_energy" | |
297 | 335 | }, { |
298 | 336 | label: '家庭人口情况', |
299 | 337 | placeholder: "请选择", |
300 | 338 | type: "select", |
301 | 339 | key: "familyMembers", |
302 | - dict:"sys_mc_visit_members" | |
340 | + dict: "sys_mc_visit_members" | |
303 | 341 | }, { |
304 | 342 | label: '电冰箱', |
305 | 343 | placeholder: "请选择", |
306 | 344 | type: "select", |
307 | 345 | key: "fridgeStatus", |
308 | - dict:'sys_mc_visit_appliance_status' | |
346 | + dict: 'sys_mc_visit_appliance_status' | |
309 | 347 | }, { |
310 | 348 | label: '空调', |
311 | 349 | placeholder: "请选择", |
312 | 350 | type: "select", |
313 | 351 | key: "acStatus", |
314 | - dict:'sys_mc_visit_appliance_status' | |
352 | + dict: 'sys_mc_visit_appliance_status' | |
315 | 353 | }, { |
316 | 354 | label: '电视', |
317 | 355 | placeholder: "请选择", |
318 | 356 | type: "select", |
319 | 357 | key: "tvStatus", |
320 | - dict:'sys_mc_visit_appliance_status' | |
358 | + dict: 'sys_mc_visit_appliance_status' | |
321 | 359 | }, { |
322 | 360 | label: '洗衣机', |
323 | 361 | placeholder: "请选择", |
324 | 362 | type: "select", |
325 | 363 | key: "washerStatus", |
326 | - dict:'sys_mc_visit_appliance_status' | |
364 | + dict: 'sys_mc_visit_appliance_status' | |
327 | 365 | }, { |
328 | 366 | label: '热水器', |
329 | 367 | placeholder: "请选择", |
330 | 368 | type: "select", |
331 | 369 | key: "waterHeaterStatus", |
332 | - dict:'sys_mc_visit_appliance_status' | |
370 | + dict: 'sys_mc_visit_appliance_status' | |
333 | 371 | }, { |
334 | 372 | label: '光伏', |
335 | 373 | placeholder: "请选择", |
336 | 374 | type: "select", |
337 | 375 | key: "pvSystemStatus", |
338 | - dict:'sys_mc_visit_appliance_status' | |
376 | + dict: 'sys_mc_visit_appliance_status' | |
339 | 377 | }, { |
340 | 378 | label: '当前地址', |
341 | 379 | placeholder: "请输入", |
... | ... | @@ -344,7 +382,8 @@ |
344 | 382 | }, { |
345 | 383 | label: '上传图片', |
346 | 384 | placeholder: "请选择", |
347 | - type: "file" | |
385 | + type: "file", | |
386 | + key: 'fieldPhotoFile' | |
348 | 387 | }], |
349 | 388 | // 决策人信息 |
350 | 389 | decisionMakersData: [{ |
... | ... | @@ -364,7 +403,7 @@ |
364 | 403 | required: true, |
365 | 404 | type: "select", |
366 | 405 | key: "dmIncomeSrc", |
367 | - dict:'sys_mc_visit_dm_income' | |
406 | + dict: 'sys_mc_visit_dm_income' | |
368 | 407 | }, { |
369 | 408 | label: '决策人联系方式', |
370 | 409 | placeholder: "请输入", |
... | ... | @@ -408,14 +447,14 @@ |
408 | 447 | required: true, |
409 | 448 | type: "select", |
410 | 449 | key: "paymentMeth", |
411 | - dict:'sys_mc_payment_meth', | |
450 | + dict: 'sys_mc_payment_meth', | |
412 | 451 | }, { |
413 | 452 | label: '收费类型', |
414 | 453 | placeholder: "请选择", |
415 | 454 | required: true, |
416 | 455 | type: "select", |
417 | 456 | key: "chargeType", |
418 | - dict:"sys_mc_charge_type" | |
457 | + dict: "sys_mc_charge_type" | |
419 | 458 | }], |
420 | 459 | // 其他信息 |
421 | 460 | otherData: [{ |
... | ... | @@ -437,34 +476,161 @@ |
437 | 476 | this.init() |
438 | 477 | }, |
439 | 478 | methods: { |
440 | - init() { | |
479 | + async init() { | |
441 | 480 | console.log(this.$store); |
442 | 481 | // 查询财年 |
443 | - this.getCurrentFiscalYear() | |
444 | - | |
482 | + await this.getCurrentFiscalYear() | |
483 | + await this.getCompanyCascader() | |
484 | + this.model.billingPersonName = uni.getStorageSync("nickName"); | |
445 | 485 | }, |
446 | 486 | async getCurrentFiscalYear() { |
447 | 487 | this.model.fiscalYear = (await getCurrentFiscalYear()).data; |
448 | 488 | console.log("当前财年", this.model.fiscalYear); |
449 | 489 | }, |
490 | + async getCompanyCascader() { | |
491 | + this.companyOption = (await getCompanyCascader()).data; | |
492 | + console.log("当前公司类", this.companyOption); | |
493 | + }, | |
450 | 494 | // 选择弹出层 |
451 | 495 | handleSelect(item) { |
452 | 496 | console.log(item); |
453 | - let dict = item.dict; | |
454 | - let dictArr = this.getDictDatas(dict); | |
455 | - this.currentName = item.key; | |
456 | - this.columns = [dictArr]; | |
457 | - // console.log("字典数组", dictArr); | |
497 | + if (item.key === 'companyCode') { | |
498 | + this.companyOption.forEach(item1 => { | |
499 | + // console.log(111,item1); | |
500 | + this.regionName.push(item1); | |
501 | + item1.children.forEach(item2 => { | |
502 | + // console.log(222,item2); | |
503 | + this.groupName.push(item2); | |
504 | + item2.children.forEach(item3 => { | |
505 | + // console.log(333,item3); | |
506 | + this.companyName.push(item3); | |
507 | + }); | |
508 | + }); | |
509 | + }); | |
510 | + // console.log("data1", data1); | |
511 | + // console.log("data2", data2); | |
512 | + // console.log("data3", data3); | |
513 | + this.columns = [this.regionName, this.groupName, this.companyName]; | |
514 | + console.log("数据", this.columns); | |
515 | + } else { | |
516 | + let dict = item.dict; | |
517 | + let dictArr = this.getDictDatas(dict); | |
518 | + this.currentName = item.key; | |
519 | + this.columns = [dictArr]; | |
520 | + } | |
458 | 521 | this.pickerShow = true; |
522 | + console.log(this.columns); | |
523 | + // console.log("字典数组", dictArr); | |
459 | 524 | }, |
460 | - // 弹出层确认 | |
525 | + // 选择弹出层确认 | |
461 | 526 | confirm(e) { |
462 | 527 | console.log("确认", e); |
463 | 528 | this.model[this.currentName] = e.value[0].value; |
464 | 529 | this.pickerShow = false; |
465 | 530 | }, |
531 | + // 选择时间弹出层 | |
532 | + handleDateTime(item) { | |
533 | + this.currentName = item.key; | |
534 | + this.datetimeShow = true; | |
535 | + console.log(item); | |
536 | + }, | |
537 | + // 时间弹出层确认 | |
538 | + dateConfirm(e) { | |
539 | + let time = this.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss'); | |
540 | + console.log("选择时间", time); | |
541 | + this.model[this.currentName] = time; | |
542 | + this.datetimeShow = false; | |
543 | + }, | |
544 | + changeHandler(e) { | |
545 | + console.log(e); | |
546 | + const { | |
547 | + columnIndex, | |
548 | + value, | |
549 | + values, // values为当前变化列的数组内容 | |
550 | + index, | |
551 | + // 微信小程序无法将picker实例传出来,只能通过ref操作 | |
552 | + picker = this.$refs.uPicker | |
553 | + } = e | |
554 | + // 当第一列值发生变化时,变化第二列(后一列)对应的选项 | |
555 | + // if (columnIndex === 0) { | |
556 | + // // picker为选择器this实例,变化第二列对应的选项 | |
557 | + // picker.setColumnValues(1, this.groupName[index]) | |
558 | + // } | |
559 | + }, | |
560 | + // 删除图片 | |
561 | + deletePic(event) { | |
562 | + this.fileList.splice(event.index, 1) | |
563 | + }, | |
564 | + // 新增图片 | |
565 | + async afterRead(event) { | |
566 | + // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 | |
567 | + let lists = [].concat(event.file) | |
568 | + let fileListLen = this.fileList.length | |
569 | + lists.map((item) => { | |
570 | + this.fileList.push({ | |
571 | + ...item, | |
572 | + status: 'uploading', | |
573 | + message: '上传中' | |
574 | + }) | |
575 | + }) | |
576 | + for (let i = 0; i < lists.length; i++) { | |
577 | + const result = await this.uploadFilePromise(lists[i].url) | |
578 | + let item = this.fileList[fileListLen] | |
579 | + this.fileList.splice(fileListLen, 1, Object.assign(item, { | |
580 | + status: 'success', | |
581 | + message: '', | |
582 | + uuid: result.uuid, | |
583 | + url: result | |
584 | + })) | |
585 | + fileListLen++ | |
586 | + } | |
587 | + console.log(this.fileList); | |
588 | + }, | |
589 | + uploadFilePromise(url) { | |
590 | + return new Promise((resolve, reject) => { | |
591 | + let a = uni.uploadFile({ | |
592 | + url: `${config.baseUrl}/schsf/mcFile/upload`, | |
593 | + filePath: url, | |
594 | + name: 'file', | |
595 | + header: { | |
596 | + Authorization: "Bearer " + uni.getStorageSync('ACCESS_TOKEN') | |
597 | + }, | |
598 | + success: (res) => { | |
599 | + console.log("上传结果", res); | |
600 | + setTimeout(() => { | |
601 | + if (res.statusCode === 200) { | |
602 | + let data = JSON.parse(res.data); | |
603 | + console.log("上传data", data.data[0]); | |
604 | + resolve(data.data[0]) | |
605 | + } | |
606 | + }, 500) | |
607 | + } | |
608 | + }); | |
609 | + }) | |
610 | + }, | |
611 | + async uploadAttachment() { | |
612 | + console.log("上传附件"); | |
613 | + uni.chooseFile({ | |
614 | + count: 1, //默认100 | |
615 | + extension:['.doc','.xlsx','.docx'], | |
616 | + success:async (res)=> { | |
617 | + let tempUrl = res.tempFilePaths[0] | |
618 | + console.log(res); | |
619 | + const result = await chargeFile.uploadFile(tempUrl); | |
620 | + this.attachmentList.push(result); | |
621 | + console.log(result); | |
622 | + } | |
623 | + }); | |
624 | + }, | |
625 | + // 重构提交数据,不影响表单数据 | |
626 | + copyMethods() { | |
627 | + this.copyModel.fieldPhotoFile = this.fileList.map(item => item.uuid).join(","); | |
628 | + }, | |
629 | + // 发起拜访 | |
466 | 630 | handleConfirm() { |
467 | - console.log('提交数据', JSON.parse(JSON.stringify(this.model))); | |
631 | + this.copyModel = this.model; | |
632 | + this.copyMethods(); | |
633 | + console.log('提交数据', JSON.parse(JSON.stringify(this.copyModel))); | |
468 | 634 | this.$modal.confirm('确认发起当前这条记录?', '温馨提示').then(() => { |
469 | 635 | console.log('确定'); |
470 | 636 | }).catch(() => { | ... | ... |
store/mudules/user.js
... | ... | @@ -54,6 +54,7 @@ const user = { |
54 | 54 | state.roleId = roleIdString; |
55 | 55 | state.entity = entityString; |
56 | 56 | state.entityName = entityNameString; |
57 | + uni.setStorageSync('nickName', sysUser.nickName) | |
57 | 58 | uni.setStorageSync('roleId', roleIdString) |
58 | 59 | uni.setStorageSync('entity', entityString) |
59 | 60 | uni.setStorageSync('entityName', entityNameString) | ... | ... |