epmet 工作端 小程序
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.

189 lines
5.5 KiB

import {
2 years ago
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: "",
2 years ago
noticeApproches: [],
serviceScopeList: []
},
serviceOptions: [],
serviceIndex: -1,
serviceOptiondIndex: -1,
serviceOptiondList: [],
visible2: false,
2 years ago
orgField: {text: 'agencyName', value: 'agencyId', children: 'subAgencyList'},
orgName: "",
orgOptions: [],
2 years ago
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: {
2 years ago
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 => {
2 years ago
let org = this.deleteChildren(res.data.subAgencyList)
this.setData({
2 years ago
orgOptions: org
})
})
},
2 years ago
noticeApprochesChange(e) {
this.setData({
2 years ago
"form.noticeApproches": e.detail
})
},
2 years ago
onShowDate() {
this.setData({showDate: true});
},
2 years ago
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()}`;
},
2 years ago
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,
2 years ago
"form.serverOrgId": this.data.serviceOptiondList[e.detail.value].id
})
},
getServiceuserList(e) {
this.setData({
serviceIndex: e.detail.value,
2 years ago
"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 || []
})
})
},
2 years ago
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
},
2 years ago
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()
})
},
}
});