diff --git a/pages/contract/contract.js b/pages/contract/contract.js index 956b9b3..a592e0a 100644 --- a/pages/contract/contract.js +++ b/pages/contract/contract.js @@ -4,7 +4,7 @@ import * as API from '../../utils/API.js'; let EVN_CONFIG = require('../../env/env'); const DISTRIBUTE_ENVIROMENT = 'IMGURL'; let { - URL_PREFIX, + URL_PREFIX, } = EVN_CONFIG[DISTRIBUTE_ENVIROMENT]; const app = getApp(); Page({ @@ -41,8 +41,14 @@ Page({ */ onLoad(options) { var that = this; - that.setData({ - scrollHeight:wx.getSystemInfoSync().windowHeight + + let qu = wx.createSelectorQuery() + qu.select("#top_view").boundingClientRect() + qu.select("#top_ban").boundingClientRect() + qu.exec(res => { + that.setData({ + scrollHeight:wx.getSystemInfoSync().windowHeight-res[0].height-res[0].top + }) }) }, @@ -62,206 +68,205 @@ Page({ } }) }, - getList:function(){ - let params = { - pageNum:this.data.pageNums, - pageSize:10, - name:this.data.name - } - UTIL.httpRequest(API.URL_GET_CONTRACTLIST,params,{ - success: (res) => { - console.log(res); - + getList:function(){ + let params = { + pageNum:this.data.pageNums, + pageSize:10, + name:this.data.name + } + UTIL.httpRequest(API.URL_GET_CONTRACTLIST,params,{ + success: (res) => { + console.log(res); if(res.code == 200){ - if(this.data.pageNums!=1&&this.data.list.length<=res.total){ + if(this.data.pageNums!=1&&this.data.list.length { + if(res.code==200){ + let new_list = this.data.list + console.log(e.currentTarget.dataset.index); + new_list.splice(e.currentTarget.dataset.index,1) + this.setData({'list':new_list}) + UTIL.showToastNoneIcon('删除成功!'); + }else{ + UTIL.showToastNoneIcon('删除失败!'); } - }) - }, - paging(){ - this.setData({ - pageNums:this.data.pageNums+1, - }) - this.getList(); - }, - goSearch(e){ - this.setData({name:e.detail}) - this.getList(); - }, - goUpdate(e){ - wx.navigateTo({ - url: '/pages/contract/add/add?id='+e.currentTarget.dataset.id, - }) - }, - delete(e){ - UTIL.httpRequest(API.URL_GET_CONTRACTDELETE + e.currentTarget.dataset.id, {method:'GET'}, { - success: (res) => { - if(res.code==200){ - let new_list = this.data.list - console.log(e.currentTarget.dataset.index); - new_list.splice(e.currentTarget.dataset.index,1) - this.setData({'list':new_list}) - UTIL.showToastNoneIcon('删除成功!'); - }else{ - UTIL.showToastNoneIcon('删除失败!'); - } + } + }) + }, + upload(e){ + this.setData({itemId:e.currentTarget.dataset.id}); + this.asyncFun(e.currentTarget.dataset.id) + this.setData({"fileList":[]}) + }, + asyncFun(id){ + let uploadList = this.data.uploadOptions + let newList = [] + let _this = this + uploadList.map( res => { + let oData = { + tableId: id, + tableName: "t_contraction_info", //上传表 + bizPath: "contraction", + fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字 + method:'GET' + } + UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, { + success: (rr) => { + console.log(rr.rows); + rr.rows.map((rrr,index) => { + rrr.url = URL_PREFIX + rrr.fileUrl + if(index==rr.rows.length-1){ + newList.push(Object.assign({},res,{"list":rr.rows})) + _this.setData({"fileList":_this.data.fileList.concat(newList)}); + _this.setData({"showUpload":true}) + } + }) + + }, + fail:(rr) =>{ + console.log(rr); + }, + complete:(rr) => { + console.log(rr); } }) - }, - upload(e){ - this.setData({itemId:e.currentTarget.dataset.id}); - this.asyncFun(e.currentTarget.dataset.id) - this.setData({"fileList":[]}) - }, - asyncFun(id){ - let uploadList = this.data.uploadOptions - let newList = [] - let _this = this - uploadList.map( res => { - let oData = { - tableId: id, - tableName: "t_contraction_info", //上传表 - bizPath: "contraction", - fileType: res.dictValue, //附件类型 1原始发票 2会议纪要 3会议照片 4 参会人员签字 - method:'GET' + }) + + }, + closeBox(){ + this.setData({"showUpload":false}) + }, + deleteImg(event){ + this.setData({"fileEvent":event}) + this.setData({"showPopup":true}); + }, + cancelTem:function(e){ + this.setData({"fileEvent":"{}"}); + this.setData({"showPopup":false}); + }, + confirmTem:function(e){ + let event = this.data.fileEvent + console.log(event); + UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+event.detail.file.id , {method:'GET'}, { + success: (res) => { + if(res.code==200){ + let ll = this.data.fileList + var jsonlist = ll[event.target.dataset.idx].list; + jsonlist.splice(event.detail.index, 1) + ll[event.target.dataset.idx].list = jsonlist + this.setData({"fileList":ll}) + this.setData({showPopup:false}); + wx.showToast({ + title: '删除成功!', + icon: 'success', + duration: 2000, + }) } - UTIL.httpRequest(API.URL_GET_ATTACHMENTLIST, oData, { - success: (rr) => { - console.log(rr.rows); - rr.rows.map((rrr,index) => { - rrr.url = URL_PREFIX + rrr.fileUrl - if(index==rr.rows.length-1){ - newList.push(Object.assign({},res,{"list":rr.rows})) - _this.setData({"fileList":_this.data.fileList.concat(newList)}); - _this.setData({"showUpload":true}) - } - }) - - }, - fail:(rr) =>{ - console.log(rr); - }, - complete:(rr) => { - console.log(rr); - } - }) - }) - - }, - closeBox(){ - this.setData({"showUpload":false}) - }, - deleteImg(event){ - this.setData({"fileEvent":event}) - this.setData({"showPopup":true}); - }, - cancelTem:function(e){ - this.setData({"fileEvent":"{}"}); - this.setData({"showPopup":false}); - }, - confirmTem:function(e){ - let event = this.data.fileEvent - console.log(event); - UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+event.detail.file.id , {method:'GET'}, { + } + }) + }, + uploadFile(uploadFile,event) { + let _this = this + return new Promise((resolve, reject) => { + wx.uploadFile({ + url: API.URL_GET_UPLOAD, + filePath: uploadFile.file.file[0].url, + name: 'file', + header: { + "Content-Type": "multipart/form-data",//记得设置 + "chartset":"utf-8", + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + formData:uploadFile, success: (res) => { - if(res.code==200){ - let ll = this.data.fileList - var jsonlist = ll[event.target.dataset.idx].list; - jsonlist.splice(event.detail.index, 1) - ll[event.target.dataset.idx].list = jsonlist - this.setData({"fileList":ll}) - this.setData({showPopup:false}); - wx.showToast({ - title: '删除成功!', - icon: 'success', - duration: 2000, - }) + res.data = JSON.parse(res.data); + if(res.statusCode == 200){ + let files = _this.data.fileList + let fName = res.data.fileUrl.split('/') + let fLength = fName.length + files[event.currentTarget.dataset.idx].list.push({ + "fileName": fName[fLength-1], + "fileType": "0", + "fileUrl":res.data.fileUrl , + "id": res.data.id, + "tableId": 6, + "url":URL_PREFIX+res.data.fileUrl + }) + _this.setData({"fileList":files}) + wx.hideLoading() } + }, + fail: (err) => { + //上传失败:修改pedding为reject + reject(err) } - }) - }, - uploadFile(uploadFile,event) { - let _this = this - return new Promise((resolve, reject) => { - wx.uploadFile({ - url: API.URL_GET_UPLOAD, - filePath: uploadFile.file.file[0].url, - name: 'file', - header: { - "Content-Type": "multipart/form-data",//记得设置 - "chartset":"utf-8", - 'Authorization':'Bearer '+getApp().globalData.userInfo.token - }, - formData:uploadFile, - success: (res) => { - res.data = JSON.parse(res.data); - if(res.statusCode == 200){ - let files = _this.data.fileList - let fName = res.data.fileUrl.split('/') - let fLength = fName.length - files[event.currentTarget.dataset.idx].list.push({ - "fileName": fName[fLength-1], - "fileType": "0", - "fileUrl":res.data.fileUrl , - "id": res.data.id, - "tableId": 6, - "url":URL_PREFIX+res.data.fileUrl - }) - _this.setData({"fileList":files}) - wx.hideLoading() - } - }, - fail: (err) => { - //上传失败:修改pedding为reject - reject(err) - } - }); - }) - }, - afterRead(event) { - let _this = this - wx.showLoading({ - title: '上传中...' - }) - let fileForm={ - file: event.detail, - fileType:event.currentTarget.dataset.idx, - tableName: "t_contraction_info", //上传表 - bizPath: "contraction", //上传目录 - tableId:_this.data.itemId - } - this.uploadFile(fileForm,event) - }, - lookDown(file,detail){ - // 获取指定字符串最后一次出现的位置,返回index - var index1 = file.detail.url.lastIndexOf('.'); - // substr(start, length) 抽取从start下标开始的length个字符,返回新的字符串; - var style = file.detail.url.substr(index1 + 1) - //判断图片类型,不需要下载,不做处理 - if(style=='png'||style=='jpg'||style=='jpeg'||style=='bmp'||style=='gif'||style=='webp'||style=='psd'||style== 'svg'||style=='tiff'){ - //判断非图片类型 - }else{ - wx.downloadFile({ - url: file.detail.url, - success(data){ - wx.openDocument({ - filePath: data.tempFilePath, - fileType: style, - showMenu:true, - success(res){ - } - }) + }); + }) + }, + afterRead(event) { + let _this = this + wx.showLoading({ + title: '上传中...' + }) + let fileForm={ + file: event.detail, + fileType:event.currentTarget.dataset.idx, + tableName: "t_contraction_info", //上传表 + bizPath: "contraction", //上传目录 + tableId:_this.data.itemId + } + this.uploadFile(fileForm,event) + }, + lookDown(file,detail){ + // 获取指定字符串最后一次出现的位置,返回index + var index1 = file.detail.url.lastIndexOf('.'); + // substr(start, length) 抽取从start下标开始的length个字符,返回新的字符串; + var style = file.detail.url.substr(index1 + 1) + //判断图片类型,不需要下载,不做处理 + if(style=='png'||style=='jpg'||style=='jpeg'||style=='bmp'||style=='gif'||style=='webp'||style=='psd'||style== 'svg'||style=='tiff'){ + //判断非图片类型 + }else{ + wx.downloadFile({ + url: file.detail.url, + success(data){ + wx.openDocument({ + filePath: data.tempFilePath, + fileType: style, + showMenu:true, + success(res){ } }) } - }, + }) + } + }, /** * 生命周期函数--监听页面显示 */ diff --git a/pages/contract/contract.wxml b/pages/contract/contract.wxml index ebc4688..8091a37 100644 --- a/pages/contract/contract.wxml +++ b/pages/contract/contract.wxml @@ -1,10 +1,10 @@ - + 合同信息 - + { console.log(res); - if(res.code == 200){ - this.setData({'data':res.summary}) - if(this.data.pageNums!=1&&this.data.financeList.length { + console.log(res); + that.setData({ + scrollHeight:wx.getSystemInfoSync().windowHeight-res[0].height-res[0].top-res[1].height-res[1].left*2 + }) }) this.getList() }, @@ -73,7 +80,7 @@ Page({ this.setData({ active:e.currentTarget.dataset.gid }) -}, + }, back:function(){ wx.navigateBack({ delta: 1 diff --git a/pages/finance/finance.wxml b/pages/finance/finance.wxml index 689058f..aef0837 100644 --- a/pages/finance/finance.wxml +++ b/pages/finance/finance.wxml @@ -1,9 +1,9 @@ - + 财务公开 - + @@ -21,7 +21,7 @@ -