123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("listCtrl", ["$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.dateParam = sp.getUrlName("date");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
-
- self.search = {
- type: 1,
- dw: "",
- date: self.dateParam == "" ? sp.currentYear() + "-" + formate(sp.currentMonth()) : self.dateParam
- }
- self.showType = 1;
- self.getYF = function () {
- var data = {
- ckey: "CODE_ZBYF",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.YF = res.data.CODE_ZBYF;
- self.getXQ()
- })
- }
- self.getXQ = function () {
- var data = {
- ckey: "CODE_ZBXQ",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.XQ = res.data.CODE_ZBXQ;
- self.getType()
- })
- }
- self.getType = function () {
- var data = {
- userid: self.userId
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDPParentName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- for (var i in res.data[0]) {
- if (res.data[0][i][0].PARENT_DATA.length > 0){
- self.search.type = res.data[0][i][0].PARENT_DATA[0].SECTION != "直属单位" ? 1 : 2;
- } else {
- self.search.type = 1;
- }
- }
- //self.search.type == res.data;
- if (self.search.type == 1) {
- self.getZBSJ()
- } else {
- self.getZBSJ1()
- }
- })
- }
- //委机关
- self.getZBSJ = function () {
- var data = {
- ckey: "CODE_ZHIBANTIME",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.ZBSJ = res.data.CODE_ZHIBANTIME;
- self.getData()
- })
- }
- //直属单位
- self.getZBSJ1 = function () {
- var data = {
- ckey: "CODE_ZHIBANTIMEZSDW",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.ZBSJ = res.data.CODE_ZHIBANTIMEZSDW;
- self.getDP()
- })
- }
- self.getDP = function () {
- var data = {
- userid: self.userId
- }
- $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
- self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
- self.getData();
- })
- }
- self.getYF()
-
- self.getData = function () {
- var year = self.search.date.split("-")[0], month = "";
- self.YF.forEach(function (item) {
- if (formate(item.CNAME) == self.search.date.split("-")[1]) {
- month = item.CODE;
- }
- })
- self.list = [];
- var data = {
- tablename: self.search.type == 1 ? "SX_PRZBB" : "SX_YFZBB",
- colums: "*",
- order: "ID desc",
- sqlwhere: { NF: year, YF: month, STOPMARK: 1 },
- sqlorwhere: "",
- sqlinwhere: "",
- sqllikewhere: self.search.type == 1 ? "" : { SQDWCODE: self.userDpCode }
- }
- $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.canExportExcel = true;
- if (res.data == null || res.data == undefined || res.data == "") {
- sp.dialog(self.search.date.split("-")[0] + "年" + self.search.date.split("-")[1] + "月暂无审批通过数据!");
- } else {
- self.parentID = res.data[0].ID;
- if (self.search.type == 1) {
- self.ZBREMARK = res.data[0].ZBREMARK;
- } else {
- self.ZBSJREMARK = res.data[0].ZBSJREMARK;
- self.ZBDH = res.data[0].ZBDH;
- self.ZBCZ = res.data[0].ZBCZ;
- self.YJJJRZBDH = res.data[0].YJJJRZBDH;
- self.YJJJRZBCZ = res.data[0].YJJJRZBCZ;
- self.ZBDD = res.data[0].ZBDD;
- self.TBR = res.data[0].TBR;
- self.REMARK = res.data[0].REMARK;
- }
- if (self.search.type == 1) {
- self.list1 = [];
- self.list2 = [];
- var data = {
- tablename: "SX_PRZBB_01",
- colums: "*",
- order: "ID",
- sqlwhere: { PID: self.parentID },
- sqlinwhere: "",
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "/g2app/ZhiBan/queryPRZBList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data.indexmark.start_index == 0) {
- self.table1 = 4; self.table2 = 1
- }
- if (res.data.indexmark.start_index2 == 0) {
- self.table1 = 1; self.table2 = 4
- }
- if (res.data.indexmark.start_index2 == -1 && res.data.indexmark.end_index2 == -1) {
- self.table1 = 4; self.table2 = 0
- }
- $.each(res.data.data, function (index, item) {
- item.RIQI = formate(item.RIQI);
- self.XQ.forEach(function (item1) {
- if (item.XINGQI == item1.CODE) {
- item.XINGQI = item1.CNAME
- }
- })
- self.ZBSJ.forEach(function (item1) {
- if (item.ZBSJ == item1.CODE) {
- item.ZBSJ = item1.CNAME
- }
- })
- if (res.data.indexmark.start_index == 0 && res.data.indexmark.start_index2 > 0) {
- if (index < res.data.indexmark.start_index2) {
- self.list1.push(item)
- } else {
- self.list2.push(item)
- }
- }
- if (res.data.indexmark.start_index2 == 0 && res.data.indexmark.start_index > 0) {
- if (index < res.data.indexmark.start_index) {
- self.list1.push(item)
- } else {
- self.list2.push(item)
- }
- }
- if (res.data.indexmark.start_index2 == -1 && res.data.indexmark.end_index2 == -1) {
- self.list1.push(item)
- }
- })
- })
- } else {
- var data1 = {
- tablename: "SX_YFZBB_01",
- colums: "*",
- order: "ID",
- sqlwhere: { PID: self.parentID },
- sqlinwhere: "",
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
- .success(function (obj1) {
- var res1 = strToJson(s4.decryptData_CBC(obj1.data));
- self.list1 = res1.data;
- self.list1.forEach(function (item) {
- item.RIQI = formate(item.RIQI);
- self.XQ.forEach(function (item1) {
- if (item.XINGQI == item1.CODE) {
- item.XINGQI = item1.CNAME
- }
- })
- self.ZBSJ.forEach(function (item1) {
- if (item.ZBSJ == item1.CODE) {
- item.ZBSJ = item1.CNAME
- }
- })
- })
- })
- }
- }
- })
- }
- self.printOut = function () {
- if (self.canExportExcel) {
- $('#printOut td').attr('t', 's')
- var defaultCellStyle = {
- font: {
- name: 'Times New Roman',
- sz: 12,
- color: {
- rgb: "000000"
- },
- bold: false, italic: false,
- underline: false
- },
- alignment: {
- vertical: "center",
- horizontal: "center", indent: 0, wrapText: true
- },
- border: {
- top: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- right: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- bottom: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- },
- left: {
- style: "thin",
- color: {
- rgb: "000000"
- }
- }
- }
- };
- var cell = { defaultCellStyle: defaultCellStyle };
- var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, (self.search.type == 1 ? "委机关值班表" : "直属单位值班表"))
- //设置表格的样式
- var wbout = XLSX.write(wb, {
- bookType: 'xlsx',
- bookSST: false,
- type: 'binary',
- cellStyles: true,
- defaultCellStyle: defaultCellStyle,
- showGridLines: false
- });
- var s2ab = function (s) {
- var buf = new ArrayBuffer(s.length);
- var view = new Uint8Array(buf);
- for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
- return buf;
- };
- try {
- saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), (self.search.type == 1 ? "委机关值班表" : "直属单位值班表") + '.xlsx')
- } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
- return wbout
- } else {
- sp.dialog('数据还未加载完成,请稍等...')
- }
- }
- //委机关查看直属单位
- self.getZSDW = function () {
- var data = {
- nf: self.search.date.split("-")[0],
- yfname: parseInt(self.search.date.split("-")[1]),
- columns: "*"
- }
- $http.post(apiurljs.login + "g2app/ZhiBan/queryZSDWList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.zsdwList = res.data;
- self.zsdwList.forEach(function (item) {
- item.BSDATE1 = sp.datefmt("yyyy-MM-dd HH:mm", item.BSDATE)
- })
- })
- }
- self.goDetail = function (item) {
- if (item.STOPMARK !='1') {
- return
- } else {
- sp.openNewWindow("detail.html?id=" + item.ID, item.CNAME + self.search.date.slice(5) + "月值班表")
- }
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(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, '<br/>').replace(/\s/g, ' '));
- };
- });
- app.directive("repeatFinish", function () {
- return {
- link: function (scope) {
- if (scope.$last == true) {
- setTimeout(function () {
- $(".sp-table").rowspan(1)
- $(".sp-table").rowspan(0)
- }, 10);
- }
- }
- };
- });
- function formate(d) {
- return d * 1 > 9 ? d * 1 : "0" + d * 1
- }
- jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
- return this.each(function () {
- var that;
- $('tr', this).each(function (row) {
- $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
- if (that != null && $(this).html() == $(that).html()) {
- var rowspan = $(that).attr("rowSpan");
- if (rowspan == undefined) {
- $(that).attr("rowSpan", 1);
- rowspan = $(that).attr("rowSpan");
- }
- rowspan = Number(rowspan) + 1;
- $(that).attr("rowSpan", rowspan);
- $(this).remove();
- } else {
- that = this;
- }
- });
- });
- });
- }
|