list.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$scope", "$http", "$timeout", "$sce", function ($scope, $http, $interval, $sce) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. }
  17. self.selectOa = 'New';
  18. self.loading = false;
  19. self.searchFlag = false;
  20. let nowDate = new Date()
  21. let y = nowDate.getFullYear()
  22. let m = nowDate.getMonth() + 1
  23. let d = nowDate.getDate()
  24. self.search = {
  25. keyword: "",
  26. startdate: "2023-09-01",//y + "-01-01",
  27. enddate: y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d),
  28. title: "",
  29. lwdw: "",
  30. startdate_: "2023-09-01",//y + "-01-01",
  31. enddate_: y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d)
  32. }
  33. self.flows = [];
  34. self.test = [];
  35. self.getFlow = function () {
  36. var data = {
  37. userid: self.userId,
  38. ntops: 0//6
  39. }
  40. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  41. .success(function (obj) {
  42. var res = strToJson(s4.decryptData_CBC(obj.data));
  43. res.data.forEach(function (item) {
  44. if (item.FLOWID != "无") {
  45. self.flows.push(item.FLOWID)
  46. self.test.push({ FLOWID: item.FLOWID, FLOWCODE: item.FLOWCODE, CNAME: item.CNAME, FILEN: item.FILEN })
  47. }
  48. })
  49. })
  50. }
  51. self.getOldUser = function () {
  52. var data = {
  53. tablename: "OLDOAUSER",
  54. colums: "*",
  55. order: "ID asc",
  56. sqlwhere: { USERNAME: self.userName },
  57. sqlinwhere: "",
  58. sqllikewhere: ""
  59. }
  60. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  61. .success(function (obj) {
  62. var res = strToJson(s4.decryptData_CBC(obj.data));
  63. if (res.data.length > 0) {
  64. self.olduserId = res.data[0].USERID;
  65. } else {
  66. self.olduserId = self.userId;
  67. }
  68. })
  69. }
  70. self.getOldUser()
  71. self.getFlow()
  72. self.noDataTip = 1; //没有数据时赋变量为0,先默认为1
  73. self.pageno = 1;
  74. self.total_count = 0;
  75. self.itemsPerPage = 10;
  76. self.pageOptions = [10, 20, 30, 40];
  77. self.getDataOld = function (pageno) {
  78. if (self.search.keyword == "") {
  79. self.search.keyword = self.search.title
  80. }
  81. if (self.search.startdate == "") {
  82. self.search.startdate = self.search.startdate_
  83. }
  84. if (self.search.enddate == "") {
  85. self.search.enddate = self.search.enddate_
  86. }
  87. self.searchFlag = true;
  88. self.loading = true;
  89. self.pageno = pageno;
  90. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  91. var data = {
  92. keyword: self.search.keyword,
  93. startdate: self.search.startdate,
  94. enddate: self.search.enddate,
  95. page: self.pageno.toString(),
  96. pagesize: self.itemsPerPage.toString(),
  97. userid: self.olduserId,//当前人userid
  98. author: "",//起始人名称
  99. title: "",
  100. accessoryname: "",//附件名
  101. libStr:""//类别
  102. }
  103. $http.post(apiurljs.login + "g2app/OAQuery/QueryDataList", {
  104. data: s4.encryptData_CBC(JSON.stringify(data))
  105. }, postCfg)
  106. .success(function (obj) {
  107. var res = strToJson(s4.decryptData_CBC(obj.data));
  108. self.loading = false;
  109. if (res.data == null || res.data == undefined || res.data == "") {
  110. self.list=[]
  111. self.noDataTip = 0;
  112. } else {
  113. self.noDataTip = 1;
  114. res.data.searchResults.forEach(function (item) {
  115. if (item.appType == '2') {
  116. item.appType_cn = '表单'
  117. } else if (item.appType == '4') {
  118. item.appType_cn = '公文'
  119. } else {
  120. item.appType_cn = ''
  121. }
  122. })
  123. self.list = res.data.searchResults;
  124. self.total_count = res.data.totalCount;
  125. }
  126. })
  127. }
  128. self.getDataNew = function (pageno) {
  129. if (self.search.title == "") {
  130. self.search.title = self.search.keyword
  131. }
  132. if (self.search.startdate_ == "") {
  133. self.search.startdate_ = self.search.startdate
  134. }
  135. if (self.search.enddate_ == "") {
  136. self.search.enddate_ = self.search.enddate
  137. }
  138. self.searchFlag = true;
  139. self.loading = true;
  140. self.pageno = pageno;
  141. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  142. var array = [{
  143. CKIND: 'VARCHAR',
  144. TABLEID: 'SYS_ROUTE_VIEW',
  145. COLID: 'TITLE',
  146. VALUEA: self.search.title,
  147. },{
  148. CKIND: 'DATETIME',
  149. TABLEID: 'SYS_ROUTE_VIEW',
  150. COLID: 'APPDATE',
  151. VALUEA: self.search.startdate_,
  152. VALUEB: self.search.enddate_,
  153. }];
  154. if (self.search.lwdw != "") {
  155. array.push( {
  156. CKIND: 'VARCHAR',
  157. TABLEID: 'SYS_ROUTE_VIEW',
  158. COLID: 'LWDW',
  159. VALUEA: self.search.lwdw,
  160. })
  161. }
  162. var data = {
  163. flowid: '',
  164. userid: self.userId,
  165. pageno: self.pageno,
  166. pagesize: self.itemsPerPage,
  167. querycondition: JSON.stringify(array)
  168. }
  169. $http.post(apiurljs.login + "g2work/routeinfo/queryDataQuanLiuChengWithPage", {
  170. data: s4.encryptData_CBC(JSON.stringify(data))
  171. }, postCfg)
  172. .success(function (obj) {
  173. var res = strToJson(s4.decryptData_CBC(obj.data));
  174. console.log(res)
  175. self.loading = false;
  176. if (res.data == null || res.data == undefined || res.data == "") {
  177. self.noDataTip = 0;
  178. self.list = []
  179. } else {
  180. self.noDataTip = 1;
  181. res.data.forEach(function (item) {
  182. if (item.STATUSINFO == 'DEAL' || item.STATUSINFO == 'START') {
  183. item.STATUSINFO_CN = '在办'
  184. } else if (item.STATUSINFO == 'STOP') {
  185. item.STATUSINFO_CN = '办结'
  186. } else {
  187. item.STATUSINFO_CN = ''
  188. }
  189. item.userStr = ''
  190. if (item.TODOLIST) {
  191. item.TODOLIST.forEach(function (iitem) {
  192. iitem.USERS.forEach(function (iiitem) {
  193. iiitem.STATUS_CN = ''
  194. if (iiitem.STATUS == '0') {
  195. iiitem.STATUS_CN = '草稿'
  196. } else if (iiitem.STATUS == '1') {
  197. iiitem.STATUS_CN = '待办'
  198. } else if (iiitem.STATUS == '2') {
  199. iiitem.STATUS_CN = '在办'
  200. }
  201. if (iiitem.USERNAME && iiitem.STATUS_CN) {
  202. if (item.userStr) {
  203. item.userStr = item.userStr + ',' + iiitem.USERNAME + '-' + iiitem.STATUS_CN
  204. } else {
  205. item.userStr = iiitem.USERNAME + '-' + iiitem.STATUS_CN
  206. }
  207. }
  208. })
  209. })
  210. }
  211. })
  212. self.list = res.data;
  213. self.total_count = res.meta.totalCount;
  214. }
  215. })
  216. }
  217. self.toNew = function(){
  218. if(self.selectOa != 'New'){
  219. self.pageno = 1
  220. self.selectOa = 'New';
  221. self.load('New')
  222. }
  223. }
  224. self.toOld = function(){
  225. if(self.selectOa != 'Old'){
  226. self.pageno = 1
  227. self.selectOa = 'Old';
  228. self.load('Old')
  229. }
  230. }
  231. self.load = function (type) {
  232. if (self.search.keyword == "" && self.search.title == "" && self.selectOa == "Old") {
  233. sp.dialog("请输入关键字!");
  234. self.searchFlag = false;
  235. return
  236. }
  237. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  238. self['getData'+type](self.pageno);
  239. } else {
  240. $timeout(function () {
  241. self.getData(self.get_lastReturnPageno);
  242. }, 1)
  243. }
  244. }
  245. self.openSearch = function () {
  246. if(self.selectOa=='New'){
  247. sp.layer("#SearchNew")
  248. }else if(self.selectOa=='Old'){
  249. sp.layer("#SearchOld")
  250. }
  251. }
  252. self.doSearch = function () {
  253. if (self.search.keyword == "" && self.search.title == "" && self.selectOa == "Old") {
  254. sp.dialog("请输入关键字!");
  255. self.searchFlag = false;
  256. return
  257. }
  258. self['getData' + self.selectOa](1)
  259. // self.load(self.selectOa);
  260. sp.layerhide()
  261. }
  262. self.cancal = function () {
  263. self.searchFlag = false;
  264. self.search = {
  265. keyword: "",
  266. startdate: "",
  267. enddate: ""
  268. }
  269. self.list = [];
  270. sp.layerhide()
  271. }
  272. self.refresh = function () {
  273. self['getData'+ self.selectOa](self.pageno);
  274. }
  275. self.goUrl = function (obj) {
  276. if(self.selectOa=='New'){
  277. let href = window.location.href
  278. let hrefArr = href.split('fontOA')
  279. if(hrefArr.length>0){
  280. self.test.forEach(function (item) {
  281. if (item.FLOWID.indexOf(obj.FLOWID) > -1) {
  282. let FILENArr = item.FILEN.split('/')
  283. sp.openNewWindow(hrefArr[0]+FILENArr[1]+'/'+obj.FILEN)
  284. }
  285. })
  286. //sp.openNewWindow(hrefArr[0]+obj.FILEN)
  287. }
  288. }else if(self.selectOa=='Old'){
  289. sp.openNewWindow(apiurljs.seeyon + "/detailt.html?url=" + obj.url, obj.accessoryName)
  290. }
  291. }
  292. self.keyLogin = function () {
  293. if (event.keyCode == 13) { //回车键的键值为13
  294. if ($(".sp-dialog").is(":hidden") == true) {
  295. self.doSearch()
  296. } else {
  297. sp.dialoghide()
  298. }
  299. }
  300. }
  301. //self.goUrl()
  302. //头部下滚冻结
  303. $(function () {
  304. //页面高度撑满
  305. setTimeout(function () {
  306. if ($(".ibox-content").height() < $(window).height() - 31) {
  307. $(".ibox-content").css("height", $(window).height() - 31)
  308. }
  309. }, 1)
  310. })
  311. }])
  312. app.filter('trustHtml', function ($sce) {
  313. return function (input) {
  314. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  315. };
  316. });