|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564 |
- // pages/apply/approval/approval.js
- import * as UTIL from '../../../utils/util.js';
- import * as API from '../../../utils/API.js';
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- isIPX: app.globalData.isIPX,
- steps: [
- {
- assigneeName: '同意',
- activityName: '测试测试',
- durationInMillis: '描述信息',
- endTime: '2022-01-02',
- comment: '同意',
- type: '1'
- },
- {
- assigneeName: '申请中',
- activityName: '测试测试',
- durationInMillis: '描述信息',
- endTime: '2022-01-02',
- comment: '同意',
- type: '2'
- },
- {
- assigneeName: '驳回',
- activityName: '测试测试',
- durationInMillis: '描述信息',
- endTime: '2022-01-02',
- comment: '同意',
- type: '3'
- },
- {
- assigneeName: '步骤四',
- activityName: '测试测试',
- durationInMillis: '描述信息',
- endTime: '2022-01-02',
- comment: '同意'
- },
- ],
- //事务总表对象
- item:{},
- detpId:"",
- itemId:"",
- active:0,
- result:[],
- show:false,
- showPopup:false,
- templateList:[],
- templateDetailList:[],
- groups:[],
- villages:[],
- towns:[],
- temName:"",
- temId:""
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({itemId:options.id,deptId:options.deptId});
- //this.getApprovalItemList();
- this.groupList();
- this.townList();
- this.villageList();
- this.getApprovalItemsById();
- },
- 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",
- method:"GET"
- }
- 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<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});
- }
- },
- getApprovalItemList:function(){
- let data={
- dataType:0,
- pageNum:1,
- pageSize:50,
- method:"GET"
- }
- UTIL.httpRequest(API.URL_GET_TEMPLATELIST, data, {
- success: (res) => {
- 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",
- method:"GET"
- }
- 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",
- method:"GET"
- }
- 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,
- method:"GET"
- }
- UTIL.httpRequest(API.URL_GET_USERLIST,d,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- res.rows.map(rr => {
- rr.approvalLevel = 3
- rr.approvalType = 1
- rr.approvalOrder = 0
- })
- _this.setData({towns:res.rows});
- }
- }
- })
- }
- })
- },
- groupList:function(){
- let data = {
- deptId : this.data.deptId,
- deptLevel:1,
- method:"GET"
- }
- UTIL.httpRequest(API.URL_GET_USERLIST,data ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- res.rows.map(rr => {
- rr.approvalLevel = 2
- rr.approvalType = 1
- rr.approvalOrder = 0
- })
- this.setData({groups:res.rows});
- }
- }
- })
-
- },
- villageList:function(){
- let data = {
- deptId : this.data.deptId,
- deptLevel:2,
- method:"GET"
- }
- UTIL.httpRequest(API.URL_GET_USERLIST,data ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- res.rows.map(rr => {
- rr.approvalLevel = 1
- rr.approvalType = 1
- rr.approvalOrder = 0
- })
- this.setData({villages:res.rows});
- }
- }
- })
- },
- onChange(event) {
- 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})
- }
- }
-
- }
- let li = this.data.templateDetailList
- li = li.filter(function(e,i,s){
- s[i].name = i+1
- s[i].approvalOrder = i+1
- return true
- })
- this.setData({templateDetailList:li})
- },
- back:function(){
- wx.navigateBack({
- delta: 1
- })
- },
- 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) {
- if (r.data.code == API.SUCCESS_CODE) {
- wx.showToast({
- title: "提交成功!",
- duration: 2000,
- icon:"success"
- })
- setTimeout(function(){
- wx.switchTab({
- url: '/pages/index/index'
- })
- },2000)
- }else{
- wx.showToast({
- title: "操作失败!",
- duration: 2000,
- icon:"error"
- })
- }
- },
- })
- },
- openBox:function(){
- var that = this ;
- that.setData({
- show: true,
- })
- },
- closeBox:function(){
- var that = this ;
- that.setData({
- show: false
- })
- },
- showPopup() {
- this.setData({
- showPopup: true,
- temName:""
- });
- },
-
- onClose() {
- this.setData({ showPopup: false});
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
|