diff --git a/pages/apply/approval/approval.js b/pages/apply/approval/approval.js index 267fca5..f69d65b 100644 --- a/pages/apply/approval/approval.js +++ b/pages/apply/approval/approval.js @@ -1,4 +1,6 @@ // pages/apply/approval/approval.js +import * as UTIL from '../../../utils/util.js'; +import * as API from '../../../utils/API.js'; const app = getApp(); Page({ @@ -40,22 +42,406 @@ Page({ comment: '同意' }, ], + //事务总表对象 + item:{}, + itemId:13, active:0, result:[], show:false, showPopup:false, + templateList:[], + templateDetailList:[], + groups:[], + villages:[], + towns:[], + temName:"", + temId:"" }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - + //this.getApprovalItemList(); + this.groupList(); + this.townList(); + this.villageList(); + this.getApprovalItemsById(); + // this.getApprovalItemList(); + }, + getApprovalItemsById(){ + let _this = this + let url = API.URL_GET_APPROVALITEMSBYID+this.data.itemId + wx.request({ + url, + method:"GET", + timeout: 60000, + header: { + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + success: function (response) { + _this.setData({item:response.data.data}) + if(_this.data.item.templateId!=""&&_this.data.item.templateId!=null){ + _this.setData({item:response.data.data,temId:_this.data.itemId}) + let d = { + templateId : _this.data.item.templateId, + orderByColumn:"id", + isAsc:"asc" + } + UTIL.httpRequest(API.URL_GET_TEMPLATEDETAIL, d, { + success: (r) => { + if (r.code == API.SUCCESS_CODE) { + _this.setData({templateDetailList:r.rows}); + let list = [] + r.rows.map(rr => { + list.push(rr.userId+"") + }) + _this.setData({result:list}) + } + } + }) + }else { + _this.getApprovalItemList() + } + } + }) + }, + inputTem:function(e){ + this.setData({temName:e.detail.value}) + }, + confirmTem:function(e){ + let data={ + approvalTemplate:{ + name:this.data.temName, + type:1, + dataType:0 + }, + approvalTemplateDetailList:this.data.templateDetailList, + method:"POST" + } + UTIL.httpRequest(API.URL_POST_MOBILEADD,data,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + let list = this.data.templateList + list.push(res.data) + this.setData({ + temId:res.data.id, + templateList:list, + temName:"", + showPopup:false + }); + } + } + }) + }, + cancelTem:function(e){ + this.setData({temName:"",showPopup:false}); + }, + upItem:function(e){ + let index = e.currentTarget.dataset.id + let item = this.data.templateDetailList[index] + let list = this.data.templateDetailList + if(index>0&&index<=list.length){ + list.splice(index,1) + list.splice(index-1,0,item) + for(let i = 0;i< list.length;i++){ + list[i].name = i+1 + } + this.setData({templateDetailList:list}); + } + }, + downItem:function(e){ + let index = e.currentTarget.dataset.id + let item = this.data.templateDetailList[index] + let list = this.data.templateDetailList + if(index>=0&&index { + if (res.code == API.SUCCESS_CODE) { + this.setData({templateList:res.rows}); + if(res.total>0){ + let d = { + templateId : res.rows[0].id, + orderByColumn:"id", + isAsc:"asc" + } + UTIL.httpRequest(API.URL_GET_TEMPLATEDETAIL, d, { + success: (r) => { + if (r.code == API.SUCCESS_CODE) { + this.setData({templateDetailList:r.rows}); + let list = [] + r.rows.map(rr => { + list.push(rr.userId+"") + }) + this.setData({result:list}) + } + } + }) + } + } + } + }) + }, + chooseTemplate:function(e){ + let data = { + templateId : e.currentTarget.dataset.id, + orderByColumn:"id", + isAsc:"asc" + } + UTIL.httpRequest(API.URL_GET_TEMPLATEDETAIL, data, { + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + this.setData({templateDetailList:res.rows}); + this.closeBox(); + } + } + }) + }, + deleteTemplate:function(e){ + let ids = [e.currentTarget.dataset.id] + let url = API.URL_GET_MOBILEREMOVE+ids + let _this = this + wx.request({ + url, + method:"GET", + timeout: 60000, + header: { + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + success: function (response) { + _this.getApprovalItemList() + } + }) + }, + townList:function(){ + let _this = this + let url = API.URL_GET_TOWNINFOBYDEPTID+0 + wx.request({ + url, + method:"GET", + timeout: 60000, + header: { + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + success: function (response) { + let d = { + deptId:response.data.data.deptId, + deptLevel:3 + } + UTIL.httpRequest(API.URL_GET_USERLIST,d,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + console.log(res); + _this.setData({towns:res.rows}); + } + } + }) + } + }) + }, + groupList:function(){ + let data = { + deptId : 187, + deptLevel:1 + } + UTIL.httpRequest(API.URL_GET_USERLIST,data ,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + this.setData({groups:res.rows}); + } + } + }) + + }, + villageList:function(){ + let data = { + deptId : 187, + deptLevel:2 + } + UTIL.httpRequest(API.URL_GET_USERLIST,data ,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + this.setData({villages:res.rows}); + } + } + }) +}, onChange(event) { - this.setData({ - result: event.detail, - }); + let _this = this + this.setData({result:event.detail}) + this.setData({templateDetailList:[]}) + let list = _this.data.templateDetailList + for (let j in event.detail){ + let str = event.detail[j] + for(let i in _this.data.groups){ + if(_this.data.groups[i].userId == str){ + let sin = _this.data.groups[i] + list.push(sin) + _this.setData({templateDetailList:list}) + } + } + for(let i in _this.data.villages){ + if(_this.data.villages[i].userId == str){ + let sin = _this.data.villages[i] + list.push(sin) + _this.setData({templateDetailList:list}) + } + } + for(let i in _this.data.towns){ + if(_this.data.towns[i].userId == str){ + let sin = _this.data.towns[i] + list.push(sin) + _this.setData({templateDetailList:list}) + } + } + } + }, + save:function(){ + let _this = this + let list = this.data.templateDetailList + list = list.filter(function(e,i,s){ + s[i].name = i+1 + return true + }) + if(this.data.temId==""||this.data.temId==null){ + let data={ + approvalTemplate:{ + name:this.data.temName, + type:1, + dataType:1 + }, + approvalTemplateDetailList:list, + method:"POST" + } + UTIL.httpRequest(API.URL_POST_MOBILEADD,data,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + let list = this.data.templateList + list.push(res.data) + this.setData({ + temId:res.data.id, + templateList:list, + temName:"" + }); + let item_ = this.data.item + item_.templateId = res.data.id + item_.method = "POST" + UTIL.httpRequest(API.URL_POST_APPROVALITEMSEDIT,item_,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + wx.showToast({ + title: "暂存成功!", + duration: 2000, + icon:"success" + }) + } + } + }) + } + } + }) + }else{ + let url = API.URL_POST_TEMPLATEEDIT + wx.request({ + url, + data: list, + method:"POST", + timeout: 60000, + header: { + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + success: function (response) { + wx.showToast({ + title: "暂存成功!", + duration: 2000, + icon:"success" + }) + }, + }) + } + }, + submit:function(){ + let _this = this + if(this.data.temId==""||this.data.temId==null){ + let data={ + approvalTemplate:{ + name:this.data.temName, + type:1, + dataType:1 + }, + approvalTemplateDetailList:this.data.templateDetailList, + method:"POST" + } + UTIL.httpRequest(API.URL_POST_MOBILEADD,data,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + let list = this.data.templateList + list.push(res.data) + this.setData({ + temId:res.data.id, + templateList:list, + temName:"" + }); + let item_ = this.data.item + item_.templateId = res.data.id + item_.method = "POST" + UTIL.httpRequest(API.URL_POST_APPROVALITEMSEDIT,item_,{ + success: (res) => { + if (res.code == API.SUCCESS_CODE) { + _this.requestSubmit() + } + } + }) + } + } + }) + }else{ + let url = API.URL_POST_TEMPLATEEDIT + wx.request({ + url, + data: _this.data.templateDetailList, + method:"POST", + timeout: 60000, + header: { + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + success: function (response) { + _this.requestSubmit() + }, + }) + } + }, + requestSubmit:function(){ + let url = API.URL_POST_APPROVALITEMSSUBMIT+this.data.item.id+"/"+this.data.item.templateId + wx.request({ + url, + method:"POST", + timeout: 60000, + header: { + 'Authorization':'Bearer '+getApp().globalData.userInfo.token + }, + success: function (r) { + wx.showToast({ + title: "提交成功!", + duration: 2000, + icon:"success" + }) + }, + }) }, openBox:function(){ var that = this ; @@ -66,15 +452,18 @@ Page({ closeBox:function(){ var that = this ; that.setData({ - show: false, + show: false }) }, showPopup() { - this.setData({ showPopup: true }); + this.setData({ + showPopup: true, + temName:"" + }); }, onClose() { - this.setData({ showPopup: false }); + this.setData({ showPopup: false}); }, /** * 生命周期函数--监听页面初次渲染完成 diff --git a/pages/apply/approval/approval.wxml b/pages/apply/approval/approval.wxml index a378531..47174b4 100644 --- a/pages/apply/approval/approval.wxml +++ b/pages/apply/approval/approval.wxml @@ -6,7 +6,7 @@ 审批事项 - + {{index+1}} @@ -28,11 +28,11 @@ - {{item.activityName}}村级主任审批 + {{item.name?item.name:index+1}}级审批{{item.nickName}} - - + + @@ -40,33 +40,18 @@ - - 董事长:张三 - 董事长:张三 - - - 董事长:张三 - 董事长:张三 + + {{item.roles[0].roleName}}:{{item.nickName}} - - 村长:张三 - 村书记:张三 - - - 村主任:张三 - 村党委:张三 + + {{item.roles[0].roleName}}:{{item.nickName}} - - 镇长:张三 - 镇书记:张三 - - - 镇主任:张三 - 镇党委:张三 + + {{item.roles[0].roleName}}:{{item.nickName}} @@ -79,12 +64,12 @@ - 保存 - 保存并提交 + 暂存 + 提交 - + + + - + - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/pages/apply/approval/approval.wxss b/pages/apply/approval/approval.wxss index b7522c6..cccadd8 100644 --- a/pages/apply/approval/approval.wxss +++ b/pages/apply/approval/approval.wxss @@ -143,7 +143,7 @@ text{display: block;} .check_box .van-col{ height: auto; } - .check_box van-checkbox:nth-child(2n) .van-checkbox { + .check_box van-checkbox:nth-child(n) .van-checkbox { margin-top: 15px; } .van-checkbox__icon-wrap { diff --git a/pages/apply/index.js b/pages/apply/index.js index 6bb5390..d18c031 100644 --- a/pages/apply/index.js +++ b/pages/apply/index.js @@ -1,4 +1,6 @@ // pages/apply/index.js +import * as UTIL from '../../utils/util.js'; +import * as API from '../../utils/API.js'; const app = getApp(); Page({ diff --git a/pages/apply/paymentTemplate/add/add.js b/pages/apply/paymentTemplate/add/add.js index 663b6ad..e637a63 100644 --- a/pages/apply/paymentTemplate/add/add.js +++ b/pages/apply/paymentTemplate/add/add.js @@ -1,4 +1,6 @@ // pages/apply/paymentTemplate/add/add.js +import * as UTIL from '../../../../utils/util.js'; +import * as API from '../../../../utils/API.js'; const app = getApp(); Page({ @@ -50,7 +52,26 @@ Page({ onLoad(options) { }, - + back:function(){ + wx.navigateBack({ + delta: 1 + }) + }, + //跳转支出申请 + goApproval: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/approval/approval', + }) + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/utils/API.js b/utils/API.js index 3e19e4a..56e1f92 100644 --- a/utils/API.js +++ b/utils/API.js @@ -71,6 +71,27 @@ const URL_GET_SELECTLIST = `${URL_PREFIX}/yinnong/payee/selectList`; //查询收款账号列表 const URL_GET_SELECTACCOUNTLIST = `${URL_PREFIX}/cashier/account/accountList`; +//查询审批流模板列表 +const URL_GET_TEMPLATELIST = `${URL_PREFIX}/service/template/list`; + +//查询审批流模板列表 +const URL_GET_TEMPLATEDETAIL = `${URL_PREFIX}/service/templateDetail/list`; +//根据系统组织机构id查询所在乡镇 +const URL_GET_TOWNINFOBYDEPTID = `${URL_PREFIX}/system/dept/getTownInfoByDeptId/`; +//根据条件查询用户信息 +const URL_GET_USERLIST = `${URL_PREFIX}/system/user/list`; +//新增模板 +const URL_POST_MOBILEADD = `${URL_PREFIX}/service/template/mobileAdd`; +//删除模板 +const URL_GET_MOBILEREMOVE = `${URL_PREFIX}/service/template/remove/`; +//通过审批事项id查询审批事项 +const URL_GET_APPROVALITEMSBYID = `${URL_PREFIX}/yinnong/approvalItems/get/`; +//审批流id保存到事项审批 +const URL_POST_APPROVALITEMSEDIT = `${URL_PREFIX}/yinnong/approvalItems/edit`; +//修改审批流数据 +const URL_POST_TEMPLATEEDIT = `${URL_PREFIX}/service/templateDetail/editBatch`; +//审核事项申请 +const URL_POST_APPROVALITEMSSUBMIT = `${URL_PREFIX}/yinnong/approvalItems/approvalItemsSubmit/`; /****************接口地址end****************/ export { @@ -104,5 +125,15 @@ export { URL_GET_GETPROJECTLIST, URL_GET_CONTRACTIONLIST, URL_GET_SELECTLIST, - URL_GET_SELECTACCOUNTLIST + URL_GET_SELECTACCOUNTLIST, + URL_GET_TEMPLATELIST, + URL_GET_TEMPLATEDETAIL, + URL_GET_TOWNINFOBYDEPTID, + URL_GET_USERLIST, + URL_POST_MOBILEADD, + URL_GET_MOBILEREMOVE, + URL_GET_APPROVALITEMSBYID, + URL_POST_APPROVALITEMSEDIT, + URL_POST_TEMPLATEEDIT, + URL_POST_APPROVALITEMSSUBMIT } \ No newline at end of file diff --git a/utils/util.js b/utils/util.js index 26a1cd7..99d2da3 100644 --- a/utils/util.js +++ b/utils/util.js @@ -117,7 +117,7 @@ function httpRequest(url, data, { finalData.token = getApp().globalData.userInfo.token; wx.request({ url, - data: finalData, + data: finalData, method:data.method, timeout: 60000, header: {