123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- '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.searchYear = sp.currentYear() * 1;
- self.searchDWMC = "";
- self.impYear = sp.currentYear() * 1;
- self.years = [sp.currentYear() * 1 - 2, sp.currentYear() * 1 - 1, sp.currentYear() * 1, sp.currentYear() * 1 + 1, sp.currentYear() * 1 + 2]
- self.getDWLX = function () {
- var data = {
- tablename: "CODE_DWLX",
- colums: "ID,CODE,CNAME",
- order: "SORTID desc",
- sqlwhere: "",
- 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.DWLX = res.data;
- 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.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
- self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
- self.getData();
- })
- }
- self.getData = function () {
- var data = {
- tablename: "SX_CYZDXMTZ",
- colums: "*",
- order: "SORTID",
- sqlwhere: { NF: self.searchYear },
- sqlinwhere: "",
- sqllikewhere: { DWMC: self.searchDWMC }
- }
- $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;
- console.log(res.data.map(function (item) { return { GLBM: item.GLBM, GLBMCODE: item.GLBMCODE } }))
- self.list.forEach(function (item) {
- item.editFlag = false;
- self.DWLX.forEach(function (item1) {
- if (item.DWLX == item1.CODE) {
- item.DWLX1 = item1.CNAME;
- }
- })
- })
- self.getDpList()
- })
- }
- self.getDWLX()
- //n=-1下移,n=1上移
- self.sortItem = function (index, n) {
- var ids = [{ ID: self.list[index].ID }, { ID: self.list[index + n].ID }], sortids = [{ SORTID: self.list[index + n].SORTID }, { SORTID: self.list[index].SORTID }];
- var data = {
- entity: "SX_CYZDXMTZ",
- data: sortids,
- setwhere: ids
- }
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success == true) {
- self.getData();
- }
- })
- }
- self.getDpList = function () {
- var data = {
- unitid: "AA"
- }
- $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.dpList = [];
- res.data.forEach(function (item) {
- if (item.CHILD_DATA.length == 0) {
- self.dpList.push(item)
- } else {
- item.CHILD_DATA.forEach(function (item1) {
- if (item1.CHILD_DATA.length == 0) {
- self.dpList.push(item1)
- } else {
- item1.CHILD_DATA.forEach(function (item2) {
- if (item2.CHILD_DATA.length == 0) {
- self.dpList.push(item2)
- }
- })
- }
- })
- }
- })
- self.dpList.forEach(function (item) {
- item.checked = false;
- })
- })
- }
- self.openDpList = function (str) {
- self.filed = str;
- sp.layer("#DpList")
- $("#DpList .sp-page").eq(0).scrollTop(0);
- }
- self.checkDpItem = function (obj) {
- $.each(self.dpList, function (index, item) {
- item.checked = false;
- })
- obj.checked = !obj.checked;
- self.submitDpList(1)
- }
- self.submitDpList = function (n) {
- $.each(self.dpList, function (index, item) {
- if (item.checked == true) {
- self[self.filed].GLBM = item.SECTION
- self[self.filed].GLBMCODE = item.CODE;
- }
- })
- if (n == 0) {
- sp.layerhide();
- }
- }
- self.openLayer = function () {
- self.searchYear = sp.currentYear() * 1;
- self.searchDWMC = "";
- sp.layer("#Search")
- }
- self.doSearch = function () {
- self.getData()
- sp.layerhide()
- }
- self.initSearch = function () {
- self.searchYear = sp.currentYear() * 1;
- self.searchDWMC = "";
- self.getData()
- sp.layerhide()
- }
- self.addItem = function () {
- if (self.editFlag == true) {
- sp.dialog("请先保存或取消编辑!")
- return
- }
- if (self.addFlag == true) {
- return
- }
- self.addFlag = true;
- self.add = {
- ID: 0,
- DWLX: self.DWLX[0].CODE,
- DWMC: "",
- GLBM: "",
- GLBMCODE: "",
- XMMC: "",
- WCSX: ""
- }
- }
- self.editItem = function (obj) {
- if (self.addFlag == true) {
- sp.dialog("请先保存或取消添加!")
- return
- }
- self.editFlag = true;
- obj.editFlag = true;
- self.edit = {
- ID: obj.ID,
- DWLX: obj.DWLX,
- DWMC: obj.DWMC,
- GLBM: obj.GLBM,
- GLBMCODE: obj.GLBMCODE,
- XMMC: obj.XMMC,
- WCSX: obj.WCSX
- }
- }
- self.saveItem = function (obj) {
- if (obj.ID == 0) {
- var data = {
- tablename: "SX_CYZDXMTZ",
- data: JSON.stringify({
- DWLX: obj.DWLX,
- DWMC: obj.DWMC,
- GLBM: obj.GLBM,
- GLBMCODE: obj.GLBMCODE,
- XMMC: obj.XMMC,
- WCSX: obj.WCSX,
- NF: self.searchYear,
- CUSERID: self.userId,
- CJRBMID: self.userDpCode,
- CDATE: sp.getLocalDate()
- })
- }
- $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) {
- self.getData();
- } else {
- sp.dialog(res.message)
- }
- })
- } else {
- var data = {
- tablename: "SX_CYZDXMTZ",
- id: obj.ID,
- data: JSON.stringify({
- DWLX: obj.DWLX,
- DWMC: obj.DWMC,
- GLBM: obj.GLBM,
- GLBMCODE: obj.GLBMCODE,
- XMMC: obj.XMMC,
- WCSX: obj.WCSX
- })
- }
- $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.getData();
- } else {
- sp.dialog(res.message)
- }
- })
- }
- }
- self.deleteItem = 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 () {
- var data = {
- tablename: "SX_CYZDXMTZ",
- id: obj.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();
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- });
- });
- }
- self.upload_sign = function () {
- $('#fileupload-sign').fileupload({
- url: apiurljs.login + 'g2app/dataabase/impExecl_ByParam',
- dataType: 'json',
- beforeSend: function (xhr, data) {
- xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
- xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_CYZDXMTZ,columnsname=DWLX|DWMC|GLBM|XMMC|WCSX,startrow=1,othercol=CJRBMID,cyear=" + self.impYear));
- },
- add: function (e, data) {
- self.uploading = true;
- data.submit();
- },
- // 上传完成后的执行逻辑
- done: function (e, data) {
- self.uploading = false;
- self.getData()
- sp.layerhide()
- }
- })
- }
- }])
|