123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983 |
- '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 = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
- $('.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 = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此文件吗?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='upDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
- $('.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);
- }
- });
- }
- }])
|