import { agencygridtree, dictlist, listServerOrg, userdemandAssign, } from "../../utils/statisticsApi"; const App = getApp() const config = require('../../utils/config') Component({ options: { styleIsolation: 'shared', }, properties: { visible: { type: Boolean, value: false }, detail: { type: Object, value: () => { }, }, id: { type: String, value: '' } }, data: { agencyId: '', loading: true, form: { serviceType: "", serverId: "", noticeApproches: [] }, serviceOptions: [], serviceIndex: -1, serviceOptiondIndex: -1, serviceOptiondList: [], visible2: false, orgField: {label: 'agencyName', value: 'agencyId', children: 'subAgencyList'}, orgName: "", orgOptions: [], }, 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: { getOrgTreeList() { let params = { agencyId: this.data.agencyId, purpose: "query" } agencygridtree(params).then(res => { this.setData({ orgOptions: res.data.subAgencyList }) }) }, onChange1(e) { console.log(e) let noticeApproches = this.data.form.noticeApproches let index = noticeApproches.indexOf(e.detail.value) if (index === -1) { noticeApproches.push(e.detail.value) } else { noticeApproches.splice(index, 1) } this.setData({ "form.noticeApproches": noticeApproches }) console.log(noticeApproches) }, close() { this.triggerEvent('close') }, sure() { userdemandAssign({ ...this.data.form, demandRecId: this.data.detail.demandRecId }).then(res => { wx.showToast({ icon: 'success', title: '操作成功' }) this.close() }) }, serviceOptiondListChange(e) { this.setData({ serviceOptiondIndex: e.detail.value, "form.serverId": this.data.serviceOptiondList[e.detail.value].id }) }, getServiceuserList(e) { this.setData({ serviceIndex: e.detail.value, "form.serviceType": 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 || [] }) }) }, onOpen2() { this.setData({visible2: true}) }, onClose2() { this.setData({visible2: false}) console.log('onClose2') }, onConfirm2(e) { let data = e.detail console.log('onConfirm2', e.detail) let params = data.cols[data.cols.length - 1][data.selectedIndex[data.selectedIndex.length - 1]] this.setData({ "form.deptId": params.agencyId, "form.deptName": params.agencyName, "form.orgType": params.level }) this.setData({orgName: data.displayValue.join('-')}) }, change1(e) { console.log(e) } } });