123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
- self.get_type = sp.getUrlName("type");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.getDpList = 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.dpList.forEach(function (item) {
- item.checked = false;
- item.USER.forEach(function (item1) {
- item1.checked = false;
- item1.USHOWNAME1 = item1.USHOWNAME.length > 3 ? item1.USHOWNAME.slice(0, 3) + "..." : item1.USHOWNAME;
- item1.USHOWNAME2 = item1.USHOWNAME.length > 10 ? item1.USHOWNAME.slice(0, 10) + "..." : item1.USHOWNAME
- })
- })
- self.DpList = {
- SQBM: JSON.parse(JSON.stringify(self.dpList))
- }
- self.AllCheckedDp = {};
- self.DpLength = {};
- self.selectDpList = {};
- self.UserList = {
- PSLD: JSON.parse(JSON.stringify(self.dpList)),
- CYR: JSON.parse(JSON.stringify(self.dpList))
- };
- self.AllChecked = {};
- self.UserLength = {};
- self.selectList = {};
- self.getData()
- })
- }
- self.getData = function () {
- var data = {
- tablename: "HYQGC",
- colums: "*",
- order: "ID desc",
- sqlwhere: "",
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: ""
- };
- $http.post(apiurljs.login + "g2app/richang/queryHYQGCDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data == null || res.data == undefined || res.data == "") {
- self.noDataTip = 0;
- } else {
- self.noDataTip = 1;
- self.addFlag = false;
- self.editFlag = false;
- self.list = res.data;
- self.list.forEach(function (item) {
- item.checked = false;
- item.editFlag = false;
- for (var i in item) {
- isNull(item, i)
- }
- console.log(item.HYJYWJ)
- item.HYJYWJ1 = item.HYJYWJ == "" ? [] : JSON.parse(item.HYJYWJ)
- item.SQSJ= sp.datefmt("yyyy-MM-dd HH:mm",item.SQSJ)
- item.PSSJ = sp.datefmt("yyyy-MM-dd HH:mm", item.PSSJ)
- item.KSSJ = sp.datefmt("yyyy-MM-dd HH:mm", item.KSSJ)
- item.GDSJ = sp.datefmt("yyyy-MM-dd HH:mm", item.GDSJ)
- })
- }
- })
- }
- self.getDpList()
- self.goUrl = function (obj) {
- if (obj.FILEN != "") {
- window.top.sp.addTabNav("FZJ07", "会议室申请", "tpl/huiyishibg/" + obj.FILEN)
- }
- }
- self.init = function () {
- $http.post(apiurljs.login + "g2app/richang/initHYQGCData", { data: s4.encryptData_CBC(JSON.stringify({})) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data))
- if (res.success == true) {
- self.getData()
- }
- })
- }
- self.btnAdd = function () {
- self.addFlag = true;
- self.editFlag = false;
- self.list.forEach(function (item) {
- item.editFlag = false;
- })
- self.edit = {
- ID: 0,
- HYMC: "",
- SQSJ: "",
- SQBM: "",
- SQBM1: "",
- PSSJ: "",
- PSLD: "",
- PSLD1: "",
- PSLDID: "",
- HYS: "",
- KSSJ: "",
- CYR: "",
- CYR1: "",
- CYRID: "",
- }
- }
- self.btnEdit = function (obj) {
- self.editFlag = true;
- obj.editFlag = true;
- self.edit = {
- ID: obj.ID,
- HYMC: obj.HYMC,
- SQSJ: obj.SQSJ,
- SQBM: obj.SQBM,
- SQBM1: obj.SQBM,
- PSSJ: obj.PSSJ,
- PSLD: obj.PSLD,
- PSLD1: obj.PSLD,
- PSLDID: obj.PSLDID,
- HYS: obj.HYS,
- KSSJ: obj.KSSJ,
- CYR: obj.CYR,
- CYR1: obj.CYR,
- CYRID: obj.CYRID,
- }
- }
- self.btnDel = function (id) {
- 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 () {
- var data = {
- tablename: "HYQGC",
- id: 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.getData(self.pageno);
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- });
- });
- }
- self.openDpList = function (str) {
- if (self.edit[str + "1"] != "") {
- return
- } else {
- 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.SQBM.indexOf(item.SECTION) != -1 && i == "SQBM") {
- 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;
- }
- }
- self.filed = str;
- 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.edit[self.filed] = self.selectDpList[self.filed].map(function (item) {
- return item.SECTION
- }).join(",")
- self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
- if (n == 0) {
- sp.layerhide();
- }
- }
- self.openUserList = function (str) {
- if (self.edit[str + "1"] != "") {
- return
- } else {
- var n = {}, all = {};
- for (var i in self.UserList) {
- self.AllChecked[i] = false;
- self.UserLength[i] = 0;
- self.selectList[i] = []
- n[i] = [];
- all[i] = 0;
- $.each(self.UserList[i], function (index, item) {
- n[i].push(0)
- item.checked = false;
- $.each(item.USER, function (index1, item1) {
- self.UserLength[i]++
- item1.checked = false;
- if (self.edit.PSLDID.indexOf(item1.USERID) != -1 && i == "PSLD") {
- n[i][index]++;
- item1.checked = true;
- self.selectList[i].push(item1);
- }
- if (self.edit.CYRID.indexOf(item1.USERID) != -1 && i == "CYR") {
- n[i][index]++;
- item1.checked = true;
- self.selectList[i].push(item1);
- }
- })
- if (n[i][index] == item.USER.length && n[i][index] != 0) {
- item.checked = true;
- all[i]++;
- }
- })
- if (all[i] == self.UserList[i].length) {
- self.AllChecked[i] = true;
- } else {
- self.AllChecked[i] = false;
- }
- }
- self.filed = str;
- 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.UserLength[self.filed] = 0;
- self.selectList[self.filed] = [];
- $.each(self.UserList[self.filed], function (index, item) {
- $.each(item.USER, function (index1, item1) {
- self.UserLength[self.filed]++;
- if (item1.checked == true) {
- AllCheckedLength++;
- self.selectList[self.filed].push(item1)
- }
- })
- })
- self.edit[self.filed] = self.selectList[self.filed].map(function (item) {
- return item.USHOWNAME
- }).join(",")
- if (self.edit[self.filed + "ID"] != undefined) {
- self.edit[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
- return item.USERID
- }).join(",")
- }
- self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
- if (n == 0) {
- sp.layerhide();
- }
- }
- self.btnSubmit = function () {
- var data = {
- tablename: "HYQGC",
- data: {
- HYMC: self.edit.HYMC,
- SQSJ: self.edit.SQSJ,
- SQBM: self.edit.SQBM,
- PSSJ: self.edit.PSSJ,
- PSLD: self.edit.PSLD,
- PSLDID: self.edit.PSLDID,
- HYS: self.edit.HYS,
- KSSJ: self.edit.KSSJ,
- CYR: self.edit.CYR,
- CYRID: self.edit.CYRID
- }
- }
- $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));
- if (res.success) {
- sp.dialog("添加成功!");
- self.getData();
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.btnSave = function () {
- var data = {
- id: self.edit.ID,
- tablename: "HYQGC",
- data: {
- HYMC: self.edit.HYMC,
- SQSJ: self.edit.SQSJ,
- SQBM: self.edit.SQBM,
- PSSJ: self.edit.PSSJ,
- PSLD: self.edit.PSLD,
- PSLDID: self.edit.PSLDID,
- HYS: self.edit.HYS,
- KSSJ: self.edit.KSSJ,
- CYR: self.edit.CYR,
- CYRID: self.edit.CYRID
- }
- }
- $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) {
- sp.dialog("保存成功!");
- self.getData();
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.openFiles = function (obj) {
- self.filesTitle = obj.HYJYWJ1[0].DOCNAME;
- self.filesList = obj.HYJYWJ1;
- sp.layer("#files");
- }
- self.openFile = function (obj) {
- let postData = {
- convertType: 0,
- fileUrl: apiurljs.login.split("glwork/")[0] + "glworkweb/" + obj.FILEURL
- };
- var postCfg_transfer = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
- .success(function (res) {
- if (res.errorcode === 0) {
- let rst = res.data;
- window.open(rst.viewUrl)
- }
- });
- }
- }])
- function isNull(obj, str) {
- if (obj[str] == null) {
- obj[str] = "";
- }
- }
|