formedit.js 59 KB

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