formedit2.js 58 KB

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