formedit.js 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. var app = angular.module('app', [
  2. ]);
  3. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  4. var self = this;
  5. var s4 = new SM4Util();
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-chineseName");
  8. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  9. self.routeid = sp.getUrlName("routeid");
  10. self.routeinfoid = sp.getUrlName("routeinfoid");
  11. self.directionid = sp.getUrlName("directionid");
  12. self.formeditid = sp.getUrlName("formeditid");
  13. self.mbid = sp.getUrlName("mbid");
  14. self.fjid = sp.getUrlName("fjid");
  15. self.docmode = sp.getUrlName("docmode");
  16. self.dotype = sp.getUrlName("dotype");
  17. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  18. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  19. self.get_type = sp.getUrlName("type");
  20. self.return = "list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  21. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  22. var postCfg = {
  23. headers: {
  24. 'Content-Type': 'application/json',
  25. 'Authorization': "Bearer " + self.get_AccessToken
  26. }
  27. };
  28. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  29. self.loading = false;
  30. self.getSwenList = function (n) {
  31. self.loading = true;
  32. self.SwenList = [];
  33. var data = {
  34. directionid: self.directionid,
  35. userid: self.userId,
  36. routeinfoid: self.routeinfoid,
  37. routeid: self.routeid,
  38. formeditid: ""
  39. }
  40. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  41. .success(function (obj) {
  42. var res = strToJson(s4.decryptData_CBC(obj.data));
  43. $.each(res.data.LINKS, function (index, item) {
  44. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  45. self.Title = item.VNAME;
  46. }
  47. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  48. if (item.TEMPFORM.indexOf("fawenfile") > -1) {
  49. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  50. } else {
  51. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  52. }
  53. } else {
  54. item.TEMPFORM = "#";
  55. }
  56. self.SwenList.push(item)
  57. })
  58. //self.SwenList.push({
  59. // VNAME: "流程图",
  60. // DIRECTIONID: self.SwenList[0].DIRECTIONID,
  61. // TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  62. //})
  63. if (n == 0) {
  64. self.getDpList();
  65. } else {
  66. self.getData()
  67. }
  68. })
  69. }
  70. self.getSwenList(0)
  71. self.getDpList = function () {
  72. var data = {
  73. unitid: "AA"
  74. }
  75. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  76. .success(function (obj) {
  77. var res = strToJson(s4.decryptData_CBC(obj.data));
  78. self.dpList = [];
  79. res.data.forEach(function (item) {
  80. if (item.CHILD_DATA.length == 0) {
  81. self.dpList.push(item)
  82. } else {
  83. item.CHILD_DATA.forEach(function (item1) {
  84. if (item1.CHILD_DATA.length == 0) {
  85. self.dpList.push(item1)
  86. } else {
  87. item1.CHILD_DATA.forEach(function (item2) {
  88. if (item2.CHILD_DATA.length == 0) {
  89. self.dpList.push(item2)
  90. }
  91. })
  92. }
  93. })
  94. }
  95. })
  96. self.dpList.forEach(function (item) {
  97. item.checked = false;
  98. })
  99. self.DpList = {
  100. ZS: JSON.parse(JSON.stringify(self.dpList)),
  101. CS: JSON.parse(JSON.stringify(self.dpList))
  102. }
  103. self.AllCheckedDp = {};
  104. self.DpLength = {};
  105. self.selectDpList = {};
  106. self.getData();
  107. })
  108. }
  109. //初始化右上角按钮
  110. self.buttonList = [];
  111. ////获取设计的表单、及数据、按钮数组---------zyg----20230519
  112. self.data = {};////参考之前已有,本次保留并拼接此数据
  113. self.readonly = {};////参考之前已有,本次保留并拼接此数据
  114. self.fb_queryDataCustom_data = {};////返回的数据
  115. self.getData = function () {
  116. self.loading = true;
  117. var data = {
  118. "ckey": "",
  119. "userid": self.userId,
  120. "formeditid": self.formeditid,
  121. "directionid": self.directionid,
  122. "routeinfoid": self.routeinfoid,
  123. "routeid": self.routeid,
  124. "id":0
  125. }
  126. //console.log(JSON.stringify(data));
  127. $http.post(apiurljs.login + "g2app/abase/queryDataCustom", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  128. .success(function (obj) {
  129. var res = strToJson(s4.decryptData_CBC(obj.data)).data;
  130. self.fb_queryDataCustom_data = res;////返回的数据
  131. //console.log(JSON.stringify(res.TableCols));
  132. $("#formDesignPart").html(s4.decryptData_CBC(res.TableData));
  133. //console.log(JSON.stringify(res.TableCols));
  134. //console.log(res.ID);
  135. /////原有业务逻辑-------
  136. var fb_json_str = "";
  137. var fb_json_readnly = "";
  138. angular.forEach(res.TableCols, function (item) {
  139. var set_str = "\"" + item.CODE + "\":\"" + item.VALUE + "\"" + ",";
  140. fb_json_str += set_str;
  141. var set_readonly = "\"" + item.CODE + "\":\"" + item.EREADONLY + "\"" + ",";
  142. fb_json_readnly += set_readonly;
  143. });
  144. var set_id_str = "\"ID\":\"" + res.ID + "\""
  145. self.data = JSON.parse("{" + fb_json_str + set_id_str + "}");
  146. //console.log(self.data);
  147. self.readonly = JSON.parse("{" + sp.cutlast(fb_json_readnly) + "}");
  148. $timeout(function () {
  149. if (self.data.ID == 0) {
  150. self.filedChange = true;
  151. } else {
  152. self.filedChange = false;
  153. }
  154. self.buttonList = self.dotype == 0 ? [] : res.FUNCLIST;
  155. var n = {}, all = {};
  156. for (var i in self.DpList) {
  157. self.AllCheckedDp[i] = false;
  158. self.DpLength[i] = 0;
  159. self.selectDpList[i] = []
  160. all[i] = 0;
  161. $.each(self.DpList[i], function (index, item) {
  162. self.DpLength[i]++
  163. if (self.data.ZS.indexOf(item.SECTION) != -1 && i == "ZS") {
  164. all[i]++;
  165. item.checked = true;
  166. self.selectDpList[i].push(item);
  167. }
  168. if (self.data.CS.indexOf(item.SECTION) != -1 && i == "CS") {
  169. all[i]++;
  170. item.checked = true;
  171. self.selectDpList[i].push(item);
  172. }
  173. })
  174. if (all[i] == self.DpList[i].length) {
  175. self.AllCheckedDp[i] = true;
  176. } else {
  177. self.AllCheckedDp[i] = false;
  178. }
  179. }
  180. }, 100);
  181. $timeout(function () {
  182. $(".formedit center").css("height", $(".formedit center").parent().next("div").height() - $(".formedit center").parent().next("div").children().eq(0).height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
  183. var height1 = $(".formedit center").css("height"), height2 = 0;
  184. $(".auto").siblings().each(function () {
  185. height2 = height2 + $(this).outerHeight();
  186. })
  187. //$(".auto").css("height", height1.slice(0, height1.length - 2) - height2);
  188. }, 200)
  189. /////原有业务逻辑-------
  190. ////自定义表单设置及赋值-----zyg---
  191. if (self.routeid == "0") {
  192. sp.radio();///单选
  193. sp.checkbox();///多选
  194. spvld.getValidate();///开始正则校验组件
  195. spbld.laydate();////操作日期控件组件
  196. //spbld.subtable();///操作子表按钮组件
  197. } else {
  198. //var get_viewData_json = "json/viewData_2.txt?ctime="+new Date();
  199. ////调用给表单赋值组件
  200. spbld.fbAssignValueToTable(JSON.stringify(res), self.userId, self.routeinfoid, self.routeid, self.get_AccessToken);
  201. //if (get_role == "read") {
  202. // ///只读状态将表单中全部设置为只读状态,不可录入编辑删除
  203. // $("body").find("button").attr("disabled", "disabled");
  204. // $("body").find("input").attr("disabled", "disabled");
  205. // $("body").find("select").attr("disabled", "disabled");
  206. // $("body").find("textarea").attr("disabled", "disabled");
  207. // $("body").find(".sp-upload-tip-close").hide(); ////附件列表的删除按钮去掉
  208. //}
  209. $timeout(function () {
  210. sp.radio();///单选
  211. sp.checkbox();///多选
  212. spvld.getValidate();///开始正则校验组件
  213. spbld.laydate();////操作日期控件组件
  214. //spbld.subtable();///操作子表按钮组件
  215. }, 1000);
  216. }
  217. ////自定义表单设置及赋值-----zyg---
  218. self.loading = false;
  219. })
  220. }
  221. //self.getData();
  222. //上层附件、业务参考、共享沟通组件
  223. self.uploading = false;
  224. self.upload = function () {
  225. $('#fileupload').fileupload({
  226. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  227. dataType: 'json',
  228. beforeSend: function (xhr, data) {
  229. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  230. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FW_ZSWPXXWENATTACHFILE,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=正式文(平、下行文)"));
  231. },
  232. add: function (e, data) {
  233. var num = 0;
  234. var acceptFileTypes = /(doc|wps|pdf|ofd)$/i;
  235. //文件类型判断
  236. $.each(data.originalFiles, function (index, item) {
  237. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  238. sp.dialog("您好,请上传doc/wps/pdf/ofd格式的文件!");
  239. return;
  240. } else {
  241. num++
  242. }
  243. })
  244. if (num == data.originalFiles.length) {
  245. self.uploading = true;
  246. data.submit();
  247. $scope.$apply();
  248. }
  249. },
  250. // 上传完成后的执行逻辑
  251. done: function (e, data) {
  252. self.uploading = false;
  253. self.getOther()
  254. }
  255. })
  256. }
  257. self.downLoad = function (item) {
  258. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  259. }
  260. self.deleteFile = function (file) {
  261. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  262. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  263. 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>";
  264. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  265. sp.openCenter(".sp-dialog");
  266. ///取消按钮
  267. $('.sp-closeDialog').click(function (event) {
  268. sp.closeCenter(".sp-dialog");
  269. event.preventDefault();
  270. event.stopPropagation();
  271. });
  272. //post消息的id
  273. $("#delDataTrue").click(function () {
  274. var data = {
  275. tablename: "FW_ZSWPXXWENATTACHFILE",
  276. id: file.ID
  277. };
  278. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  279. .success(function (obj) {
  280. var res = strToJson(s4.decryptData_CBC(obj.data));
  281. sp.dialoghide();
  282. if (res.success) {
  283. self.getOther();
  284. } else {
  285. sp.dialog("删除失败,请联系管理员!");
  286. }
  287. });
  288. });
  289. }
  290. self.searchCj = function () {
  291. var data1 = {
  292. ckey: "CODE_PLUGINKINDS",
  293. routeinfoid: self.routeinfoid
  294. }
  295. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  296. .success(function (obj1) {
  297. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  298. self.KINDS = res1.data.CODE_PLUGINKINDS;
  299. var data2 = {
  300. ckey: "CODE_PLUGINDTYPE",
  301. routeinfoid: self.routeinfoid
  302. }
  303. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
  304. .success(function (obj2) {
  305. var res2 = strToJson(s4.decryptData_CBC(obj2.data));
  306. self.DTYPE = res2.data.CODE_PLUGINDTYPE;
  307. var data3 = {
  308. ckey: "CODE_PLUGINAUTHMAN",
  309. routeinfoid: self.routeinfoid
  310. }
  311. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data3)) }, postCfg)
  312. .success(function (obj3) {
  313. var res3 = strToJson(s4.decryptData_CBC(obj3.data));
  314. self.AUTHMAN = res3.data.CODE_PLUGINAUTHMAN;
  315. self.search = {
  316. KINDS: "",
  317. DTYPE: ""
  318. }
  319. self.addSC = {};
  320. self.getCJlist(0)
  321. })
  322. })
  323. })
  324. }
  325. self.getCJlist = function (n) {
  326. var data = {
  327. kinds: self.search.KINDS,
  328. dtype: self.search.DTYPE,
  329. ctype: "C02"
  330. }
  331. $http.post(apiurljs.login + "g2app/plugin/queryDataList", data, postCfg)
  332. .success(function (res) {
  333. self.CJlist = res.data;
  334. self.CJlist.forEach(function (item) {
  335. self.AUTHMAN.forEach(function (item1) {
  336. if (item.AUTHMAN == item1.CODE) {
  337. item.AUTHMAN1 = item1.CNAME;
  338. }
  339. })
  340. })
  341. if (n == 0) {
  342. sp.layer("#addCJ")
  343. }
  344. })
  345. }
  346. self.deleteCJ = function (CJ) {
  347. var data = {
  348. id: CJ.ID
  349. }
  350. $http.post(apiurljs.login + "g2app/plugin/deletePluginRouteByID", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  351. .success(function (obj) {
  352. var res = strToJson(s4.decryptData_CBC(obj.data));
  353. if (res.success == true) {
  354. self.getOther()
  355. } else {
  356. sp.dialog(res.message)
  357. }
  358. })
  359. }
  360. self.Meeting = function () {
  361. $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
  362. .success(function (obj) {
  363. var res = strToJson(s4.decryptData_CBC(obj.data));
  364. self.dpList = res.data;
  365. self.dpList1 = [];
  366. self.dpList.forEach(function (item) {
  367. self.dpList1.push(item)
  368. item.USER.forEach(function (item1) {
  369. item1.show = true;
  370. })
  371. })
  372. self.activeDep = 0;
  373. self.userList = self.dpList1[0].USER;
  374. self.meetUser = [];
  375. sp.layer("#meet")
  376. })
  377. }
  378. self.searchName = "";
  379. self.searchPerson = function () {
  380. self.dpList1 = [];
  381. self.dpList.forEach(function (item) {
  382. if (item.DEP.indexOf(self.searchName) > -1) {
  383. self.dpList1.push(item)
  384. }
  385. })
  386. self.activeDep = 0;
  387. self.userList = self.dpList1[0].USER;
  388. }
  389. self.addmeet = function () {
  390. self.dpList.forEach(function (item) {
  391. item.USER.forEach(function (item1) {
  392. if (item1.checked == true && item1.show == true) {
  393. self.meetUser.push(item1);
  394. item1.checked = false;
  395. item1.show = false;
  396. }
  397. })
  398. })
  399. }
  400. self.delmeet = function () {
  401. self.meetUser.forEach(function (item) {
  402. if (item.checked == true) {
  403. item.checked = false;
  404. item.show = true;
  405. }
  406. })
  407. self.meetUser = self.meetUser.filter(function (item) {
  408. return item.show == false;
  409. })
  410. }
  411. self.joinMeet = function () {
  412. var data1 = {
  413. routeid: self.routeid,
  414. routeinfoid: self.routeinfoid,
  415. cman: self.userId,
  416. cname: self.data.BT + "—共享沟通",
  417. userids: self.meetUser.map(function (item) {
  418. return item.USERID
  419. }).join(",")
  420. }
  421. $http.post(apiurljs.login + "g2work/meetcoop/createMeetcoop", data1, postCfg)
  422. .success(function (res1) {
  423. sp.layerhide()
  424. if (res1.success == true) {
  425. self.getOther()
  426. } else {
  427. sp.dialog(res1.message)
  428. }
  429. })
  430. }
  431. self.deleteMeet = function (meet) {
  432. var data = {
  433. meetid: meet.MEETID
  434. }
  435. $http.post(apiurljs.login + "g2work/meetcoop/deleteDataByID", data, postCfg)
  436. .success(function (res) {
  437. if (res.success == true) {
  438. self.getOther()
  439. } else {
  440. sp.dialog(res.message)
  441. }
  442. })
  443. }
  444. self.goAttach = function (index, n) {
  445. self.SwenList.forEach(function (item) {
  446. if (item.TEMPFORM.indexOf("attachlist.html") > -1) {
  447. if (n == 1) {
  448. window.location.href = item.TEMPFORM + "&FileNum=" + index
  449. } else if (n == 2) {
  450. window.location.href = item.TEMPFORM + "&CjNum=" + index
  451. } else if (n == 3) {
  452. window.location.href = item.TEMPFORM + "&addSC=" + index
  453. } else if (n == 4) {
  454. window.location.href = item.TEMPFORM + "&meet=" + index
  455. }
  456. }
  457. })
  458. }
  459. //获取附件和插件
  460. self.getOther = function () {
  461. var data = {
  462. tablename: "FW_ZSWPXXWENATTACHFILE",
  463. colums: "*",
  464. order: "ID desc",
  465. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  466. sqlinwhere: "",
  467. sqllikewhere: ""
  468. }
  469. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  470. .success(function (obj) {
  471. var res = strToJson(s4.decryptData_CBC(obj.data));
  472. self.arrayFile = res.data;
  473. var data1 = {
  474. routeinfoid: self.routeinfoid
  475. }
  476. $http.post(apiurljs.login + "g2app/plugin/queryPluginRouteDataList", data1, postCfg)
  477. .success(function (res1) {
  478. self.cjList = res1.data;
  479. var data2 = {
  480. routeid: self.routeid,
  481. routeinfoid: self.routeinfoid
  482. }
  483. $http.post(apiurljs.login + "g2work/meetcoop/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
  484. .success(function (obj2) {
  485. var res2 = strToJson(s4.decryptData_CBC(obj2.data));
  486. self.meetList = res2.data;
  487. })
  488. })
  489. })
  490. }
  491. //获取意见(不上表)
  492. self.opiniontype = 99;
  493. self.getOpinion1 = function () {
  494. var data = {
  495. cmanid: self.userId,
  496. routeinfoid: self.routeinfoid,
  497. routeid: "",//self.routeid,
  498. tableid: "FW_ZSWPXXW",
  499. colid: "",
  500. opiniontype: self.opiniontype,
  501. orderbycol: "CDATE desc"
  502. }
  503. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  504. .success(function (obj) {
  505. var res = strToJson(s4.decryptData_CBC(obj.data));
  506. if (res.success == true) {
  507. self.YJ.nulla = res.data;
  508. self.YJ.nullaSTATUS = false;
  509. self.YJ.nulla.forEach(function (item) {
  510. item.CDATE = sp.datefmt("yyyy-MM-dd HH:mm", item.CDATE);
  511. //if (item.ROUTEID == self.routeid && item.COLID == "") {
  512. // self.YJ.nullaSTATUS = true;
  513. //}
  514. })
  515. } else {
  516. sp.dialog(res.message)
  517. }
  518. })
  519. }
  520. //判断页面字段是否只读readonly、是否隐藏show
  521. self.hide = function (type, field) {
  522. if (self.dotype == 0 && type == "readonly") {
  523. return true;
  524. } else {
  525. if (self[type][field] == true) {
  526. return true;
  527. } else {
  528. return false;
  529. }
  530. }
  531. }
  532. //右上角按钮调用方法
  533. self.btnEvent = function (item) {
  534. switch (item.CODE) {
  535. case "SAVEITEM": self.btnSave(0); break;
  536. case "PRINTITEM": self.btnPrint(); break;
  537. case "MEETITEM": self.Meet(); break;
  538. case "SENDLOG": self.RouteList(); break;
  539. default: self.forward(item); break;
  540. }
  541. }
  542. self.openDpList = function (str) {
  543. if (self.hide("readonly", str) == true) {
  544. return
  545. } else {
  546. self.filed = str;
  547. //self.AllCheckedDp = false;
  548. sp.layer("#DpList")
  549. $("#DpList .sp-page").eq(0).scrollTop(0);
  550. }
  551. }
  552. self.checkAllDp = function () {
  553. self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
  554. $.each(self.DpList[self.filed], function (index, item) {
  555. item.checked = self.AllCheckedDp[self.filed];
  556. })
  557. self.submitDpList(1)
  558. }
  559. self.checkDpItem = function (item) {
  560. item.checked = !item.checked;
  561. var n = 0;
  562. $.each(self.DpList[self.filed], function (index, item) {
  563. if (item.checked == true) {
  564. n++
  565. }
  566. })
  567. if (n == self.DpList[self.filed].length) {
  568. self.AllCheckedDp[self.filed] = true;
  569. } else {
  570. self.AllCheckedDp[self.filed] = false;
  571. }
  572. self.submitDpList(1)
  573. }
  574. self.submitDpList = function (n) {
  575. var AllCheckedLength1 = 0;
  576. self.selectDpList[self.filed] = [];
  577. $.each(self.DpList[self.filed], function (index, item) {
  578. if (item.checked == true) {
  579. AllCheckedLength1++;
  580. self.selectDpList[self.filed].push(item)
  581. }
  582. })
  583. self.data[self.filed] = self.selectDpList[self.filed].map(function (item) {
  584. return item.SECTION
  585. }).join(",")
  586. self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
  587. self.changeFiled(self.filed)
  588. if (n == 0) {
  589. sp.layerhide();
  590. }
  591. }
  592. self.openUserList = function (str) {
  593. if (self.hide("readonly", str) == true) {
  594. return
  595. } else {
  596. self.filed = str;
  597. //self.AllChecked[self.filed] = false;
  598. sp.layer("#userList")
  599. $("#userList .sp-page").eq(0).scrollTop(0);
  600. }
  601. }
  602. self.checkAllUser = function () {
  603. self.AllChecked[self.filed] = !self.AllChecked[self.filed];
  604. $.each(self.UserList[self.filed], function (index, item) {
  605. item.checked = self.AllChecked[self.filed];
  606. $.each(item.USER, function (index1, item1) {
  607. item1.checked = self.AllChecked[self.filed];
  608. })
  609. })
  610. self.submitUserList(1)
  611. }
  612. self.checkUserItem = function (item) {
  613. item.checked = !item.checked;
  614. $.each(item.USER, function (index, item1) {
  615. item1.checked = item.checked;
  616. })
  617. var n = 0;
  618. $.each(self.UserList[self.filed], function (index, item) {
  619. if (item.checked == true) {
  620. n++
  621. }
  622. })
  623. if (n == self.UserList[self.filed].length) {
  624. self.AllChecked[self.filed] = true;
  625. } else {
  626. self.AllChecked[self.filed] = false;
  627. }
  628. self.submitUserList(1)
  629. }
  630. self.checkUser = function (item) {
  631. item.checked = !item.checked;
  632. var n = [], all = 0;
  633. $.each(self.UserList[self.filed], function (x, y) {
  634. n.push(0);
  635. $.each(y.USER, function (x1, y1) {
  636. if (y1.checked == true) {
  637. n[x]++
  638. }
  639. })
  640. if (n[x] == y.USER.length && n[x] != 0) {
  641. y.checked = true;
  642. all++
  643. } else {
  644. y.checked = false;
  645. }
  646. })
  647. if (all == self.UserList[self.filed].length) {
  648. self.AllChecked[self.filed] = true;
  649. } else {
  650. self.AllChecked[self.filed] = false;
  651. }
  652. self.submitUserList(1)
  653. }
  654. self.submitUserList = function (n) {
  655. var AllCheckedLength = 0;
  656. self.selectList[self.filed] = [];
  657. $.each(self.UserList[self.filed], function (index, item) {
  658. $.each(item.USER, function (index1, item1) {
  659. if (item1.checked == true) {
  660. AllCheckedLength++;
  661. self.selectList[self.filed].push(item1)
  662. }
  663. })
  664. })
  665. self.data[self.filed] = self.selectList[self.filed].map(function (item) {
  666. return item.USHOWNAME
  667. }).join(",")
  668. if (self.data[self.filed + "ID"] != undefined) {
  669. self.data[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
  670. return item.USERID
  671. }).join(",")
  672. }
  673. self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
  674. self.changeFiled(self.filed)
  675. if (n == 0) {
  676. sp.layerhide();
  677. }
  678. }
  679. //保存提交
  680. self.btnSave = function (n) {
  681. if (spngvld.submit("#formDesignPart")) {
  682. ///前端保存遍历自定义表单数据
  683. var get_json_str = spbld.fbFrtTableJson("#formDesignPart", self.fb_queryDataCustom_data.TableName);
  684. $timeout(function () {
  685. if (sp.isval(get_json_str)) {
  686. var dataArray = [];
  687. dataArray.push(JSON.parse(get_json_str));
  688. var data = {
  689. ckey: self.fb_queryDataCustom_data.TableName,
  690. id: self.data.ID,
  691. routeid: self.routeid,
  692. routeinfoid: self.routeinfoid,
  693. routeinfotitle: "",
  694. directionid: self.directionid,
  695. formeditid: self.formeditid,
  696. data: JSON.stringify(dataArray)
  697. }
  698. //console.log(JSON.stringify(data));
  699. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  700. .success(function (obj) {
  701. var res = strToJson(s4.decryptData_CBC(obj.data));
  702. if (res.code == 0) {
  703. self.data.ID = res.data.ID;
  704. self.routeid = res.data.ROUTEID;
  705. self.routeinfoid = res.data.ROUTEINFOID;
  706. self.filedChange = false;
  707. if (n == 0) {
  708. sp.dialog("保存成功!");
  709. $timeout(function () {
  710. sp.dialoghide()
  711. }, 1500)
  712. self.getSwenList(1);
  713. } else if (n == 1) {
  714. self.forward(self.btnItem);
  715. } else if (n == 2) {
  716. self.sendAll();
  717. } else if (n == 3) {
  718. self.btnPrint();
  719. }
  720. } else {
  721. sp.dialog(res.message)
  722. }
  723. });
  724. }
  725. }, 100);
  726. }
  727. }
  728. //打印
  729. self.btnPrint = function () {
  730. if (self.filedChange == true) {
  731. self.btnSave(3)
  732. } else {
  733. // 创建隐藏的可下载链接
  734. //eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=moban1.ftl&tablename=FW_ZSWPXXW&outfilepath=/tmp/正式文(平、下行文).wps&printdate=RGRQ&routeinfoid=" + self.routeinfoid));
  735. var postData = {
  736. convertType: 29,
  737. fileUrl: apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=moban1.ftl&tablename=FW_ZSWPXXW&outfilepath=/tmp/正式文(平、下行文).wps&printdate=RGRQ&routeinfoid=" + self.routeinfoid))
  738. };
  739. var postCfg_transfer = {
  740. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  741. transformRequest: function (data) {
  742. return $.param(data);
  743. }
  744. };
  745. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  746. .success(function (res) {
  747. //console.log(res);
  748. if (res.errorcode === 0) {
  749. let rst = res.data;
  750. //console.log(rst.viewUrl);
  751. var eleLink = document.createElement('a');
  752. eleLink.download = "";
  753. eleLink.style.display = 'none';
  754. eleLink.href = rst.viewUrl
  755. // 触发点击
  756. document.body.appendChild(eleLink);
  757. eleLink.click();
  758. // 然后移除
  759. document.body.removeChild(eleLink);
  760. } else {
  761. sp.dialog(res.message);
  762. }
  763. });
  764. }
  765. }
  766. /*综合打印*/
  767. self.printFiled = 1;
  768. self.btnPrint1 = function () {
  769. if (self.filedChange == true) {
  770. self.btnSave(3)
  771. } else {
  772. sp.layer("#print")
  773. }
  774. }
  775. self.printSubmit = function () {
  776. if (self.printFiled == 1) {
  777. var templatefilename = "moban1"
  778. } else if (self.printFiled == 2) {
  779. var templatefilename = "mobanoption"
  780. } else {
  781. var templatefilename = "moban30_all"
  782. }
  783. var data = {
  784. templatefilename: templatefilename + ".ftl",
  785. outfilepath: "/tmp/正式文(平、下行文)" + sp.datefmt('yyyyMMddHHmmss', sp.getLocalDate()) + ".wps",
  786. routeinfoid: self.routeinfoid,
  787. tablename: "FW_ZSWPXXW",
  788. printtype: self.printFiled
  789. }
  790. $http.post(apiurljs.login + "g2app/dataabase/PrintWordExtend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  791. .success(function (obj) {
  792. var res = strToJson(s4.decryptData_CBC(obj.data));
  793. //window.open("../../../printPreview.html?url=" + apiurljs.login + "g2work" + res.data[0].url)
  794. window.parent.sp.addTabNav('printPreview', '打印预览', "printPreview.html?url=" + apiurljs.login + "g2work" + res.data[0].url)
  795. })
  796. //// 创建隐藏的可下载链接
  797. //var eleLink = document.createElement('a');
  798. //eleLink.download = "";
  799. //eleLink.style.display = 'none';
  800. //eleLink.href = apiurljs.login + "g2app/dataabase/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=" + templatefilename + ".ftl&tablename=FW_ZSWPXXW&outfilepath=/tmp/正式文(平、下行文).wps&printdate=LWRQ,DBSX&routeinfoid=" + self.routeinfoid + "&printtype=" + self.printFiled));
  801. //// 触发点击
  802. //document.body.appendChild(eleLink);
  803. //eleLink.click();
  804. //// 然后移除
  805. //document.body.removeChild(eleLink);
  806. sp.layerhide()
  807. }
  808. //签写意见编辑状态
  809. self.opinion = {
  810. WLDQFL: false,
  811. WLDQFLImg: false,
  812. WLDSSL: false,
  813. WLDSSLImg: false,
  814. FLSH: false,
  815. FLSHImg: false,
  816. GPJZSC: false,
  817. GPJZSCImg: false,
  818. SX: false,
  819. SXImg: false,
  820. BMFZRYJ: false,
  821. BMFZRYJImg: false,
  822. HBCSYJ: false,
  823. HBCSYJImg: false,
  824. nulla: false
  825. }
  826. self.YJ = {
  827. WLDQFL: [],
  828. WLDQFLSTATUS: false,
  829. WLDSSL: [],
  830. WLDSSLSTATUS: false,
  831. FLSH: [],
  832. FLSHSTATUS: false,
  833. GPJZSC: [],
  834. GPJZSCSTATUS: false,
  835. SX: [],
  836. SXSTATUS: false,
  837. BMFZRYJ: [],
  838. BMFZRYJSTATUS: false,
  839. HBCSYJ: [],
  840. HBCSYJSTATUS: false,
  841. nulla: [],
  842. nullaSTATUS: false
  843. }
  844. //意见(下表)
  845. self.openOptionList = function () {
  846. if (self.routeinfoid == 0 && self.routeid == 0) {
  847. sp.dialog("请先保存!")
  848. return;
  849. }
  850. if (self.opinion.nulla == true) {
  851. return;
  852. }
  853. self.nulla = "";
  854. $(".optionList").css("height", 149)
  855. self.opinion.nulla = true;
  856. }
  857. self.closeOptionList = function () {
  858. $(".optionList").css("height", 389)
  859. self.opinion.nulla = false;
  860. }
  861. self.submitOptionList = function () {
  862. var data = {
  863. cmanid: self.userId,
  864. routeinfoid: self.routeinfoid,
  865. routeid: self.routeid,
  866. tableid: "FW_ZSWPXXW",
  867. colid: "",
  868. opiniontype: 99,
  869. cresult: "",
  870. opinion: self.nulla,
  871. opinionimage: ""
  872. }
  873. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  874. .success(function (obj) {
  875. var res = strToJson(s4.decryptData_CBC(obj.data));
  876. if (res.success == true) {
  877. self.getOpinion1();
  878. self.opinion.nulla = false;
  879. $(".optionList").css("height", 389)
  880. } else {
  881. sp.dialog(res.message)
  882. }
  883. })
  884. }
  885. self.changeOptionList = function (item) {
  886. self.nulla = item.OPINION;
  887. self.opinion.nulla = true;
  888. }
  889. //意见附件(下表)
  890. self.uploading1 = false;
  891. self.upload1 = function () {
  892. $('#fileupload1').fileupload({
  893. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  894. dataType: 'json',
  895. beforeSend: function (xhr, data) {
  896. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  897. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  898. + ",routeid=" + self.routeid + ",tableid=FW_ZSWPXXW"));
  899. },
  900. // 上传完成后的执行逻辑
  901. done: function (e, data) {
  902. self.uploading1 = false;
  903. self.getOpinion1()
  904. }
  905. })
  906. }
  907. //下载意见表附件
  908. self.downLoadOption = function (item) {
  909. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  910. }
  911. //删除意见表附件
  912. self.deleteOptionFile = function (file) {
  913. var data = {
  914. tablename: "SYS_ROUTE_ATTACHLIST",
  915. sqlwhere: "ROUTEID='" + file.ROUTEID + "' and FILEID='" + file.FILEID + "' and FILEDATE='" + file.FILEDATE + "'"
  916. };
  917. $http.post(apiurljs.login + "g2app/dataabase/deletBywhere", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  918. .success(function (obj) {
  919. var res = strToJson(s4.decryptData_CBC(obj.data));
  920. sp.dialoghide();
  921. if (res.success) {
  922. self.getOpinion1();
  923. } else {
  924. sp.dialog("删除失败,请联系管理员!");
  925. }
  926. });
  927. }
  928. //发生修改
  929. self.changeFiled = function (str) {
  930. self.filedChange = true;
  931. if (str = "XXGKSH") {
  932. self.XXGKSH.forEach(function (item) {
  933. if (item.CODE == self.data.XXGKSH) {
  934. self.data.XXGKSH1 = item.CNAME
  935. }
  936. })
  937. }
  938. }
  939. //转发
  940. self.forward = function (obj) {
  941. self.activeGroup = "部门";
  942. self.forwardUser = [];
  943. self.searchName = "";
  944. self.saveZB = false;
  945. self.btnItem = obj;
  946. if (self.filedChange == true) {
  947. self.btnSave(1)
  948. } else {
  949. var data = {
  950. codefuncbutton: self.btnItem.CODE,
  951. directionid: self.directionid,
  952. directionidtarget: self.btnItem.DIRECTIONIDTARGET,
  953. userid: self.userId,
  954. routeinfoid: self.routeinfoid,
  955. routeid: self.routeid
  956. }
  957. $http.post(apiurljs.login + "g2app/abase/queryDataSendByTarget", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  958. .success(function (obj) {
  959. var res = strToJson(s4.decryptData_CBC(obj.data));
  960. self.showContent = true;
  961. self.directions = res.data;//所有可选流向
  962. self.direction = self.directions[0];//所选流向
  963. if (self.direction.ENDNODETYPE == 1 || self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL") {
  964. self.showContent = false;
  965. self.forward1(0)
  966. } else if (self.direction.ENDNODETYPE == 3) {
  967. self.showContent = true;
  968. self.forwardUser = [];
  969. self.directionList = self.direction["DIRECTION.CHILD"];
  970. $.each(self.directionList, function (index, item) {
  971. item.forwardUser = index;
  972. self.forwardUser.push([])
  973. //item.show = false;
  974. item.Dep = [];//部门
  975. item.Dep.push(item.SENDUSERS.SECTS[0]);
  976. item.organCode = item.Dep[0].CODE;//所选部门编号
  977. $.each(item.Dep, function (index1, item1) {
  978. item1.open = true;
  979. $.each(item1.C_H_I_L_D, function (index2, item2) {
  980. item2.open = true;
  981. })
  982. })
  983. item.people = item.SENDUSERS.USERS;//人员
  984. item.people.forEach(function (item1) {
  985. item1.show = true;
  986. })
  987. item.mainSend = null;//主送
  988. item.copySend = [];//抄送
  989. })
  990. self.activeDirection = self.directionList[0]
  991. console.log(self.activeDirection)
  992. self.forward2(0)
  993. } else {
  994. self.showContent = true;
  995. self.forwardUser = [];
  996. self.Dep = [];//部门
  997. self.Dep.push(self.direction.SENDUSERS.SECTS[0]);
  998. self.organCode = self.Dep[0].CODE;//所选部门编号
  999. $.each(self.Dep, function (index, item) {
  1000. item.open = true;
  1001. $.each(item.C_H_I_L_D, function (index1, item1) {
  1002. item1.open = true;
  1003. })
  1004. })
  1005. self.people = self.direction.SENDUSERS.USERS;//人员
  1006. self.people.forEach(function (item) {
  1007. item.show = true;
  1008. })
  1009. self.mainSend = null;//主送
  1010. self.copySend = [];//抄送
  1011. self.forward1(0)
  1012. }
  1013. //setTimeout(function () {
  1014. // sp.layer("#forward");
  1015. //}, 100)
  1016. })
  1017. }
  1018. }
  1019. //转发(新)
  1020. self.forward1 = function (n) {
  1021. if (n == 0) {
  1022. sp.layer("#forward");
  1023. } else {
  1024. if (self.activeGroup == "自定义") {
  1025. self.getZbList()
  1026. }
  1027. }
  1028. self.activeUser = null;
  1029. self.moveFlag1 = false;
  1030. self.moveFlag2 = false;
  1031. }
  1032. self.searchPerson = function () {
  1033. self.people.forEach(function (item) {
  1034. if (item.USERNAME.indexOf(self.searchName) > -1) {
  1035. item.show = true;
  1036. } else {
  1037. item.show = false;
  1038. }
  1039. })
  1040. }
  1041. self.adduser = function () {
  1042. self.people.forEach(function (item) {
  1043. if (item.checked == true && item.show == true) {
  1044. self.forwardUser.push(item);
  1045. item.checked = false;
  1046. item.show = false;
  1047. }
  1048. })
  1049. if (self.forwardUser.length == 1) {
  1050. self.moveFlag1 = false;
  1051. self.moveFlag2 = false;
  1052. return;
  1053. }
  1054. self.getmoveFlag()
  1055. }
  1056. self.deluser = function () {
  1057. self.forwardUser.forEach(function (item) {
  1058. if (item.checked == true) {
  1059. item.checked = false;
  1060. item.show = true;
  1061. }
  1062. })
  1063. self.forwardUser = self.forwardUser.filter(function (item) {
  1064. return item.show == false;
  1065. })
  1066. if (self.forwardUser.length == 1) {
  1067. self.moveFlag1 = false;
  1068. self.moveFlag2 = false;
  1069. return;
  1070. }
  1071. self.getmoveFlag()
  1072. }
  1073. self.adduserAll = function () {
  1074. self.people.forEach(function (item) {
  1075. if (item.show == true) {
  1076. self.forwardUser.push(item);
  1077. item.checked = false;
  1078. item.show = false;
  1079. }
  1080. })
  1081. if (self.forwardUser.length == 1) {
  1082. self.moveFlag1 = false;
  1083. self.moveFlag2 = false;
  1084. return;
  1085. }
  1086. self.getmoveFlag()
  1087. }
  1088. self.deluserAll = function () {
  1089. self.forwardUser.forEach(function (item) {
  1090. item.checked = false;
  1091. item.show = true;
  1092. })
  1093. self.forwardUser = [];
  1094. self.moveFlag1 = false;
  1095. self.moveFlag2 = false;
  1096. }
  1097. self.checkForwardUser = function (n) {
  1098. if (self.activeUser != n) {
  1099. self.activeUser = n;
  1100. } else {
  1101. self.activeUser = null;
  1102. }
  1103. if (self.forwardUser.length == 1) {
  1104. self.moveFlag1 = false;
  1105. self.moveFlag2 = false;
  1106. return;
  1107. }
  1108. if (self.activeUser == null) {
  1109. self.moveFlag1 = false;
  1110. self.moveFlag2 = false;
  1111. } else {
  1112. self.getmoveFlag()
  1113. }
  1114. }
  1115. self.getmoveFlag = function () {
  1116. if (self.activeUser == 0) {
  1117. self.moveFlag1 = false;
  1118. self.moveFlag2 = true;
  1119. } else if (self.activeUser == self.forwardUser.length - 1) {
  1120. self.moveFlag1 = true;
  1121. self.moveFlag2 = false;
  1122. } else {
  1123. self.moveFlag1 = true;
  1124. self.moveFlag2 = true;
  1125. }
  1126. }
  1127. self.moveUp = function () {
  1128. var a = self.forwardUser[self.activeUser], b = self.forwardUser[self.activeUser - 1];
  1129. self.forwardUser[self.activeUser] = b;
  1130. self.forwardUser[self.activeUser - 1] = a;
  1131. self.activeUser = self.activeUser - 1;
  1132. self.getmoveFlag()
  1133. }
  1134. self.moveDown = function () {
  1135. var a = self.forwardUser[self.activeUser], b = self.forwardUser[self.activeUser + 1];
  1136. self.forwardUser[self.activeUser] = b;
  1137. self.forwardUser[self.activeUser + 1] = a;
  1138. self.activeUser = self.activeUser + 1;
  1139. self.getmoveFlag()
  1140. }
  1141. self.getZbList = function () {
  1142. var data = {
  1143. userid: self.userId
  1144. }
  1145. $http.post(apiurljs.login + "g2app/usercustom/queryCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1146. .success(function (obj) {
  1147. var res = strToJson(s4.decryptData_CBC(obj.data));
  1148. self.zbList = res.data;
  1149. self.zbCode = self.zbList[0].CODE;
  1150. self.people.forEach(function (item) {
  1151. item.show = false;
  1152. self.zbList.forEach(function (item1) {
  1153. item1.USERS.forEach(function (item2) {
  1154. if (item.USERID == item2.USERID) {
  1155. item.show = true;
  1156. item.set = self.zbCode;
  1157. }
  1158. })
  1159. self.forwardUser.forEach(function (obj) {
  1160. item1.USERS.forEach(function (item2) {
  1161. if (obj.USERID == item2.USERID) {
  1162. obj.show = false;
  1163. obj.set = self.zbCode;
  1164. }
  1165. })
  1166. })
  1167. })
  1168. })
  1169. })
  1170. }
  1171. self.checkZB = function (item1) {
  1172. self.zbCode = item1.CODE;
  1173. self.people.forEach(function (item) {
  1174. item.show = false;
  1175. item.checked = false;
  1176. item1.USERS.forEach(function (item2) {
  1177. if (item.USERID == item2.USERID) {
  1178. item.show = true;
  1179. item.set = self.zbCode;
  1180. }
  1181. })
  1182. })
  1183. self.forwardUser.forEach(function (obj) {
  1184. item1.USERS.forEach(function (item2) {
  1185. if (obj.USERID == item2.USERID) {
  1186. obj.show = false;
  1187. obj.set = self.zbCode;
  1188. }
  1189. })
  1190. })
  1191. }
  1192. self.delZB = function (item) {
  1193. var data = {
  1194. code: item.CODE,
  1195. userid: self.userId
  1196. }
  1197. $http.post(apiurljs.login + "g2app/usercustom/delCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1198. .success(function (obj) {
  1199. var res = strToJson(s4.decryptData_CBC(obj.data));
  1200. if (res.success == true) {
  1201. self.getZbList()
  1202. }
  1203. })
  1204. }
  1205. self.btnSaveZB = function () {
  1206. if (self.forwardUser.length == 0) {
  1207. return
  1208. }
  1209. var data = {
  1210. userid: self.userId,
  1211. cname: self.cnameZB,
  1212. userids: JSON.stringify(self.forwardUser.map(function (item) {
  1213. return { userid: item.USERID }
  1214. }))
  1215. }
  1216. $http.post(apiurljs.login + "g2app/usercustom/saveCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1217. .success(function (obj) {
  1218. var res = strToJson(s4.decryptData_CBC(obj.data));
  1219. if (res.success == true) {
  1220. self.searchName = "";
  1221. self.saveZB = false;
  1222. self.getZbList()
  1223. }
  1224. })
  1225. }
  1226. //a代表所选项上一级,b代表当前所选项
  1227. self.setMainSend = function (a, b) {
  1228. a.mainSend = b;
  1229. }
  1230. self.setCopySend = function (a, b) {
  1231. a.copySend.push(b);
  1232. }
  1233. self.delCopySend = function (a, b) {
  1234. a.copySend.splice(a.copySend.indexOf(b), 1)
  1235. }
  1236. self.sendFlag = false;
  1237. self.send = function () {
  1238. self.sendFlag = true;
  1239. if (self.forwardUser.length == 0) {
  1240. sp.layerhide()
  1241. sp.dialog("请选择人员!");
  1242. $timeout(function () {
  1243. sp.dialoghide()
  1244. sp.layer("#forward");
  1245. }, 2000)
  1246. return
  1247. }
  1248. if (self.direction.ENDNODETYPE == 1) {
  1249. var sendUser = {
  1250. DIRECTIONID: self.direction.DIRECTIONID,
  1251. MAINUSERID: "STOP",
  1252. COPYUSERID: ""
  1253. }
  1254. } else if (self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL") {
  1255. var sendUser = {
  1256. DIRECTIONID: self.direction.DIRECTIONID,
  1257. MAINUSERID: "",
  1258. COPYUSERID: ""
  1259. }
  1260. } else {
  1261. //if (self.mainSend == null && (self.direction.SENDRULE == 0 || self.direction.SENDRULE == 1)) {
  1262. // self.mainNull = true;
  1263. // self.sendFlag = false;
  1264. // return;
  1265. //}
  1266. //var sendUser = {
  1267. // DIRECTIONID: self.direction.DIRECTIONID,
  1268. // MAINUSERID: self.mainSend ? self.mainSend.USERID : "",
  1269. // COPYUSERID: self.copySend.map(function (item) {
  1270. // return item.USERID
  1271. // }).join("|")
  1272. //}
  1273. var sendUser = {
  1274. DIRECTIONID: self.direction.DIRECTIONID,
  1275. MAINUSERID: self.forwardUser.map(function (item) {
  1276. return item.USERID
  1277. }).join("|"),
  1278. COPYUSERID: ""
  1279. }
  1280. }
  1281. var data = {
  1282. codefuncbutton: self.direction.CODEFUNCBUTTON,
  1283. directionid: self.directionid,
  1284. userid: self.userId,
  1285. routeinfoid: self.routeinfoid,
  1286. routeid: self.routeid,
  1287. data: "[" + JSON.stringify(sendUser) + "]"
  1288. }
  1289. $http.post(apiurljs.login + "g2app/abase/saveDataSend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1290. .success(function (obj) {
  1291. var res = strToJson(s4.decryptData_CBC(obj.data));
  1292. self.sendFlag = false;
  1293. sp.closeCenter('.sp-layer');
  1294. if (res.success == true) {
  1295. sp.dialog("发送成功!");
  1296. $timeout(function () {
  1297. window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  1298. }, 1500)
  1299. } else {
  1300. sp.dialog(res.message)
  1301. }
  1302. })
  1303. }
  1304. self.openPeopleList = function (item1) {
  1305. $.each(self.directionList, function (index, item) {
  1306. if (item.CNAME == item1.CNAME) {
  1307. item.show = !item1.show;
  1308. } else {
  1309. item.show = false;
  1310. }
  1311. })
  1312. }
  1313. self.sendAll = function () {
  1314. if (self.filedChange == true) {
  1315. self.btnSave(2)
  1316. } else {
  1317. var sendUser = [];
  1318. self.directionList.forEach(function (item) {
  1319. if (item.mainSend != null || item.copySend.length > 0) {
  1320. sendUser.push({
  1321. DIRECTIONID: item.DIRECTIONID,
  1322. MAINUSERID: self.mainSend.map(function (item) {
  1323. return item.USERID
  1324. }).join("|"),
  1325. COPYUSERID: item.copySend.map(function (item1) {
  1326. return item1.USERID
  1327. }).join("|")
  1328. })
  1329. }
  1330. })
  1331. var data = {
  1332. codefuncbutton: self.direction.CODEFUNCBUTTON,
  1333. directionid: self.directionid,
  1334. userid: self.userId,
  1335. routeinfoid: self.routeinfoid,
  1336. routeid: self.routeid,
  1337. data: JSON.stringify(sendUser)
  1338. }
  1339. $http.post(apiurljs.login + "g2app/abase/saveDataSend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1340. .success(function (obj) {
  1341. var res = strToJson(s4.decryptData_CBC(obj.data));
  1342. sp.closeCenter('.sp-layer');
  1343. if (res.success == true) {
  1344. sp.dialog("发送成功!");
  1345. $timeout(function () {
  1346. window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  1347. }, 1500)
  1348. } else {
  1349. sp.dialog(res.message)
  1350. }
  1351. })
  1352. }
  1353. }
  1354. //查看流转记录
  1355. self.RouteList = function () {
  1356. var data = {
  1357. directionid: self.directionid,
  1358. userid: self.userId,
  1359. routeid: self.routeid,
  1360. routeinfoid: self.routeinfoid,
  1361. }
  1362. $http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1363. .success(function (obj) {
  1364. var res = strToJson(s4.decryptData_CBC(obj.data));
  1365. self.routeList = res.data;
  1366. $.each(self.routeList, function (index, item) {
  1367. item.mainUser = [];
  1368. item.copyUsers = [];
  1369. $.each(item.USERS, function (index1, item1) {
  1370. if (item1.KIND == 0) {
  1371. item.mainUser.push(item1.USERNAME);
  1372. } else {
  1373. item.copyUsers.push(item1.USERNAME);
  1374. }
  1375. })
  1376. item.mainUser = item.mainUser.join(",");
  1377. item.copyUsers = item.copyUsers.join(",");
  1378. })
  1379. $timeout(function (item) {
  1380. sp.layer("#RouteList");
  1381. }, 100);
  1382. })
  1383. }
  1384. //头部下滚冻结
  1385. $(function () {
  1386. $(".sp-page-center").eq(0).css("max-height", $(window).height() - 160).css("height", $(window).height() - 160)
  1387. $(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
  1388. //$("body").bind("scroll", function () {
  1389. // var scrollTop = $("body").scrollTop();
  1390. // if (scrollTop == 0) {
  1391. // $(".FixTop").removeClass("FixTop");
  1392. // }
  1393. // if (scrollTop > 35) {
  1394. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  1395. // }
  1396. //});
  1397. //页面高度撑满
  1398. $timeout(function () {
  1399. if ($(".ibox-content").height() < $(window).height() - 31) {
  1400. $(".ibox-content").css("height", $(window).height() - 31)
  1401. }
  1402. }, 1)
  1403. })
  1404. }])
  1405. app.filter('trustHtml', function ($sce) {
  1406. return function (input) {
  1407. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  1408. };
  1409. });