import * as UTIL from '../../utils/util.js'; import * as API from '../../utils/API.js'; Page({ data: { //顶部胶囊按钮位置信息rect CustomMenuButton: null, wrokScrollHeight:0, userInfoObj:{}, //用户信息, item:"", address: '', //详细收货地址(四级) value: [0, 0, 0], // 地址选择器省市区 暂存 currentIndex region: '', //所在地区 deptId: '', regionValue: [0, 0, 0], // 地址选择器省市区 最终 currentIndex provinces: [], // 一级地址 citys: [], // 二级地址 areas: [], // 三级地址 visible: false, isCanConfirm: true, //是否禁止在第一列滚动期间点击确定提交数据 bookId:"", bookName:"", bookList:[], active:1, // 待办列表 todoList:[], // 已办列表 doneList:[], // 已发起 yfqList:[], // 已制单 yzdList:[], //待办数量 todoNum:0, //已办数量 doneNum:0, //已发起数量 yfqNum:0, //已制单数量 yzdNum:0, //字典 transferType:[ {"dictVale":1,"dictLabel":"村账户转账"}, {"dictVale":2,"dictLabel":"公务卡转账"}, {"dictVale":3,"dictLabel":"虚拟挂账"}, {"dictVale":4,"dictLabel":"代管账户转账"}, {"dictVale":5,"dictLabel":"母子转账"}, {"dictVale":10,"dictLabel":"现金提现"}, {"dictVale":11,"dictLabel":"现金使用"}, {"dictVale":12,"dictLabel":"汇票支出"} ] }, onLoad: function (options) { //获取用户信息 this.getUserInfo() //获取滚动条高度 this.computeBarLocation(); //查询待办 this.getTaskList(); //查询已办 this.getTaskDoneList(); //查询已发起 this.getTransferList(); this.getTransferList1(); //查询已制单 this.getTransferList2(); //查询dept this.getTreeDept(); }, reset:function(){ this.setData({ active:1, todoList:[], doneList:[], yfqList:[], yzdList:[], todoNum:0, doneNum:0, yfqNum:0, yzdNum:0 }) }, switchTab:function(e){ this.setData({ active:e.currentTarget.dataset.gid }) }, dictTranslate(d,value){ let val = "" for(var index in d){ if(d[index].dictVale==value){ return val = d[index].dictLabel } } }, getTaskList:function(e){ let data = { pageNum:1, pageSize:10, orderByColumn:"A.ID_", isAsc:"desc", systemType:4, method:"GET" } UTIL.httpRequest(API.URL_GET_TASKLIST,data, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({todoNum:res.total}) if(res.rows!=null&&res.rows!=""){ for(let i = 0;i { console.log(res); }, complete: (res) => { } }) }, getTaskDoneList:function(e){ let data = { pageNum:1, pageSize:10, orderByColumn:"A.ID_", isAsc:"desc", systemType:4, method:"GET" } UTIL.httpRequest(API.URL_GET_TASKDONELIST,data, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({doneNum:res.total}) if(res.rows!=null&&res.rows!=""){ for(var index in res.rows){ let d = this.dictTranslate(this.data.transferType,res.rows[index].formData.transferType) res.rows[index].formData.transferType = d } this.setData({doneList:res.rows}) } } }, fail: (res) => { console.log(res); }, complete: (res) => { } }) }, getTransferList:function(e){ let data = { // pageNum:1, // pageSize:10, transferType:"1", auditStatus:"2", method:"GET" } UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, { success: (res) => { console.log(res); if (res.code == API.SUCCESS_CODE) { let a = this.data.yfqNum+res.total this.setData({yfqNum:a}) let b = this.data.yfqList this.setData({yfqList:res.rows.concat(b)}) } }, fail: (res) => { }, complete: (res) => { } }) }, getTransferList1:function(e){ let data = { // pageNum:1, // pageSize:10, transferType:"1", auditStatus:"3", method:"GET" } UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, { success: (res) => { console.log(res); if (res.code == API.SUCCESS_CODE) { let a = this.data.yfqNum+res.total this.setData({yfqNum:a}) let b = this.data.yfqList this.setData({yfqList:res.rows.concat(b)}) } }, fail: (res) => { }, complete: (res) => { } }) }, //已制单 getTransferList2:function(e){ let data = { // pageNum:1, // pageSize:10, transferType:"1", auditStatus:"0", method:"GET" } UTIL.httpRequest(API.URL_GET_TRANSFERLIST,data, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({yzdNum:res.total}) this.setData({yzdList:res.rows}) } }, fail: (res) => { }, complete: (res) => { } }) }, //跳转收入登记 swichInCome:function(e){ wx.navigateTo({ url: '../inCome/inCome?', }) }, //跳转支出申请 swichPayment:function(e){ console.log(e.currentTarget.dataset.current); // let cur = e.currentTarget.dataset.current; // if (this.data.currentTaB == cur) { // return false; // }else{ // wx.navigateTo({ // url: '../inCome/index?id=' + id, // }) // } wx.navigateTo({ url: '/pages/apply/index?', }) }, toList:function(){ wx.navigateTo({ url: '/pages/handle/liist?active='+this.data.active, }) }, /* 计算bar 高度*/ computeBarLocation() { var that = this; let CustomMenuButton = wx.getMenuButtonBoundingClientRect(); let CustomWidows = wx.getSystemInfoSync(); // 根据文档,先创建一个SelectorQuery对象实例 let query = wx.createSelectorQuery().in(this); query.select('.top_title').boundingClientRect(); query.select('.information_header').boundingClientRect(); query.select('.navList_main').boundingClientRect(); query.select('.child_function').boundingClientRect(); query.select('.work_plan').boundingClientRect(); query.exec((res) => { let wrokScrollHeight = CustomWidows.windowHeight; res.forEach((v)=>{ wrokScrollHeight = wrokScrollHeight - v.height; }) wrokScrollHeight = wrokScrollHeight-CustomMenuButton.top-CustomMenuButton.bottom -15; that.setData({ wrokScrollHeight: wrokScrollHeight, }); }) that.setData({ CustomMenuButton: CustomMenuButton, }); }, /* 获取用户信息*/ getUserInfo(){ UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({userInfoObj:res.user}) this.setData({region:res.user.deptName}) this.setData({item:JSON.stringify(res.user)}) this.getBookList() } } }) }, /* 获取区镇村*/ getTreeDept:function(){ UTIL.httpRequest(API.URL_GET_TREESELECTBYUSER, {method:'GET'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({provinces:res.data}) this.setData({citys:res.data[0].children}) this.setData({areas:res.data[0].children[this.data.value[1]].children}) } } }) }, /* 获取区镇村*/ getBookList:function(){ let d = { loginDeptID : this.data.userInfoObj.loginDeptId } UTIL.httpRequest(API.URL_GET_BOOKLISTBYDEPTID,d, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({bookList:res.rows}) if(this.data.bookName==""&&res.total>0){ this.setData({bookName:res.rows[0].bookName}) this.setData({bookId:res.rows[0].id}) }else if(this.data.bookName==""&&res.total==0){ this.setData({bookName:"无可用账套"}) } } },fail:(res) => { },complete:(res) => { } }) }, bindPickerChange:function(e){ this.setData({ bookId: this.data.bookList[e.detail.value].id, bookName:this.data.bookList[e.detail.value].bookName }) let data={ loginBookId:this.data.bookList[e.detail.value].id } let _this = this UTIL.httpRequest(API.URL_GET_CHANGEBOOK,data, { success: (res) => { _this.reset() _this.onLoad() } }) }, closePopUp() { this.setData({ visible: false }) }, pickAddress() { this.setData({ visible: true, value: [...this.data.regionValue] }) }, // 处理省市县联动逻辑 并保存 value cityChange(e) { var value = e.detail.value let { provinces, citys } = this.data var provinceNum = value[0] var cityNum = value[1] var areaNum = value[2] if (this.data.value[0] !== provinceNum) { var id = provinces[provinceNum].id this.setData({ value: [provinceNum, 0, 0], citys: this.data.provinces[provinceNum].children, areas: this.data.provinces[provinceNum].children[cityNum].children }) } else if (this.data.value[1] !== cityNum) { var id = citys[cityNum].id this.setData({ value: [provinceNum, cityNum, 0], areas: this.data.provinces[provinceNum].children[cityNum].children }) } else { this.setData({ value: [provinceNum, cityNum, areaNum] }) } console.log(this.data.value); }, preventTouchmove() {}, // 城市选择器 // 点击地区选择取消按钮 cityCancel(e) { var id = this.data.provinces[0].id this.setData({ citys: this.data.lastCitys || this.data.userInfoObj.parentDeptName, //默认北京市辖区, areas: this.data.lastAreas || this.data.userInfoObj.deptName, value: [...this.data.regionValue], visible: false }) }, // 提交时由序号获取省市区id getRegionId(type) { let value = this.data.regionValue let provinceId = this.data.provinces[value[0]].id let townId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id let areaId = '' if (this.data.provinces[value[0]].children[value[1]].children[value[2]].id) { areaId = this.data.provinces[value[0]].children[value[1]].children[value[2]].id } else { areaId = 0 } if (type === 'provinceId') { return provinceId } else if (type === 'townId') { return townId } else { return areaId } }, chooseStart(e) { this.setData({ isCanConfirm: false }) }, chooseEnd(e) { this.setData({ isCanConfirm: true }) }, // 点击地区选择确定按钮 citySure(e) { if (this.data.isCanConfirm) { var value = this.data.value this.setData({ visible: false }) // 将选择的城市信息显示到输入框 try { var region = (this.data.provinces[value[0]].label || '') + (this.data.citys[value[1]].label || '') if (this.data.areas.length > 0) { region = this.data.areas[value[2]].label || '' } else { this.data.value[2] = 0 } } catch (error) { console.log('adress select something error') } this.setData({ region: region, lastCitys: this.data.citys, lastAreas: this.data.areas, regionValue: value, deptId:this.getRegionId('areas') }, () => { let data={ loginDeptID : this.getRegionId('areas') } let _this = this UTIL.httpRequest(API.URL_GET_CHANGEDEPT,data, { success: (res) => { setTimeout(()=>{ _this.reset() _this.onLoad() },1000) } }) }) } } })