'use strict';
var app = angular.module('app', [
]);
app.controller("formeditCtrl", ["$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.directionid = sp.getUrlName("directionid");
self.formeditid = sp.getUrlName("formeditid");
self.docmode = sp.getUrlName("docmode");
self.dotype = sp.getUrlName("dotype");
self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
self.get_type = sp.getUrlName("type");
sp.fitHeight("#iframe_WO", 100);
if (self.get_lastReturnPage != "") {
self.return = "../../../" + self.get_lastReturnPage + "?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
} else {
self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
}
var postCfg = {
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + self.get_AccessToken
}
};
self.video = false;
self.QianPi = false;
self.watchNum = 0;
//初始化右上角按钮
self.buttonList = []
self.getSwenList = function () {
self.SwenList = [];
var data = {
directionid: self.directionid,
userid: self.userId,
routeinfoid: self.routeinfoid,
routeid: self.routeid,
formeditid: ""
}
$http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
$.each(res.data.LINKS, function (index, item) {
item.TEMPFORM = item.TEMPFORM + "&flowid=" + sp.getUrlName("flowid")
if (item.TEMPFORM.indexOf("fawenfile.html") > -1) {
self.Title = item.VNAME;
}
if (item.TEMPFORM.indexOf("?docmode") > 0) {
if (item.TEMPFORM.indexOf("attachlist") > -1 || item.TEMPFORM.indexOf("fawenfile") > -1) {
item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
} else {
item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
}
} else {
item.TEMPFORM = "#";
}
self.SwenList.push(item)
})
self.SwenList.push({
VNAME: "流程图",
DIRECTIONID: self.SwenList[0].DIRECTIONID,
TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
})
self.getGWZL()
})
}
self.getSwenList(0)
self.getGWZL = function () {
var data = {
tablename: "CODE_GWTYPE",
colums: "ID,CODE,CNAME,FLOWID",
order: "ID desc",
sqlwhere: {
USEMARK: 1,
FLOWID: sp.getUrlName("flowid")
},
sqlinwhere: "",
sqllikewhere: ""
}
$http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
console.log(res.data)
self.GWZL = res.data;
//console.log(JSON.stringify(self.GWZL));
self.getDOCKIND()
})
}
self.getDOCKIND = function () {
var data = {
ckey: "CODE_DOCKIND",
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.DOCKIND = res.data.CODE_DOCKIND;
self.getFuncList()
})
}
self.getFuncList = function () {
var data = {
ckey: "FW_ZSWPXXW",
id: 0,
directionid: self.directionid,
formeditid: self.formeditid,
routeid: self.routeid,
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.file = {
GWZL: res.data.FW_ZSWPXXW.GWZL,
DOCKIND: self.DOCKIND[0].CODE
}
var data = {
ckey: "FAWEN_FILES",
id: 0,
directionid: self.directionid,
formeditid: self.formeditid,
routeid: self.routeid,
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj1) {
var res1 = strToJson(s4.decryptData_CBC(obj1.data));
self.buttonList = self.dotype == 0 ? [] : res1.data["FAWEN_FILES.FUNCLIST"];
///---zyg---********************************
self.getFileByKind(1, self.DOCKIND[0].CODE);
self.getFileByKind(2, self.DOCKIND[1].CODE);
self.getFileByKind(3, self.DOCKIND[2].CODE);
})
})
}
///---zyg---*************************************************************************
self.btnCreateFileKind = function () {
var dialogHead = "温馨提示×";
var dialogBody = "
您确认要创建吗?
";
var dialogFoot = "";
$('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
sp.openCenter(".sp-dialog");
///取消按钮
$('.sp-closeDialog').click(function (event) {
sp.closeCenter(".sp-dialog");
event.preventDefault();
event.stopPropagation();
});
//post消息的id
$("#delDataTrue").click(function () {
var data = {
dockind: self.file.DOCKIND,
routeinfoid: self.routeinfoid,
gwtype: self.file.GWZL
}
console.log(data);
$http.post(apiurljs.login + "g2app/fawenfiles/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
console.log(JSON.stringify(res));
sp.dialoghide();
if (res.success) {
self.getFileByKind(1, self.DOCKIND[0].CODE);
//self.getFileByKind(2, self.DOCKIND[1].CODE);
} else {
sp.dialog("创建失败,请联系管理员!");
}
///
});
});
};
self.gaoTypeArrayFirst = [];
self.gaoTypeArraySecond = [];
self.leftFileKind_active_id = "";///当前选中的文件的id
self.getFileByKind = function (ctype, dockindStr) {
var data = {
dockind: dockindStr,
routeinfoid: self.routeinfoid
}
//console.log(data);
$http.post(apiurljs.login + "g2app/fawenfiles/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (ctype == 1) {
self.gaoTypeArrayFirst = res.data;
if (sp.isval(self.gaoTypeArrayFirst)) {
///self.getFileWo("1111219901", "自定义表单工作梳理.doc", "http://10.233.22.204:8088/glwork/g2work/files2/inline/865e508cb0c706bd2e09e73f2168cb8a/431d39d5e28fec47bc346a3b8e2f35f7/e887aae5ae9ae8a1a8e58d95e5b7a5e4bd9ce9878fe9878de696b0e6a2b3e79086.doc");
///http://10.233.22.204:8088/glworkweb/UploadAttach/doc1090286669558296576.wps
var set_filepath = apiurljs.login.split("glwork/")[0] + "glworkweb/" + self.gaoTypeArrayFirst[0].FILEURL;
//console.log(set_filepath);
self.getFileWo(self.gaoTypeArrayFirst[0].ID, self.gaoTypeArrayFirst[0].FILENAMES, set_filepath);
self.leftFileKind_active_id = self.gaoTypeArrayFirst[0].ID;
} else {
$("#iframe_WO").attr("src", "");
self.leftFileKind_active_id = "";
}
} else if (ctype == 2) {
self.gaoTypeArraySecond = res.data;
if (self.gaoTypeArraySecond.length > 0) {
self.browse(self.gaoTypeArraySecond[0])
} else {
$("#iframe_WO").attr("src", "");
}
} else if (ctype == 3) {
self.gaoTypeArrayThird = res.data;
if (self.gaoTypeArrayThird.length > 0) {
self.browse(self.gaoTypeArrayThird[0])
} else {
$("#iframe_WO").attr("src", "");
}
}
///
})
};
self.btnClickFileKind = function (itemdata) {
///点击过程稿标题--zyg--20230328---***********
self.leftFileKind_active_id = itemdata.ID;
var set_filepath = apiurljs.login.split("glwork/")[0] + "glworkweb/" + itemdata.FILEURL;
self.getFileWo(itemdata.ID, itemdata.FILENAMES, set_filepath);
};
self.btnDelFileKind = function (itemdata, n) {
///点击过程稿--删除图标--zyg--20230328---***********
var dialogHead = "温馨提示×";
var dialogBody = "删除后不可恢复,您确认要删除吗?
";
var dialogFoot = "";
$('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
sp.openCenter(".sp-dialog");
///取消按钮
$('.sp-closeDialog').click(function (event) {
sp.closeCenter(".sp-dialog");
event.preventDefault();
event.stopPropagation();
});
//post消息的id
$("#delDataTrue").click(function () {
var data = {
id: itemdata.ID
}
$http.post(apiurljs.login + "g2app/fawenfiles/deleteDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
//console.log(JSON.stringify(res));
sp.dialoghide();
if (res.success) {
self.getFileByKind(n, self.DOCKIND[n - 1].CODE);
} else {
sp.dialog("创建失败,请联系管理员!");
}
///
});
});
};
self.getFileWo = function (fileid, filename, filepath) {
//var str = "jsonParams: %7B%22method%22%3A1%2C%22params%22%3A%7B%22userId%22%3A%2210.222.33.204%22%2C%22fileId%22%3A%22bcc3655a692547259a2f2335f78cd52f_558347767%22%2C%22filePath%22%3A%22%2Fdoc1090299906328735744.wps%22%2C%22userRight%22%3A0%2C%22mobileFlag%22%3Afalse%2C%22saveFlag%22%3Atrue%7D%2C%22indexFlag%22%3Atrue%7D";
//console.log(decodeURIComponent(str));
////调用永中中转--zyg--**********************************--2023
var data = {
method: 1,
params: {
userId: self.userName,
fileId: fileid,
fileName: filename,
filePath: filepath,
userRight: self.dotype == 1 ? 0 : 1, // 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
//saveFlag: true, /// true:自动保存文档 false:不自动保存文档 (默认为true)
callbackUrl: apiurljs.login + "g2app/fawenfiles/uploadFile"
}
};
//console.log(JSON.stringify(data))
$.ajax({
url: apiurljs.yzFileWo + "api.do",
data: {
jsonParams: encodeURIComponent(JSON.stringify(data))
},
type: "POST",
dataType: "json",
general: false,
async: false,
success: function (data) {
//console.log(data);
if (data) {
if (data.errorCode === "0") {
let rst = data.result;
//console.log(rst.urls);
if (rst && rst.urls) {
var get_urls = rst.urls;
//console.log(get_urls);
if (typeof (get_urls) === "string") {
$timeout(function () {
$("#iframe_WO").attr("src", get_urls);
})
} else {
console.warn("无效的urls:" + get_urls);
}
} else {
console.warn("ajax响应内容data.result有问题:" + rst);
}
} else {
alert(data.errorMessage);
}
} else {
console.warn("ajax响应内容为空!");
}
},
});
};
//self.btnSave_1 = function () {
// document.getElementById("iframe_WO").contentWindow.YozoOffice.Application.ActiveDocument.Save(true);
//}
self.btnSave = function () {
////调用永中保存函数--zyg--**********************************--2023
//console.log("保存文件");
var data = {
method: 2,
params: {
fileId: self.leftFileKind_active_id
}
};
$.ajax({
url: apiurljs.yzFileWo + "api.do",
data: {
jsonParams: encodeURIComponent(JSON.stringify(data))
},
type: "POST",
dataType: "json",
general: false,
async: false,
success: function (data) {
//console.log(data);
if (data && data.errorCode === "0") {
sp.dialog("保存成功");
}
},
});
}
//打印
self.printFile = function () {
document.getElementById("iframe_WO").contentWindow.YozoOffice.print();
}
self.btnXiuDing = function () {
console.log("开启/关闭修订模式")
}
//右上角按钮调用方法
self.btnEvent = function (item) {
switch (item.CODE) {
case "SAVEITEM": self.btnSave(); break;
case "PRINTITEM": self.printFile(); break;
case "SAVEOFD": self.toOFD(); break;
case "GAIZITEM": self.qianZ(); break;
case "SENDLOG": self.RouteList(); break;
default: self.forward(item); break;
}
}
//生成终稿
self.toOFD = function () {
if (self.gaoTypeArraySecond.length != 0) {
sp.dialog("请删除成文稿后,点击文件保存!")
$timeout(function () {
sp.dialoghide()
}, 1000)
return
}
var data = {
routeinfoid: self.routeinfoid,
gwtype: self.file.GWZL,
dockind: "D02"
}
$http.post(apiurljs.login + "g2app/fawenfiles/convertDataFinalOFDFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success == true) {
self.getFileByKind(2, self.DOCKIND[1].CODE)
}
})
}
//签章
self.qianZ = function () {
if (self.gaoTypeArrayThird.length != 0 || self.gaoTypeArraySecond.length != 0) {
sp.dialog("请删除终稿、签章稿后,点击签章!")
$timeout(function () {
sp.dialoghide()
}, 1000)
return
}
var data = {
srcpath: "/root/TongWeb7.0/applications/glworkweb/UploadAttach/" + self.gaoTypeArraySecond[0].FILENAMES,
outpath: "/root/TongWeb7.0/applications/glworkweb/UploadAttach",
routeinfoid: self.routeinfoid,
gwtype: self.file.GWZL,
dockind: "D03"
}
$http.post(apiurljs.login + "g2app/signature/getSignature", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success == true) {
self.getFileByKind(3, self.DOCKIND[2].CODE)
}
})
}
self.download = function (item) {
window.open(apiurljs.login.split("glwork/")[0] + "glworkweb/" + item.FILEURL)
}
self.browse = function (item) {
var set_convertType;
if (item.FILEEXT == "ofd") {
set_convertType = 570;
} else {
set_convertType = 0;
}
let postData = {
convertType: set_convertType,
fileUrl: apiurljs.login.split("glwork/")[0] + "glworkweb/" + item.FILEURL
};
var postCfg_transfer = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
transformRequest: function (data) {
return $.param(data);
}
};
$http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
.success(function (res) {
//console.log(res);
if (res.errorcode === 0) {
$("#iframe_WO").attr("src", res.data.viewUrl);
} else {
sp.dialog(res.message);
}
});
}
//转发
self.forward = function (obj) {
self.activeGroup = "部门";
self.forwardUser = [];
self.searchName = "";
self.saveZB = false;
self.btnItem = obj;
if (self.filedChange == true) {
self.btnSave(1)
} else {
var data = {
codefuncbutton: self.btnItem.CODE,
directionid: self.directionid,
directionidtarget: self.btnItem.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.ENDNODETYPE == 1 || self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL") {
self.showContent = false;
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.show = false;
item.Dep = [];//部门
item.Dep.push(item.SENDUSERS.SECTS[0]);
item.organCode = item.Dep[0].CODE;//所选部门编号
$.each(item.Dep, function (index1, item1) {
item1.open = true;
$.each(item1.C_H_I_L_D, function (index2, item2) {
item2.open = true;
})
})
item.people = item.SENDUSERS.USERS;//人员
item.people.forEach(function (item1) {
item1.show = true;
})
item.mainSend = null;//主送
item.copySend = [];//抄送
})
self.activeDirection = self.directionList[0]
console.log(self.activeDirection)
self.forward2(0)
} else {
self.showContent = true;
self.forwardUser = [];
self.Dep = [];//部门
self.Dep.push(self.direction.SENDUSERS.SECTS[0]);
self.organCode = self.Dep[0].CODE;//所选部门编号
$.each(self.Dep, function (index, item) {
item.open = true;
$.each(item.C_H_I_L_D, function (index1, item1) {
item1.open = true;
})
})
self.people = self.direction.SENDUSERS.USERS;//人员
self.people.forEach(function (item) {
item.show = true;
})
self.mainSend = null;//主送
self.copySend = [];//抄送
self.forward1(0)
}
//setTimeout(function () {
// sp.layer("#forward");
//}, 100)
})
}
}
//转发(新)
self.forward1 = function (n) {
if (n == 0) {
sp.layer("#forward");
} else {
if (self.activeGroup == "自定义") {
self.getZbList()
}
}
self.activeUser = null;
self.moveFlag1 = false;
self.moveFlag2 = false;
}
self.searchPerson = function () {
self.people.forEach(function (item) {
if (item.USERNAME.indexOf(self.searchName) > -1) {
item.show = true;
} else {
item.show = false;
}
})
}
self.adduser = function () {
self.people.forEach(function (item) {
if (item.checked == true && item.show == true) {
self.forwardUser.push(item);
item.checked = false;
item.show = false;
}
})
if (self.forwardUser.length == 1) {
self.moveFlag1 = false;
self.moveFlag2 = false;
return;
}
self.getmoveFlag()
}
self.deluser = function () {
self.forwardUser.forEach(function (item) {
if (item.checked == true) {
item.checked = false;
item.show = true;
}
})
self.forwardUser = self.forwardUser.filter(function (item) {
return item.show == false;
})
if (self.forwardUser.length == 1) {
self.moveFlag1 = false;
self.moveFlag2 = false;
return;
}
self.getmoveFlag()
}
self.adduserAll = function () {
self.people.forEach(function (item) {
if (item.show == true) {
self.forwardUser.push(item);
item.checked = false;
item.show = false;
}
})
if (self.forwardUser.length == 1) {
self.moveFlag1 = false;
self.moveFlag2 = false;
return;
}
self.getmoveFlag()
}
self.deluserAll = function () {
self.forwardUser.forEach(function (item) {
item.checked = false;
item.show = true;
})
self.forwardUser = [];
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.length - 1) {
self.moveFlag1 = true;
self.moveFlag2 = false;
} else {
self.moveFlag1 = true;
self.moveFlag2 = true;
}
}
self.moveUp = function () {
var a = self.forwardUser[self.activeUser], b = self.forwardUser[self.activeUser - 1];
self.forwardUser[self.activeUser] = b;
self.forwardUser[self.activeUser - 1] = a;
self.activeUser = self.activeUser - 1;
self.getmoveFlag()
}
self.moveDown = function () {
var a = self.forwardUser[self.activeUser], b = self.forwardUser[self.activeUser + 1];
self.forwardUser[self.activeUser] = b;
self.forwardUser[self.activeUser + 1] = a;
self.activeUser = self.activeUser + 1;
self.getmoveFlag()
}
self.getZbList = function () {
var data = {
userid: self.userId
}
$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));
self.zbList = res.data;
self.zbCode = self.zbList[0].CODE;
self.people.forEach(function (item) {
item.show = false;
self.zbList.forEach(function (item1) {
item1.USERS.forEach(function (item2) {
if (item.USERID == item2.USERID) {
item.show = true;
item.set = self.zbCode;
}
})
self.forwardUser.forEach(function (obj) {
item1.USERS.forEach(function (item2) {
if (obj.USERID == item2.USERID) {
obj.show = false;
obj.set = self.zbCode;
}
})
})
})
})
})
}
self.checkZB = function (item1) {
self.zbCode = item1.CODE;
self.people.forEach(function (item) {
item.show = false;
item.checked = false;
item1.USERS.forEach(function (item2) {
if (item.USERID == item2.USERID) {
item.show = true;
item.set = self.zbCode;
}
})
})
self.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.length == 0) {
return
}
var data = {
userid: self.userId,
cname: self.cnameZB,
userids: JSON.stringify(self.forwardUser.map(function (item) {
return { userid: item.USERID }
}))
}
$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.saveZB = false;
self.getZbList()
}
})
}
//a代表所选项上一级,b代表当前所选项
self.setMainSend = function (a, b) {
a.mainSend = b;
}
self.setCopySend = function (a, b) {
a.copySend.push(b);
}
self.delCopySend = function (a, b) {
a.copySend.splice(a.copySend.indexOf(b), 1)
}
self.sendFlag = false;
self.send = function () {
self.sendFlag = true;
if (self.direction.ENDNODETYPE == 1) {
var sendUser = {
DIRECTIONID: self.direction.DIRECTIONID,
MAINUSERID: "STOP",
COPYUSERID: ""
}
} else if (self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL") {
var sendUser = {
DIRECTIONID: self.direction.DIRECTIONID,
MAINUSERID: "",
COPYUSERID: ""
}
} else {
if (self.forwardUser.length == 0) {
sp.layerhide()
sp.dialog("请选择人员!");
$timeout(function () {
sp.dialoghide()
sp.layer("#forward");
}, 2000)
return
}
//if (self.mainSend == null && (self.direction.SENDRULE == 0 || self.direction.SENDRULE == 1)) {
// self.mainNull = true;
// self.sendFlag = false;
// return;
//}
//var sendUser = {
// DIRECTIONID: self.direction.DIRECTIONID,
// MAINUSERID: self.mainSend ? self.mainSend.USERID : "",
// COPYUSERID: self.copySend.map(function (item) {
// return item.USERID
// }).join("|")
//}
var sendUser = {
DIRECTIONID: self.direction.DIRECTIONID,
MAINUSERID: self.forwardUser.map(function (item) {
return item.USERID
}).join("|"),
COPYUSERID: ""
}
}
var data = {
codefuncbutton: self.direction.CODEFUNCBUTTON,
directionid: self.directionid,
userid: self.userId,
routeinfoid: self.routeinfoid,
routeid: self.routeid,
data: "[" + JSON.stringify(sendUser) + "]"
}
$http.post(apiurljs.login + "g2app/abase/saveDataSend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.sendFlag = false;
sp.closeCenter('.sp-layer');
if (res.success == true) {
sp.dialog("发送成功!");
$timeout(function () {
window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
}, 1500)
} else {
sp.dialog(res.message)
}
})
}
self.openPeopleList = function (item1) {
$.each(self.directionList, function (index, item) {
if (item.CNAME == item1.CNAME) {
item.show = !item1.show;
} else {
item.show = false;
}
})
}
self.sendAll = function () {
if (self.filedChange == true) {
self.btnSave(2)
} else {
var sendUser = [];
self.directionList.forEach(function (item) {
if (item.mainSend != null || item.copySend.length > 0) {
sendUser.push({
DIRECTIONID: item.DIRECTIONID,
MAINUSERID: item.mainSend ? item.mainSend.USERID : "",
COPYUSERID: item.copySend.map(function (item1) {
return item1.USERID
}).join("|")
})
}
})
var data = {
codefuncbutton: self.direction.CODEFUNCBUTTON,
directionid: self.directionid,
userid: self.userId,
routeinfoid: self.routeinfoid,
routeid: self.routeid,
data: JSON.stringify(sendUser)
}
$http.post(apiurljs.login + "g2app/abase/saveDataSend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
sp.closeCenter('.sp-layer');
if (res.success == true) {
if (apiurljs.sendMsg == true) {
if (self.mainSend) {
var data = {
acceptuserid: self.mainSend.USERID,
flowid: "AA18",
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/message/queryDataTodoFilen", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success) {
var data = {
users: self.mainSend.UINPUTNAME,
title: "你有一份新邮件",
subtitle: self.data.BT,
content: "请及时处理",
link: window.location.origin + "/g2workweb/fromMessage.html?userid=" + self.mainSend.USERID + "&&openPage=" + res.data + "&dotype=" + self.dotype + "&type=" + self.get_type + "&&PKID=FZF08&&CNAME=发文管理"
}
$http.post(apiurljs.login + "g2app/message/sendEmailMessage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.data.status == 200) {
sp.dialog("发送成功!");
$timeout(function () {
window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
}, 1500)
} else {
sp.dialog(res.message)
}
})
} else {
sp.dialog(res.message)
}
})
} else {
var n = 0;
$.each(self.copySend, function (index, item) {
var data = {
acceptuserid: item.USERID,
flowid: "AA18",
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/message/queryDataTodoFilen", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success) {
var data = {
users: item.UINPUTNAME,
title: "你有一份新邮件",
subtitle: self.data.BT,
content: "请及时处理",
link: window.location.origin + "/g2workweb/fromMessage.html?userid=" + item.USERID + "&&openPage=" + res.data + "&dotype=" + self.dotype + "&type=" + self.get_type + "&&PKID=FZF08&&CNAME=发文管理"
}
$http.post(apiurljs.login + "g2app/message/sendEmailMessage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.data.status == 200) {
n++
} else {
sp.dialog(res.message);
return false
}
})
} else {
sp.dialog(res.message);
return false
}
})
})
if (n == self.copySend.length) {
sp.dialog("发送成功!");
$timeout(function () {
window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
}, 1500)
}
}
} else {
sp.dialog("发送成功!");
$timeout(function () {
window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
}, 1500)
}
} else {
sp.dialog(res.message)
}
})
}
}
//查看流转记录
self.RouteList = function () {
$(".sp-page-center").hide();
var data = {
directionid: self.directionid,
userid: self.userId,
routeid: self.routeid,
routeinfoid: self.routeinfoid,
}
$http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.routeList = res.data;
$.each(self.routeList, function (index, item) {
$.each(item.USERS, function (index1, item1) {
if (item1.KIND == 0) {
item.mainUser = [];
item.mainUser.push(item1.USERNAME);
item.mainUser = item.mainUser.join(",");
} else if (item1.KIND == 1) {
item.copyUsers = [];
item.copyUsers.push(item1.USERNAME)
item.copyUsers = item.copyUsers.join(",");
} else {
item.mainUser = [];
item.mainUser.push(item1.USERNAME);
item.mainUser = item.mainUser.join(",");
}
})
})
$time(function (item) {
sp.layer("#RouteList");
}, 100);
})
}
//头部下滚冻结
$(function () {
$(".sp-page-center").css("max-height", $(window).height() - 58).css("height", $(window).height() - 58)
//页面高度撑满
setTimeout(function () {
if ($(".ibox-content").height() < $(window).height() - 31) {
$(".ibox-content").css("height", $(window).height() - 31)
}
}, 1)
$(".sp-bgMask").bind("click", function () {
$('.sp-page-center').show(); $('.Browse').attr('src', $('.Browse').attr('src'));
});
})
}])