123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("taizhangCtrl", ["$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");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.loading = false;
- self.search = { DATE1: sp.monthfirst(sp.getLocalDate()), DATE2: sp.formatMonthLast(sp.getLocalDate()), CPH: "" };
- self.getCX = function () {
- var data = {
- tablename: "CODE_CXDMB"
- }
- $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.cxList = res.data;
- self.getData(self.pageno);
- })
- }
- self.getCX()
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 10;
- self.pageOptions = [10, 20, 30, 40];
- self.getData = function (pageno) {
- self.list = [];
- self.loading = false;
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
- var data = {
- tablename: "SX_GWYCPQD",
- colums: "*,TO_CHAR(YCKSSJ,'yyyy-mm-dd')as YCKSSJ1,TO_CHAR(YCJSSJ,'yyyy-mm-dd')as YCJSSJ1",
- order: "SQSJ",
- sqlwhere: " and MARKFINISHED=1" + (self.search.CPH != "" ? " and CPH like'%" + self.search.CPH + "%'" : "") +
- (self.search.DATE1 != "" ? " and YCKSSJ BETWEEN '" + self.search.DATE1 + " 00:00:00' AND '" + self.search.DATE2 + " 23:59:59'" : ""),
- pageno: self.pageno,
- pagesize: self.itemsPerPage
- }
- $http.post(apiurljs.login + "g2app/dataabase/queryFormFlowWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.loading = false;
- self.list = res.data;
- self.list.forEach(function (item) {
- item.GLS = item.HDLC - item.CCLC;
- self.cxList.forEach(function (item1) {
- if (item.CXXQ == item1.CODE) {
- item.CX = item1.CNAME;
- }
- })
- })
- console.log(self.list)
- self.total_count = res.totalCount;
- })
- }
- self.openLayer = function () {
- sp.layer("#Search")
- }
- self.doSearch = function () {
- sp.layerhide()
- if (self.search.DATE1 == "" || self.search.DATE2 == "") {
- sp.dialog("时间不可为空!");
- return
- }
- self.getData(1);
- }
- self.cancal = function () {
- self.search = {
- DATE1: sp.monthfirst(sp.getLocalDate()),
- DATE2: sp.formatMonthLast(sp.getLocalDate()),
- CPH: ""
- }
- self.getData(1);
- sp.layerhide()
- }
- self.refresh = function () {
- self.getData(self.pageno);
- }
- self.changeGLS = function (obj) {
- self.edit = {
- ID: obj.ID,
- CCLC: obj.CCLC,
- HDLC: obj.HDLC
- }
- sp.layer("#GLS")
- }
- self.btnSaveGLS = function () {
- var data = {
- tablename: "SX_GWYCPQD",
- id: self.edit.ID,
- data: {
- CCLC: self.edit.CCLC,
- HDLC: self.edit.HDLC
- }
- }
- $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(self.pageno);
- $timeout(function () {
- sp.dialoghide();
- }, 1000)
- } else {
- sp.dialog(res.message);
- }
- })
- }
- self.printOut = function () {
- if (self.canExportExcel) {
- $('#table 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('#table'), cell, document.title)
- //设置表格的样式
- 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' }), document.title + '.xlsx')
- } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
- return wbout
- } else {
- sp.dialog('数据还未加载完成,请稍等...')
- }
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- }, 1)
- })
- }])
|