var app = angular.module('app', [
]);
app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
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.mbid = sp.getUrlName("mbid");
self.fjid = sp.getUrlName("fjid");
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");
self.return = "list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
var postCfg = {
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + self.get_AccessToken
}
};
self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
self.loading = false;
self.getSwenList = function (n) {
self.loading = true;
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) {
if (item.TEMPFORM.indexOf("formedit.html") > -1) {
self.Title = item.VNAME;
}
if (item.TEMPFORM.indexOf("?docmode") > 0) {
if (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]
//})
if (n == 0) {
self.getDpList();
} else {
self.getData()
}
})
}
self.getSwenList(0)
self.getDpList = function () {
var data = {
unitid: "AA"
}
$http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.dpList = [];
res.data.forEach(function (item) {
if (item.CHILD_DATA.length == 0) {
self.dpList.push(item)
} else {
item.CHILD_DATA.forEach(function (item1) {
if (item1.CHILD_DATA.length == 0) {
self.dpList.push(item1)
} else {
item1.CHILD_DATA.forEach(function (item2) {
if (item2.CHILD_DATA.length == 0) {
self.dpList.push(item2)
}
})
}
})
}
})
self.dpList.forEach(function (item) {
item.checked = false;
})
self.DpList = {
ZS: JSON.parse(JSON.stringify(self.dpList)),
CS: JSON.parse(JSON.stringify(self.dpList))
}
self.AllCheckedDp = {};
self.DpLength = {};
self.selectDpList = {};
self.getData();
})
}
//初始化右上角按钮
self.buttonList = [];
////获取设计的表单、及数据、按钮数组---------zyg----20230519
self.data = {};////参考之前已有,本次保留并拼接此数据
self.readonly = {};////参考之前已有,本次保留并拼接此数据
self.fb_queryDataCustom_data = {};////返回的数据
self.getData = function () {
self.loading = true;
var data = {
"ckey": "",
"userid": self.userId,
"formeditid": self.formeditid,
"directionid": self.directionid,
"routeinfoid": self.routeinfoid,
"routeid": self.routeid,
"id":0
}
//console.log(JSON.stringify(data));
$http.post(apiurljs.login + "g2app/abase/queryDataCustom", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data)).data;
self.fb_queryDataCustom_data = res;////返回的数据
//console.log(JSON.stringify(res.TableCols));
$("#formDesignPart").html(s4.decryptData_CBC(res.TableData));
//console.log(JSON.stringify(res.TableCols));
//console.log(res.ID);
/////原有业务逻辑-------
var fb_json_str = "";
var fb_json_readnly = "";
angular.forEach(res.TableCols, function (item) {
var set_str = "\"" + item.CODE + "\":\"" + item.VALUE + "\"" + ",";
fb_json_str += set_str;
var set_readonly = "\"" + item.CODE + "\":\"" + item.EREADONLY + "\"" + ",";
fb_json_readnly += set_readonly;
});
var set_id_str = "\"ID\":\"" + res.ID + "\""
self.data = JSON.parse("{" + fb_json_str + set_id_str + "}");
//console.log(self.data);
self.readonly = JSON.parse("{" + sp.cutlast(fb_json_readnly) + "}");
$timeout(function () {
if (self.data.ID == 0) {
self.filedChange = true;
} else {
self.filedChange = false;
}
self.buttonList = self.dotype == 0 ? [] : res.FUNCLIST;
var n = {}, all = {};
for (var i in self.DpList) {
self.AllCheckedDp[i] = false;
self.DpLength[i] = 0;
self.selectDpList[i] = []
all[i] = 0;
$.each(self.DpList[i], function (index, item) {
self.DpLength[i]++
if (self.data.ZS.indexOf(item.SECTION) != -1 && i == "ZS") {
all[i]++;
item.checked = true;
self.selectDpList[i].push(item);
}
if (self.data.CS.indexOf(item.SECTION) != -1 && i == "CS") {
all[i]++;
item.checked = true;
self.selectDpList[i].push(item);
}
})
if (all[i] == self.DpList[i].length) {
self.AllCheckedDp[i] = true;
} else {
self.AllCheckedDp[i] = false;
}
}
}, 100);
$timeout(function () {
$(".formedit center").css("height", $(".formedit center").parent().next("div").height() - $(".formedit center").parent().next("div").children().eq(0).height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
var height1 = $(".formedit center").css("height"), height2 = 0;
$(".auto").siblings().each(function () {
height2 = height2 + $(this).outerHeight();
})
//$(".auto").css("height", height1.slice(0, height1.length - 2) - height2);
}, 200)
/////原有业务逻辑-------
////自定义表单设置及赋值-----zyg---
if (self.routeid == "0") {
sp.radio();///单选
sp.checkbox();///多选
spvld.getValidate();///开始正则校验组件
spbld.laydate();////操作日期控件组件
//spbld.subtable();///操作子表按钮组件
} else {
//var get_viewData_json = "json/viewData_2.txt?ctime="+new Date();
////调用给表单赋值组件
spbld.fbAssignValueToTable(JSON.stringify(res), self.userId, self.routeinfoid, self.routeid, self.get_AccessToken);
//if (get_role == "read") {
// ///只读状态将表单中全部设置为只读状态,不可录入编辑删除
// $("body").find("button").attr("disabled", "disabled");
// $("body").find("input").attr("disabled", "disabled");
// $("body").find("select").attr("disabled", "disabled");
// $("body").find("textarea").attr("disabled", "disabled");
// $("body").find(".sp-upload-tip-close").hide(); ////附件列表的删除按钮去掉
//}
$timeout(function () {
sp.radio();///单选
sp.checkbox();///多选
spvld.getValidate();///开始正则校验组件
spbld.laydate();////操作日期控件组件
//spbld.subtable();///操作子表按钮组件
}, 1000);
}
////自定义表单设置及赋值-----zyg---
self.loading = false;
})
}
//self.getData();
//上层附件、业务参考、共享沟通组件
self.uploading = false;
self.upload = function () {
$('#fileupload').fileupload({
url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
dataType: 'json',
beforeSend: function (xhr, data) {
xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FW_ZSWPXXWENATTACHFILE,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=正式文(平、下行文)"));
},
add: function (e, data) {
var num = 0;
var acceptFileTypes = /(doc|wps|pdf|ofd)$/i;
//文件类型判断
$.each(data.originalFiles, function (index, item) {
if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
sp.dialog("您好,请上传doc/wps/pdf/ofd格式的文件!");
return;
} else {
num++
}
})
if (num == data.originalFiles.length) {
self.uploading = true;
data.submit();
$scope.$apply();
}
},
// 上传完成后的执行逻辑
done: function (e, data) {
self.uploading = false;
self.getOther()
}
})
}
self.downLoad = function (item) {
window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
}
self.deleteFile = function (file) {
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 = {
tablename: "FW_ZSWPXXWENATTACHFILE",
id: file.ID
};
$http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
sp.dialoghide();
if (res.success) {
self.getOther();
} else {
sp.dialog("删除失败,请联系管理员!");
}
});
});
}
self.searchCj = function () {
var data1 = {
ckey: "CODE_PLUGINKINDS",
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
.success(function (obj1) {
var res1 = strToJson(s4.decryptData_CBC(obj1.data));
self.KINDS = res1.data.CODE_PLUGINKINDS;
var data2 = {
ckey: "CODE_PLUGINDTYPE",
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
.success(function (obj2) {
var res2 = strToJson(s4.decryptData_CBC(obj2.data));
self.DTYPE = res2.data.CODE_PLUGINDTYPE;
var data3 = {
ckey: "CODE_PLUGINAUTHMAN",
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data3)) }, postCfg)
.success(function (obj3) {
var res3 = strToJson(s4.decryptData_CBC(obj3.data));
self.AUTHMAN = res3.data.CODE_PLUGINAUTHMAN;
self.search = {
KINDS: "",
DTYPE: ""
}
self.addSC = {};
self.getCJlist(0)
})
})
})
}
self.getCJlist = function (n) {
var data = {
kinds: self.search.KINDS,
dtype: self.search.DTYPE,
ctype: "C02"
}
$http.post(apiurljs.login + "g2app/plugin/queryDataList", data, postCfg)
.success(function (res) {
self.CJlist = res.data;
self.CJlist.forEach(function (item) {
self.AUTHMAN.forEach(function (item1) {
if (item.AUTHMAN == item1.CODE) {
item.AUTHMAN1 = item1.CNAME;
}
})
})
if (n == 0) {
sp.layer("#addCJ")
}
})
}
self.deleteCJ = function (CJ) {
var data = {
id: CJ.ID
}
$http.post(apiurljs.login + "g2app/plugin/deletePluginRouteByID", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success == true) {
self.getOther()
} else {
sp.dialog(res.message)
}
})
}
self.Meeting = function () {
$http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.dpList = res.data;
self.dpList1 = [];
self.dpList.forEach(function (item) {
self.dpList1.push(item)
item.USER.forEach(function (item1) {
item1.show = true;
})
})
self.activeDep = 0;
self.userList = self.dpList1[0].USER;
self.meetUser = [];
sp.layer("#meet")
})
}
self.searchName = "";
self.searchPerson = function () {
self.dpList1 = [];
self.dpList.forEach(function (item) {
if (item.DEP.indexOf(self.searchName) > -1) {
self.dpList1.push(item)
}
})
self.activeDep = 0;
self.userList = self.dpList1[0].USER;
}
self.addmeet = function () {
self.dpList.forEach(function (item) {
item.USER.forEach(function (item1) {
if (item1.checked == true && item1.show == true) {
self.meetUser.push(item1);
item1.checked = false;
item1.show = false;
}
})
})
}
self.delmeet = function () {
self.meetUser.forEach(function (item) {
if (item.checked == true) {
item.checked = false;
item.show = true;
}
})
self.meetUser = self.meetUser.filter(function (item) {
return item.show == false;
})
}
self.joinMeet = function () {
var data1 = {
routeid: self.routeid,
routeinfoid: self.routeinfoid,
cman: self.userId,
cname: self.data.BT + "—共享沟通",
userids: self.meetUser.map(function (item) {
return item.USERID
}).join(",")
}
$http.post(apiurljs.login + "g2work/meetcoop/createMeetcoop", data1, postCfg)
.success(function (res1) {
sp.layerhide()
if (res1.success == true) {
self.getOther()
} else {
sp.dialog(res1.message)
}
})
}
self.deleteMeet = function (meet) {
var data = {
meetid: meet.MEETID
}
$http.post(apiurljs.login + "g2work/meetcoop/deleteDataByID", data, postCfg)
.success(function (res) {
if (res.success == true) {
self.getOther()
} else {
sp.dialog(res.message)
}
})
}
self.goAttach = function (index, n) {
self.SwenList.forEach(function (item) {
if (item.TEMPFORM.indexOf("attachlist.html") > -1) {
if (n == 1) {
window.location.href = item.TEMPFORM + "&FileNum=" + index
} else if (n == 2) {
window.location.href = item.TEMPFORM + "&CjNum=" + index
} else if (n == 3) {
window.location.href = item.TEMPFORM + "&addSC=" + index
} else if (n == 4) {
window.location.href = item.TEMPFORM + "&meet=" + index
}
}
})
}
//获取附件和插件
self.getOther = function () {
var data = {
tablename: "FW_ZSWPXXWENATTACHFILE",
colums: "*",
order: "ID desc",
sqlwhere: { ROUTEINFOID: self.routeinfoid },
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));
self.arrayFile = res.data;
var data1 = {
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2app/plugin/queryPluginRouteDataList", data1, postCfg)
.success(function (res1) {
self.cjList = res1.data;
var data2 = {
routeid: self.routeid,
routeinfoid: self.routeinfoid
}
$http.post(apiurljs.login + "g2work/meetcoop/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
.success(function (obj2) {
var res2 = strToJson(s4.decryptData_CBC(obj2.data));
self.meetList = res2.data;
})
})
})
}
//获取意见(不上表)
self.opiniontype = 99;
self.getOpinion1 = function () {
var data = {
cmanid: self.userId,
routeinfoid: self.routeinfoid,
routeid: "",//self.routeid,
tableid: "FW_ZSWPXXW",
colid: "",
opiniontype: self.opiniontype,
orderbycol: "CDATE desc"
}
$http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success == true) {
self.YJ.nulla = res.data;
self.YJ.nullaSTATUS = false;
self.YJ.nulla.forEach(function (item) {
item.CDATE = sp.datefmt("yyyy-MM-dd HH:mm", item.CDATE);
//if (item.ROUTEID == self.routeid && item.COLID == "") {
// self.YJ.nullaSTATUS = true;
//}
})
} else {
sp.dialog(res.message)
}
})
}
//判断页面字段是否只读readonly、是否隐藏show
self.hide = function (type, field) {
if (self.dotype == 0 && type == "readonly") {
return true;
} else {
if (self[type][field] == true) {
return true;
} else {
return false;
}
}
}
//右上角按钮调用方法
self.btnEvent = function (item) {
switch (item.CODE) {
case "SAVEITEM": self.btnSave(0); break;
case "PRINTITEM": self.btnPrint(); break;
case "MEETITEM": self.Meet(); break;
case "SENDLOG": self.RouteList(); break;
default: self.forward(item); break;
}
}
self.openDpList = function (str) {
if (self.hide("readonly", str) == true) {
return
} else {
self.filed = str;
//self.AllCheckedDp = false;
sp.layer("#DpList")
$("#DpList .sp-page").eq(0).scrollTop(0);
}
}
self.checkAllDp = function () {
self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
$.each(self.DpList[self.filed], function (index, item) {
item.checked = self.AllCheckedDp[self.filed];
})
self.submitDpList(1)
}
self.checkDpItem = function (item) {
item.checked = !item.checked;
var n = 0;
$.each(self.DpList[self.filed], function (index, item) {
if (item.checked == true) {
n++
}
})
if (n == self.DpList[self.filed].length) {
self.AllCheckedDp[self.filed] = true;
} else {
self.AllCheckedDp[self.filed] = false;
}
self.submitDpList(1)
}
self.submitDpList = function (n) {
var AllCheckedLength1 = 0;
self.selectDpList[self.filed] = [];
$.each(self.DpList[self.filed], function (index, item) {
if (item.checked == true) {
AllCheckedLength1++;
self.selectDpList[self.filed].push(item)
}
})
self.data[self.filed] = self.selectDpList[self.filed].map(function (item) {
return item.SECTION
}).join(",")
self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
self.changeFiled(self.filed)
if (n == 0) {
sp.layerhide();
}
}
self.openUserList = function (str) {
if (self.hide("readonly", str) == true) {
return
} else {
self.filed = str;
//self.AllChecked[self.filed] = false;
sp.layer("#userList")
$("#userList .sp-page").eq(0).scrollTop(0);
}
}
self.checkAllUser = function () {
self.AllChecked[self.filed] = !self.AllChecked[self.filed];
$.each(self.UserList[self.filed], function (index, item) {
item.checked = self.AllChecked[self.filed];
$.each(item.USER, function (index1, item1) {
item1.checked = self.AllChecked[self.filed];
})
})
self.submitUserList(1)
}
self.checkUserItem = function (item) {
item.checked = !item.checked;
$.each(item.USER, function (index, item1) {
item1.checked = item.checked;
})
var n = 0;
$.each(self.UserList[self.filed], function (index, item) {
if (item.checked == true) {
n++
}
})
if (n == self.UserList[self.filed].length) {
self.AllChecked[self.filed] = true;
} else {
self.AllChecked[self.filed] = false;
}
self.submitUserList(1)
}
self.checkUser = function (item) {
item.checked = !item.checked;
var n = [], all = 0;
$.each(self.UserList[self.filed], function (x, y) {
n.push(0);
$.each(y.USER, function (x1, y1) {
if (y1.checked == true) {
n[x]++
}
})
if (n[x] == y.USER.length && n[x] != 0) {
y.checked = true;
all++
} else {
y.checked = false;
}
})
if (all == self.UserList[self.filed].length) {
self.AllChecked[self.filed] = true;
} else {
self.AllChecked[self.filed] = false;
}
self.submitUserList(1)
}
self.submitUserList = function (n) {
var AllCheckedLength = 0;
self.selectList[self.filed] = [];
$.each(self.UserList[self.filed], function (index, item) {
$.each(item.USER, function (index1, item1) {
if (item1.checked == true) {
AllCheckedLength++;
self.selectList[self.filed].push(item1)
}
})
})
self.data[self.filed] = self.selectList[self.filed].map(function (item) {
return item.USHOWNAME
}).join(",")
if (self.data[self.filed + "ID"] != undefined) {
self.data[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
return item.USERID
}).join(",")
}
self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
self.changeFiled(self.filed)
if (n == 0) {
sp.layerhide();
}
}
//保存提交
self.btnSave = function (n) {
if (spngvld.submit("#formDesignPart")) {
///前端保存遍历自定义表单数据
var get_json_str = spbld.fbFrtTableJson("#formDesignPart", self.fb_queryDataCustom_data.TableName);
$timeout(function () {
if (sp.isval(get_json_str)) {
var dataArray = [];
dataArray.push(JSON.parse(get_json_str));
var data = {
ckey: self.fb_queryDataCustom_data.TableName,
id: self.data.ID,
routeid: self.routeid,
routeinfoid: self.routeinfoid,
routeinfotitle: "",
directionid: self.directionid,
formeditid: self.formeditid,
data: JSON.stringify(dataArray)
}
//console.log(JSON.stringify(data));
$http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.code == 0) {
self.data.ID = res.data.ID;
self.routeid = res.data.ROUTEID;
self.routeinfoid = res.data.ROUTEINFOID;
self.filedChange = false;
if (n == 0) {
sp.dialog("保存成功!");
$timeout(function () {
sp.dialoghide()
}, 1500)
self.getSwenList(1);
} else if (n == 1) {
self.forward(self.btnItem);
} else if (n == 2) {
self.sendAll();
} else if (n == 3) {
self.btnPrint();
}
} else {
sp.dialog(res.message)
}
});
}
}, 100);
}
}
//打印
self.btnPrint = function () {
if (self.filedChange == true) {
self.btnSave(3)
} else {
// 创建隐藏的可下载链接
//eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=moban1.ftl&tablename=FW_ZSWPXXW&outfilepath=/tmp/正式文(平、下行文).wps&printdate=RGRQ&routeinfoid=" + self.routeinfoid));
var postData = {
convertType: 29,
fileUrl: apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=moban1.ftl&tablename=FW_ZSWPXXW&outfilepath=/tmp/正式文(平、下行文).wps&printdate=RGRQ&routeinfoid=" + self.routeinfoid))
};
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) {
let rst = res.data;
//console.log(rst.viewUrl);
var eleLink = document.createElement('a');
eleLink.download = "";
eleLink.style.display = 'none';
eleLink.href = rst.viewUrl
// 触发点击
document.body.appendChild(eleLink);
eleLink.click();
// 然后移除
document.body.removeChild(eleLink);
} else {
sp.dialog(res.message);
}
});
}
}
/*综合打印*/
self.printFiled = 1;
self.btnPrint1 = function () {
if (self.filedChange == true) {
self.btnSave(3)
} else {
sp.layer("#print")
}
}
self.printSubmit = function () {
if (self.printFiled == 1) {
var templatefilename = "moban1"
} else if (self.printFiled == 2) {
var templatefilename = "mobanoption"
} else {
var templatefilename = "moban30_all"
}
var data = {
templatefilename: templatefilename + ".ftl",
outfilepath: "/tmp/正式文(平、下行文)" + sp.datefmt('yyyyMMddHHmmss', sp.getLocalDate()) + ".wps",
routeinfoid: self.routeinfoid,
tablename: "FW_ZSWPXXW",
printtype: self.printFiled
}
$http.post(apiurljs.login + "g2app/dataabase/PrintWordExtend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
//window.open("../../../printPreview.html?url=" + apiurljs.login + "g2work" + res.data[0].url)
window.parent.sp.addTabNav('printPreview', '打印预览', "printPreview.html?url=" + apiurljs.login + "g2work" + res.data[0].url)
})
//// 创建隐藏的可下载链接
//var eleLink = document.createElement('a');
//eleLink.download = "";
//eleLink.style.display = 'none';
//eleLink.href = apiurljs.login + "g2app/dataabase/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=" + templatefilename + ".ftl&tablename=FW_ZSWPXXW&outfilepath=/tmp/正式文(平、下行文).wps&printdate=LWRQ,DBSX&routeinfoid=" + self.routeinfoid + "&printtype=" + self.printFiled));
//// 触发点击
//document.body.appendChild(eleLink);
//eleLink.click();
//// 然后移除
//document.body.removeChild(eleLink);
sp.layerhide()
}
//签写意见编辑状态
self.opinion = {
WLDQFL: false,
WLDQFLImg: false,
WLDSSL: false,
WLDSSLImg: false,
FLSH: false,
FLSHImg: false,
GPJZSC: false,
GPJZSCImg: false,
SX: false,
SXImg: false,
BMFZRYJ: false,
BMFZRYJImg: false,
HBCSYJ: false,
HBCSYJImg: false,
nulla: false
}
self.YJ = {
WLDQFL: [],
WLDQFLSTATUS: false,
WLDSSL: [],
WLDSSLSTATUS: false,
FLSH: [],
FLSHSTATUS: false,
GPJZSC: [],
GPJZSCSTATUS: false,
SX: [],
SXSTATUS: false,
BMFZRYJ: [],
BMFZRYJSTATUS: false,
HBCSYJ: [],
HBCSYJSTATUS: false,
nulla: [],
nullaSTATUS: false
}
//意见(下表)
self.openOptionList = function () {
if (self.routeinfoid == 0 && self.routeid == 0) {
sp.dialog("请先保存!")
return;
}
if (self.opinion.nulla == true) {
return;
}
self.nulla = "";
$(".optionList").css("height", 149)
self.opinion.nulla = true;
}
self.closeOptionList = function () {
$(".optionList").css("height", 389)
self.opinion.nulla = false;
}
self.submitOptionList = function () {
var data = {
cmanid: self.userId,
routeinfoid: self.routeinfoid,
routeid: self.routeid,
tableid: "FW_ZSWPXXW",
colid: "",
opiniontype: 99,
cresult: "",
opinion: self.nulla,
opinionimage: ""
}
$http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success == true) {
self.getOpinion1();
self.opinion.nulla = false;
$(".optionList").css("height", 389)
} else {
sp.dialog(res.message)
}
})
}
self.changeOptionList = function (item) {
self.nulla = item.OPINION;
self.opinion.nulla = true;
}
//意见附件(下表)
self.uploading1 = false;
self.upload1 = function () {
$('#fileupload1').fileupload({
url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
dataType: 'json',
beforeSend: function (xhr, data) {
xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
+ ",routeid=" + self.routeid + ",tableid=FW_ZSWPXXW"));
},
// 上传完成后的执行逻辑
done: function (e, data) {
self.uploading1 = false;
self.getOpinion1()
}
})
}
//下载意见表附件
self.downLoadOption = function (item) {
window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
}
//删除意见表附件
self.deleteOptionFile = function (file) {
var data = {
tablename: "SYS_ROUTE_ATTACHLIST",
sqlwhere: "ROUTEID='" + file.ROUTEID + "' and FILEID='" + file.FILEID + "' and FILEDATE='" + file.FILEDATE + "'"
};
$http.post(apiurljs.login + "g2app/dataabase/deletBywhere", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
sp.dialoghide();
if (res.success) {
self.getOpinion1();
} else {
sp.dialog("删除失败,请联系管理员!");
}
});
}
//发生修改
self.changeFiled = function (str) {
self.filedChange = true;
if (str = "XXGKSH") {
self.XXGKSH.forEach(function (item) {
if (item.CODE == self.data.XXGKSH) {
self.data.XXGKSH1 = item.CNAME
}
})
}
}
//转发
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.forwardUser.length == 0) {
sp.layerhide()
sp.dialog("请选择人员!");
$timeout(function () {
sp.dialoghide()
sp.layer("#forward");
}, 2000)
return
}
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.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: self.mainSend.map(function (item) {
return item.USERID
}).join("|"),
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) {
sp.dialog("发送成功!");
$timeout(function () {
window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
}, 1500)
} else {
sp.dialog(res.message)
}
})
}
}
//查看流转记录
self.RouteList = function () {
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) {
item.mainUser = [];
item.copyUsers = [];
$.each(item.USERS, function (index1, item1) {
if (item1.KIND == 0) {
item.mainUser.push(item1.USERNAME);
} else {
item.copyUsers.push(item1.USERNAME);
}
})
item.mainUser = item.mainUser.join(",");
item.copyUsers = item.copyUsers.join(",");
})
$timeout(function (item) {
sp.layer("#RouteList");
}, 100);
})
}
//头部下滚冻结
$(function () {
$(".sp-page-center").eq(0).css("max-height", $(window).height() - 160).css("height", $(window).height() - 160)
$(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
//$("body").bind("scroll", function () {
// var scrollTop = $("body").scrollTop();
// if (scrollTop == 0) {
// $(".FixTop").removeClass("FixTop");
// }
// if (scrollTop > 35) {
// $(".sp-page-title").parents(".sp-box").addClass("FixTop");
// }
//});
//页面高度撑满
$timeout(function () {
if ($(".ibox-content").height() < $(window).height() - 31) {
$(".ibox-content").css("height", $(window).height() - 31)
}
}, 1)
})
}])
app.filter('trustHtml', function ($sce) {
return function (input) {
return $sce.trustAsHtml(input.replace(/\n/g, '
').replace(/\s/g, ' '));
};
});