'use strict'; var app = angular.module('app', []); app.controller("forwardCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.routeid = sp.getUrlName("routeid"); self.routeinfoid = sp.getUrlName("routeinfoid"); self.copyrightid = sp.getUrlName("copyrightid"); self.directionid = sp.getUrlName("directionid"); self.formeditid = sp.getUrlName("formeditid"); self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType"); self.directionFlag = false; var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.getDirectionFlag = function () { var data = { copyrightid: self.copyrightid } $http.post(apiurljs.login + "g2work/abase/queryFormeditSignByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.data.length > 0) { self.directionFlag = true; } self.getHasUser() }) } self.getDirectionFlag() //已发人员,补发时去掉 self.getHasUser = function () { var data = { routeid: self.routeid, routeinfoid: self.routeinfoid, columns: "DIRECTIONID,USERID,KIND" } $http.post(apiurljs.login + "g2app/dataabase/queryUseridByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.hasUser = res.data; self.forward() }) } //转发 self.forward = function () { self.activeGroup = "部门"; self.searchName = ""; self.searchRole = ""; self.saveZB = false; self.jiaqian = false; var data = { codefuncbutton: sp.getUrlName("codefuncbutton"), directionid: self.directionid, directionidtarget: sp.getUrlName("directionidtarget"), userid: self.userId, routeinfoid: self.routeinfoid, routeid: self.routeid } $http.post(apiurljs.login + "g2app/abase/queryDataSendByTarget", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.showContent = true; self.directions = res.data; //所有可选流向 self.direction = self.directions[0]; //所选流向 if (self.direction.SENDERRORS && self.direction.SENDERRORS.MESSAGE != "") { self.showContent = false; self.direction.CODEFUNCTITLE = self.direction.SENDERRORS.MESSAGE; window.parent.document.getElementById("forwardWin").style.height = "110px"; window.parent.sp.setCenter("#forward") self.forward1(0) return } if (self.direction.ENDNODETYPE == 1 || self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL" || self .direction.CODEFUNCBUTTON == "SENDCOMMIT") { self.showContent = false; self.direction.CODEFUNCTITLE = self.direction.CODEFUNCTITLE; self.direction.CODEMARK = self.direction.CODEMARK; window.parent.document.getElementById("forwardWin").style.height = "100px"; window.parent.sp.setCenter("#forward") self.forward1(0) } else if (self.direction.ENDNODETYPE == 3) { self.showContent = true; self.forwardUser = []; self.directionList = self.direction["DIRECTION.CHILD"]; $.each(self.directionList, function (index, item) { item.forwardUser = index; self.forwardUser.push([]) item.people1 = item.SENDUSERS.USERS.USERS; //人员 item.people1.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) }) }) item.people2 = item.SENDUSERS.USERSALL.USERS; //人员 item.people2.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) }) }) item.people = JSON.parse(JSON.stringify(item.people1)); }) self.activeDirection = self.directionList[0] self.roleList = self.activeDirection.SENDUSERS.USERS.ROLES; if (self.deviceType == "pad") { window.parent.document.getElementById("forwardWin").style.height = "440px"; } else { window.parent.document.getElementById("forwardWin").style.height = "740px"; } window.parent.sp.setCenter("#forward") self.forward1(0) } else { self.forwardUser = []; self.directionList = []; self.directionList.push(self.direction) $.each(self.directionList, function (index, item) { item.forwardUser = index; self.forwardUser.push([]) item.people1 = item.SENDUSERS.USERS.USERS; //人员 item.people1.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) }) }) item.people2 = item.SENDUSERS.USERSALL.USERS; //人员 item.people2.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) }) }) item.people = JSON.parse(JSON.stringify(item.people1)); }) self.activeDirection = self.directionList[0] self.roleList = self.direction.SENDUSERS.USERS.ROLES; //var n = 0; //self.directionList[0].people1.forEach(function (item) { // n = n + item.USERS.length; //}) //if (n == 1) { //如果推荐人员唯一时,缺省直接赋值转发,可以重新选择 // self.showContent = false; // self.adduserAll(2); // var usernameStr = ""; // self.directionList[0].people1.forEach(function (item) { // if (item.USERS.length == 1) { // usernameStr = item.USERS[0].USERNAME // } // }) // //var usernameStr = self.direction.SENDUSERS.USERS.USERS[0].USERS[0].USERNAME; // self.direction.CODEFUNCTITLE = "确认后将转发【" + usernameStr + "】"; // window.parent.document.getElementById("forwardWin").style.height = "110px"; // window.parent.sp.setCenter("#forward") // self.forward1(0) //} else { self.showContent = true; if (self.deviceType == "pad") { window.parent.document.getElementById("forwardWin").style.height = "440px"; } else { window.parent.document.getElementById("forwardWin").style.height = "740px"; } window.parent.sp.setCenter("#forward") self.forward1(0) //} } }) } self.resetup = function () { self.showContent = true; if (self.deviceType == "pad") { window.parent.document.getElementById("forwardWin").style.height = "440px"; } else { window.parent.document.getElementById("forwardWin").style.height = "740px"; } window.parent.sp.setCenter("#forward") } //转发(新) self.forward1 = function (n) { if (n == 0) { $("#forward").show(); } else { if (self.activeGroup == "部门") { if (self.jiaqian == true) { //self.directionList = self.direction["DIRECTION.CHILD"]; $.each(self.directionList, function (index, item) { item.people2.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) self.forwardUser[self.activeDirection .forwardUser].forEach(function (item3) { if (item2.USERID == item3.USERID) { item2.show = false; } }) }) }) item.people = JSON.parse(JSON.stringify(item.people2)); }) self.roleList = self.activeDirection.SENDUSERS.USERSALL.ROLES; } else { //self.directionList = self.direction["DIRECTION.CHILD"]; $.each(self.directionList, function (index, item) { item.people1.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) self.forwardUser[self.activeDirection .forwardUser].forEach(function (item3) { if (item2.USERID == item3.USERID) { item2.show = false; } }) }) }) item.people = JSON.parse(JSON.stringify(item.people1)); }) self.roleList = self.activeDirection.SENDUSERS.USERS.ROLES; } } else if (self.activeGroup == "自定义分组") { self.getZbList(2) } else if (self.activeGroup == "常用分组") { self.getZbList2(2) } } if (self.direction.ENDNODETYPE != 1 && self.direction.CODEFUNCBUTTON != "SENDCOPYEND" && self.direction.CODEFUNCBUTTON != "SENDPERUSAL" && self.direction.CODEFUNCBUTTON != "SENDCOMMIT") { self.itemShow() self.activeUser = null; self.moveFlag1 = false; self.moveFlag2 = false; } } //网关切换流向 self.changeType = function (n) { self.type = n; self.activeDirection = self.directionList[n]; if (self.activeDirection.jiaqian == true) { self.activeGroup = '常用分组' } else { self.activeGroup = '部门' } self.forward1(1) } //流程加签 self.addDirection = function (obj) { var n = 0; self.directionList.forEach(function (item) { if (item.CNAME == obj.CNAME) { n = n + 1; } }) if (n == 0) { self.directionList.push({ forwardUser: self.directionList.length, CNAME: "加签:" + obj.CNAME, DIRECTIONID: obj.FORMEDITID, jiaqian: true, people: [], people1: [], people2: [], }) self.forwardUser.push([]) self.changeType(self.directionList.length - 1) } } //加签流程移除 self.delDirection = function (n) { self.changeType(n - 1); self.directionList.splice(n, 1) self.forwardUser.splice(n, 1) } self.jiaqianCheck = function () { if (self.jiaqian == true) { $.each(self.directionList, function (index, item) { item.people2.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) self.forwardUser[self.activeDirection .forwardUser].forEach(function (item3) { if (item2.USERID == item3.USERID) { item2.show = false; } }) }) }) item.people = JSON.parse(JSON.stringify(item.people2)); }) self.roleList = self.activeDirection.SENDUSERS.USERSALL.ROLES; } else { $.each(self.directionList, function (index, item) { item.people1.forEach(function (item1) { item1.show = false; item1.childshow = false; item1.USERS.forEach(function (item2) { item2.show = true; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == item.DIRECTIONID) { if (JSON.stringify(x.DATALIST).indexOf(item2.USERID) > -1) { item2.show = false; } else { item1.show = true; } } }) self.forwardUser[self.activeDirection .forwardUser].forEach(function (item3) { if (item2.USERID == item3.USERID) { item2.show = false; } }) }) }) item.people = JSON.parse(JSON.stringify(item.people1)); }) self.roleList = self.activeDirection.SENDUSERS.USERS.ROLES; } } //n==1全选;n==2全清;n==3反选 self.ForwardCheck = function (n) { if (n == 1) { self.activeDirection.people.forEach(function (item) { item.USERS.forEach(function (item1) { item1.checked = true; }) }) } else if (n == 2) { self.activeDirection.people.forEach(function (item) { item.USERS.forEach(function (item1) { item1.checked = false; }) }) } else if (n == 3) { self.activeDirection.people.forEach(function (item) { item.USERS.forEach(function (item1) { item1.checked = !item1.checked;; }) }) } } self.searchPerson = function () { self.activeDirection.people.forEach(function (item) { item.show = false; var n = 0; item.USERS.forEach(function (item1) { item1.show = false; if (self.activeGroup == "部门") { if (item1.ROLECODE.indexOf(self.searchRole) > -1 && item1.USERNAME.indexOf(self.searchName) > -1) { item1.show = true; n++ self.forwardUser.forEach(function (item2) { if (item1.USERID == item2.USERID) { item1.show = false; } }) } else { item1.show = false; } } else { if (item1.USERNAME.indexOf(self.searchName) > -1) { item1.show = true; n++ self.forwardUser.forEach(function (item2) { if (item1.USERID == item2.USERID) { item1.show = false; } }) } else { item1.show = false; } } }) if (n > 0) { item.show = true; item.childshow = false; } }) } self.searchPerson2 = function () { if (self.activeGroup == "自定义分组") { self.getZbMsList() } else { self.getZbMsList2() } } self.chekcDP = function (obj) { obj.USERS.forEach(function (item) { item.checked = !item.checked; }) self.adduser() } self.checkAddUser = function (obj) { var type = 1; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == self.activeDirection.DIRECTIONID) { x.DATALIST.forEach(function (x1) { if (x1.KIND == 0) { type = 2 } }) } }) obj.checked = true; self.activeDirection.people.forEach(function (item, index) { item.USERS.forEach(function (item1, index1) { if (item1.checked == true && item1.show == true) { self.forwardUser[self.activeDirection.forwardUser].push(item1); item1.checked = false; item1.show = false; } }) }) self.getmoveFlag() if (self.forwardUser[self.activeDirection.forwardUser].length == 1) { self.moveFlag1 = false; self.moveFlag2 = false; return; } } self.adduser = function () { var type = 1; self.hasUser.forEach(function (x) { if (x.DIRECTIONID == self.activeDirection.DIRECTIONID) { x.DATALIST.forEach(function (x1) { if (x1.KIND == 0) { type = 2 } }) } }) self.activeDirection.people.forEach(function (item, index) { item.USERS.forEach(function (item1, index1) { if (item1.checked == true && item1.show == true) { self.forwardUser[self.activeDirection.forwardUser].push(item1); item1.checked = false; item1.show = false; } }) }) self.getmoveFlag() if (self.forwardUser[self.activeDirection.forwardUser].length == 1) { self.moveFlag1 = false; self.moveFlag2 = false; return; } } self.deluser = function () { self.forwardUser[self.activeDirection.forwardUser].forEach(function (item) { if (item.checked == true) { item.checked = false; item.show = true; item.childshow = false; self.activeDirection.people.forEach(function (x) { x.USERS.forEach(function (y) { if (item.USERID == y.USERID) { y.checked = false; y.show = true; } }) }) } }) self.forwardUser[self.activeDirection.forwardUser] = self.forwardUser[self.activeDirection.forwardUser].filter(function (item) { return item.show == false; }) self.getmoveFlag() if (self.forwardUser[self.activeDirection.forwardUser].length == 1) { self.moveFlag1 = false; self.moveFlag2 = false; return; } } self.adduserAll = function () { self.activeDirection.people.forEach(function (item, index) { item.USERS.forEach(function (item1, index1) { if (item1.show == true) { self.forwardUser[self.activeDirection.forwardUser].push(item1); item1.checked = false; item1.show = false; } }) }) self.getmoveFlag() if (self.forwardUser[self.activeDirection.forwardUser].length == 1) { self.moveFlag1 = false; self.moveFlag2 = false; return; } } self.deluserAll = function () { self.forwardUser[self.activeDirection.forwardUser].forEach(function (item) { item.checked = false; item.show = true; item.childshow = false; self.activeDirection.people.forEach(function (x) { x.USERS.forEach(function (y) { if (item.USERID == y.USERID) { y.checked = false; y.show = true; } }) }) }) self.forwardUser[self.activeDirection.forwardUser] = []; self.getmoveFlag() self.moveFlag1 = false; self.moveFlag2 = false; } self.checkForwardUser = function (n) { if (self.activeUser != n) { self.activeUser = n; } else { self.activeUser = null; } if (self.forwardUser.length == 1) { self.moveFlag1 = false; self.moveFlag2 = false; return; } if (self.activeUser == null) { self.moveFlag1 = false; self.moveFlag2 = false; } else { self.getmoveFlag() } } self.getmoveFlag = function () { if (self.activeUser == 0) { self.moveFlag1 = false; self.moveFlag2 = true; } else if (self.activeUser == self.forwardUser[self.activeDirection.forwardUser].length - 1) { self.moveFlag1 = true; self.moveFlag2 = false; } else { self.moveFlag1 = true; self.moveFlag2 = true; } self.itemShow() } self.itemShow = function () { if (self.direction.SENDERRORS.MESSAGE == "") { self.activeDirection.people.forEach(function (item) { item.show = false; if (item.USERS.USERS) { item.USERS.USERS.forEach(function (item1) { if (item1.show == true) { item.show = true //item.childshow = false; } }) } else { item.USERS.forEach(function (item1) { if (item1.show == true) { item.show = true //item.childshow = false; } }) } }) } } self.moveUp = function () { var a = self.forwardUser[self.activeDirection.forwardUser][self.activeUser], b = self.forwardUser[self.activeDirection.forwardUser][self.activeUser - 1]; self.forwardUser[self.activeDirection.forwardUser][self.activeUser] = b; self.forwardUser[self.activeDirection.forwardUser][self.activeUser - 1] = a; self.activeUser = self.activeUser - 1; self.getmoveFlag() } self.moveDown = function () { var a = self.forwardUser[self.activeDirection.forwardUser][self.activeUser], b = self.forwardUser[self.activeDirection.forwardUser][self.activeUser + 1]; self.forwardUser[self.activeDirection.forwardUser][self.activeUser] = b; self.forwardUser[self.activeDirection.forwardUser][self.activeUser + 1] = a; self.activeUser = self.activeUser + 1; self.getmoveFlag(n) } self.getZbList = function () { var data = { userid: self.userId } $http.post(apiurljs.login + "g2app/usercustom/queryCustomDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.zdyfzList = [] if (res.data.length > 0) { for (let i = 0; i < res.data.length; i++) { self.zdyfzList.push({ ZID: res.data[i].CODE, ZUM: res.data[i].CNAME }) } self.searchRole = self.zdyfzList[self.zdyfzList.length-1].ZID self.getZbMsList() } else { self.activeDirection.people = []; } }) } self.getZbList3 = function () { var data = { userid: self.userId } $http.post(apiurljs.login + "g2app/usercustom/queryCustomDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.zdyfzList = [] if (res.data.length > 0) { for (let i = 0; i < res.data.length; i++) { self.zdyfzList.push({ ZID: res.data[i].CODE, ZUM: res.data[i].CNAME }) } self.searchRole = self.zdyfzList[self.zdyfzList.length - 1].ZID self.getZbMsList() } else { self.activeDirection.people = []; } }) } //常用分组 self.getZbList2 = function () { var data = { userid: self.userId } $http.post(apiurljs.login + "g2app/usercustom/queryGeneralDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.zdyfzList = [] if (res.data.length > 0) { for (let i = 0; i < res.data.length; i++) { self.zdyfzList.push({ ZID: res.data[i].CODE, ZUM: res.data[i].CNAME }) } self.searchRole = self.zdyfzList[self.zdyfzList.length - 1].ZID self.getZbMsList2() } else { self.activeDirection.people = []; } }) } self.getZbMsList = function () { var data = { userid: self.userId, code: self.searchRole } $http.post(apiurljs.login + "g2app/usercustom/queryCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); $.each(self.directionList, function (index, item) { item.people = res.data }) self.activeDirection.people = self.directionList[0].people[0].USERS.USERS self.activeDirection.people.forEach(function (item) { var n = 0; item.USERS.forEach(function (item1) { item1.show = true; self.forwardUser[self.activeDirection.forwardUser] .forEach(function (obj) { if (obj.USERID == item1.USERID) { n = n + 1; item1.show = false; } }) }) item.show = item.USERS.length != n; item.childshow = false; }) }) } self.getZbMsList2 = function () { var data = { userid: self.userId, code: self.searchRole } $http.post(apiurljs.login + "g2app/usercustom/queryGeneralData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); $.each(self.directionList, function (index, item) { item.people = res.data }) self.activeDirection.people = self.directionList[0].people[0].USERS.USERS self.activeDirection.people.forEach(function (item) { var n = 0; item.USERS.forEach(function (item1) { item1.show = true; self.forwardUser[self.activeDirection.forwardUser] .forEach(function (obj) { if (obj.USERID == item1.USERID) { n = n + 1; item1.show = false; } }) }) item.show = item.USERS.length != n; item.childshow = false; }) }) } self.checkZB = function (item1) { self.zbCode = item1.CODE; self.activeDirection.people.forEach(function (item) { item.show = false; item.checked = false; item1.USERS.forEach(function (item2) { if (item.USERID == item2.USERID) { item.show = true; item.childshow = false; item.set = self.zbCode; } }) }) self.forwardUser[self.activeDirection.forwardUser].forEach(function (obj) { item1.USERS.forEach(function (item2) { if (obj.USERID == item2.USERID) { obj.show = false; obj.set = self.zbCode; } }) }) } self.delZB = function (item) { var data = { code: item.CODE, userid: self.userId } $http.post(apiurljs.login + "g2app/usercustom/delCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success == true) { self.getZbList() } }) } self.btnSaveZB = function () { if (self.forwardUser[self.activeDirection.forwardUser].length == 0) { return } var data = { userid: self.userId, cname: self.cnameZB, userids: JSON.stringify(self.forwardUser[self.activeDirection.forwardUser].map( function (item) { return { userid: item.USERID, username: item.USERNAME } })) } $http.post(apiurljs.login + "g2app/usercustom/saveCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success == true) { self.searchName = ""; self.searchRole = ""; self.saveZB = false; self.activeGroup = '自定义分组' self.forwardUser[self.activeDirection.forwardUser] = [] self.getZbList3(n) } }) } self.sendFlag = false; self.sendAll = function () { self.sendFlag = true; var sendUser = []; var n = 0, text = []; self.directionList.forEach(function (item) { if (self.forwardUser[item.forwardUser].length > 0) { n++ sendUser.push({ directionid: item.DIRECTIONID, userid: self.forwardUser[item.forwardUser].map(function (item1) { return item1.USERID }).join(",") }) } else { text.push(item.CNAME) } }) if (n == 0) { window.top.sp.layerhide() window.top.sp.dialog(text.join(",") + "
未选择人员,请选择至少一项人员!"); self.sendFlag = false; return } var data = { userid: self.userId, routeid: self.routeid, routeinfoid: self.routeinfoid, data: JSON.stringify(sendUser) } $http.post(apiurljs.login + "g2app/dataabase/addSysRouteRecode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.goFunc(sp.getUrlName("directionidtarget")) self.sendFlag = false; window.parent.sp.layerhide() if (res.success == true) { window.top.sp.dialog("发送成功!"); setTimeout(function () { window.top.location.reload() }, 2000) } else { window.top.sp.dialog(res.message) } }) .error(function () { self.sendFlag = false; }) } self.goFunc = function (str) { switch (str) { case "SequenceFlow_02bni32_c2c3da8e-be69-47f5-9e7e-522923444b67": self.GUIDANG(); break; case "Flow_1q1jyh7_bbd06bd0-1ca2-409b-9f1e-35de93d46a27": self.SXDBYS(); break; case "Flow_1k5r8tm_094430ce-e841-4a09-83f0-ccbb59f1cce1": self.GWDBYQ(); break; case "Flow_1rbo1mh_094430ce-e841-4a09-83f0-ccbb59f1cce1": self.GWDBYQ(); break; case "SequenceFlow_02bni32_af78f780-9140-42c4-81c5-34fd14fcf9b3": self.WJFBB(); break; } } self.GUIDANG = function () { var data = { routeinfoid: [self.data.DAROUTEINFOID], userid: self.userId, username: self.userName, updata: [], columns: "ID,DOCUMENTID,DOCUMENTTYPE,SERIALNUM,MAINDPT,ATTACHMENT,ISSUINGAGENCY,DOCISSUEDDATE,ANNOTATION,CCDPT,PRINTSENDDPT,PRINTDATE,RELEASELEVEL,ARCHCODE,ARCHYEAR,RETENTPERIOD,ORGANIZATIONMA,ITEMNUM,ELECTRONICID,ENVIRONINFO,SOFTWENVIRON,HARDWENVIRON,DISTYPE,DISACTOR,DISDPT,DISTIME,DISLRESULT,MIJIQIXIAN,EMERGENCYDEGREE,DOCISSUERID,DOCISSUEDNUM,SIGNER,DOCTITLE,FINISHEDDATE,FLOWID,SENDSTATUS,CREATDATE,CREATUSERID,CREATNAME,SENDNAME,SENDUSERID,SENDDATE,MODELMARK,MERGEID,MOBANNAME,TABLENAME,WENHAO,DANGANML,ZRZ,JIANHAO,YESHU,BEIZHU,DPCODE,DPNAME,DAROUTEINFOID AS ROUTEINFOID" } $http.post(apiurljs.login + "g2app/DangAn/YJYGDSendDataZL", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj1) { }) } self.SXDBYS = function () { var data1 = { tablename: self.data.YTABLENAME, id: self.data.YID, data: { SQYQRQ: self.data.SQYQSJ, ZZYQWCQX: getNextDate(self.data.YYQBJSJ, parseInt(self.data.YQTS)), DBSX: getNextDate(self.data.YYQBJSJ, parseInt(self.data.YQTS)) } } $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg) .success(function (obj1) { var res1 = strToJson(s4.decryptData_CBC(obj1.data)); if (res1.success) { var data2 = { routeinfoid: self.routeinfoid, userid: self.userId, edate: getNextDate(self.data.YYQBJSJ, parseInt(self.data.YQTS)), linkrouteinfoid: self.data.YROUTEINFOID } $http.post(apiurljs.login + "g2work/routeinfo/addRouteinfoTimelimitDelayedate", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg) .success(function (obj2) { var res2 = strToJson(s4.decryptData_CBC(obj2.data)); }) } else { sp.dialog(res1.message) return false } }) } self.GWDBYQ = function () { var data1 = { tablename: self.data.YTABLENAME, id: self.data.YID, data: { DBSX: self.data.SQYQSJ } } $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj1) { var res1 = strToJson(s4.decryptData_CBC(obj1.data)); if (res1.success) { var data2 = { routeinfoid: self.routeinfoid, userid: self.userId, edate: self.data.SQYQSJ, linkrouteinfoid: self.data.YROUTEINFOID } $http.post(apiurljs.login + "g2work/routeinfo/addRouteinfoTimelimitDelayedate", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj2) { var res2 = strToJson(s4.decryptData_CBC(obj2.data)); }) } else { sp.dialog(res1.message) return false } }) } self.WJFBB = function () { var data = { tablename: "SX_FBLIST", data: { WJLY: "WJ", FLOWID: "AA50", FORMROUTEINFOID: self.routeinfoid, FBUSERID: self.userId, FBNAME: self.userName, LM: window.parent.getData().LX, FBRQ: sp.getLocalDate(), FBBM: window.parent.getData().FBBM, WJBT: window.parent.getData().WJBT } } $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj1) { }) } }]) //返回n天后日期 function getNextDate(time, n) { var date = ""; $.ajax({ url: apiurljs.login + "g2app/dataabase/getTheoryDate", type: 'post', async: false, contentType: "application/json", beforeSend: function (request) { request.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken")); }, data: JSON.stringify({ data: s4.encryptData_CBC(JSON.stringify({ startdate: time + " 00:00:00", yqday: n })) }), dataType: "json", success: function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); date = sp.format(res.data); } }) return date }