let Utils = require("../../utils/util") let Constant = require('../../utils/constant.js'); let app = getApp(); Page({ /** * 页面的初始数据 */ data: { m_userInfo: app.globalData.userInfo, m_CurrentStationID: 1, //当前考核的泵站ID context: "", canvasw: 0, //画布宽度 canvash: 0, //画布高度 canvasSrc: "", arrx: [], isButtonDown: false, //是否在绘制中 currentCriteriasIndex: 1, //当前评分项的序号 currentCriteriasList: [], //当前的评分标准内容 visibleCriteriasModel: false, //显示评分标准弹框 testAbnormalDesc: "运行异常", m_currentDate: "", //当前日期 m_currentLoaction: "", //当前位置 exceptionDesc: "", //异常描述 visibeStandard: false, //显示隐藏评分标准提示 currentStatus: true, //当前考核项的状态 isVisibleModel: false, m_CurrentAllScore: 0, //总分 m_CurrentCompletedNum: 0, //当前考核了的数量 m_AllCompletedNum: 0, //考核总数 m_DataList: [], isHaveSave: false, //是否以保存 isComplateSing: false, //是否已签名 show: true, //退出提示框显示状态 overlayStyle: "background-color: rgba(0, 0, 0, 0.7)" //退出提示框显示蒙版样式 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getCurrentLocation() this.setData({ m_currentDate: this.getCurrentYMD(), m_CurrentStationID: options.stationID }) this.startCanvas() this.initAssessTableData() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, onUnload() {}, // 初始化考核列表数据 initAssessTableData() { let stationID = this.data.m_CurrentStationID wx.showLoading({ title: '数据加载中...', }) wx.request({ method: 'GET', url: Constant.BASE_SERVER_URL + 'inspectv4/StationScore/IngRecord/GetRecords', data: { StaionID: stationID, }, success: res => { wx.hideLoading() // console.log(res, 145) let result = res.data if (result.Code != 0) { wx.showToast({ title: result.Message, icon: "error", duration: 1000 }) return; } let responesData = result.Data let assessTableData = [] for (let i = 0; i < responesData.length; i++) { const element = responesData[i]; let obj = { itemID: "", name: "", //考核名称 currentStatus: null, //当前的考核状态 stdScore: "", //最高分值 maxScore: "", score: "", //当前分值 scoreDesc: "", //评分标准 abnomalDesc: "", //异常描述 criterias: [], //评分标准项 isShowScoreDesc: false, //是否显示评分标准 isShowAbnomalDesc: false, //是否显示异常描述 isHaveChild: false, //是否有子类 isExpand: true, //是否展开 child: [] //子类列表 } if (element.Items.length == 0) { break; } //判断返回的数据的项的长度只有1个的情况 if (element.Items.length > 0 && element.Items.length == 1) { let item = element.Items[0] if (item.Criterias.length == 0) { item.Criterias.push({ StdScore: "", Note: "" }) } if (item.Score == -1) { item.Score = "" } if (item.Score == "") { obj.currentStatus = null } else if (item.Score < item.MaxScore) { obj.currentStatus = false } else if (item.Score == item.MaxScore) { obj.currentStatus = true } obj.itemID = item.ItemID obj.name = item.Name obj.score = item.Score obj.abnomalDesc = item.Note obj.maxScore = item.MaxScore // obj.scoreDesc = item.Criterias[0].Note // obj.stdScore = item.Criterias[0].StdScore obj.criterias = item.Criterias assessTableData.push(obj) this.data.m_AllCompletedNum++ //判断返回的数据的项的长度大于1个的情况 } else if (element.Items.length > 1) { obj.name = element.Name obj.isHaveChild = true let objChilds = [] for (let j = 0; j < element.Items.length; j++) { let child = {} const childs = element.Items[j]; if (childs.Criterias.length == 0) { childs.Criterias.push({ StdScore: " ", Note: " " }) } if (childs.Score == -1) { childs.Score = "" } if (childs.Score == "") { child.currentStatus = null } else if (childs.Score < childs.MaxScore) { child.currentStatus = false } else if (childs.Score == childs.MaxScore) { child.currentStatus = true } child.itemID = childs.ItemID child.name = childs.Name child.maxScore = childs.MaxScore child.score = childs.Score // child.stdScore = childs.Criterias[0].StdScore // child.scoreDesc = childs.Criterias[0].Note child.abnomalDesc = childs.Note child.criterias = childs.Criterias child.isExpand = false //是否展开 child.isShowScoreDesc = false child.isShowAbnomalDesc = false //是否显示评分标准 objChilds.push(child) this.data.m_AllCompletedNum++ } obj.child = objChilds assessTableData.push(obj) } } this.setData({ m_DataList: assessTableData, m_AllCompletedNum: this.data.m_AllCompletedNum }) this.getCountSroce() this.getCurrentProgress() // console.log(this.data.m_DataList,158) }, fail: err => { wx.hideLoading() wx.showToast({ title: "接口请求失败" + err, icon: "error", duration: 1000 }) // console.log(err) } }) }, //初始化签名画布的配置 startCanvas: function () { //画布初始化执行 var that = this; //获取系统信息 wx.getSystemInfo({ success: function (res) { let canvasw = res.windowWidth; let canvash = res.windowHeight; that.setData({ canvasw: canvasw, canvash: canvash }); } }); this.initCanvas(); this.cleardraw(); }, //初始化函数 initCanvas: function () { let context = wx.createCanvasContext('canvas'); context.beginPath() context.fillStyle = 'rgba(255, 255, 255, 0)'; context.setStrokeStyle('#000000'); context.setLineWidth(4); context.setLineCap('round'); context.setLineJoin('round'); this.setData({ context: context }) }, canvasStart: function (event) { this.setData({ isButtonDown: true }) let arrx = this.data.arrx let arry = this.data.arry let arrz = this.data.arrz arrz.push(0); arrx.push(event.changedTouches[0].x); arry.push(event.changedTouches[0].y); this.setData({ arrx: arrx, arry: arry, arrz: arrz }) }, canvasMove: function (event) { let context = this.data.context let isButtonDown = this.data.isButtonDown let arrx = this.data.arrx let arry = this.data.arry let arrz = this.data.arrz let canvasw = this.data.canvasw let canvash = this.data.canvash if (isButtonDown) { arrz.push(1); arrx.push(event.changedTouches[0].x); arry.push(event.changedTouches[0].y); } for (var i = 0; i < arrx.length; i++) { if (arrz[i] == 0) { context.moveTo(arrx[i], arry[i]) } else { context.lineTo(arrx[i], arry[i]) } } context.clearRect(0, 0, canvasw, canvash); context.setStrokeStyle('#000000'); context.setLineWidth(4); context.setLineCap('round'); context.setLineJoin('round'); context.stroke(); context.draw(false); this.setData({ context: context, arrx: arrx, arry: arry, arrz: arrz }) }, canvasEnd: function (event) { this.setData({ isButtonDown: false }) }, //清除画布 cleardraw: function () { let context = this.data.context let arrx = this.data.arrx let arry = this.data.arry let arrz = this.data.arrz let canvasw = this.data.canvasw let canvash = this.data.canvash arrx = []; arry = []; arrz = []; context.clearRect(0, 0, canvasw, canvash); context.draw(true); this.setData({ context: context, arrx: arrx, arry: arry, arrz: arrz }) }, //将绘制的canvas图形转换成为图片 uploadImg() { var that = this //生成图片 wx.canvasToTempFilePath({ canvasId: 'canvas', //设置输出图片的宽高 // destWidth:150, // destHeight:150, // fileType:'jpg', quality: 1.0, success: function (res) { // console.log(res) // canvas图片地址 res.tempFilePath that.setData({ isComplateSing: true, canvasSrc: res.tempFilePath, isVisibleModel: false }) }, fail: function () { wx.showModal({ title: '提示', content: 'canvas生成图片失败。微信当前版本不支持,请更新到最新版本!', showCancel: false }); }, complete: function () {} }) }, //获取当前的年月日 getCurrentYMD() { let ymd = Utils.getNewDateArry.getNewDateArry().ymd let currentData = ymd[0] + "-" + ymd[1] + "-" + ymd[2] return currentData }, //获取当前的定位 getCurrentLocation() { let _this = this wx.getLocation({ type: "gcj02", altitude: true, success: res => { // console.log(res, 33) if (res.longitude == 0 || res.latitude == 0) { //当前位置信号较弱,请换个位置尝试 wx.showModal({ title: '提示', content: '当前信号较弱请换个位置尝试', success(res) { if (res.confirm) { return; } else if (res.cancel) { return; } } }) } let latitude = res.latitude let longitude = res.longitude _this.getAddressInfo(latitude, longitude) }, fail: err => { console.log(err) } }) }, //根据经纬度获取当前的位置信息 getAddressInfo(lat, long) { let _this = this //发送请求通过经纬度反查地址信息 let getAddressUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + long + "&key=GFDBZ-D3NKX-LNL4Z-TSWGU-RYCE3-4HB3I"; wx.request({ url: getAddressUrl, success: function (result) { _this.setData({ m_currentLoaction: result.data.result.address }) return }, fail: err => { wx.showModal({ title: '提示', content: '获取位置失败请打开定位' }) console.log(err) return; } }); }, // 选择当前位置 tapChooseLocation() { let that = this; wx.chooseLocation({ success: function (res) { console.log("chooseLocation", res) that.setData({ m_currentLoaction: res.name, }) }, fail: err => { wx.showModal({ title: '提示', content: '选择位置失败' }) return } }); }, //分值输入 点击完成的时候触发 confirmInput(e) { let index = e.currentTarget.dataset.index if (e.detail.value == "") { this.data.m_DataList[index].score = e.detail.value this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() return } let value = parseInt(e.detail.value) if (value > this.data.m_DataList[index].maxScore || value < this.data.m_DataList[index].maxScore) { this.data.m_DataList[index].score = value this.data.m_DataList[index].currentStatus = false this.data.m_DataList[index].isShowScoreDesc = true this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() return } if (value == this.data.m_DataList[index].maxScore) { this.data.m_DataList[index].currentStatus = true } this.data.m_DataList[index].score = value this.data.m_DataList[index].isShowScoreDesc = false this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() }, //添加分数 addScore(e) { let index = e.currentTarget.dataset.index let currentScore = this.data.m_DataList[index].score //当前分数 let maxScore = this.data.m_DataList[index].maxScore //最大分数 if (currentScore == "") { currentScore = 0 } if (currentScore >= maxScore) { this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() return } ++currentScore if (currentScore == maxScore) { this.data.m_DataList[index].currentStatus = true } else { this.data.m_DataList[index].currentStatus = false } this.data.m_DataList[index].score = currentScore this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() }, //减去分数 reduceScore(e) { let index = e.currentTarget.dataset.index let currentScore = this.data.m_DataList[index].score //当前分数 let maxScore = this.data.m_DataList[index].maxScore //最大分数 if (currentScore == "") { currentScore = 0 } if (currentScore <= 0) { this.data.m_DataList[index].currentStatus = false this.data.m_DataList[index].score = currentScore this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() return } --currentScore if (currentScore < maxScore) { this.data.m_DataList[index].currentStatus = false } this.data.m_DataList[index].score = currentScore this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() }, //子项添加分数 addChildScore(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex let currentScore = this.data.m_DataList[index].child[childIndex].score //当前分数 let maxScore = this.data.m_DataList[index].child[childIndex].maxScore //最大分数 // console.log( this.data.m_DataList[index].child,519) if (currentScore == "") { currentScore = 0 } if (currentScore >= maxScore) { this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() return } ++currentScore if (currentScore == maxScore) { this.data.m_DataList[index].child[childIndex].currentStatus = true } else { this.data.m_DataList[index].currentStatus = false } this.data.m_DataList[index].child[childIndex].score = currentScore this.setData({ m_DataList: this.data.m_DataList }) let childcurrentAllScore = 0 //所有子项的当前分数总和 let childMaxAllScore = 0 //所有子项的最大分数总和 this.data.m_DataList[index].child.forEach(item => { childcurrentAllScore = childcurrentAllScore + (item.score == "" ?0 : item.score) childMaxAllScore = childMaxAllScore + item.maxScore }) if (childcurrentAllScore == childMaxAllScore) { this.data.m_DataList[index].currentStatus = true this.setData({ m_DataList:this.data.m_DataList }) } this.getCountSroce() this.getCurrentProgress() }, //子项减去分数 reduceChildScore(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex let currentScore = this.data.m_DataList[index].child[childIndex].score //当前分数 let maxScore = this.data.m_DataList[index].child[childIndex].maxScore //最大分数 if (currentScore == "") { currentScore = 0 } if (currentScore <= 0) { this.data.m_DataList[index].currentStatus = false this.data.m_DataList[index].child[childIndex].score = currentScore this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() return } --currentScore if (currentScore < maxScore) { this.data.m_DataList[index].currentStatus = false } this.data.m_DataList[index].child[childIndex].score = currentScore this.setData({ m_DataList: this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() }, //有多层考核项时 分值输入点击完成的时候触发 confirmChildInput(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex let maxScore = this.data.m_DataList[index].child[childIndex].maxScore // console.log(this.data.m_DataList[index].child[childIndex],579) if(e.detail.value < 0 || e.detail.value > maxScore){ e.detail.value = this.data.m_DataList[index].child[childIndex].score this.data.m_DataList[index].child[childIndex].currentStatus = false } if(e.detail.value == maxScore){ this.data.m_DataList[index].child[childIndex].currentStatus = true } let value = parseInt(e.detail.value == ""? 0 : e.detail.value) // if (value > this.data.m_DataList[index].child[childIndex].maxScore || value < 0) { // return // } // console.log(value,628) this.data.m_DataList[index].child[childIndex].score = value this.data.m_DataList[index].child[childIndex].isShowScoreDesc = false this.setData({ m_DataList: this.data.m_DataList }) let childcurrentAllScore = 0 //所有子项的当前分数总和 let childMaxAllScore = 0 //所有子项的最大分数总和 this.data.m_DataList[index].child.forEach(item => { childcurrentAllScore = childcurrentAllScore + (item.score == "" ?0 : item.score) childMaxAllScore = childMaxAllScore + item.maxScore }) if (childcurrentAllScore == childMaxAllScore) { console.log(642) this.data.m_DataList[index].currentStatus = true }else { this.data.m_DataList[index].currentStatus = false } this.setData({ m_DataList:this.data.m_DataList }) this.getCountSroce() this.getCurrentProgress() }, //监听异常情况描述的输入 inputDesc(e) { let index = e.currentTarget.dataset.index let value = e.detail.value this.data.m_DataList[index].abnomalDesc = value this.setData({ m_DataList: this.data.m_DataList }) }, childInputDesc(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex let value = e.detail.value this.data.m_DataList[index].child[childIndex].abnomalDesc = value this.setData({ m_DataList: this.data.m_DataList }) }, //显示隐藏异常描述 tapVisibleStandard(e) { let index = e.currentTarget.dataset.index this.data.m_DataList[index].isShowAbnomalDesc = !this.data.m_DataList[index].isShowAbnomalDesc this.setData({ m_DataList: this.data.m_DataList }) }, //显示评分标准选择 tapVisibleCriterias(e) { // console.log(e,628) let type = e.currentTarget.dataset.type let index = e.currentTarget.dataset.index if (type == "normal") { this.data.currentCriteriasList = this.data.m_DataList[index].criterias } else if (type == "child") { let childIndex = e.currentTarget.dataset.childIndex this.data.currentCriteriasList = this.data.m_DataList[index].child[childIndex].criterias } this.data.visibleCriteriasModel = true this.data.currentCriteriasIndex = index + 1 this.setData({ m_DataList: this.data.m_DataList, visibleCriteriasModel: this.data.visibleCriteriasModel, currentCriteriasList: this.data.currentCriteriasList, currentCriteriasIndex: this.data.currentCriteriasIndex }) // console.log(this.data.currentCriteriasList,645) }, //关闭评分标准弹框 hideCriteriasModel(e) { let index = e.currentTarget.dataset.index this.data.visibleCriteriasModel = false this.setData({ m_DataList: this.data.m_DataList, visibleCriteriasModel: this.data.visibleCriteriasModel }) }, //考核状态选择 tapStatus(e) { let index = e.currentTarget.dataset.index if (this.data.m_DataList[index].currentStatus == null) { this.data.m_DataList[index].currentStatus = true this.data.m_DataList[index].score = this.data.m_DataList[index].maxScore if (this.data.m_DataList[index].child.length > 0) { this.data.m_DataList[index].child.forEach(element => { element.score = element.maxScore element.currentStatus = true }); } this.getCountSroce() this.getCurrentProgress() } else if (this.data.m_DataList[index].currentStatus == true) { if (this.data.m_DataList[index].child.length > 0) { this.data.m_DataList[index].child.forEach(element => { element.currentStatus = null }); } this.data.m_DataList[index].currentStatus = null this.getCurrentProgress() } else if (this.data.m_DataList[index].currentStatus == false) { this.data.m_DataList[index].currentStatus = null this.getCurrentProgress() } this.setData({ m_DataList: this.data.m_DataList, }) }, //正常考核状态 tapStatusNormal(e) { let index = e.currentTarget.dataset.index if (this.data.m_DataList[index].currentStatus == null) { this.data.m_DataList[index].currentStatus = true this.data.m_DataList[index].score = this.data.m_DataList[index].maxScore if (this.data.m_DataList[index].child.length > 0) { this.data.m_DataList[index].child.forEach(element => { element.score = element.maxScore element.currentStatus = true }); } this.getCurrentProgress() this.getCountSroce() } else { if (this.data.m_DataList[index].child.length > 0) { this.data.m_DataList[index].child.forEach(element => { element.currentStatus = null }); } this.data.m_DataList[index].currentStatus = null this.getCurrentProgress() } this.setData({ m_DataList: this.data.m_DataList, // m_CurrentCompletedNum: this.data.m_CurrentCompletedNum }) //console.log(this.data.m_DataList, index, 384) }, //展开切换 tapChangeExpand(e) { let index = e.currentTarget.dataset.index this.data.m_DataList[index].isExpand = !this.data.m_DataList[index].isExpand this.setData({ m_DataList: this.data.m_DataList, }) }, //点击显示子列表 tapVisibleChild(e) { let index = e.currentTarget.dataset.index this.data.m_DataList[index].isExpand = !this.data.m_DataList[index].isExpand this.setData({ m_DataList: this.data.m_DataList }) }, //子级考核项考核状态选择 tapChildStatus(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex if (this.data.m_DataList[index].child[childIndex].currentStatus == null) { this.data.m_DataList[index].child[childIndex].currentStatus = true this.data.m_DataList[index].child[childIndex].score = this.data.m_DataList[index].child[childIndex].maxScore this.data.m_CurrentCompletedNum++ this.getCountSroce() } else if (this.data.m_DataList[index].child[childIndex].currentStatus == true) { this.data.m_DataList[index].child[childIndex].currentStatus = null this.data.m_CurrentCompletedNum-- } else if (this.data.m_DataList[index].child[childIndex].currentStatus == false) { this.data.m_DataList[index].child[childIndex].currentStatus = null this.data.m_CurrentCompletedNum-- } this.setData({ m_DataList: this.data.m_DataList, m_CurrentCompletedNum: this.data.m_CurrentCompletedNum }) }, //子考核项正常考核状态 tapChildStatusNormal(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex if (this.data.m_DataList[index].child[childIndex].currentStatus == null) { this.data.m_DataList[index].child[childIndex].currentStatus = true this.data.m_DataList[index].child[childIndex].score = this.data.m_DataList[index].child[childIndex].maxScore this.data.m_CurrentCompletedNum++ this.getCountSroce() } else { this.data.m_DataList[index].child[childIndex].currentStatus = null this.data.m_CurrentCompletedNum-- } this.setData({ m_DataList: this.data.m_DataList, m_CurrentCompletedNum: this.data.m_CurrentCompletedNum }) }, //子考核项异常考核状态 tapChildStatusAbnormal(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex if (this.data.m_DataList[index].child[childIndex].currentStatus == null) { this.data.m_DataList[index].child[childIndex].currentStatus = false this.data.m_CurrentCompletedNum++; } else { this.data.m_DataList[index].child[childIndex].currentStatus = null this.data.m_CurrentCompletedNum--; } this.setData({ m_DataList: this.data.m_DataList, m_CurrentCompletedNum: this.data.m_CurrentCompletedNum }) }, //显示隐藏 子考核项备注 tapChildVisibleStandard(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex this.data.m_DataList[index].child[childIndex].isShowAbnomalDesc = !this.data.m_DataList[index].child[childIndex].isShowAbnomalDesc this.setData({ m_DataList: this.data.m_DataList }) }, //获取当前的完成进度 getCurrentProgress() { let currentCompletedNum = 0 let m_DataList = this.data.m_DataList for (let index = 0; index < m_DataList.length; index++) { const item = m_DataList[index]; if (item.child.length == 0) { if (item.currentStatus == null) { continue; } else { currentCompletedNum++ } } else { for (let j = 0; j < item.child.length; j++) { const child = item.child[j]; if (child.currentStatus == null) { continue; } currentCompletedNum++ } } } this.setData({ m_CurrentCompletedNum: currentCompletedNum }) }, //获取表格总分 getCountSroce() { let m_DataList = this.data.m_DataList let sroce = 0 for (let index = 0; index < m_DataList.length; index++) { const item = m_DataList[index]; if (item.child.length == 0) { if (item.score == "") { continue; } sroce += parseFloat(item.score) } else { for (let j = 0; j < item.child.length; j++) { const child = item.child[j]; if (child.score == "") { continue; } sroce += parseInt(child.score) } } } this.setData({ m_CurrentAllScore: sroce }) // console.log(sroce, 474) }, //获取当前审核了的项的个数 getCurrentCompletedNum() { let m_DataList = this.data.m_DataList let currentCompletedNum = this.data.m_CurrentCompletedNum for (let index = 0; index < m_DataList.length; index++) { const item = m_DataList[index]; if (item.child.length == 0) { if (item.currentStatus == null) { currentCompletedNum--; continue; } else { currentCompletedNum++; continue; } } else { for (let j = 0; j < item.child.length; j++) { const child = item.child[j]; if (child.currentStatus == null) { currentCompletedNum--; continue; } else { currentCompletedNum++; continue; } } } } this.setData({ m_CurrentCompletedNum: currentCompletedNum }) }, //弹出签名框 eidtAutograph() { let _this = this this.setData({ isVisibleModel: true }) this.initCanvas() }, //隐藏签名弹框 hideAutographModal() { //检查是否已经保存了签名 if (!this.data.isComplateSing) { this.cleardraw(); } this.setData({ isVisibleModel: false }) }, //保存考核列表数据 saveAssessTable() { let StationID = this.data.m_CurrentStationID let TotalScore = this.data.m_CurrentAllScore let RecordUserID = this.data.m_userInfo.EmployeeID let ProgressInfo = this.data.m_CurrentCompletedNum + "/" + this.data.m_AllCompletedNum let Details = this.getCurrentAssessItem() wx.showLoading({ title: '保存中', }) wx.request({ method: "POST", url: Constant.BASE_SERVER_URL + 'inspectv4/StationScore/IngRecord/SaveRecords', data: { StationID: StationID, TotalScore: TotalScore, RecordUserID: RecordUserID, ProgressInfo: ProgressInfo, Details: Details }, success: res => { wx.hideLoading() let result = res.data if (result.Code != 0) { wx.showToast({ title: result.Message, icon: "error", duration: 1500 }) return; } wx.showToast({ title: '保存成功', icon: 'success', duration: 1500 }) this.setData({ isHaveSave: true, }) //通知上一个页面 let pages = getCurrentPages(); // console.log(pages,832) if (pages != null && pages.length > 1) { var beforePage = pages[pages.length - 2]; if (beforePage.initStationList != null) beforePage.initStationList(); } }, fail: err => { wx.hideLoading() wx.showToast({ title: err, icon: 'error', duration: 1500 }) } }) }, //获取当前已考核的项 用于保存 getCurrentAssessItem() { let dataList = this.data.m_DataList let items = [] for (let i = 0; i < dataList.length; i++) { const element = dataList[i]; if (element.child.length == 0) { let node = element let item = { ItemID: 0, Score: 0, Note: "" } if (node.score != "") { item.ItemID = node.itemID item.Score = node.score item.Note = node.abnomalDesc items.push(item) } } else if (element.child.length > 1) { for (let j = 0; j < element.child.length; j++) { const node = element.child[j]; let item = { ItemID: 0, Score: 0, Note: "" } if (node.score != "") { item.ItemID = node.itemID item.Score = node.score item.Note = node.abnomalDesc items.push(item) } } } } return items }, //离开页面前触发 onBeforeLeave() { if (this.data.isHaveSave) { wx.navigateBack({ delta: 1, }) return } wx.showModal({ title: "提示", content: "您确定已保存数据?", showCancel: true, cancelText: "取消", success: (res) => { if (res.confirm) { this.setData({ show: false }) wx.navigateBack({ delta: 1, }) } else if (res.cancel) { this.setData({ show: false }) wx.navigateBack({ delta: 1, }) } }, fail: () => {} }) }, //选择异常情况常用语标签 selectAbnormalTag(e) { // console.log(e,1027) let index = e.currentTarget.dataset.index let content = e.currentTarget.dataset.content this.data.m_DataList[index].abnomalDesc = content // console.log(this.data.m_DataList,1032) this.setData({ m_DataList: this.data.m_DataList }) }, childSelectAbnormalTag(e) { let index = e.currentTarget.dataset.index let childIndex = e.currentTarget.dataset.childIndex let content = e.currentTarget.dataset.content this.data.m_DataList[index].child[childIndex].abnomalDesc = content // console.log(this.data.m_DataList,1032) this.setData({ m_DataList: this.data.m_DataList }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return Constant.Share; }, })