You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							188 lines
						
					
					
						
							5.5 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							188 lines
						
					
					
						
							5.5 KiB
						
					
					
				| import { | |
|     agencygridtree, commonDemand, | |
|     dictlist, listServerOrg, | |
| } from "../../utils/statisticsApi"; | |
| 
 | |
| const App = getApp() | |
| const config = require('../../utils/config') | |
| Component({ | |
|     properties: { | |
|         visible: { | |
|             type: Boolean, | |
|             value: false | |
|         }, | |
|         detail: { | |
|             type: Object, | |
|             value: () => { | |
|             }, | |
|         }, | |
|         id: { | |
|             type: String, | |
|             value: '' | |
|         } | |
|     }, | |
|     data: { | |
|         agencyId: '', | |
|         loading: true, | |
|         form: { | |
|             serviceType: "", | |
|             serverId: "", | |
|             noticeApproches: [], | |
|             serviceScopeList: [] | |
|         }, | |
|         serviceOptions: [], | |
|         serviceIndex: -1, | |
|         serviceOptiondIndex: -1, | |
|         serviceOptiondList: [], | |
|         visible2: false, | |
|         orgField: {text: 'agencyName', value: 'agencyId', children: 'subAgencyList'}, | |
|         orgName: "", | |
|         orgOptions: [], | |
|         showService: false, | |
|         fieldValue: '', | |
|         cascaderValue: '', | |
|         showDate: false | |
|     }, | |
|     ready: function () { | |
| 
 | |
|         dictlist({ | |
|             dictType: "user_demand_service_type", | |
|         }).then((res) => { | |
|             this.setData({ | |
|                 serviceOptions: res.data | |
|             }) | |
|         }) | |
|         if (!this.agencyId) { | |
|             this.setData({ | |
|                 agencyId: App.globalData.user.agencyId | |
|             }) | |
|         } | |
|         this.getOrgTreeList() | |
|     }, | |
| 
 | |
|     methods: { | |
|         onShowService() { | |
|             this.setData({ | |
|                 showService: true, | |
|             }); | |
|             console.log(111, this.data.showService) | |
|         }, | |
| 
 | |
|         onCloseService() { | |
|             this.setData({ | |
|                 showService: false, | |
|             }); | |
|         }, | |
| 
 | |
|         onFinishService(e) { | |
|             const {selectedOptions, value} = e.detail; | |
|             const fieldValue = selectedOptions | |
|                 .map((option) => option.agencyName || option.agencyName) | |
|                 .join('/'); | |
|             let serviceScopeList = selectedOptions[selectedOptions.length - 1] | |
|             this.setData({ | |
|                 fieldValue, | |
|                 showService: false, | |
|                 cascaderValue: value, | |
|                 "form.serviceScopeList": [ | |
|                     { | |
|                         objectId: serviceScopeList.agencyId, | |
|                         objectName: serviceScopeList.agencyName, | |
|                         objectType: serviceScopeList.level | |
|                     } | |
|                 ] | |
|             }) | |
|         }, | |
|         getOrgTreeList() { | |
|             let params = { | |
|                 agencyId: this.data.agencyId, | |
|                 purpose: "query" | |
|             } | |
|             agencygridtree(params).then(res => { | |
|                 let org = this.deleteChildren(res.data.subAgencyList) | |
|                 this.setData({ | |
|                     orgOptions: org | |
|                 }) | |
|             }) | |
|         }, | |
|         noticeApprochesChange(e) { | |
|             this.setData({ | |
|                 "form.noticeApproches": e.detail | |
|             }) | |
|         }, | |
|         onShowDate() { | |
|             this.setData({showDate: true}); | |
|         }, | |
|         onCloseDate() { | |
|             this.setData({showDate: false}); | |
|         }, | |
|         formatDate(date) { | |
|             date = new Date(date); | |
|             return `${date.getFullYear()}-${date.getMonth() + 1 > 10 ? date.getMonth() + 1 : '0' + (date.getMonth() + 1)}-${date.getDate() > 10 ? date.getDate() : '0' + date.getDate()}`; | |
|         }, | |
|         onConfirmDate(event) { | |
|             const [start, end] = event.detail; | |
|             this.setData({ | |
|                 showDate: false, | |
|                 date: `${this.formatDate(start)} ~ ${this.formatDate(end)}`, | |
|                 "form.serviceTimeStart": `${this.formatDate(start)} 00:00:00`, | |
|                 "form.serviceTimeEnd": `${this.formatDate(end)} 00:00:00`, | |
|             }); | |
|         }, | |
| 
 | |
|         serviceOptiondListChange(e) { | |
|             this.setData({ | |
|                 serviceOptiondIndex: e.detail.value, | |
|                 "form.serverOrgId": this.data.serviceOptiondList[e.detail.value].id | |
|             }) | |
|         }, | |
|         getServiceuserList(e) { | |
|             this.setData({ | |
|                 serviceIndex: e.detail.value, | |
|                 "form.serverOrgType": this.data.serviceOptions[e.detail.value].value | |
|             }) | |
|             let params = { | |
|                 serviceTypeId: this.data.detail.categoryCode[1],//上级ID | |
|                 serverOrgType: this.data.serviceOptions[e.detail.value].value,//选的类型 | |
|                 businessType: "resi_service", | |
|             }; | |
| 
 | |
|             // serviceOptiondIndex | |
|             listServerOrg(params).then((res) => { | |
|                 this.setData({ | |
|                     serviceOptiondList: res.data || [] | |
|                 }) | |
|             }) | |
|         }, | |
|         deleteChildren(node) { | |
|             node.forEach(item => { | |
|                 if ('subAgencyList' in item && !item.subAgencyList) { | |
|                     delete item.subAgencyList | |
|                 } else if ('subAgencyList' in item && item.subAgencyList.length) { | |
|                     this.deleteChildren(item.subAgencyList) | |
|                 } | |
|             }) | |
|             return node | |
|         }, | |
| 
 | |
|         close() { | |
|             this.triggerEvent('close') | |
|         }, | |
|         sure() { | |
|             commonDemand({ | |
|                 ...this.data.detail, | |
|                 assignFlag: 1, | |
|                 assignInfo: { | |
|                     ...this.data.form, | |
|                 } | |
|                 // demandRecId: this.data.detail.demandRecId | |
|             }).then(res => { | |
|                 wx.showToast({ | |
|                     icon: 'success', | |
|                     title: '操作成功' | |
|                 }) | |
|                 this.close() | |
|             }) | |
|         }, | |
|     } | |
| });
 | |
| 
 |