'use strict';
var app = angular.module('app', [
'angularUtils.directives.dirPagination',
]);
app.controller("indexCtrl", ["$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");
var postCfg = {
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + self.get_AccessToken
}
};
self.CrossPage = window.parent.CrossPage;
$(".filelist").css("height", $(".sp-wrapper-left").height() - 70)
self.getLeftTree = function () {
var data = {
tablename: "KNOWLEDGETREE",
cuserid: self.userId
}
$http.post(apiurljs.login + "g2app/dataabase/getTreeListByTablename2", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.leftTree = res.data;
self.checkNode(self.leftTree[0].C_H_I_L_D_DATA[0])
})
}
self.getLeftTree();
self.addNode = function () {
self.add = {
"tablename": "KNOWLEDGETREE",
"PARENT_CNAME": "知识库",
"code": "P01",
"levels": "1",
"cname": "",
"userid": self.userId
}
sp.layer('#layer_box_add')
}
///修改菜单
self.editNode = function (obj) {
self.edit = {
"id": obj.ID,
"tablename": "KNOWLEDGETREE",
"cname": obj.CNAME,
"userid": self.userId
}
sp.layer('#layer_box_edit');
};
self.btnSaveNode = function (n) {
if (n == 1) {
var data = {
"tablename": self.add.tablename,
"code": self.add.code,
"levels": self.add.levels,
"cname": self.add.cname,
"userid": self.add.userid
}
$http.post(apiurljs.login + "g2app/dataabase/TreeAdd", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success) {
sp.layerhide();
self.getLeftTree();
} else {
sp.layerhide();
sp.dialog(res.message);
}
})
} else {
var data = {
"id": self.edit.id,
"tablename": self.edit.tablename,
"setwhere": {
"CNAME": self.edit.cname
}
}
$http.post(apiurljs.login + "g2app/dataabase/setColumnsById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success) {
sp.layerhide();
self.getLeftTree();
} else {
sp.layerhide();
sp.dialog(res.message);
}
})
}
}
self.deleteNode = function (obj) {
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 () {
sp.dialoghide();
var postData = {
id: obj.ID,
tablename: "KNOWLEDGETREE",
parentid: obj.PARENTID
}
$http.post(apiurljs.login + "g2app/dataabase/delNode", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success) {
self.getLeftTree();
} else {
sp.dialog(res.message);
}
});
});
}
self.checkNode = function (obj) {
self.active = obj;
self.getRightData();
}
self.search = {
type: "",
name: ""
}
//关闭wps刷新
$scope.WpsClose = function () {
self.getRightData();
}
self.listType = 1;
self.getRightData = function () {
switch (self.active.CODE) {
case "P0101": self.getGG(); break;
case "P0102": self.getGR(); break;
case "P0103": self.getFX(); break;
case "P0104": self.getBFX(); break;
default: self.getSelfData(); break
}
}
self.getFileType = function (str) {
var img = /(jpg|png|gif|tif|ico|bmp|tga|pic)$/i;
var audio = /(mp3|wma|ape|flac|dts|m4a|aac|ac3|mmf|amr|m4r|ogg)$/i;
var video = /(mp4|mkv|avi|flv|mov|wmv|3gp|3g2|mpg|vob|swf)$/i;
var text = /(doc|docx|wps|ppt|pptx|xls|xlsx|ofd|pdf|txt|rar|zip)$/i;
if (img.test(str) == true) {
return "img"
} else if (audio.test(str) == true) {
return "audio"
} else if (video.test(str) == true) {
return "video"
} else if (text.test(str) == true) {
return "text"
} else {
return "other"
}
}
self.getGG = function () {
self.list = [];
var data = {
tablename: "KNOWLEDGEATTACHLIST",
pageno: 0,
pagesize: 0,
colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
order: "ID",
sqlwhere: {
ROUTEINFOID: self.active.ID
},
sqlorwhere: "",
sqlinwhere: "",
sqllikewhere: {
FILEOLDNAME: self.search.name
}
}
if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
delete data.sqlwhere.ATTACHTYPE
} else {
data.sqlwhere.ATTACHTYPE = self.search.type
}
$http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.list = res.data;
$.each(self.list, function (index, item) {
item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
item.img = "css/doc.png";
} else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
item.img = "css/ppt.png";
} else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
item.img = "css/xls.png";
} else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
item.img = "css/ofd.png";
} else {
item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
}
})
})
}
self.getGR = function () {
self.list = [];
var data = {
tablename: "KNOWLEDGEATTACHLIST",
pageno: 0,
pagesize: 0,
colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
order: "ID",
sqlwhere: {
ROUTEINFOID: self.active.ID,
USERID: self.userId
},
sqlorwhere: "",
sqlinwhere: "",
sqllikewhere: {
FILEOLDNAME: self.search.name
}
}
if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
delete data.sqlwhere.ATTACHTYPE
} else {
data.sqlwhere.ATTACHTYPE = self.search.type
}
$http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.list = res.data;
$.each(self.list, function (index, item) {
item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
item.img = "css/doc.png";
} else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
item.img = "css/ppt.png";
} else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
item.img = "css/xls.png";
} else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
item.img = "css/ofd.png";
} else {
item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
}
})
})
}
self.getFX = function () {
self.list = [];
var data = {
tablename: "KNOWLEDGEATTACHLIST",
pageno: 0,
pagesize: 0,
colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
order: "ID",
sqlwhere: {
USERID: self.userId,
SHAREMARK: 1
},
sqlorwhere: "",
sqlinwhere: "",
sqllikewhere: {
FILEOLDNAME: self.search.name
}
}
if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
delete data.sqlwhere.ATTACHTYPE
} else {
data.sqlwhere.ATTACHTYPE = self.search.type
}
$http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.list = res.data;
$.each(self.list, function (index, item) {
item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
item.img = "css/doc.png";
} else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
item.img = "css/ppt.png";
} else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
item.img = "css/xls.png";
} else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
item.img = "css/ofd.png";
} else {
item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
}
})
})
}
self.getBFX = function () {
self.list = [];
var data = {
tablename: "KNOWLEDGEATTACHLIST",
pageno: 0,
pagesize: 0,
colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
order: "ID",
sqlwhere: {},
sqlorwhere: "",
sqlinwhere: "",
sqllikewhere: {
FILEOLDNAME: self.search.name,
TOSHAREUSERID: self.userId
}
}
if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
delete data.sqlwhere.ATTACHTYPE
} else {
data.sqlwhere.ATTACHTYPE = self.search.type
}
$http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.list = res.data;
$.each(self.list, function (index, item) {
item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
item.img = "css/doc.png";
} else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
item.img = "css/ppt.png";
} else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
item.img = "css/xls.png";
} else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
item.img = "css/ofd.png";
} else {
item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
}
})
})
}
self.getSelfData = function () {
self.list = [];
var data = {
tablename: "KNOWLEDGEATTACHLIST",
pageno: 0,
pagesize: 0,
colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
order: "ID",
sqlwhere: {
ROUTEINFOID: self.active.ID
},
sqlorwhere: "",
sqlinwhere: "",
sqllikewhere: {
FILEOLDNAME: self.search.name
}
}
if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
delete data.sqlwhere.ATTACHTYPE
} else {
data.sqlwhere.ATTACHTYPE = self.search.type
}
$http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
self.list = res.data;
$.each(self.list, function (index, item) {
item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
item.img = "css/doc.png";
} else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
item.img = "css/ppt.png";
} else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
item.img = "css/xls.png";
} else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
item.img = "css/ofd.png";
} else {
item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
}
})
})
}
self.changeListType = function (n) {
if (n == self.listType) {
return;
} else {
self.listType = n;
}
}
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=KNOWLEDGEATTACHLIST,routeinfoid=" + self.active.ID + ",code=" + self.active.CODE + ",ATTACHTYPE=" + self.Filetype + ",userid=" + self.userId));
},
add: function (e, data) {
self.Filetype = self.getFileType(data.files[0].name);
//文件类型判断
//if (!self.Filetype) {
// sp.dialog(data.files[0].name + "文件类型不对");
// return;
//} else {
self.uploading = true;
data.submit(); $scope.$apply();
//}
},
// 上传完成后的执行逻辑
done: function (e, data) {
self.uploading = false;
var arrayFile = strToJson(s4.decryptData_CBC(data.result.data))
//sp.transmit2("FILEMANAGER_SHENQING", "行政", "", arrayFile.data, self.active.ID, "KNOWLEDGEATTACHLIST")
//sp.transmit1("FILEMANAGER_SHENQING", "行政", "", arrayFile.data[0].FILENAMES, arrayFile.data[0].FILEEXT, arrayFile.data[0].FILESIZE, arrayFile.data[0].FILEURL, arrayFile.data[0].FILEID, self.active.ID, "KNOWLEDGEATTACHLIST")
self.getRightData();
sp.dialog("上传成功!")
$timeout(function () {
sp.dialoghide()
},1500)
}
})
}
self.downloadFile = function (item) {
window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
}
self.fxFile = function (obj) {
self.fxFileID = obj.ID;
self.fxFileName = obj.FILEOLDNAME;
self.fxFileName1 = obj.FILEOLDNAME.slice(0, 20) + "...";
if (obj.TOSHAREUSERID) {
self.personList.forEach(function (item) {
item.C_H_I_L_D_DATA.forEach(function (item2) {
item2.isChecked = obj.TOSHAREUSERID.indexOf(item2.userid) > -1 ? true : false;
})
item.C_H_I_L_D.forEach(function (item3) {
item3.isChecked = false;
item3.C_H_I_L_D_DATA.forEach(function (item4) {
item4.isChecked = obj.TOSHAREUSERID.indexOf(item4.userid) > -1 ? true : false;
})
item3.C_H_I_L_D.forEach(function (item5) {
item5.isChecked = false;
item5.C_H_I_L_D_DATA.forEach(function (item6) {
item6.isChecked = obj.TOSHAREUSERID.indexOf(item6.userid) > -1 ? true : false;
})
})
})
})
}
sp.layer("#layer_fenxiang")
}
self.btnFX = function () {
var TOSHAREUSERID = []
self.personList.forEach(function (item) {
item.C_H_I_L_D_DATA.forEach(function (item2) {
if (item2.isChecked) {
TOSHAREUSERID.push(item2.userid);
}
})
item.C_H_I_L_D.forEach(function (item3) {
item3.C_H_I_L_D_DATA.forEach(function (item4) {
if (item4.isChecked) {
TOSHAREUSERID.push(item4.userid);
}
})
item3.C_H_I_L_D.forEach(function (item5) {
item5.C_H_I_L_D_DATA.forEach(function (item6) {
if (item6.isChecked) {
TOSHAREUSERID.push(item6.userid);
}
})
})
})
})
sp.layerhide();
var data = {
id: self.fxFileID,
tablename: "KNOWLEDGEATTACHLIST",
data: {
TOSHAREUSERID: TOSHAREUSERID.join(","),
SHAREMARK: 1
}
}
$http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
if (res.success) {
self.getRightData();
} else {
sp.dialog(res.message)
}
})
}
//参会人员
self.getPeople = function () {
var data = {
code: "AA"
}
$http.post(apiurljs.login + "g2app/calendar/querySect", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
$.each(res.data[0].C_H_I_L_D, function (index, item) {
item.isChecked = false;
$.each(item.C_H_I_L_D_DATA, function (index2, item2) {
item2.isChecked = false;
})
$.each(item.C_H_I_L_D, function (index3, item3) {
item3.isChecked = false;
$.each(item3.C_H_I_L_D_DATA, function (index4, item4) {
item4.isChecked = false;
})
$.each(item3.C_H_I_L_D, function (index5, item5) {
item5.isChecked = false;
$.each(item5.C_H_I_L_D_DATA, function (index6, item6) {
item6.isChecked = false;
})
})
})
})
self.personList = res.data[0].C_H_I_L_D;
})
}
self.getPeople()
//一级部门的勾选
self.firstDepartSelect = function (index) {
var flag = self.personList[index].isChecked;
self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
item.isChecked = flag;
})
self.personList[index].C_H_I_L_D.forEach(function (item2) {
item2.isChecked = flag;
item2.C_H_I_L_D_DATA.forEach(function (item3) {
item3.isChecked = flag;
});
item2.C_H_I_L_D.forEach(function (item4) {
item4.isChecked = flag;
item4.C_H_I_L_D_DATA.forEach(function (item5) {
item5.isChecked = flag;
});
})
})
var itemTotal = self.personList.length;
var itemSelect = 0;
self.personList.forEach(function (item) {
if (item.isChecked) {
itemSelect++
}
})
if (itemTotal == itemSelect) {
self.isSelectedAll = true;
} else {
self.isSelectedAll = false;
}
}
//二级部门的勾选
self.secondDepartSelect = function (index, index2) {
var flag = self.personList[index].C_H_I_L_D[index2].isChecked;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
item.isChecked = flag;
})
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.forEach(function (item2) {
item2.isChecked = flag;
item2.C_H_I_L_D_DATA.forEach(function (item3) {
item3.isChecked = flag;
});
})
var totalDepat = self.personList[index].C_H_I_L_D.length;
var selectDepart = 0
self.personList[index].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
selectDepart++
}
})
if (totalDepat == selectDepart) {
var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
var childSelect = 0;
self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
childSelect++;
}
})
if (childSelect == childTotal) {
self.personList[index].isChecked = true;
} else {
self.personList[index].isChecked = false;
}
} else {
self.personList[index].isChecked = false;
}
var itemTotal = self.personList.length;
var itemSelect = 0;
self.personList.forEach(function (item) {
if (item.isChecked) {
itemSelect++
}
})
if (itemTotal == itemSelect) {
self.isSelectedAll = true;
} else {
self.isSelectedAll = false;
}
}
//三级部门点击
self.thirdDepartSelect = function (index, index2, index3) {
var flag = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].isChecked;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].C_H_I_L_D_DATA.forEach(function (item) {
item.isChecked = flag;
})
var thirdDepat = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.length;
var thirdDepart = 0;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
thirdDepart++
}
})
if (thirdDepat == thirdDepart) {
var thirdTotal = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.length;
var thirdSelect = 0;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
thirdSelect++;
}
})
if (thirdSelect == thirdTotal) {
self.personList[index].C_H_I_L_D[index2].isChecked = true;
} else {
self.personList[index].C_H_I_L_D[index2].isChecked = false;
}
} else {
self.personList[index].C_H_I_L_D[index2].isChecked = false;
}
var totalDepat = self.personList[index].C_H_I_L_D.length;
var selectDepart = 0
self.personList[index].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
selectDepart++
}
})
if (totalDepat == selectDepart) {
var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
var childSelect = 0;
self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
childSelect++;
}
})
if (childSelect == childTotal) {
self.personList[index].isChecked = true;
} else {
self.personList[index].isChecked = false;
}
} else {
self.personList[index].isChecked = false;
}
var itemTotal = self.personList.length;
var itemSelect = 0;
self.personList.forEach(function (item) {
if (item.isChecked) {
itemSelect++
}
})
if (itemTotal == itemSelect) {
self.isSelectedAll = true;
} else {
self.isSelectedAll = false;
}
}
//三级部门人员点击
self.thirdUserSelect = function (index, index2, index3) {
var totalNum = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].C_H_I_L_D_DATA.length;
var selectNum = 0;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
selectNum++;
}
})
if (totalNum == selectNum) {
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].isChecked = true;
} else {
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].isChecked = false;
}
var thirdDepat = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.length;
var thirdDepart = 0;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
thirdDepart++
}
})
if (thirdDepat == thirdDepart) {
var thirdTotal = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.length;
var thirdSelect = 0;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
thirdSelect++;
}
})
if (thirdSelect == thirdTotal) {
self.personList[index].C_H_I_L_D[index2].isChecked = true;
} else {
self.personList[index].C_H_I_L_D[index2].isChecked = false;
}
} else {
self.personList[index].C_H_I_L_D[index2].isChecked = false;
}
var totalDepat = self.personList[index].C_H_I_L_D.length;
var selectDepart = 0
self.personList[index].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
selectDepart++
}
})
if (totalDepat == selectDepart) {
var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
var childSelect = 0;
self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
childSelect++;
}
})
if (childSelect == childTotal) {
self.personList[index].isChecked = true;
} else {
self.personList[index].isChecked = false;
}
} else {
self.personList[index].isChecked = false;
}
var itemTotal = self.personList.length;
var itemSelect = 0;
self.personList.forEach(function (item) {
if (item.isChecked) {
itemSelect++
}
})
if (itemTotal == itemSelect) {
self.isSelectedAll = true;
} else {
self.isSelectedAll = false;
}
}
//二级部门人员点击
self.secondUserSelect = function (index, index2) {
var totalNum = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.length;
var selectNum = 0;
self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
selectNum++;
}
})
if (totalNum == selectNum) {
self.personList[index].C_H_I_L_D[index2].isChecked = true;
} else {
self.personList[index].C_H_I_L_D[index2].isChecked = false;
}
var totalDepat = self.personList[index].C_H_I_L_D.length;
var selectDepart = 0
self.personList[index].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
selectDepart++
}
})
if (totalDepat == selectDepart) {
var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
var childSelect = 0;
self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
childSelect++;
}
})
if (childSelect == childTotal) {
self.personList[index].isChecked = true;
} else {
self.personList[index].isChecked = false;
}
} else {
self.personList[index].isChecked = false;
}
var itemTotal = self.personList.length;
var itemSelect = 0;
self.personList.forEach(function (item) {
if (item.isChecked) {
itemSelect++
}
})
if (itemTotal == itemSelect) {
self.isSelectedAll = true;
} else {
self.isSelectedAll = false;
}
}
//一级部门人员点击
self.firstUserSelect = function (index) {
var totalDepat = self.personList[index].C_H_I_L_D.length;
var selectDepart = 0
self.personList[index].C_H_I_L_D.forEach(function (item) {
if (item.isChecked) {
selectDepart++
}
})
if (totalDepat == selectDepart) {
var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
var childSelect = 0;
self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
if (item.isChecked) {
childSelect++;
}
})
if (childSelect == childTotal) {
self.personList[index].isChecked = true;
} else {
self.personList[index].isChecked = false;
}
} else {
self.personList[index].isChecked = false;
}
var itemTotal = self.personList.length;
var itemSelect = 0;
self.personList.forEach(function (item) {
if (item.isChecked) {
itemSelect++
}
})
if (itemTotal == itemSelect) {
self.isSelectedAll = true;
} else {
self.isSelectedAll = false;
}
}
//全选函数
self.isSelectedAll = false;
self.selectAll = function () {
var flag = self.isSelectedAll;
self.personList.forEach(function (item) {
item.isChecked = flag;
item.C_H_I_L_D_DATA.forEach(function (item2) {
item2.isChecked = flag;
})
item.C_H_I_L_D.forEach(function (item3) {
item3.isChecked = flag;
item3.C_H_I_L_D_DATA.forEach(function (item4) {
item4.isChecked = flag;
})
item3.C_H_I_L_D.forEach(function (item5) {
item5.isChecked = flag;
item5.C_H_I_L_D_DATA.forEach(function (item6) {
item6.isChecked = flag;
})
})
})
})
}
self.deleteFile = function (item) {
var dialogHead = "温馨提示×";
var dialogBody = "您确认要删除此文件吗?
";
var dialogFoot = "";
$('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
sp.openCenter(".sp-dialog");
$('.sp-closeDialog').click(function (event) {
sp.dialoghide();
event.preventDefault();
event.stopPropagation();
});
$("#upDataTrue").click(function () {
sp.dialoghide();
var data = {
id: item.ID,
tablename: "KNOWLEDGEATTACHLIST"
}
$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));
if (res.success) {
self.getRightData();
//sp.deltransmit(item.FILEID)
} else {
sp.dialog(res.message)
}
})
});
}
self.openAddFile = function () {
self.add = {
FILESNAME: "",
}
sp.layer("#layer_addwps")
}
self.btnAddWps = function () {
var data = {
tablename: "KNOWLEDGEATTACHLIST",
data: {
FILENAMES: self.add.FILESNAME + ".wps",
FILEEXT: "",
ATTACHTYPE: "text",
CODE: self.active.CODE,
USERID: self.userId,
ROUTEINFOID: self.active.ID
}
}
$http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
.success(function (obj) {
var res = strToJson(s4.decryptData_CBC(obj.data));
sp.layerhide()
if (res.success == true) {
self.getRightData()
} else {
sp.dialeg(res.message)
}
})
}
self.goUrl = function (obj) {
var set_convertType = 0;
if (obj.FILEEXT == "pdf") {
set_convertType = 20;
} else if (obj.FILEEXT == "ofd") {
set_convertType = 570;
} else if (/(jpg|png|gif|bmp)$/i.test(obj.FILEEXT) == true) {
set_convertType = 23;
} else {
set_convertType = 0;
}
let postData = {
convertType: set_convertType,
fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
};
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;
window.open(rst.viewUrl)
} else {
sp.dialog(res.message);
}
});
}
}])