formedit.js 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  5. var self = this;
  6. var s4 = new SM4Util();
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.routeid = sp.getUrlName("routeid");
  11. self.routeinfoid = sp.getUrlName("routeinfoid");
  12. self.copyrightid = sp.getUrlName("copyrightid");
  13. self.directionid = sp.getUrlName("directionid");
  14. self.formeditid = sp.getUrlName("formeditid");
  15. self.mbid = sp.getUrlName("mbid");
  16. self.fjid = sp.getUrlName("fjid");
  17. self.docmode = sp.getUrlName("docmode");
  18. self.dotype = sp.getUrlName("dotype");
  19. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  20. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  21. self.get_type = sp.getUrlName("type");
  22. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  23. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  24. var postCfg = {
  25. headers: {
  26. 'Content-Type': 'application/json',
  27. 'Authorization': "Bearer " + self.get_AccessToken
  28. }
  29. };
  30. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  31. //上层附件、业务参考、共享沟通组件
  32. self.uploading = false;
  33. self.upload = function () {
  34. var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
  35. return item.CNAME
  36. })
  37. $('#fileupload').fileupload({
  38. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  39. dataType: 'json',
  40. beforeSend: function (xhr, data) {
  41. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  42. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=委机关值班表"));
  43. },
  44. add: function (e, data) {
  45. var num = 0;
  46. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  47. //文件类型判断
  48. $.each(data.originalFiles, function (index, item) {
  49. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  50. sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  51. return;
  52. } else {
  53. num++
  54. }
  55. })
  56. if (num == data.originalFiles.length) {
  57. self.uploading = true;
  58. data.submit();
  59. $scope.$apply();
  60. }
  61. },
  62. // 上传完成后的执行逻辑
  63. done: function (e, data) {
  64. self.uploading = false;
  65. self.getOther()
  66. }
  67. })
  68. }
  69. self.downLoad = function (item) {
  70. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  71. }
  72. //意见(下表)
  73. self.openOptionList = function () {
  74. if (self.routeinfoid == 0 && self.routeid == 0) {
  75. sp.dialog("请先保存!")
  76. return;
  77. }
  78. if (self.opinion.nulla == true) {
  79. return;
  80. }
  81. self.nulla = "";
  82. $(".optionList").css("height", 149)
  83. self.opinion.nulla = true;
  84. }
  85. self.closeOptionList = function () {
  86. $(".optionList").css("height", 389)
  87. self.opinion.nulla = false;
  88. }
  89. self.submitOptionList = function () {
  90. var data = {
  91. cmanid: self.userId,
  92. routeinfoid: self.routeinfoid,
  93. routeid: self.routeid,
  94. tableid: "FW_ZB",
  95. colid: "",
  96. opiniontype: 99,
  97. cresult: "",
  98. opinion: self.nulla,
  99. opinionimage: ""
  100. }
  101. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  102. .success(function (obj) {
  103. var res = strToJson(s4.decryptData_CBC(obj.data));
  104. if (res.success == true) {
  105. self.getOpinion1();
  106. self.opinion.nulla = false;
  107. $(".optionList").css("height", 389)
  108. } else {
  109. sp.dialog(res.message)
  110. }
  111. })
  112. }
  113. self.changeOptionList = function (item) {
  114. self.nulla = item.OPINION;
  115. self.opinion.nulla = true;
  116. }
  117. self.deleteFile = function (file) {
  118. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  119. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  120. 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>";
  121. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  122. sp.openCenter(".sp-dialog");
  123. ///取消按钮
  124. $('.sp-closeDialog').click(function (event) {
  125. sp.closeCenter(".sp-dialog");
  126. event.preventDefault();
  127. event.stopPropagation();
  128. });
  129. //post消息的id
  130. $("#delDataTrue").click(function () {
  131. var data = {
  132. tablename: "FILE_ATTACH",
  133. id: file.ID
  134. };
  135. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  136. .success(function (obj) {
  137. var res = strToJson(s4.decryptData_CBC(obj.data));
  138. sp.dialoghide();
  139. if (res.success) {
  140. self.getOther();
  141. } else {
  142. sp.dialog("删除失败,请联系管理员!");
  143. }
  144. });
  145. });
  146. }
  147. self.goAttach = function (obj) {
  148. if (obj) {
  149. if (apiurljs.zhType.indexOf(obj.FILEEXT) == -1) {
  150. sp.dialog("文件暂不支持在线预览,请点击下载查看!")
  151. return
  152. }
  153. $("#attachlist")[0].contentWindow.openFile(obj)
  154. if ($(".fa-chevron-down").is(":hidden") == true) {
  155. showToggle(document.getElementById("toggleButton"))
  156. }
  157. } else {
  158. if ($("#attachlist").attr("src") == '') {
  159. $("#attachlist").attr("src", "attachlist.html?page=formedit&routeinfoid=" + self.routeinfoid)
  160. }
  161. }
  162. }
  163. self.readonly = {
  164. NF: false,
  165. YF: false,
  166. SQDW: false,
  167. TWODAY: false,
  168. LSH: false,
  169. ZB: false,
  170. ZBREMARK: false,
  171. SPYJ: false
  172. }
  173. self.show = {
  174. ZBREMARK: false,
  175. SPYJ: false
  176. }
  177. //初始化右上角按钮
  178. self.buttonList = []
  179. self.yearList = [];
  180. for (var i = 0; i < 11; i++) {
  181. if (i < 5) {
  182. self.yearList.push(sp.currentYear() * 1 - 5 + i)
  183. } else if (i == 5) {
  184. self.yearList.push(sp.currentYear())
  185. } else if (i > 5) {
  186. self.yearList.push(sp.currentYear() * 1 + i - 5)
  187. }
  188. }
  189. self.times = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12",
  190. "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
  191. self.getFLOW = function () {
  192. var data = {
  193. copyrightid: self.copyrightid
  194. }
  195. $http.post(apiurljs.login + "g2work/flow/queryDataByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  196. .success(function (obj) {
  197. var res = strToJson(s4.decryptData_CBC(obj.data));
  198. self.flowTitle = res.data.CNAME;
  199. })
  200. }
  201. self.getSwenList = function (n) {
  202. self.SwenList = [];
  203. var data = {
  204. directionid: self.directionid,
  205. userid: self.userId,
  206. routeinfoid: self.routeinfoid,
  207. routeid: self.routeid,
  208. formeditid: ""
  209. }
  210. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  211. .success(function (obj) {
  212. var res = strToJson(s4.decryptData_CBC(obj.data));
  213. if (self.copyrightid == "") {
  214. self.copyrightid = res.data.LINKS[0].COPYRIGHTID
  215. }
  216. $.each(res.data.LINKS, function (index, item) {
  217. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  218. self.Title = item.VNAME;
  219. }
  220. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  221. if (item.TEMPFORM.indexOf("attachlist") > -1) {
  222. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  223. } else {
  224. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  225. }
  226. } else {
  227. item.TEMPFORM = "#";
  228. }
  229. self.SwenList.push(item)
  230. })
  231. self.SwenList.push({
  232. VNAME: "流程图",
  233. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  234. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  235. })
  236. if (n == 0) {
  237. self.getDP()
  238. self.getFLOW()
  239. self.getOther()
  240. } else {
  241. self.getData()
  242. }
  243. })
  244. }
  245. self.getSwenList(0)
  246. self.getDP = function () {
  247. var data = {
  248. userid: self.userId
  249. }
  250. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  251. .success(function (obj) {
  252. var res = strToJson(s4.decryptData_CBC(obj.data));
  253. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  254. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  255. self.getYF1();
  256. })
  257. }
  258. self.getYF1 = function () {
  259. var data = {
  260. tablename: "SX_YFZBB",
  261. colums: "YF",
  262. order: "ID",
  263. sqlwhere: { SQDWCODE: self.userDpCode },
  264. sqlorwhere: "",
  265. sqlinwhere: "",
  266. sqllikewhere: ""
  267. }
  268. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  269. .success(function (obj) {
  270. var res = strToJson(s4.decryptData_CBC(obj.data));
  271. self.YF1 = res.data;
  272. self.getYF()
  273. })
  274. }
  275. self.getYF = function () {
  276. var data = {
  277. ckey: "CODE_ZBYF",
  278. routeinfoid: self.routeinfoid
  279. }
  280. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  281. .success(function (obj) {
  282. var res = strToJson(s4.decryptData_CBC(obj.data));
  283. self.YF = res.data.CODE_ZBYF;
  284. self.nextYF = self.YF[0].CODE
  285. self.YF.forEach(function (item) {
  286. //item.disabled = false;
  287. //self.YF1.forEach(function (item1) {
  288. // if(item.CODE==item1.YF){
  289. // item.disabled = true;
  290. // }
  291. //})
  292. if (item.CNAME == sp.currentMonth() + 1 && sp.currentMonth() < 12) {
  293. self.nextYF = item.CODE;
  294. }
  295. })
  296. self.getXQ()
  297. })
  298. }
  299. self.getXQ = function () {
  300. var data = {
  301. ckey: "CODE_ZBXQ",
  302. routeinfoid: self.routeinfoid
  303. }
  304. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  305. .success(function (obj) {
  306. var res = strToJson(s4.decryptData_CBC(obj.data));
  307. self.XQ = res.data.CODE_ZBXQ;
  308. self.getZBSJ()
  309. })
  310. }
  311. self.getZBSJ = function () {
  312. var data = {
  313. ckey: "CODE_ZHIBANTIMEZSDW",
  314. routeinfoid: self.routeinfoid
  315. }
  316. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  317. .success(function (obj) {
  318. var res = strToJson(s4.decryptData_CBC(obj.data));
  319. self.ZBSJ = res.data.CODE_ZHIBANTIMEZSDW;
  320. self.getDBLD()
  321. })
  322. }
  323. self.getDBLD = function () {
  324. var data = {
  325. tablename: "SX_ZHIBANRYGL",
  326. colums: "*",
  327. order: "ID",
  328. sqlwhere: { "MANMARK": "C01" },
  329. sqlorwhere: "",
  330. sqlinwhere: "",
  331. sqllikewhere: ""
  332. }
  333. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  334. .success(function (obj) {
  335. var res = strToJson(s4.decryptData_CBC(obj.data));
  336. self.DBLD = res.data;
  337. self.getUserList()
  338. })
  339. }
  340. self.getUserList = function () {
  341. $http.post(apiurljs.login + "g2work/datazu/queryDataUserList", { data: s4.encryptData_CBC(JSON.stringify({ "zid": "AA", "levels": "0" })) }, postCfg)
  342. .success(function (obj) {
  343. var res = strToJson(s4.decryptData_CBC(obj.data));
  344. self.userList = res.data;
  345. self.userList.forEach(function (item) {
  346. item.users.forEach(function (item1) {
  347. item1.checked = false;
  348. item1.ushowname1 = item1.ushowname.length > 3 ? item1.ushowname.slice(0, 3) + "..." : item1.ushowname;
  349. item1.ushowname2 = item1.ushowname.length > 10 ? item1.ushowname.slice(0, 10) + "..." : item1.ushowname
  350. })
  351. })
  352. self.getData()
  353. })
  354. }
  355. self.getZBXZ = function () {
  356. $http.get("../js/zbxz2.txt")
  357. .success(function (res) {
  358. self.zbxzMR = res.NR;
  359. self.getData()
  360. })
  361. }
  362. //获取数据
  363. self.getData = function () {
  364. var data = {
  365. ckey: "SX_YFZBB",
  366. id: 0,
  367. directionid: self.directionid,
  368. formeditid: self.formeditid,
  369. routeid: self.routeid,
  370. routeinfoid: self.routeinfoid
  371. }
  372. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  373. .success(function (obj) {
  374. var res = strToJson(s4.decryptData_CBC(obj.data));
  375. self.data = {
  376. ID: res.data.SX_YFZBB.ID,
  377. NF: res.data.SX_YFZBB.NF == "" ? (self.nextYF == "C01" ? parseInt(sp.currentYear()) + 1 : parseInt(sp.currentYear())) : res.data.SX_YFZBB.NF,
  378. YF: res.data.SX_YFZBB.YF == "" ? self.nextYF : res.data.SX_YFZBB.YF,
  379. SQDW: res.data.SX_YFZBB.SQDW == "" ? self.userDpName : res.data.SX_YFZBB.SQDW,
  380. TWODAY: res.data.SX_YFZBB.TWODAY == "true",
  381. LSH: res.data.SX_YFZBB.LSH == "" ? "" : res.data.SX_YFZBB.LSH,
  382. //ZBREMARK: res.data.SX_YFZBB.ZBREMARK == "" ? self.zbxzMR : res.data.SX_YFZBB.ZBREMARK,
  383. ZBSJREMARK: res.data.SX_YFZBB.ZBSJREMARK == "" ? "上午08:00—14;00;下午14:00—20:00;夜间20:00—08:00" : res.data.SX_YFZBB.ZBSJREMARK,
  384. ZBDH: res.data.SX_YFZBB.ZBDH,
  385. ZBCZ: res.data.SX_YFZBB.ZBCZ,
  386. YJJJRZBDH: res.data.SX_YFZBB.YJJJRZBDH,
  387. YJJJRZBCZ: res.data.SX_YFZBB.YJJJRZBCZ,
  388. ZBDD: res.data.SX_YFZBB.ZBDD,
  389. TBR: res.data.SX_YFZBB.TBR == "" ? self.userName : res.data.SX_YFZBB.TBR,
  390. REMARK: res.data.SX_YFZBB.REMARK,
  391. SQRUSERID: res.data.SX_YFZBB.SQRUSERID == "" ? self.userId : res.data.SX_YFZBB.SQRUSERID,
  392. SQDWCODE: res.data.SX_YFZBB.SQDWCODE == "" ? self.userDpCode : res.data.SX_YFZBB.SQDWCODE
  393. };
  394. self.YF.forEach(function (item) {
  395. if (self.data.YF == item.CODE) {
  396. self.data.YF1 = item.CNAME;
  397. }
  398. })
  399. self.readonly = {
  400. NF: res.data.SX_YFZBB["NF.EREADONLY"] == "true",
  401. YF: res.data.SX_YFZBB["YF.EREADONLY"] == "true",
  402. SQDW: res.data.SX_YFZBB["SQDW.EREADONLY"] == "true",
  403. TWODAY: res.data.SX_YFZBB["TWODAY.EREADONLY"] == "true",
  404. LSH: res.data.SX_YFZBB["LSH.EREADONLY"] == "true",
  405. ZB: res.data.SX_YFZBB["ZB.EREADONLY"] == "true",
  406. ZBSJREMARK: res.data.SX_YFZBB["ZBSJREMARK.EREADONLY"] == "true",
  407. ZBDH: res.data.SX_YFZBB["ZBDH.EREADONLY"] == "true",
  408. ZBCZ: res.data.SX_YFZBB["ZBCZ.EREADONLY"] == "true",
  409. YJJJRZBDH: res.data.SX_YFZBB["YJJJRZBDH.EREADONLY"] == "true",
  410. YJJJRZBCZ: res.data.SX_YFZBB["YJJJRZBCZ.EREADONLY"] == "true",
  411. ZBDD: res.data.SX_YFZBB["ZBDD.EREADONLY"] == "true",
  412. //TBR: res.data.SX_YFZBB["TBR.EREADONLY"] == "true",
  413. REMARK: res.data.SX_YFZBB["REMARK.EREADONLY"] == "true",
  414. //ZBREMARK: res.data.SX_YFZBB["ZBREMARK.EREADONLY"] == "true",
  415. SPYJ: res.data.SX_YFZBB["SPYJ.EREADONLY"] == "true"
  416. }
  417. self.show = {
  418. ZBREMARK: res.data.SX_YFZBB["ZBREMARK.ESHOW"] == "true",
  419. SPYJ: res.data.SX_YFZBB["SPYJ.ESHOW"] == "true"
  420. }
  421. if (self.data.ID == 0) {
  422. self.filedChange = true;
  423. } else {
  424. self.filedChange = false;
  425. }
  426. self.buttonList = res.data["SX_YFZBB.FUNCLIST"];
  427. self.getChildList()
  428. self.getOpinion('SPYJ')
  429. })
  430. }
  431. self.getLSH = function () {
  432. var data = {
  433. length: 3,
  434. cyear: sp.currentYear(),
  435. cmonth: self.data.YF1
  436. }
  437. $http.post(apiurljs.login + "g2app/ZhiBan/queryZhiBanLSH_ZSDW", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  438. .success(function (obj) {
  439. var res = strToJson(s4.decryptData_CBC(obj.data));
  440. self.LSH = res.data;
  441. self.data.LSH = self.LSH.YEAR + self.LSH.MONTH + self.LSH.NUMBER
  442. })
  443. }
  444. //获取附件和插件
  445. self.getOther = function () {
  446. var data = {
  447. tablename: "FILE_ATTACH",
  448. colums: "*",
  449. order: "ID desc",
  450. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  451. sqlinwhere: "",
  452. sqllikewhere: ""
  453. }
  454. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  455. .success(function (obj) {
  456. var res = strToJson(s4.decryptData_CBC(obj.data));
  457. self.arrayFile1 = [];
  458. if (res.data.length > 0) {
  459. res.data.forEach(function (item) {
  460. if (item.ATTACHTYPE.indexOf("-正文") > -1) {
  461. self.arrayFile = item;
  462. } else {
  463. self.arrayFile1.push(item)
  464. }
  465. })
  466. }
  467. })
  468. }
  469. self.getChildList = function () {
  470. var data = {
  471. tablename: "SX_YFZBB_01",
  472. colums: "*",
  473. order: "ID",
  474. sqlwhere: { PID: self.data.ID },
  475. sqlinwhere: "",
  476. sqllikewhere: ""
  477. }
  478. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  479. .success(function (obj) {
  480. var res = strToJson(s4.decryptData_CBC(obj.data));
  481. self.list = res.data;
  482. self.AddFlag = false;
  483. self.EditFlag = false;
  484. self.list.forEach(function (item) {
  485. item.editFlag = false;
  486. item.RIQI = formate(item.RIQI);
  487. //self.XQ.forEach(function (item1) {
  488. // if (item.XINGQI == item1.CODE) {
  489. // item.XINGQI1 = item1.CNAME
  490. // }
  491. //})
  492. self.ZBSJ.forEach(function (item1) {
  493. if (item.ZBSJ == item1.CODE) {
  494. item.ZBSJ2 = item1.CNAME
  495. }
  496. })
  497. })
  498. self.getRiQiList()
  499. })
  500. }
  501. //导入
  502. self.upload3 = function () {
  503. $('#fileupload3').fileupload({
  504. url: apiurljs.login + 'g2app/ZhiBan/impExecl_PRZB_ZSDW',
  505. dataType: 'json',
  506. beforeSend: function (xhr, data) {
  507. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  508. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_YFZBB,id=" + self.data.ID + ",code_table=CODE_ZHIBANTIMEZSDW,mobanname=mobanzsdw.xlsx,cyear=" + self.data.NF + ",cmonth=" + formate(self.data.YF1)));
  509. },
  510. add: function (e, data) {
  511. self.uploading = true;
  512. data.submit();
  513. },
  514. // 上传完成后的执行逻辑
  515. done: function (e, data) {
  516. self.uploading = false;
  517. self.getSwenList(1)
  518. sp.layerhide()
  519. }
  520. })
  521. }
  522. //下载当月模板
  523. self.downloadMonth = function () {
  524. var eleLink = document.createElement('a');
  525. eleLink.download = "";
  526. eleLink.style.display = 'none';
  527. console.log(s4.encryptData_CBC("mobanname=mobanzsdw.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)))
  528. eleLink.href = apiurljs.login + "g2app/zhiban/ExpZhiBanMoBan?data=" + encodeURIComponent(s4.encryptData_CBC("mobanname=mobanzsdw.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)));
  529. // 触发点击
  530. document.body.appendChild(eleLink);
  531. eleLink.click();
  532. // 然后移除
  533. document.body.removeChild(eleLink);
  534. }
  535. //初始化子表
  536. self.childInit = function () {
  537. self.cyearList = [];
  538. for (var i = 0; i < 6; i++) {
  539. if (i < 5) {
  540. self.cyearList.push(sp.currentYear() * 1 - 5 + i)
  541. } else if (i == 5) {
  542. self.cyearList.push(sp.currentYear())
  543. }
  544. }
  545. self.target = {
  546. cyear: sp.currentMonth() == 1 ? sp.currentYear() * 1 - 1 : sp.currentYear() * 1,
  547. cmonth: sp.currentMonth() == 1 ? 12 : sp.currentMonth() * 1
  548. }
  549. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  550. var dialogBody = "<div class=\"sp-dialog-body\">您确认要初始化" + self.data.NF + "年" + self.data.YF1 + "月值班信息吗?</div>";
  551. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='DataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  552. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  553. sp.openCenter(".sp-dialog");
  554. ///取消按钮
  555. $('.sp-closeDialog').click(function (event) {
  556. sp.closeCenter(".sp-dialog");
  557. event.preventDefault();
  558. event.stopPropagation();
  559. });
  560. //post消息的id
  561. $("#DataTrue").click(function () {
  562. sp.dialoghide()
  563. self.btnSave(4)
  564. });
  565. }
  566. self.btnInit = function () {
  567. var data = {
  568. tablename: "SX_YFZBB_01",
  569. columns: "NYBIAOSHI",
  570. sqlwhere: { NYBIAOSHI: self.data.NF + "-" + formate(self.data.YF1), PID: self.data.ID },
  571. sqlinwhere: {},
  572. sqllikewhere: {}
  573. }
  574. $http.post(apiurljs.login + "g2app/Data/QueryCountByTablenameWithCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  575. .success(function (obj1) {
  576. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  577. if (res1.data > 0) {
  578. sp.dialog("当月已有数据!")
  579. } else {
  580. var data = {
  581. cyear: self.data.NF,
  582. cmonth: self.data.YF1,
  583. id: self.data.ID
  584. }
  585. $http.post(apiurljs.login + "g2app/zhiban/InitPRZBZSDWZhibanMan", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  586. .success(function (obj2) {
  587. var res2 = strToJson(s4.decryptData_CBC(obj2.data));
  588. self.getChildList()
  589. })
  590. }
  591. })
  592. }
  593. //获取意见(上表)
  594. self.getOpinion = function (str) {
  595. var data = {
  596. cmanid: self.userId,
  597. routeinfoid: self.routeinfoid,
  598. routeid: "",//self.routeid,
  599. tableid: "SX_YFZBB",
  600. colid: str,
  601. opiniontype: 0,
  602. orderbycol: "CDATE desc"
  603. }
  604. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  605. .success(function (obj) {
  606. var res = strToJson(s4.decryptData_CBC(obj.data));
  607. if (res.success == true) {
  608. self.YJ[str] = res.data;
  609. self.YJ[str + "STATUS"] = false;
  610. self.YJ[str].forEach(function (item) {
  611. item.CDATE = sp.datefmt("yyyy-MM-dd HH:mm", item.CDATE);
  612. if (item.ROUTEID == self.routeid) {
  613. self.YJ[str + "STATUS"] = true;
  614. }
  615. })
  616. } else {
  617. sp.dialog(res.message)
  618. }
  619. })
  620. }
  621. //判断页面字段是否只读readonly、是否隐藏show
  622. self.hide = function (type, field) {
  623. if (self.dotype == 0 && type == "readonly") {
  624. return true;
  625. } else {
  626. if (self[type][field] == true) {
  627. return true;
  628. } else {
  629. return false;
  630. }
  631. }
  632. }
  633. //右上角按钮调用方法
  634. self.btnEvent = function (item) {
  635. switch (item.CODE) {
  636. case "SAVEITEM": self.btnSave(0); break;
  637. case "PRINTITEM": self.btnPrint(); break;
  638. case "MEETITEM": self.Meet(); break;
  639. case "SENDLOG": self.RouteList(); break;
  640. default: self.forward(item); break;
  641. }
  642. }
  643. //保存提交
  644. self.btnSave = function (n) {
  645. if (spngvld.submit("#topDiv")) {
  646. var dataArray = [];
  647. dataArray.push(self.data);
  648. var data = {
  649. ckey: "SX_YFZBB",
  650. id: self.data.ID,
  651. routeid: self.routeid,
  652. routeinfoid: self.routeinfoid,
  653. routeinfotitle: self.data.NF + "年" + self.data.YF1 + "月月份值班",//self.data.TITLE,
  654. directionid: self.directionid,
  655. formeditid: self.formeditid,
  656. data: JSON.stringify(dataArray)
  657. }
  658. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  659. .success(function (obj) {
  660. var res = strToJson(s4.decryptData_CBC(obj.data));
  661. if (res.code == 0) {
  662. self.data.ID = res.data.ID;
  663. self.routeid = res.data.ROUTEID;
  664. self.routeinfoid = res.data.ROUTEINFOID;
  665. self.filedChange = false;
  666. if (n == 0) {
  667. sp.dialog("保存成功!");
  668. $timeout(function () {
  669. sp.dialoghide()
  670. }, 1500)
  671. self.getSwenList(1)
  672. } else if (n == 1) {
  673. self.forward(self.btnItem);
  674. } else if (n == 2) {
  675. self.sendAll();
  676. } else if (n == 3) {
  677. self.RYADD()
  678. } else if (n == 4) {
  679. self.btnInit()
  680. }
  681. } else {
  682. sp.dialog(res.message)
  683. }
  684. })
  685. }
  686. }
  687. //获取所选年月所有日期
  688. self.getRiQiList = function () {
  689. self.RiQiList = [];
  690. self.YF.forEach(function (item) {
  691. if (self.data.YF == item.CODE) {
  692. self.data.YF1 = item.CNAME;
  693. }
  694. })
  695. var lastDay = sp.getLastDayOfMonth(self.data.NF, self.data.YF1);
  696. var n = lastDay.slice(lastDay.length - 2, lastDay.length)
  697. for (var i = 1; i <= n; i++) {
  698. self.RiQiList.push({ date: formate(i) })
  699. }
  700. if (self.data.LSH == "") {
  701. self.getLSH()
  702. }
  703. }
  704. //值班人员添加
  705. self.RYADD = function () {
  706. self.AddFlag = true;
  707. self.editFlag = true;
  708. self.edit = {
  709. ID: 0,
  710. RIQI: formate(new Date().getDate()),
  711. DBLDXM: "",
  712. ZW: "",
  713. BGGH: "",
  714. SJHM: "",
  715. ZBGBXM1: "",
  716. ZBGBXM1SJHM: "",
  717. ZBGBXM2: "",
  718. ZBGBXM2SJHM: "",
  719. ZBSJ: self.ZBSJ[0].CODE,
  720. XINGQI: ""
  721. };
  722. self.checkDate()
  723. if (self.data.ID == 0) {
  724. self.btnSave(3)
  725. }
  726. }
  727. //值班人员编辑
  728. self.RYEDIT = function (item) {
  729. self.EditFlag = true;
  730. item.editFlag = true;
  731. self.edit = {
  732. ID: item.ID,
  733. RIQI: item.RIQI,
  734. DBLDXM: item.DBLDXM,
  735. ZW: item.ZW,
  736. BGGH: item.BGGH,
  737. SJHM: item.SJHM,
  738. ZBGBXM1: item.ZBGBXM1,
  739. ZBGBXM1SJHM: item.ZBGBXM1SJHM,
  740. ZBGBXM2: item.ZBGBXM2,
  741. ZBGBXM2SJHM: item.ZBGBXM2SJHM,
  742. ZBSJ: item.ZBSJ,
  743. XINGQI: item.XINGQI
  744. };
  745. //self.XQ.forEach(function (item1) {
  746. // if (item1.CNAME == self.edit.XINGQI) {
  747. // self.edit.XINGQI = item1.CODE
  748. // }
  749. //})
  750. }
  751. self.RYSAVE = function () {
  752. var ushowname = [self.edit.DBLDXM, self.edit.ZBGBXM1, self.edit.ZBGBXM2].filter(function (item) {
  753. return item != ""
  754. })
  755. var data = {
  756. ushowname: ushowname.join("|")
  757. }
  758. $http.post(apiurljs.login + "g2app/ZhiBan/queryManUserid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  759. .success(function (obj) {
  760. var res = strToJson(s4.decryptData_CBC(obj.data));
  761. for (var i in res.data) {
  762. if (i == self.edit.DBLDXM) {
  763. self.edit.DBLDXMUSERID = res.data[i];
  764. } else if (i == self.edit.ZBGBXM1) {
  765. self.edit.ZBGBXMUSERID1 = res.data[i];
  766. } else if (i == self.edit.ZBGBXM2) {
  767. self.edit.ZBGBXMUSERID2 = res.data[i];
  768. }
  769. }
  770. if (self.edit.ID == 0) {
  771. var text = JSON.stringify({
  772. PID: self.data.ID,
  773. RIQI: self.edit.RIQI,
  774. DBLDXM: self.edit.DBLDXM,
  775. DBLDXMUSERID: self.edit.DBLDXMUSERID,
  776. ZW: self.edit.ZW,
  777. BGGH: self.edit.BGGH,
  778. SJHM: self.edit.SJHM,
  779. ZBGBXM1: self.edit.ZBGBXM1,
  780. ZBGBXMUSERID1: self.edit.ZBGBXMUSERID1,
  781. ZBGBXM1SJHM: self.edit.ZBGBXM1SJHM,
  782. ZBGBXM2: self.edit.ZBGBXM2,
  783. ZBGBXMUSERID2: self.edit.ZBGBXMUSERID2,
  784. ZBGBXM2SJHM: self.edit.ZBGBXM2SJHM,
  785. ZBSJ: self.edit.ZBSJ,
  786. XINGQI: self.edit.XINGQI
  787. })
  788. var data = {
  789. tablename: "SX_YFZBB_01",
  790. id: 0,
  791. data: text
  792. }
  793. $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  794. .success(function (obj) {
  795. var res = strToJson(s4.decryptData_CBC(obj.data));
  796. if (res.success) {
  797. self.getChildList();
  798. sp.dialog("添加成功!")
  799. $timeout(function () {
  800. sp.dialoghide()
  801. }, 2000)
  802. } else {
  803. sp.dialog(res.message)
  804. }
  805. })
  806. } else {
  807. var text = JSON.stringify({
  808. RIQI: self.edit.RIQI,
  809. DBLDXM: self.edit.DBLDXM,
  810. DBLDXMUSERID: self.edit.DBLDXMUSERID,
  811. ZW: self.edit.ZW,
  812. BGGH: self.edit.BGGH,
  813. SJHM: self.edit.SJHM,
  814. ZBGBXM1: self.edit.ZBGBXM1,
  815. ZBGBXMUSERID1: self.edit.ZBGBXMUSERID1,
  816. ZBGBXM1SJHM: self.edit.ZBGBXM1SJHM,
  817. ZBGBXM2: self.edit.ZBGBXM2,
  818. ZBGBXMUSERID2: self.edit.ZBGBXMUSERID2,
  819. ZBGBXM2SJHM: self.edit.ZBGBXM2SJHM,
  820. ZBSJ: self.edit.ZBSJ,
  821. XINGQI: self.edit.XINGQI
  822. })
  823. var data = {
  824. tablename: "SX_YFZBB_01",
  825. id: self.edit.ID,
  826. data: text
  827. }
  828. $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  829. .success(function (obj) {
  830. var res = strToJson(s4.decryptData_CBC(obj.data));
  831. if (res.success) {
  832. var data1 = {
  833. tablename: "SX_YFZBB",
  834. id: self.data.ID,
  835. data: {
  836. LSH: (parseInt(self.data.LSH) + 1).toString()
  837. }
  838. }
  839. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  840. .success(function (obj1) {
  841. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  842. if (res1.success == true) {
  843. self.getData();
  844. sp.dialog("编辑成功!")
  845. $timeout(function () {
  846. sp.dialoghide()
  847. }, 2000)
  848. } else {
  849. sp.dialog(res.message)
  850. }
  851. })
  852. $timeout(function () {
  853. sp.dialoghide()
  854. }, 2000)
  855. } else {
  856. sp.dialog(res.message)
  857. }
  858. })
  859. }
  860. })
  861. }
  862. self.btnDel = function (item) {
  863. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  864. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  865. 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>";
  866. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  867. sp.openCenter(".sp-dialog");
  868. ///取消按钮
  869. $('.sp-closeDialog').click(function (event) {
  870. sp.closeCenter(".sp-dialog");
  871. event.preventDefault();
  872. event.stopPropagation();
  873. });
  874. //post消息的id
  875. $("#delDataTrue").click(function () {
  876. var data = {
  877. tablename: "SX_YFZBB_01",
  878. id: item.ID
  879. };
  880. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  881. .success(function (obj) {
  882. var res = strToJson(s4.decryptData_CBC(obj.data));
  883. sp.dialoghide();
  884. if (res.success) {
  885. self.getChildList();
  886. } else {
  887. sp.dialog("删除失败,请联系管理员!");
  888. }
  889. });
  890. });
  891. }
  892. self.openUserList = function (str) {
  893. self.filed = str;
  894. self.userList.forEach(function (item) {
  895. item.users.forEach(function (item1) {
  896. item1.checked = false;
  897. if (item1.ushowname == self.edit[self.filed]) {
  898. item1.checked = true;
  899. }
  900. })
  901. })
  902. sp.layer("#userList")
  903. $("#userList .sp-page").eq(0).scrollTop(0);
  904. }
  905. self.checkUser = function (item) {
  906. $.each(self.userList, function (x, y) {
  907. $.each(y.users, function (x1, y1) {
  908. y1.checked = y1.userid == item.userid;
  909. if (y1.checked == true) {
  910. self.edit[self.filed] = y1.ushowname;
  911. if (self.filed == "DBLDXM") {
  912. self.edit.ZW = y.section
  913. self.edit.DBLDXMUSERID = y1.userid;
  914. } else if (self.filed == "ZBGBXM1") {
  915. self.edit.ZBGBXMUSERID1 = y1.userid;
  916. } else if (self.filed == "ZBGBXM2") {
  917. self.edit.ZBGBXMUSERID2 = y1.userid;
  918. }
  919. }
  920. })
  921. })
  922. }
  923. self.openDateList = function () {
  924. self.RiQiList.forEach(function (item) {
  925. item.checked = false;
  926. if (item.date == self.edit.RIQI) {
  927. item.checked = true;
  928. }
  929. })
  930. sp.layer("#dateList")
  931. }
  932. self.checkDate = function () {
  933. var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  934. //self.XQ.forEach(function (item) {
  935. // if (item.CNAME == weeks[new Date(self.data.NF + "-" + self.data.YF1 + "-" + self.edit.RIQI).getDay()]) {
  936. // self.edit.XINGQI = item.CODE;
  937. // }
  938. //})
  939. }
  940. self.changeLD = function () {
  941. self.DBLD.forEach(function (item) {
  942. if (item.CNAME == self.edit.DBLDXM) {
  943. self.edit.DBLDXMUSERID = item.USERID;
  944. self.edit.ZW = item.ZHIWU;
  945. self.edit.BGGH = item.TEL;
  946. self.edit.SJHM = item.MOBILEPHONE;
  947. }
  948. })
  949. }
  950. //前端导出
  951. self.printOut = function () {
  952. if (self.canExportExcel) {
  953. $('#printOut td').attr('t', 's')
  954. var defaultCellStyle = {
  955. font: {
  956. name: 'Times New Roman',
  957. sz: 12,
  958. color: {
  959. rgb: "000000"
  960. },
  961. bold: false, italic: false,
  962. underline: false
  963. },
  964. alignment: {
  965. vertical: "center",
  966. horizontal: "center", indent: 0, wrapText: true
  967. },
  968. border: {
  969. top: {
  970. style: "thin",
  971. color: {
  972. rgb: "000000"
  973. }
  974. },
  975. right: {
  976. style: "thin",
  977. color: {
  978. rgb: "000000"
  979. }
  980. },
  981. bottom: {
  982. style: "thin",
  983. color: {
  984. rgb: "000000"
  985. }
  986. },
  987. left: {
  988. style: "thin",
  989. color: {
  990. rgb: "000000"
  991. }
  992. }
  993. }
  994. };
  995. var cell = { defaultCellStyle: defaultCellStyle };
  996. var wb = XLSX.utils.table_to_book_addtitle(document.querySelector('#printOut'), cell, "市住房城乡建设委机关" + self.data.NF + "年" + self.data.YF1 + "月份值班表")
  997. //设置表格的样式
  998. var wbout = XLSX.write(wb, {
  999. bookType: 'xlsx',
  1000. bookSST: false,
  1001. type: 'binary',
  1002. cellStyles: true,
  1003. defaultCellStyle: defaultCellStyle,
  1004. showGridLines: false
  1005. });
  1006. var s2ab = function (s) {
  1007. var buf = new ArrayBuffer(s.length);
  1008. var view = new Uint8Array(buf);
  1009. for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  1010. return buf;
  1011. };
  1012. try {
  1013. saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), '市住房城乡建设委机关' + self.data.NF + '年' + self.data.YF1 + '月份值班表.et')
  1014. } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
  1015. return wbout
  1016. } else {
  1017. sp.dialog('数据还未加载完成,请稍等...')
  1018. }
  1019. }
  1020. //签写意见编辑状态
  1021. self.opinion = {
  1022. SPYJ: false,
  1023. SPYJImg: false
  1024. }
  1025. self.YJ = {
  1026. SPYJ: [],
  1027. SPYJSTATUS: false
  1028. }
  1029. //下载意见表附件
  1030. self.downLoadOption = function (item) {
  1031. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  1032. }
  1033. //删除意见表附件
  1034. self.deleteOptionFile = function (file, str) {
  1035. var data = {
  1036. routeid: file.ROUTEID,
  1037. tableid: "SX_YFZBB",
  1038. colid: str,
  1039. fileid: file.FILEID
  1040. };
  1041. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1042. .success(function (obj) {
  1043. var res = strToJson(s4.decryptData_CBC(obj.data));
  1044. sp.dialoghide();
  1045. if (res.success) {
  1046. if (str != "") {
  1047. self.getOpinion(str);
  1048. } else {
  1049. self.getOpinion1();
  1050. }
  1051. } else {
  1052. sp.dialog("删除失败,请联系管理员!");
  1053. }
  1054. });
  1055. }
  1056. //意见附件(上表)
  1057. self.upload2 = function (str) {
  1058. $('#fileupload-' + str).fileupload({
  1059. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  1060. dataType: 'json',
  1061. beforeSend: function (xhr, data) {
  1062. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  1063. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  1064. + ",routeid=" + self.routeid + ",tableid=SX_YFZBB,colid=" + str));
  1065. },
  1066. // 上传完成后的执行逻辑
  1067. done: function (e, data) {
  1068. self.uploading1 = false;
  1069. self.getOpinion(str)
  1070. }
  1071. })
  1072. }
  1073. //签写意见
  1074. self.openOpinion = function (str) {
  1075. if (self.routeinfoid == 0 && self.routeid == 0) {
  1076. sp.dialog("请先保存!")
  1077. return;
  1078. }
  1079. self.opinion[str] = true;
  1080. }
  1081. //修改意见
  1082. self.changeOpinion = function (str) {
  1083. self.data[str] = self.YJ[str][0].OPINION;
  1084. self.opinion[str] = true;
  1085. }
  1086. self.changeOpinionItem = function (str, item) {
  1087. if (item.OPINIONIMAGE != "") {
  1088. self.QianZi(str);
  1089. self.opinion[str + "Img"] = true;
  1090. }
  1091. self.data[str] = item.OPINION;
  1092. self.opinion[str] = true;
  1093. }
  1094. //提交意见
  1095. self.Sopinion = function (str) {
  1096. if (self.opinion[str + "Img"] == true) {
  1097. self.data[str] = $("#" + str + "QZ").find("canvas")[0].toDataURL();
  1098. } else {
  1099. self.data[str] = $("#" + str).val();
  1100. }
  1101. //opiniontype:0上表,99不上表
  1102. var data = {
  1103. cmanid: self.userId,
  1104. routeinfoid: self.routeinfoid,
  1105. routeid: self.routeid,
  1106. tableid: "SX_YFZBB",
  1107. colid: str,
  1108. opiniontype: 0,
  1109. cresult: "",
  1110. opinion: self.opinion[str + "Img"] == false ? self.data[str] : "",
  1111. opinionimage: self.opinion[str + "Img"] == true ? self.data[str] : ""
  1112. }
  1113. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1114. .success(function (obj) {
  1115. var res = strToJson(s4.decryptData_CBC(obj.data));
  1116. if (res.success == true) {
  1117. self.getOpinion(str);
  1118. self.opinion[str] = false;
  1119. self.opinion[str + "Img"] = false;
  1120. self.data[str] = "";
  1121. self.changeFiled(str)
  1122. } else {
  1123. sp.dialog(res.message)
  1124. }
  1125. })
  1126. }
  1127. //删除意见
  1128. self.Dopinion = function (str, item) {
  1129. var data = {
  1130. cmanid: self.userId,
  1131. routeid: self.routeid,
  1132. tableid: "SX_YFZBB",
  1133. colid: str,
  1134. }
  1135. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1136. .success(function (obj) {
  1137. var res = strToJson(s4.decryptData_CBC(obj.data));
  1138. if (res.success == true) {
  1139. if (str != "") {
  1140. self.getOpinion(str);
  1141. } else {
  1142. self.getOpinion1();
  1143. }
  1144. self.changeFiled(str)
  1145. } else {
  1146. sp.dialog(res.message)
  1147. }
  1148. })
  1149. }
  1150. self.phraseText = "";//添加常用语
  1151. self.phraseList = []//常用语列表
  1152. //获取常用语库
  1153. self.phrase = function (colid) {
  1154. sp.layer("#phrase");
  1155. self.colid = colid;
  1156. self.getPhrase();
  1157. }
  1158. //添加常用语到常用语库
  1159. self.Aphrase = function () {
  1160. if (self.phraseText == "") {
  1161. return;
  1162. }
  1163. var data = {
  1164. cmanid: self.userId,
  1165. tableid: "SX_YFZBB",
  1166. colid: self.colid,
  1167. contents: self.phraseText
  1168. }
  1169. $http.post(apiurljs.login + "g2app/abase/insertDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1170. .success(function (obj) {
  1171. var res = strToJson(s4.decryptData_CBC(obj.data));
  1172. if (res.success == true) {
  1173. self.phraseText = "";
  1174. self.getPhrase();
  1175. } else {
  1176. sp.dialog(res.message)
  1177. }
  1178. })
  1179. }
  1180. //获取常用语库
  1181. self.getPhrase = function () {
  1182. var data = {
  1183. cmanid: self.userId,
  1184. tableid: "SX_YFZBB",
  1185. colid: self.colid
  1186. }
  1187. $http.post(apiurljs.login + "g2app/abase/queryDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1188. .success(function (obj) {
  1189. var res = strToJson(s4.decryptData_CBC(obj.data));
  1190. self.phraseList = res.data;
  1191. self.phraseSelect = self.phraseList[0].CONTENTS;
  1192. })
  1193. }
  1194. //从常用语库删除
  1195. self.Dphrase = function () {
  1196. var id = null;
  1197. $.each(self.phraseList, function (index, item) {
  1198. if (item.CONTENTS == self.phraseSelect) {
  1199. id = item.ID;
  1200. }
  1201. })
  1202. var data = {
  1203. id: id
  1204. }
  1205. $http.post(apiurljs.login + "g2app/abase/deleteDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1206. .success(function (obj) {
  1207. var res = strToJson(s4.decryptData_CBC(obj.data));
  1208. self.getPhrase();
  1209. })
  1210. }
  1211. //常用语确认为意见
  1212. self.btnPhrase = function () {
  1213. if (!self.colid) {
  1214. self.nulla = self.phraseSelect;
  1215. } else {
  1216. self.data[self.colid] = self.phraseSelect;
  1217. }
  1218. sp.layerhide();
  1219. }
  1220. //签字—手写
  1221. self.QianZi = function (str) {
  1222. self.opinion[str + "Img"] = true;
  1223. setTimeout(function () {
  1224. new lineCanvas(str + "QZ")
  1225. }, 1)
  1226. }
  1227. //清除手写
  1228. self.canvasClear = function (str) {
  1229. var cxt = $("#" + str + "QZ").find("canvas")[0].getContext("2d");
  1230. cxt.clearRect(0, 0, $("#" + str + "QZ").find("canvas")[0].width, $("#" + str + "QZ").find("canvas")[0].height)
  1231. }
  1232. //发生修改
  1233. self.changeFiled = function (str) {
  1234. self.filedChange = true;
  1235. }
  1236. //转发
  1237. self.forward = function (obj) {
  1238. self.btnItem = obj;
  1239. if (self.filedChange == true) {
  1240. self.btnSave(1)
  1241. } else {
  1242. $("#forwardWin").attr("src", "../../forward/forward.html?routeid=" + self.routeid + "&routeinfoid=" + self.routeinfoid + "&copyrightid=" + self.copyrightid + "&directionid=" + self.directionid + "&formeditid=" + self.formeditid + "&codefuncbutton=" + obj.CODE + "&directionidtarget=" + obj.DIRECTIONIDTARGET + "&cookie=zhibanmgr")
  1243. sp.layer("#forward")
  1244. }
  1245. }
  1246. //查看流转记录
  1247. self.RouteList = function () {
  1248. if (self.deviceType == "pad") {
  1249. window.location.href = "../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  1250. } else {
  1251. sp.openNewWindow("../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1], "流程图")
  1252. }
  1253. //var data = {
  1254. // directionid: self.directionid,
  1255. // userid: self.userId,
  1256. // routeid: self.routeid,
  1257. // routeinfoid: self.routeinfoid,
  1258. //}
  1259. //$http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1260. //.success(function (obj) {
  1261. // var res = strToJson(s4.decryptData_CBC(obj.data));
  1262. // self.routeList = res.data;
  1263. // $.each(self.routeList, function (index, item) {
  1264. // item.mainUser = [];
  1265. // item.copyUsers = [];
  1266. // $.each(item.USERS, function (index1, item1) {
  1267. // if (item1.KIND == 0) {
  1268. // item.mainUser.push(item1.USERNAME);
  1269. // } else {
  1270. // item.copyUsers.push(item1.USERNAME);
  1271. // }
  1272. // })
  1273. // item.mainUser = item.mainUser.join(",");
  1274. // item.copyUsers = item.copyUsers.join(",");
  1275. // })
  1276. // setTimeout(function (item) {
  1277. // sp.layer("#RouteList");
  1278. // }, 100);
  1279. //})
  1280. }
  1281. self.active = null;
  1282. self.activeItem = function (obj,str,n) {
  1283. if (self.active == null) {
  1284. self.active = obj;
  1285. } else {
  1286. self.active = null;
  1287. }
  1288. console.log(obj, str, n)
  1289. }
  1290. self.reSizeRow = function () {
  1291. var bodybox = document.getElementById("bodyDiv");
  1292. var topbox = document.getElementById("topDiv");
  1293. var bottombox = document.getElementById("bottomDiv");
  1294. var line = document.getElementById("lineDiv");
  1295. document.getElementById("lineDiv").addEventListener("mousedown", function (event) {
  1296. $(".mousemove").show()
  1297. var bodyboxH = bodybox.clientHeight;
  1298. var topboxH = topbox.clientHeight;
  1299. var bottomboxH = bottombox.clientHeight;
  1300. //var y = event.pageY - line.offsetTop;
  1301. var y = event.pageY - line.clientHeight;
  1302. document.addEventListener("mousemove", boxMove)
  1303. function boxMove(event) {
  1304. if (topboxH * 1 + (event.pageY - y) * 1 - 36 <= 45) {
  1305. //
  1306. } else if (bottomboxH * 1 - (event.pageY - y) * 1 - 36 <= 45) {
  1307. //
  1308. } else {
  1309. topbox.style.height = topboxH * 1 + (event.pageY - y) * 1 - 36 + "px";
  1310. //topbox.getElementsByTagName("iframe")[0].style.height = topboxH * 1 + (event.pageY - y) * 1 - 45 + "px";
  1311. bottombox.style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 + 36 + "px";
  1312. bottombox.getElementsByTagName("iframe")[0].style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 - 25 + "px";
  1313. }
  1314. }
  1315. document.addEventListener("mouseup", function () {
  1316. $(".mousemove").hide()
  1317. document.removeEventListener("mousemove", boxMove)
  1318. })
  1319. })
  1320. }
  1321. ////头部关键字搜索---20230905
  1322. self.headBtnSearchKeyword = "";
  1323. self.headSearchResult = [];
  1324. self.headSearchResult_view = false;
  1325. self.headBtnSearch = function () {
  1326. if (sp.isval(self.headBtnSearchKeyword)) {
  1327. self.headSearchResult = [];
  1328. var data = {
  1329. "url": "/basic/api/StatSelect/selectCodeList",
  1330. "data": { "keyWord": self.headBtnSearchKeyword }
  1331. }
  1332. //console.log(JSON.stringify(data));
  1333. $http.post(apiurljs.login + "g2app/yizhangtu/selectCodeList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1334. .success(function (obj) {
  1335. var res = strToJson(s4.decryptData_CBC(obj.data));
  1336. //console.log(JSON.stringify(res.data));
  1337. self.headSearchResult = res.data.build;
  1338. if (sp.isval(self.headSearchResult)) {
  1339. self.headSearchResult_view = true;
  1340. } else {
  1341. self.headSearchResult_view = false;
  1342. }
  1343. })
  1344. } else {
  1345. self.headSearchResult_view = false;
  1346. }
  1347. };
  1348. self.headKeywordPage = function (itemdata) {
  1349. var get_token = localStorage.getItem("main-token");
  1350. var set_url = apiurljs.onePic + "wholeProcessPage/?token=" + get_token + "&name=" + itemdata.name + "&type=" + itemdata.type + "&id=" + itemdata.id;
  1351. $('#attachlist')[0].contentWindow.openTool(set_url, '一张图');
  1352. self.headSearchResult_view = false;
  1353. };
  1354. self.onePic = function () {
  1355. $('#attachlist')[0].contentWindow.openTool(apiurljs.onePic + "wholeProcessPage/?token=" + localStorage.getItem("main-token"), "地图搜索")
  1356. }
  1357. //头部下滚冻结
  1358. $(function () {
  1359. $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
  1360. $(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
  1361. //$("body").bind("scroll", function () {
  1362. // var scrollTop = $("body").scrollTop();
  1363. // if (scrollTop == 0) {
  1364. // $(".FixTop").removeClass("FixTop");
  1365. // }
  1366. // if (scrollTop > 35) {
  1367. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  1368. // }
  1369. //});
  1370. //页面高度撑满
  1371. setTimeout(function () {
  1372. if ($(".ibox-content").height() < $(window).height() - 31) {
  1373. $(".ibox-content").css("height", $(window).height() - 31)
  1374. }
  1375. $(".mousemove").css("top", 0).css("left", 0).css("width", $(window).width()).css("height", $(window).height() - 10)
  1376. }, 1)
  1377. })
  1378. }])
  1379. app.directive("repeatFinish", function () {
  1380. return {
  1381. link: function (scope) {
  1382. if (scope.$last == true) {
  1383. setTimeout(function () {
  1384. $(".zb-table").rowspan(1)
  1385. $(".zb-table").rowspan(0)
  1386. }, 10);
  1387. }
  1388. }
  1389. };
  1390. });
  1391. app.filter('trustHtml', function ($sce) {
  1392. return function (input) {
  1393. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  1394. };
  1395. });
  1396. //canvas画布签字
  1397. function lineCanvas(obj) {
  1398. var self = this;
  1399. self.linewidth = 1;
  1400. self.color = "#000000";
  1401. self.background = "#ffffff";
  1402. self.canvas = document.createElement("canvas");
  1403. document.getElementById(obj).appendChild(self.canvas);
  1404. self.cxt = self.canvas.getContext("2d");
  1405. self.canvas.width = document.getElementById(obj).clientWidth;
  1406. self.canvas.height = document.getElementById(obj).scrollHeight;
  1407. self.cxt.fillStyle = self.background;
  1408. self.cxt.fillRect(0, 0, self.canvas.width, self.canvas.width);
  1409. self.cxt.strokeStyle = self.color;
  1410. self.cxt.lineWidth = self.linewidth;
  1411. self.cxt.lineCap = "round";
  1412. //开始绘制
  1413. self.canvas.addEventListener("mousedown", function (e) {
  1414. self.cxt.beginPath();
  1415. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop());
  1416. self.canvas.addEventListener("mousemove", move)
  1417. }.bind(self), false);
  1418. //绘制中
  1419. function move() {
  1420. var e = window.event;
  1421. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop());
  1422. self.cxt.stroke();
  1423. }
  1424. //结束绘制
  1425. self.canvas.addEventListener("mouseup", up)
  1426. function up() {
  1427. self.cxt.closePath();
  1428. self.canvas.removeEventListener("mousemove", move)
  1429. }
  1430. };
  1431. function formate(n) {
  1432. return n * 1 > 9 ? n * 1 : "0" + n * 1;
  1433. }
  1434. function getNum(arr, name) {
  1435. var n = -1;
  1436. $.each(arr, function (index, item) {
  1437. if (item.CNAME == name) {
  1438. n = index
  1439. }
  1440. })
  1441. return n
  1442. }
  1443. function isNull(str) {
  1444. if (str == "" || str == null || str == undefined) {
  1445. return false
  1446. } else {
  1447. return true
  1448. }
  1449. }
  1450. jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
  1451. return this.each(function () {
  1452. var that;
  1453. $('tr', this).each(function (row) {
  1454. $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
  1455. if (that != null && $(this).html() == $(that).html()) {
  1456. var rowspan = $(that).attr("rowSpan");
  1457. if (rowspan == undefined) {
  1458. $(that).attr("rowSpan", 1);
  1459. rowspan = $(that).attr("rowSpan");
  1460. }
  1461. rowspan = Number(rowspan) + 1;
  1462. $(that).attr("rowSpan", rowspan);
  1463. $(this).remove();
  1464. } else {
  1465. that = this;
  1466. }
  1467. });
  1468. });
  1469. });
  1470. }
  1471. function showToggle(e) {
  1472. $(e).children().toggle()
  1473. $(e).next().toggle()
  1474. }
  1475. function toggleYJL(e) {
  1476. if ($(e).children(".fa-angle-double-down").is(":hidden") == true) {
  1477. $("#topDiv").css("height", 160)
  1478. $(e).parent().css("height", 450)
  1479. $("#attachlist").css("height", 200)
  1480. $("#bottomDiv").css("height", "")
  1481. } else {
  1482. $("#topDiv").css("height", 600)
  1483. $(e).parent().css("height", 10)
  1484. }
  1485. $(e).children().toggle()
  1486. }