123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- 'use strict';
- 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.get_id = sp.getUrlName("id");
- self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
- 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.getZBSJ()
- })
- }
- self.getYF()
- self.getZBSJ = 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.getData()
- })
- }
- //获取数据
- self.getData = function () {
- var data = {
- tablename: "SX_YFZBB",
- colums: "*",
- order: "ID",
- sqlwhere: { ID: self.get_id },
- 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.data = {
- ID: res.data[0].ID,
- NF: res.data[0].NF,
- YF: res.data[0].YF,
- SQDW: res.data[0].SQDW,
- LSH: res.data[0].LSH,
- ZBSJREMARK: res.data[0].ZBSJREMARK,
- ZBDH: res.data[0].ZBDH,
- ZBCZ: res.data[0].ZBCZ,
- YJJJRZBDH: res.data[0].YJJJRZBDH,
- YJJJRZBCZ: res.data[0].YJJJRZBCZ,
- ZBDD: res.data[0].ZBDD,
- TBR: res.data[0].TBR,
- REMARK: res.data[0].REMARK
- };
- self.YF.forEach(function (item) {
- if (self.data.YF == item.CODE) {
- self.data.YF1 = item.CNAME;
- }
- })
- self.getChildList()
- })
- }
- self.getChildList = function () {
- var data = {
- tablename: "SX_YFZBB_01",
- colums: "*",
- order: "ID",
- sqlwhere: { PID: self.data.ID },
- 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.list = res.data;
- self.AddFlag = false;
- self.EditFlag = false;
- self.list.forEach(function (item) {
- item.editFlag = false;
- item.RIQI = formate(item.RIQI);
- self.ZBSJ.forEach(function (item1) {
- if (item.ZBSJ == item1.CODE) {
- item.ZBSJ2 = item1.CNAME
- }
- })
- })
- })
- }
- self.downLoadT = function () {
- var eleLink = document.createElement('a');
- eleLink.download = "";
- eleLink.style.display = 'none';
- eleLink.href = apiurljs.login + "g2app/zhiban/ExpZhiBanMoBanT?data=" + encodeURIComponent(s4.encryptData_CBC("mobanname=zsdwzb.xlsx&code_table=CODE_ZHIBANTIMEZSDW&title=市住房城乡建设委直属单位" + self.data.NF + "年" + self.data.YF1 + "月份值班表&id=" + self.data.ID + "&cyear=" + self.data.NF + "&cmonth=" + formate(self.data.YF1) + "&sqdw=" + self.data.SQDW + "&lsh=" + self.data.LSH + "&bssj=" + sp.minsToDate("yyyy-MM-dd hh:mm:ss", parseFloat(sp.getUrlName("bssj")))));
- // 触发点击
- document.body.appendChild(eleLink);
- eleLink.click();
- // 然后移除
- document.body.removeChild(eleLink);
- }
- //前端导出
- 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.data.NF + "年" + self.data.YF1 + "月份值班表")
- //设置表格的样式
- 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.data.NF + '年' + self.data.YF1 + '月份值班表.et')
- } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
- return wbout
- } else {
- sp.dialog('数据还未加载完成,请稍等...')
- }
- }
- //头部下滚冻结
- $(function () {
- $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
- $(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
- app.directive("repeatFinish", function () {
- return {
- link: function (scope) {
- if (scope.$last == true) {
- setTimeout(function () {
- $(".zb-table").rowspan(1)
- $(".zb-table").rowspan(0)
- }, 10);
- }
- }
- };
- });
- function formate(n) {
- return n * 1 > 9 ? n * 1 : "0" + n * 1;
- }
- function getNum(arr, name) {
- var n = -1;
- $.each(arr, function (index, item) {
- if (item.CNAME == name) {
- n = index
- }
- })
- return n
- }
- function isNull(str) {
- if (str == "" || str == null || str == undefined) {
- return false
- } else {
- return true
- }
- }
- 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;
- }
- });
- });
- });
- }
|