list.js 12 KB

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