const app = getApp(); var util = require('../../../utils/util.js'); var util1 = require('../../utils/wgs84Gcj02.js'); var timerListJd = []; var timerList = []; var Jdtime; var Datetime; var searchTimer; Page({ data: { Type: [], // 原先默认为【1】 typeStr: '', // 原先默认为 "1" listType: '', // 传递过来的参数 mileage: 0, //里程 mileage1: 0, //转化进制后的里程 posObj: { latitude: null, longitude: null, }, //当前坐标点 lastPosObj: { latitude: null, longitude: null, }, //上一个坐标点 polyline: [], //路线数组 flag: false, flag1: true, info: {}, //当前巡查对象 hours: '0' + 0, // 时 minute: '0' + 0, // 分 second: '0' + 0, // 秒 imgDailog: false, //发现问题 弹框 uploaderList: [], //保存上传图片url的数组 fFileurl: [], uploaderNum: 0, //已经上传的图片数目 formFileurl: [], //上传图片返回数据 arrPoint: [], //坐标数组 arrAddress: [], startTime: '', parkList: [], parkIndex: 0, isExist: 0, yhdwList: [], yhdwIndex: 0, // =========== WorkList: [], //工单列表 text: null, //工单内容 workZb: { latitude: null, longitude: null, // 记录 发现问题的 坐标 }, // 判断是否已经创建 巡查单 status: false, endFlag: false, xiping: false, position: '', //角色权限判断 positionFlag: false, yhCompanyId: null, maintenanceCompanyId: null, checkFlag: false, // 选路 checkboxEd: false, //控制选路的 显示 ldList: [], // 路 路段 的 数组 集合 addldList: [], // 要巡查的 路段 allldList: [], //所有的 路段 作为查询 isBack:false, vehicleFlag: false, vehicleList: [{ id: 1, name: '步行' }, { id: 2, name: '非机动车' }, { id: 3, name: '机动车' }, ], addVehicleList: [], // 巡查单 InspectionInfo: {}, // 问题类型 workTypeList: [], worktypeIndex: 0, workNum: 0, //问题数量 XDSflag: 1, huatanFlag: false, huatanList: [], huatanIndex: 0, huatanType: '1', temperature: '', //温度 humidity: '', //湿度 wormList: [], wormIndex: null, hostbiology: '', //寄主生物 hazardRatio: 0, //危害率 remark: '', dangerLevelLIst: [], dangerLevelIndex: null, pestNewName: '', issueTypeList: [], issueTypeIndex: null, bchFlag: false, //是否显示病虫害 xdsList: [], matchedDailog:false, detailList:[],//已匹配路段 }, huatanEdit(e) { this.setData({ huatanType: e.detail.value, }); }, bindHostInput(e) { this.setData({ hostbiology: e.detail.value, }); }, bindHazardRatioInput(e) { this.setData({ // hazardRatio: parseInt(e.detail.value), hazardRatio: e.detail.value }); }, dangerLevelChange(e) { this.setData({ dangerLevelIndex: e.detail.value, hazardRatio: this.data.dangerLevelLIst[e.detail.value].label }); }, bindRemarkInput(e) { this.setData({ remark: e.detail.value, }); }, getHuatanbyid(i1, i2) { var that = this; app.loading(); let url = app.globalData.httpsUrlServer + '/roadplantscondition/t-lhzx-road-plants-condition/list'; let data = { sectionId: i1, maintenanceCompanyId: i2, }; app.getReqNew(url, data, (res) => { if (res.code == 0) { that.setData({ huatanList: res.data, }); app.hideloading(); } }) }, // 切换花坛 changeHuatna(e) { this.setData({ huatanIndex: e.detail.value, }); }, // 添加路 路段 addItem(e) { let obj = e.currentTarget.dataset.item; let state; if (this.data.addldList.length > 0) { state = this.data.addldList.findIndex((v) => { return v.id == obj.id; }); if (state == -1) { this.data.addldList.push(obj); } else { app.toast('已添加'); } } else { this.data.addldList.push(obj); } this.setData({ addldList: this.data.addldList, }); }, // 删除路 和路段 removeItem(e) { let obj = e.currentTarget.dataset.item; this.data.addldList = this.data.addldList.filter((v) => { return v.id != obj.id; }); this.setData({ addldList: this.data.addldList, }); }, // 搜索 路 和路段 searchItem(e) { clearTimeout(searchTimer); searchTimer = setTimeout(() => { wx.showLoading({ title: '加载中', mask: true, }); let val = e.detail.value.trim(); let arr = []; this.data.allldList.forEach((v) => { let flag1 = v.roadName ? v.roadName.indexOf(val) != -1 : false; let flag2 = v.roadStartSpot ? v.roadStartSpot.indexOf(val) != -1 : false; let flag3 = v.roadEndSpot ? v.roadEndSpot.indexOf(val) != -1 : false; if (flag1 || flag2 || flag3) { arr.push(v); } }); this.setData({ ldList: arr, }); wx.hideLoading(); }, 1000); if (e.detail.value.trim() == '') { // 给 数组 重新赋值 但是已选择 的不能存在 this.setData({ ldList: this.data.allldList, }); } }, // 清空 路 和路段 clearItem() { console.log('所有的路段', this.data.allldList); console.log('未选的路段', this.data.ldList); console.log('选择的路段', this.data.addldList); }, // 隐藏 hideCk() { let that = this; // 设置花坛 // let id1 = that.data.parkList[that.data.parkIndex].sectionId; let id1 = that.data.parkList[that.data.parkIndex].fParkid; let id2; if (that.data.yhdwList.length == 0) { id2 = that.data.yhCompanyId; } else { // maintenanceCompanyId id2 = that.data.yhdwList[that.data.yhdwIndex].oldMaintenanceCompanyId; } that.getHuatanbyid(id1, id2); this.setData({ checkboxEd: false, }); }, onSupple() { this.setData({ checkboxEd: false, }); }, onBack(){ this.setData({ checkboxEd: false, }); }, // 显示 ShowCk() { if (!this.data.parkList[this.data.parkIndex]) { return app.toast('请先选择路段'); } if (this.data.flag) { return app.toast('巡查过程中不可更换'); } // let id = this.data.parkList[this.data.parkIndex].sectionId; let id = this.data.parkList[this.data.parkIndex].id; if (id) { if (this.data.addldList.length == 0) { // this.getLdListbyid(id); this.getLdListbyid(); } this.setData({ checkboxEd: true, }); } else { return app.toast('请先选择路段'); } }, ShowVehicle() { this.setData({ vehicleFlag: true, }); }, hideVehicle() { this.setData({ vehicleFlag: false, }); }, addVehicle(e) { let obj = e.currentTarget.dataset.item; let state; if (this.data.addVehicleList.length > 0) { state = this.data.addVehicleList.findIndex((v) => { return v.id == obj.id; }); if (state == -1) { this.data.addVehicleList.push(obj); } else { app.toast('已添加'); } } else { this.data.addVehicleList.push(obj); } this.setData({ addVehicleList: this.data.addVehicleList, }); }, removeVehicle(e) { let obj = e.currentTarget.dataset.item; this.data.addVehicleList = this.data.addVehicleList.filter((v) => { return v.id != obj.id; }); this.setData({ addVehicleList: this.data.addVehicleList, }); }, // 获取坐标 tap1() { let that = this; wx.getLocation({ type: 'gcj02', isHighAccuracy: true, success(res) { var arr = []; arr.push({ latitude: res.latitude, longitude: res.longitude, }); that.getAddress(res.latitude, res.longitude); that.data.arrPoint = that.data.arrPoint.concat(arr); that.setData({ arrPoint: that.data.arrPoint, posObj: { latitude: res.latitude, longitude: res.longitude, }, }); // 每次获取上一次的坐标点 计算里程数 // 纬度 纬度 if (that.data.arrPoint.length > 2) { let last = that.data.arrPoint[that.data.arrPoint.length - 2]; that.data.lastPosObj.latitude = last.latitude; that.data.lastPosObj.longitude = last.longitude; that.setData({ lastPosObj: that.data.lastPosObj, }); that.distance( that.data.posObj.latitude * 1, that.data.posObj.longitude * 1, that.data.lastPosObj.latitude * 1, that.data.lastPosObj.longitude * 1 ); } }, }); }, getAddress(latitude, longitude) { let that = this; wx.request({ url: 'https://apis.map.qq.com/ws/geocoder/v1/', //仅为示例,并非真实的接口地址 data: { location: latitude + ',' + longitude, get_poi: 1, key: "PIDBZ-L75KO-6HKWR-SGRJQ-IP7VV-UZBLJ", }, header: { 'content-type': 'application/json' // 默认值 }, success(res) { let address = res.data.result.address_component.street; that.setData({ arrAddress: that.dedupe(that.data.arrAddress.concat(address)) }) } }) }, dedupe(array) { return Array.from(new Set(array)); }, // 切换 行道树 或者绿地 或者 花坛 toggleXDS(e) { app.loading(); this.setData({ XDSflag: e.detail.value, }); this.getWorkTypeList(e.detail.value); if (e.detail.value == 3) { this.setData({ huatanFlag: true, }); } else { this.setData({ huatanFlag: false, }); } }, // 点击 确定按钮 UploadP() { if (this.data.huatanFlag) { // if (!this.data.huatanList[this.data.huatanIndex]) // return app.toast('请选择花坛'); if (this.data.formFileurl.length < 2) return app.toast('至少上传2张图片'); if (this.data.huatanType == 1) { if (this.data.XDSflag != 4) { if (this.data.text == null || this.data.text.trim() == '') { return app.toast('请填写问题描述'); } } } } else { if (this.data.formFileurl.length == 0) { return app.toast('请上传问题图片'); } if (this.data.XDSflag == 4) { if (this.data.issueTypeIndex == null) { return app.toast('请选择问题类型'); } } else { if (!this.data.workTypeList[this.data.worktypeIndex]) { return app.toast('请选择问题分类'); } if (this.data.text == null || this.data.text.trim() == '') { return app.toast('请填写问题描述'); } } } // 问题单保存 // console.log('问题分类', this.data.workTypeList[this.data.worktypeIndex]); // wx.showLoading({ // title: '加载中', // mask: true, // }); if (this.data.XDSflag == 4) { // if (this.data.hazardRatio == null || this.data.hazardRatio == '') { // return app.toast('请填写危害率'); // } let url = app.globalData.httpsUrlServer + '/patrolTrack/issue/'; let formFileList = this.data.formFileurl; let newArr = []; formFileList.map(item => { let obj = { fileDes: item.fileDes, fileFormat: item.fileFormat, fileName: item.string1, fileSize: item.fileSize, fileUrl: item.fileUrl }; newArr.push(obj); }) // let fileCoordinates = // this.data.workZb.latitude + ',' + this.data.workZb.longitude; let fileCoordinates = util1.transformFromGCJToWGS( this.data.workZb.latitude, this.data.workZb.longitude ); let pestName = null; let pestId = null; if (this.data.wormIndex != null) { pestId = this.data.wormList[this.data.wormIndex].id; if (pestId == -1) { // if(!this.data.pestNewName){ // return app.toast('请输入病虫害名称'); // } pestName = this.data.pestNewName; if (!pestName) { pestId = null; } } else { pestName = this.data.wormList[this.data.wormIndex].pestName; } } if (this.data.dangerLevelIndex == null) { return app.toast('请选择危害程度'); } console.log(this.data.dangerLevelLIst[this.data.dangerLevelIndex], 'this.data.dangerLevelLIst[this.data.dangerLevelIndex]') let data = { patrolId: this.data.InspectionInfo.id, pestName: pestName, pestId: pestId, remark: this.data.remark, host: this.data.hostbiology, // dangerRate:this.data.hazardRatio, dangerLevel: this.data.dangerLevelLIst[this.data.dangerLevelIndex].id, dangerLevelName: this.data.dangerLevelLIst[this.data.dangerLevelIndex].name, issueType: 2, state: 0, dangerType: this.data.issueTypeList[this.data.issueTypeIndex].fWorkordertypeid, dangerTypeName: this.data.issueTypeList[this.data.issueTypeIndex].fName, // thresholdValue: this.data.issueTypeList[this.data.issueTypeIndex].thresholdValue, patrolTrackIssueFileList: newArr, currentCoordinates: fileCoordinates.longitude + ',' + fileCoordinates.latitude, temperature: this.data.temperature, humidity: this.data.humidity } app.postReqNew(url, data, (res) => { if (res.code == 0) { if (!(this.data.Type.indexOf(this.data.XDSflag) + 1)) { this.data.Type.push(this.data.XDSflag); } let str123 = this.data.Type.join(','); this.setData({ imgDailog: false, XDSflag: 1, text: null, formFileurl: [], typeStr: str123, isExist: data.dangerLevel == 0 ? 0 : 1, }); this.setData({ InspectionInfo: res.data, }); app.toast('问题上传成功'); this.loadWormList(); } else { this.setData({ imgDailog: false, XDSflag: 1, text: null, formFileurl: [], XDSflag: 1, // isExist: 0, }); app.toast('问题上传失败'); } }); } else { // 发送 请求 并向 问题数组中存值 this.setData({ workNum: this.data.workNum + 1, }); let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrackFile'; let obj = {}; let arr = []; this.data.formFileurl.forEach((v) => { v.fileCoordinates = this.data.workZb.latitude + ',' + this.data.workZb.longitude; v.remark = this.data.text; let obj = util1.transformFromGCJToWGS( this.data.workZb.latitude, this.data.workZb.longitude ); v.fileCoordinatesGc = obj.latitude + ',' + obj.longitude; v.createDate = util.formatTime(new Date()); v.string3 = this.data.workTypeList[this.data.worktypeIndex].fValuecode; v.string4 = this.data.workTypeList[this.data.worktypeIndex].fName; // 选择行道树 v.number4 = this.data.XDSflag; if (this.data.XDSflag == 3) { // v.number5 = this.data.huatanList[ // this.data.huatanIndex // ].id; // id // v.string5 = this.data.huatanList[this.data.huatanIndex].address; // v.string5 = // this.data.huatanList[this.data.huatanIndex].fAttractionsName + // '--' + // this.data.huatanList[this.data.huatanIndex].fAttractionsPlace; // 名字 } v.number2 = this.data.huatanFlag ? this.data.huatanType : '1'; }); obj.fileList = this.data.formFileurl; arr.push(obj); let data = { aassessNo: this.data.InspectionInfo.aassessNo, //巡查单号 fileList: arr, //图片列表 id: this.data.InspectionInfo.id, }; app.postReq(url, data, (res) => { if (res.status == 200) { if (!(this.data.Type.indexOf(this.data.XDSflag) + 1)) { this.data.Type.push(this.data.XDSflag); } let str123 = this.data.Type.join(','); this.setData({ imgDailog: false, XDSflag: 1, text: null, formFileurl: [], typeStr: str123, isExist: 1, }); app.toast('问题上传成功'); } else { this.setData({ imgDailog: false, XDSflag: 1, text: null, formFileurl: [], XDSflag: 1, // isExist: 0, }); app.toast('问题上传失败'); } }); } //清空图片 文本 关闭弹框 }, changeType(e) { this.setData({ worktypeIndex: e.detail.value, }); // if(this.data.XDSflag == 4){ // this.loadWormList(); // this.hazardRateInit(); // } }, issueTypeChange(e) { console.log(e, 'issueTypeChange') this.setData({ issueTypeIndex: e.detail.value, dangerLevelIndex: null }); this.loadWormList(); this.hazardRateInit(); }, //加载昆虫 loadWormList() { let that = this; let pestType = that.data.issueTypeList[that.data.issueTypeIndex].id; let url = app.globalData.httpsUrlServer + '/common/pestType/list'; let data = { pestType: pestType }; app.getReqNew(url, data, (res) => { let newA = [{ id: -1, pestName: '手动输入病虫名称' }]; let lists = [...newA, ...res.data]; that.setData({ wormList: lists, wormIndex: null }); }); }, changeWorm(e) { this.setData({ wormIndex: e.detail.value, }); }, pestNameInput(e) { this.setData({ pestNewName: e.detail.value, }); }, // 图片上传 uploader: function () { var that = this; var token = wx.getStorageSync('token'); let maxSize = 1024 * 1024 * 5; let maxLength = 5; wx.chooseImage({ count: 5, //最多可以选择的图片总数 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 success: function (res) { wx.showLoading({ title: '上传中', mask: true, }); for (let i = 0; i < res.tempFiles.length; i++) { if (res.tempFiles[i].size > maxSize) { flag = false; wx.showModal({ content: '图片太大,不允许上传', showCancel: false, success: function (res) { if (res.confirm) { //console.log('用户点击确定') } }, }); return; } } if (res.tempFiles.length > maxLength) { wx.showModal({ content: '最多能上传' + maxLength + '张图片', showCancel: false, success: function (res) { if (res.confirm) { //console.log('确定'); } }, }); } for (var i = 0; i < res.tempFilePaths.length; i++) { wx.uploadFile({ url: app.globalData.httpsUrlServer + '/file/uploadPatrolFile', filePath: res.tempFilePaths[i], name: 'images', header: { 'Content-Type': 'application/json;charset=UTF-8', token: token, fSource: 1, }, success: function (res) { if (res.statusCode == 200) { var data = JSON.parse(res.data); if (data.status == 200) { that.setData({ fFileurl: that.data.fFileurl.concat(data.data[0].fileDes), formFileurl: that.data.formFileurl.concat(data.data[0]), }); setTimeout(() => { wx.showToast({ title: '图片上传成功', mask: true, duration: 1000, }); }, 500); } else if (data.status == 600) { wx.showModal({ title: '登陆失败', content: '登录信息失效,请重新登录', success(res) { if (res.confirm) { wx.navigateTo({ url: '/pages/login/login', }); } else if (res.cancel) { wx.navigateTo({ url: '/pages/login/login', }); } }, }); } else { // 上传失败了 wx.showToast({ title: '图片上传失败', mask: true, duration: 2000, }); } } }, fail: function (res) { //console.log('失败', res); wx.showToast({ title: '图片上传失败', icon: 'fail', duration: 1000, success(res) { //console.log(res); }, }); }, }); } }, }); }, // 删除图片 clearImg: function (e) { var index = e.currentTarget.dataset.index; let that = this; //console.log(index) let arr2 = this.data.formFileurl.filter((v, i) => { return i == index; // 删除 线上 }); let url = app.globalData.httpsUrlServer + '/file/deleteFile'; let data = { fileDes: arr2[0], }; wx.showLoading({ title: '删除中', mask: true, }); app.postReq(url, data, (res) => { if (res.status == 200) { let arr = that.data.uploaderList.filter((v, i) => { return i != index; }); let arr1 = that.data.formFileurl.filter((v, i) => { return i != index; // 删除线上 上传 }); that.setData({ uploaderList: arr, formFileurl: arr1, }); app.toast('删除成功'); } else { app.toast('删除失败'); } }); }, // 预览图片 showImg: function (e) { //获取当前图片的下标 console.log(this.data.formFileurl); //console.log(e) var index = e.currentTarget.dataset.index; // //所有图片 var imgs = this.data.formFileurl.map((v) => { return v.fileUrl; }); wx.previewImage({ //当前显示图片 current: imgs[index].fileUrl, //所有图片 urls: imgs, }); }, // 查看路线 lineRoad() { var that = this; that.setData({ polyline: [{ points: that.data.arrPoint, color: '#FF0000', width: 9, arrowLine: true, borderWidth: 1, borderColor: '#555', }, ], }); }, // 文本域 input(e) { this.setData({ text: e.detail.value, }); }, // 按钮组 ↓ ↓ ↓ ↓ ↓ ↓ ↓ // 开始巡查 openAndEndSetting() { var that = this; // if (this.data.addldList.length == 0) { // return app.toast('请选择路段'); // } if (this.data.addVehicleList.length == 0) { return app.toast('请选择交通工具'); } // 开始巡查 wx.showModal({ title: '提示', content: '确定开始巡查', success(res) { if (res.confirm) { // 记录当前点位 wx.showToast({ title: '正在创建新的巡查记录', icon: 'loading', duration: 2000, }); wx.getLocation({ type: 'gcj02', isHighAccuracy: true, success(res) { var arr = []; arr.push({ latitude: res.latitude, longitude: res.longitude, }); that.getAddress(res.latitude, res.longitude); that.data.arrPoint = that.data.arrPoint.concat(arr); that.setData({ arrPoint: that.data.arrPoint, posObj: { latitude: res.latitude, longitude: res.longitude, }, }); that.createBuild(); }, }); // console.log('用户点击确定'); // that.build() // 开始执行 } else if (res.cancel) { console.log('用户点击取消'); } }, }); }, // 暂停巡查 stopSetting() { console.log('暂停巡查'); timerList.forEach((v) => { clearInterval(v); }); timerListJd.forEach((v) => { clearInterval(v); }); this.setData({ flag1: false, }); }, // 继续巡查 goSetting() { console.log('继续巡查'); var that = this; wx.getLocation({ type: 'gcj02', isHighAccuracy: true, success(res) { var arr = []; arr.push({ latitude: res.latitude, longitude: res.longitude, }); // that.getAddress(res.latitude, res.longitude); that.data.arrPoint = that.data.arrPoint.concat(arr); that.setData({ arrPoint: that.data.arrPoint, posObj: { latitude: res.latitude, longitude: res.longitude, }, }); }, }); Datetime = setInterval(() => { that.setInterval(); }, 1000); timerList.push(Datetime); Jdtime = setInterval(() => { that.tap1(); //获取坐标 that.lineRoad(); //画线 that.build(); // 更新数据 }, 10000); timerListJd.push(Jdtime); this.setData({ flag1: true, }); }, //重新巡查 restInspection() { this.stopSetting(); var that = this; console.log('重新巡查'); wx.showModal({ title: '提示', content: '是否要重新巡查', success(res) { if (res.confirm) { console.log('用户点击确定'); wx.showLoading({ title: '加载中', }); that.reovem(); } else if (res.cancel) { console.log('用户点击取消'); } }, }); }, // 生成本次巡查单 提交功能 sumbit() { var that = this; // 暂停 this.stopSetting(); wx.showModal({ title: '提示', content: '确定结束本次巡查吗?', success(res) { if (res.confirm) { // 保存最后一次 点位 wx.getLocation({ type: 'gcj02', isHighAccuracy: true, success(res) { var arr = []; arr.push({ latitude: res.latitude, longitude: res.longitude, }); that.getAddress(res.latitude, res.longitude); that.data.arrPoint = that.data.arrPoint.concat(arr); that.setData({ arrPoint: that.data.arrPoint, posObj: { latitude: res.latitude, longitude: res.longitude, }, }); that.isOverSpeed() // // 处理demo // // 发现问题工单 // if (that.data.workNum != 0) { // wx.showModal({ // title: '提示', // content: '巡查中发现问题,确定则创建工单', // success(res) { // if (res.confirm) { // that.build(); // that.sendGD(); // that.out(); // } else if (res.cancel) { // that.build(); // that.out(); // } // }, // }); // } else { // that.build(); // that.out(); // } }, }); } else if (res.cancel) { // 用户取消 } }, }); }, // 点击 发现问题 打开弹框 openDailog() { let that = this; this.setData({ imgDailog: true, huatanFlag: false, dangerLevelIndex: null, issueTypeIndex: null, host: '' }); that.getUserInfo(); // 记录当前点位 wx.getLocation({ type: 'gcj02', isHighAccuracy: true, success: (res) => { this.data.workZb.latitude = res.latitude; this.data.workZb.longitude = res.longitude; this.setData({ workZb: this.data.workZb, }); var httpUrl = 'https://free-api.heweather.net/s6/weather/now?' var loca = res.latitude + ',' + res.longitude; wx.request({ url: httpUrl, data: { location: loca, key: 'e3f16084c5bb4aeda37a6b5b4c7c0032' }, success: (res) => { let result = res.data.HeWeather6[0].now; that.setData({ temperature: result.tmp + '℃', humidity: result.hum }) } }) }, }); let id1 = that.data.parkList[that.data.parkIndex].fParkid; let id2; if (that.data.yhdwList.length == 0) { id2 = that.data.yhCompanyId; } else { // maintenanceCompanyId id2 = that.data.yhdwList[that.data.yhdwIndex].oldMaintenanceCompanyId; } that.getHuatanbyid(id1, id2); }, // 关闭 弹框 closeDailog() { this.setData({ imgDailog: false, XDSflag: 1, }); }, // 选择路段 bindPickerParkChange(e) { let index = e.detail.value; this.setData({ parkIndex: index, allldList: [], addldList: [], ldList: [], }); let id = this.data.parkList[this.data.parkIndex].fParkid; // 获取当前 路段下的养护单位 this.getYhdwList(id); }, // 选择养护单位 bindPickerParkChange2(e) { let index = e.detail.value; this.setData({ yhdwIndex: index, }); }, // 计时器 setInterval() { const that = this; var second = that.data.second; var minute = that.data.minute; var hours = that.data.hours; second++; if (second >= 60) { minute = Number(minute) + Math.floor(second / 60); second = 0; // 大于等于60秒归零 if (minute >= 60) { minute = 0; // 大于等于60分归零 hours++; if (hours < 10) { // 少于10补零 that.setData({ hours: '0' + hours, }); } else { that.setData({ hours: hours, }); } } if (minute < 10) { // 少于10补零 that.setData({ minute: '0' + minute, }); } else { that.setData({ minute: minute, }); } } if (second < 10) { // 少于10补零 that.setData({ second: '0' + second, }); } else { that.setData({ second: second, }); } }, // 获取地图上两点的距离 distance(lat1, lng1, lat2, lng2) { var that = this; lat1 = lat1 || 0; lng1 = lng1 || 0; lat2 = lat2 || 0; lng2 = lng2 || 0; var rad1 = (lat1 * Math.PI) / 180.0; var rad2 = (lat2 * Math.PI) / 180.0; var a = rad1 - rad2; var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0; var r = 6378137; var s = ( r * 2 * Math.asin( Math.sqrt( Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos(rad2) * Math.pow(Math.sin(b / 2), 2) ) ) ).toFixed(0); var kilimeter = (s * 1 + that.data.mileage * 1).toFixed(1); var kilimeter000 = ((s * 1 + that.data.mileage * 1) / 1000).toFixed(3); that.setData({ mileage: kilimeter, mileage1: kilimeter000, }); // that.Inspection() }, createBuild() { var that = this; let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrack'; // 开始坐标 处理 let start = ''; let startGc = ''; for (let k1 in that.data.arrPoint[0]) { start += that.data.arrPoint[0][k1]; start += ','; } start = start.slice(0, start.length - 1); // 开始 gc 坐标处理 let obj1 = util1.transformFromGCJToWGS( that.data.arrPoint[0].latitude, that.data.arrPoint[0].longitude ); for (let k4 in obj1) { startGc += obj1[k4]; startGc += ','; } startGc = startGc.slice(0, startGc.length - 1); let detailList = that.data.addldList; detailList.map(item => { item.roadId = item.id }) let VehicleArr = []; let addVehicleList = this.data.addVehicleList; addVehicleList.map(item => { VehicleArr.push(item.id); }) let data = { type: '', //绿地巡查 之前默认绿地巡查 为1; objectId: this.data.parkList[this.data.parkIndex].oldSectionId, //标段 objectName: this.data.parkList[this.data.parkIndex].sectionName, //表单名称 number3: this.data.yhCompanyId, // 养护单位id detailList: detailList, //选的路段 string3: VehicleArr.toString(), startTime: new Date().getTime(), //开始 时间 startCoordinates: start, //开始坐标 startCoordinatesGc: startGc, // 开始gc坐标 }; if (this.data.position == '绿化科中心') { // data.number3 = this.data.yhdwList[this.data.yhdwIndex].fYhcompanyid; data.number3 = this.data.yhdwList[this.data.yhdwIndex].oldMaintenanceCompanyId; } app.postReq(url, data, (res) => { if (res.status == 200) { wx.hideLoading(); Datetime = setInterval(() => { that.setInterval(); }, 1000); timerList.push(Datetime); Jdtime = setInterval(() => { that.tap1(); //获取坐标 that.lineRoad(); // 画线 that.build(); // 更新数据 }, 10000); timerListJd.push(Jdtime); that.setData({ flag: true, InspectionInfo: res.data, }); } }); }, // 更新 巡查单 build(islast, isSupple) { var that = this; // console.log(this.data.InspectionInfo); let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrack'; let data = this.data.InspectionInfo; // 总路程坐标处理 let totol = ''; let totolGc = ''; that.data.arrPoint.forEach((v) => { for (let k3 in v) { totol += v[k3]; totol += ','; } totol = totol.slice(0, totol.length - 1); totol += ';'; }); totol = totol.slice(0, totol.length - 1); let arr = []; that.data.arrPoint.forEach((v) => { let obj3 = util1.transformFromGCJToWGS(v.latitude, v.longitude); arr.push(obj3); }); arr.forEach((v) => { for (let k6 in v) { totolGc += v[k6]; totolGc += ','; } totolGc = totolGc.slice(0, totolGc.length - 1); totolGc += ';'; }); totolGc = totolGc.slice(0, totolGc.length - 1); // 总路程坐标处理 ↑ ↑ ↑ ↑ ↑ // 结束坐标处理 ↓↓↓↓↓↓↓↓ let end = ''; let endGc = ''; for (let k2 in that.data.arrPoint[that.data.arrPoint.length - 1]) { end += that.data.arrPoint[that.data.arrPoint.length - 1][k2]; end += ','; } end = end.slice(0, end.length - 1); let obj2 = util1.transformFromGCJToWGS( that.data.arrPoint[that.data.arrPoint.length - 1].latitude, that.data.arrPoint[that.data.arrPoint.length - 1].longitude ); for (let k5 in obj2) { endGc += obj2[k5]; endGc += ','; } endGc = endGc.slice(0, endGc.length - 1); // 结束坐标处理 ↑↑↑↑↑↑↑↑ data.totalCoordinates = totol; data.totalCoordinatesGc = totolGc; data.endCoordinates = end; data.endCoordinatesGc = endGc; data.endTime = util.formatTime(new Date()); data.totalTime = that.data.hours * 60 * 60 + that.data.minute * 60 + that.data.second * 1; data.mileage = that.data.mileage1; // data.fileList = that.data.WorkList; data.isExist = that.data.isExist; data.type = that.data.typeStr; // 最后一次提交,附加反编译地址 if (islast && !isSupple) { let roadList = []; let arrAddress = that.data.arrAddress; if (arrAddress.length > 0) { arrAddress.map(item => { roadList.push({ roadName: item }) }) } data.roadList = roadList; } if (isSupple) { let detailList = that.data.addldList; detailList.map(item => { item.roadId = item.id }) data.detailList = detailList; } app.postReq(url, data, (res) => { if (res.status == 200) { // that.setData({ // InspectionInfo: res.data, // }); // 最后一次提交,提示已匹配道路信息 if(isSupple && islast){ if (that.data.workNum != 0) { wx.showModal({ title: '提示', content: '巡查中发现问题,确定则创建工单?', success(res) { if (res.confirm) { that.sendGD(); that.out(); // wx.navigateBack({ // delta: 1 // }) } else if (res.cancel) { that.out(); // wx.navigateBack({ // delta: 1 // }) } }, }); } else { that.out(); // wx.navigateBack({ // delta: 1 // }) } } else if (islast && !isSupple) { that.setData({ 'InspectionInfo.roadList': [], detailList:res.data.detailList, matchedDailog:true }); } else { console.log('巡查进度更新'); that.setData({ InspectionInfo: res.data, }); } } else { console.log('巡查进度更新失败,请检查网络重试,本次巡查记录已经保存'); } }); }, openRoadDailog(){ let that = this; let id = that.data.parkList[that.data.parkIndex].id; if (id) { if (that.data.addldList.length == 0) { // this.getLdListbyid(id); that.getLdListbyid(); } that.setData({ checkboxEd: true, }); } else { return app.toast('请先选择路段'); } }, addRoadList(){ let that = this; this.build(true,true) }, cancelAndSave(){ let that = this; if (that.data.workNum != 0) { wx.showModal({ title: '提示', content: '巡查中发现问题,确定则创建工单?', success(res) { if (res.confirm) { that.sendGD(); that.out(); // wx.navigateBack({ // delta: 1 // }) } else if (res.cancel) { that.out(); // wx.navigateBack({ // delta: 1 // }) } }, }); } else { that.out(); // wx.navigateBack({ // delta: 1 // }) } }, isOverSpeed(type) { var that = this; // console.log(this.data.InspectionInfo); let url = app.globalData.httpsUrlServer + '/lhgyWork/patrolTrackIsSpeeding'; let data = this.data.InspectionInfo; // 总路程坐标处理 let totol = ''; let totolGc = ''; that.data.arrPoint.forEach((v) => { for (let k3 in v) { totol += v[k3]; totol += ','; } totol = totol.slice(0, totol.length - 1); totol += ';'; }); totol = totol.slice(0, totol.length - 1); let arr = []; that.data.arrPoint.forEach((v) => { let obj3 = util1.transformFromGCJToWGS(v.latitude, v.longitude); arr.push(obj3); }); arr.forEach((v) => { for (let k6 in v) { totolGc += v[k6]; totolGc += ','; } totolGc = totolGc.slice(0, totolGc.length - 1); totolGc += ';'; }); totolGc = totolGc.slice(0, totolGc.length - 1); // 总路程坐标处理 ↑ ↑ ↑ ↑ ↑ // 结束坐标处理 ↓↓↓↓↓↓↓↓ let end = ''; let endGc = ''; for (let k2 in that.data.arrPoint[that.data.arrPoint.length - 1]) { end += that.data.arrPoint[that.data.arrPoint.length - 1][k2]; end += ','; } end = end.slice(0, end.length - 1); let obj2 = util1.transformFromGCJToWGS( that.data.arrPoint[that.data.arrPoint.length - 1].latitude, that.data.arrPoint[that.data.arrPoint.length - 1].longitude ); for (let k5 in obj2) { endGc += obj2[k5]; endGc += ','; } endGc = endGc.slice(0, endGc.length - 1); // 结束坐标处理 ↑↑↑↑↑↑↑↑ data.totalCoordinates = totol; data.totalCoordinatesGc = totolGc; data.endCoordinates = end; data.endCoordinatesGc = endGc; data.endTime = util.formatTime(new Date()); data.totalTime = that.data.hours * 60 * 60 + that.data.minute * 60 + that.data.second * 1; data.mileage = that.data.mileage1; // data.fileList = that.data.WorkList; data.isExist = that.data.isExist; data.type = that.data.typeStr; let roadList = []; let arrAddress = that.data.arrAddress; if (arrAddress.length > 0) { arrAddress.map(item => { roadList.push({ roadName: item }) }) } data.roadList = roadList; app.postReqNew2(url, { data: data }, (res) => { if (res.status == 200) { if (res.data) { wx.navigateBack({ delta: 1 }) } else { wx.showModal({ title: '提示', content: '巡查失败!', success(res) { if (res.confirm) { wx.navigateBack({ delta: 1 }) } } }) } } }); }, NavBack() { let that = this; if (!this.data.flag) { wx.navigateBack({ delta: 1 }) } else { if(that.data.matchedDailog){ that.cancelAndSave(); }else{ wx.showModal({ title: '提示', content: '确定结束本次巡查吗?', success(res) { if (res.confirm) { // 保存最后一次 点位 wx.getLocation({ type: 'gcj02', isHighAccuracy: true, success(res) { var arr = []; arr.push({ latitude: res.latitude, longitude: res.longitude, }); that.getAddress(res.latitude, res.longitude); that.data.arrPoint = that.data.arrPoint.concat(arr); that.setData({ arrPoint: that.data.arrPoint, posObj: { latitude: res.latitude, longitude: res.longitude, }, }); that.isOverSpeed('back'); }, }); } else if (res.cancel) { // 用户取消 } }, }); } } }, // 生成工单 sendGD(val) { var that = this; let pages = getCurrentPages(); //页面栈 let beforePage = ''; beforePage = pages[pages.length - 1]; let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrackWork'; let data = { id: this.data.InspectionInfo.id, }; app.postReq(url, data, (res) => { if (res.status == 200) { if (val == 'flag') { beforePage.onPullDownRefresh(); } } }); }, // 删除 巡查单 reovem() { var that = this; let url = app.globalData.httpsUrlServer + '/lhgyWork/deletePatrolTrack'; let data = { id: this.data.InspectionInfo.id, }; app.postReq(url, data, (res) => { if (res.status == 200) { that.setData({ flag: false, flag1: true, hours: '0' + 0, // 时 minute: '0' + 0, // 分 second: '0' + 0, // 秒 polyline: [], //路线数组 workNum: 0, //问题数量 addldList: [], // 要巡查的 路段 arrPoint: [], //坐标数组 InspectionInfo: {}, addVehicleList: [] // 交通工具 }); wx.hideLoading(); } else {} }); }, // 页面进入加载 onLoad: function (options) { if (options.listType) { this.setData({ listType: options.listType, }); } wx.disableAlertBeforeUnload({ message: '测试' }) var that = this; // 获取 选择项(公园,路段,等选择功能...) that.userSelect(); that.getWorkTypeList(); // 检测是否开启定位功能 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ wx.startLocationUpdateBackground({ success(res) { console.log('开启后台定位', res); }, fail(res) { console.log('开启后台定位失败', res); }, }); that.checkLocation(); // 检测是否开启定位功能 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //获取当前的坐标 wx.getLocation({ type: 'gcj02', // isHighAccuracy: true, success: (res) => { that.setData({ posObj: { latitude: res.latitude, longitude: res.longitude, }, }); }, }); }, onUnload() { }, getUserInfo() { let that = this; // await let url = app.globalData.httpsUrlServer + '/sysroleinfo/selectRoleInfoByUserId'; wx.request({ url: url, method: 'get', header: { Accept: 'application/json', 'content-type': 'application/json;charset=UTF-8', token: wx.getStorageSync('token'), fSource: 1, }, success: function (res) { let userInfo = res.data.data; let flagArr = [false, false, false]; userInfo.map(item => { if (item.fRolecode == 'ZBY') { flagArr[0] = true; } if (item.fRolecode == 'LHKYHDW') { flagArr[1] = true; } if (item.fRolecode == 'LHK' || item.fRolecode == 'XTGLY') { flagArr[2] = true; } }) if (flagArr[2] || (flagArr[0] && flagArr[1])) { let xdsList = [{ name: '行道树', id: 1, checked: (that.data.listType == '' || that.data.listType == '1') ? true : false }, { name: '绿地', id: 2, checked: that.data.listType == '2' ? true : false }, { name: '花坛', id: 3, checked: that.data.listType == '3' ? true : false }, { name: '病虫害', id: 4, checked: that.data.listType == '4' ? true : false } ] that.setData({ xdsList: xdsList }) } else if (flagArr[1]) { let xdsList = [{ name: '行道树', id: 1, checked: (that.data.listType == '' || that.data.listType == '1') ? true : false }, { name: '绿地', id: 2, checked: that.data.listType == '2' ? true : false }, { name: '花坛', id: 3, checked: that.data.listType == '3' ? true : false } ] that.setData({ xdsList: xdsList }) } else if (flagArr[0]) { console.log(this.listType, 'flagArr[0]'); let xdsList = [{ name: '病虫害', id: 4, checked: true }] that.setData({ xdsList: xdsList }) let obj = { detail: { value: 4 } } that.toggleXDS(obj); } const typeIndex = that.data.xdsList.findIndex(o => { return o.checked == true; }); if (typeIndex > -1) { that.toggleXDS({ detail: { value: that.data.xdsList[typeIndex].id, } }); // that.issueTypeChange({ // detail: { // value: typeIndex, // } // }); } }, fail: function (err) { reject(err); }, }); }, onUnload: function () {}, onShow: function () {}, onHide() {}, // 获取 数据 ↓ ↓ ↓ ↓ ↓ // 判断人员, 选择公园权限 ( 选择项 ) userSelect() { let that = this; let position = wx.getStorageSync('position'); let position2 = wx.getStorageSync('position2'); // 如果是 中心 人员 获取所有路段 console.log(position) console.log(position2) // 如果是 养护人员 获取自己的 路段 that.getLDbyId(); }, // 查询所有标段 根据养护单位id 查询路段标 // getLDbyId() { // wx.showLoading({ // title: '加载中', // mask: true, // }); // let that = this; // let url = // app.globalData.httpsUrlServer + // // "/t-lhgy-section/selectSectionByCompany" // '/tLhgyFacilitySummaryRoad/selectRoadInfoByYhCompanyId'; // console.log('养护公司id:'+ wx.getStorageSync('yhCompanyId')) // let data = { // // yhCompanyId: wx.getStorageSync('yhCompanyId'), // maintenanceCompanyId: wx.getStorageSync('maintenanceCompanyId'), // }; // this.setData({ // yhCompanyId: wx.getStorageSync('yhCompanyId'), // }); // app.postReq(url, data, (res) => { // if (res.status == 200) { // that.setData({ // parkList: res.data, // }); // wx.hideLoading(); // } // }); // }, getLDbyId() { wx.showLoading({ title: '加载中', mask: true, }); let that = this; let url = app.globalData.httpsUrlServer + '/parkInfoApp/selectAppParkInfoList'; // let data = { // // yhCompanyId: wx.getStorageSync('yhCompanyId'), // maintenanceCompanyId: wx.getStorageSync('maintenanceCompanyId'), // }; this.setData({ yhCompanyId: wx.getStorageSync('yhCompanyId'), maintenanceCompanyId: wx.getStorageSync('maintenanceCompanyId'), }); console.log('getLDbyId') app.getReq(url, (res) => { console.log('getLDbyId-res', res) if (res.status == 200) { that.setData({ parkList: res.data, }); wx.hideLoading(); } }); }, // 获得当前路段 的所有 路和路段 // getLdListbyid(id) { // wx.showLoading({ // title: '加载中', // mask: true, // }); // let url = // app.globalData.httpsUrlServer + // '/tLhgyFacilitySummaryRoad/selectBySectionId'; // let data = { // sectionId: id, // }; // app.postReq(url, data, (res) => { // // console.log("res", res) // if (res.status == 200) { // let arr = res.data; // let newArr = []; // arr.forEach((v) => { // if (v.roadScopeList) { // v.roadScopeList.forEach((item) => { // newArr.push(item); // }); // } // }); // this.setData({ // ldList: newArr, // allldList: newArr, //所有的路段 留查询使用 // }); // // console.log('路和路段'); // // console.log(this.data.ldList); // wx.hideLoading(); // } // }); // }, getLdListbyid() { let that = this; wx.showLoading({ title: '加载中', mask: true, }); let url = app.globalData.httpsUrlServer + '/road/selectRoadList'; // let url = // app.globalData.httpsUrlServer + // '/road/selectRoadList'; let data = { sectionId: that.data.parkList[that.data.parkIndex].fParkid, maintenanceCompanyId: that.data.maintenanceCompanyId }; if (that.data.yhdwList.length == 0) { data.maintenanceCompanyId = that.data.maintenanceCompanyId } else { data.maintenanceCompanyId = that.data.yhdwList[that.data.yhdwIndex].id } app.getReqNew(url, data, (res) => { if (res.code == 0) { let arr = res.data; // let newArr = []; // arr.forEach((v) => { // if (v.roadScopeList) { // v.roadScopeList.forEach((item) => { // newArr.push(item); // }); // } // }); this.setData({ ldList: arr, allldList: arr, //所有的路段 留查询使用 }); // console.log('路和路段'); // console.log(this.data.ldList); wx.hideLoading(); } }); }, getYhdwList(id) { wx.showLoading({ title: '加载中', mask: true, }); let that = this; let url = app.globalData.httpsUrlServer + '/maintenance/company/selectMaintenanceCompanyBySectionId'; let data = { sectionId: id, }; app.getReqNew(url, data, (res) => { // console.log("res", res) if (res.code == 0) { that.setData({ yhdwList: res.data, }); wx.hideLoading(); } }); }, // 获取问题类型 getWorkTypeList(val = 1) { let that = this; // 获取等待 app.loading('loading~'); if (val == 4) { let surl = app.globalData.httpsUrlServer + '/common/kind/list'; let data = { type: 1 } app.getReqNew(surl, data, (res) => { if (res.code == "0") { let lists = res.data; this.setData({ issueTypeList: lists, }); } app.hideloading(); }); } else { let url = app.globalData.httpsUrlServer + '/woworkordertype/selectOrderTypeList'; let data = { }; app.getReq(url, (res) => { console.log('sadfaf', res) if (res.status == 200) { let lists = res.data.filter(item => item.fParentid == 3); this.setData({ workTypeList: lists, }); // that.hazardRateInit(); // that.loadWormList(); } app.hideloading(); }); } // if (val == 4) { // let surl = app.globalData.httpsUrlServer + // '/common/kind/list'; // let data = { // type: 1 // } // // let lists = [{fValuecode:1,fName:'食叶性害虫'}, // // {fValuecode:2,fName:'刺吸性害虫'}, // // {fValuecode:3,fName:'钻蛀性害虫'}, // // {fValuecode:4,fName:'地下害虫'}, // // {fValuecode:5,fName:'病害类'}] // app.getReqNew(surl, data, (res) => { // if (res.code == "0") { // let lists = res.data; // // lists.map(item =>{ // // item.fValuecode = item.id; // // item.fName = item.kindName; // // }) // this.setData({ // issueTypeList: lists, // }); // // that.hazardRateInit(); // // that.loadWormList(); // } // app.hideloading(); // }); // // this.setData({ // // workTypeList: lists, // // }); // // app.hideloading(); // } else { // app.postReq(url, data, (res) => { // if (res.status == 200) { // this.setData({ // workTypeList: res.data, // }); // app.hideloading(); // } // }); // } }, hazardRateInit() { let arr1 = []; let issueTypeList = this.data.issueTypeList; let issueTypeIndex = this.data.issueTypeIndex; if (issueTypeList[issueTypeIndex].id == 1 || issueTypeList[issueTypeIndex].id == 2 || issueTypeList[issueTypeIndex].id == 5) { arr1 = [{ name: '轻度(≤10%)', id: 0, label: '≤10%' }, { name: '中度(>10%,≤15%)', id: 1, label: '>10%,≤15%' }, { name: '重度(>15%)', id: 2, label: '>15%' } ]; } else if (issueTypeList[issueTypeIndex].id == 3 || issueTypeList[issueTypeIndex].id == 4) { arr1 = [{ name: '轻度(零星为害)', id: 0, label: '零星为害' }, { name: '中度(≤3%)', id: 1, label: '≤3%' }, { name: '重度(>3%)', id: 2, label: '>3%' } ]; } else { arr1 = [{ name: '轻度(≤10%)', id: 0, label: '≤10%' }, { name: '中度(>10%,≤15%)', id: 1, label: '>10%,≤15%' }, { name: '重度(>15%)', id: 2, label: '>15%' } ]; } this.setData({ dangerLevelLIst: arr1, // hazardRatio:arr1[this.data.dangerLevelIndex].label }) }, // 设置项 ↓ ↓ ↓ ↓ ↓ ↓ //校验位置权限是否打开 checkLocation() { let that = this; //选择位置,需要用户授权 wx.getSetting({ success(res) { //console.log("res", res) if ( !res.authSetting['scope.userLocation'] && !res.authSetting['scope.userLocationBackground'] ) { wx.authorize({ scope: 'scope.userLocation', success() { wx.showToast({ //这里提示失败原因 title: '授权成功!', duration: 1500, }); }, fail() { that.showSettingToast('需要授权位置信息'); }, }); } }, }); }, // 打开权限设置页提示框 showSettingToast: function (e) { var that = this; wx.showModal({ title: '提示!', confirmText: '去设置', showCancel: false, content: e, success: function (res) { if (res.confirm) { wx.openSetting({ success: (res) => { //console.log("设置res", res) if (res.errMsg == 'openSetting:ok') { // wx.navigateBack({ // delta: 1, // }) wx.hideToast(); setTimeout(() => { app.toast('设置成功'); that.onLoad(); }, 500); } }, fail: (err) => { //console.log("err", err) wx.showToast({ //这里提示失败原因 title: '授权失败', duration: 1500, }); }, }); } }, }); }, onHide() {}, onShow: function () {}, out() { this.setData({ endFlag: true, }); let pages = getCurrentPages(); //页面栈 let beforePage = ''; beforePage = pages[pages.length - 2]; wx.navigateBack({ delta: 1, //返回上一级页面 success: function () { beforePage.onPullDownRefresh(); }, }); }, out1() { this.setData({ endFlag: true, }); let pages = getCurrentPages(); //页面栈 let beforePage = ''; beforePage = pages[pages.length - 2]; beforePage.onPullDownRefresh(); }, onUnload() { var that = this; that.stopSetting(); if (this.data.arrPoint.length == 0) { return; } if (this.data.endFlag) return; if (that.data.workNum != 0) { wx.showModal({ title: '提示', content: '巡查中发现问题,确定则创建工单', success(res) { if (res.confirm) { that.build(); that.sendGD('flag'); } else if (res.cancel) { that.build(); that.out1(); } }, }); } else { that.build(); that.out1(); } }, });