// pages/dangerousProject/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { show: false, loadShow:false, loginName:'', userName:'', deptId:'', projectName:'', projectId:'', prjectRelation:{}, //参数 timeline:[], changeNameList:[], changeName:'', changeContext:'', allPoint:0, outPoint:0, comPoint:0, approval:0, titleindex:0, fileList: [], id:'', initData:{}, }, //项目切换 返回值 onProjectSelect(e){ this.onClickShow(); let projectId = e.detail.id; let projectName = e.detail.text; app.globalData.projectId = projectId; app.globalData.projectName = projectName; this.setData({ projectId:projectId, projectName:projectName, changeNameList:[], titleindex:0, changeName:'', allPoint:0, outPoint:0, comPoint:0, approval:0, timeline:[] }) this.onLoad(); }, onImagesArr(e){ // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 wx.uploadFile({ //图片上传地址 url: app.globalData.reqUrl+'/weixin/security/fileUpload', filePath: e.detail[0], name: 'file', header: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" }, formData: { user: 'test' }, success:res => { // 上传完成需要更新 fileList let data = JSON.parse(res.data); let fileList = this.data.fileList fileList.push({url: data.url}); this.setData({ fileList:fileList}); this.updateDanger(res.data,e.currentTarget.dataset.id) }, }); }, showPopup() { this.setData({ show: true }); }, onClose() { this.setData({ show: false }); }, onClickShow() { this.setData({ loadShow: true }); }, onClickHide() { this.setData({ loadShow: false }); }, // 项目头部切换 onClickTitle(e){ this.setData({ titleindex:e.target.dataset.id, changeName:'', changeNameList:[] }); this.getChangeSignature(); }, onSelectDangerName(e){ this.setData({ changeName:e.detail.text, }) this.getChangeSignature(); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this; //加载蒙版 that.onClickShow(); //获取缓存数据 wx.getStorage({ key: 'userinfo', success:function(res){ that.setData({ loginName:res.data.loginName, userName:res.data.userName, deptId:res.data.deptId, projectName: app.globalData.projectName, projectId:app.globalData.projectId, initData:{text:app.globalData.projectName,id:app.globalData.projectId} }) that.getProjectCorrespondence(); } }) }, /** * 项目对应关系 */ getProjectCorrespondence() { var that = this; wx.request({ url: app.globalData.reqUrl + '/weixin/training/getProjectCorrespondence', data: { "projectId": that.data.projectId, }, method: "get", success: function (res) { that.setData({ prjectRelation:res.data }) that.getChangeSignature(); } }) }, /** * 变更签认 */ getChangeSignature(){ var that = this; wx.request({ url: app.globalData.szhUrl+'/system/alterationEndorseConfig/list1', method: 'post', data: { pageNum: 1, pageSize: 9999, projectId: that.data.prjectRelation.szh, alterationType:that.data.titleindex, alterationName:that.data.changeName }, success: resData => { that.onClickHide(); let data = resData.data.rows; //总数 let allPoint = data.length; //已通过 let comPoint = 0; //审批中 let approval = 0; //不通过 let outPoint = 0; //变更名称 let changeNameList = []; //变更列表 let timeline = []; if(data.length > 0){ for(let i = 0;i 0){ for(let j = 0;j0?changeNameList[0].text:'', changeContext:changeNameList.length>0?changeNameList[0].context:'', timeline:timeline }) } }) }, /** * 图片上传 */ updateDanger:function(fileUrl,id){ wx.request({ header: { 'content-type': 'application/x-www-form-urlencoded' }, url:app.globalData.reqUrl+'/weixin/security/updateDanger', data:{ "deptId":this.data.deptId, "projectId":this.data.projectId, "id":id, "fileUrl":fileUrl, "subName":this.data.loginName, }, method:"POST", success:function(res){ console.log("======"+res.data.code); } }) }, /** * 文件信息查看 * @param {*} e */ previewImg(e){ let suffix = e.currentTarget.dataset.suffix; let url = e.currentTarget.dataset.url; let images = [url]; if(suffix == 'pdf'){ wx.downloadFile({ url: url, success: function (res) { const filePath = res.tempFilePath wx.openDocument({ filePath: filePath, success: function (res) { console.log('打开文档成功') } }) } }) }else{ wx.previewImage({ current: url, //当前图片地址 urls: images, //所有要预览的图片的地址集合 数组形式 success: function(res) {}, fail: function(res) {}, complete: function(res) {}, }) } }, /** * 返回到技术管理 */ goGCLB:function(){ wx.redirectTo({ url: '../../pages/technical-management/index' }) }, })