formlist.js 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. var app = angular.module('app', ["angularUtils.directives.dirPagination"]);
  2. app.controller("formlistCtrl", ["$scope", "$http", "$compile", "$timeout", function ($scope, $http, $compile, $timeout) {
  3. var self = this;
  4. var s4 = new SM4Util();
  5. // sp.fitHeight("#formTypePart", 150);
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-username");
  8. self.userCName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.flowid = sp.getUrlName("FLOWKND");
  11. $("#formTypePart").height($("body").height() - 140);
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. };
  18. self.CrossPage = window.parent.CrossPage;
  19. self.loading = false;
  20. //表单类型
  21. self.formTypeAray = [
  22. {"cval": "NORMAL", "cname": "一般表"},
  23. {"cval": "MDETAIL", "cname": "主细表"},
  24. {"cval": "FILETBL", "cname": "附件表"},
  25. {"cval": "CODETBL", "cname": "代码表"},
  26. {"cval": "TREESTAL", "cname": "树状表"},
  27. {"cval": "ENTITYTB", "cname": "实体表"}
  28. ];
  29. ////初始化左侧效果--start--*****************************************
  30. self.active = {
  31. STATUS: 0,
  32. TYPE: "",
  33. CNAME:""
  34. };
  35. //self.active.STATUS = sp.getUrlName("leftActive") || 0;
  36. //self.active.TYPE = sp.getUrlName("leftActiveType") || "";
  37. ///激活状态的设置,考虑上来就加载和从详情页面返回的两种情况
  38. self.setMsgActive = function () {
  39. $(".sp-msg-left-bottom .sp-msg-left-lh").removeClass("sp-msg-left-active");
  40. $(".sp-msg-left-bottom .sp-msg-left-lh:eq(" + self.active.STATUS + ")").addClass("sp-msg-left-active");
  41. };
  42. setTimeout(function () {
  43. self.setMsgActive();
  44. }, 800);
  45. self.getMsgData = function (str, $item, CNAME) {
  46. var time1 = sp.getLocalDate1();
  47. self.ctime = sp.getLocalDate1();
  48. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/form/queryData")
  49. if (str == 0) {
  50. self.active = {
  51. STATUS: str,
  52. TYPE: "",
  53. CNAME: CNAME
  54. };
  55. } else {
  56. self.active = {
  57. STATUS: str,
  58. TYPE: $item.PKID,
  59. CNAME: CNAME
  60. };
  61. }
  62. $(".sp-msg-left-bottom .sp-msg-left-lh").removeClass("sp-msg-left-active");
  63. $(".sp-msg-left-bottom .sp-msg-left-lh:eq(" + str + ")").addClass("sp-msg-left-active");
  64. self.showType = "List";
  65. self.getFormData();///加载表单
  66. };
  67. ////初始化左侧效果--end--*****************************************
  68. ///加载机构
  69. self.unitList = []; ///数组
  70. self.unit = ""; ///机构名称
  71. self.getUnit = function () {
  72. self.loading = true;
  73. $http.post(apiurljs.login + "g2work/sect/querySectAdmin", {data: s4.encryptData_CBC("")}, postCfg)
  74. .success(function (obj) {
  75. var res = strToJson(s4.decryptData_CBC(obj.data));
  76. if (res.success) {
  77. if (sp.isval(res.data)) {
  78. self.unitList = res.data;
  79. self.unit = res.data[0].CODE;
  80. self.getFormType();///加载表单类别
  81. } else {
  82. self.unitList = [];
  83. self.loading = false;
  84. }
  85. } else {
  86. sp.dialog(res.message);
  87. self.unitList = [];
  88. self.loading = false;
  89. }
  90. })
  91. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  92. if (textStatus != 200) {
  93. self.loading = false;
  94. }
  95. })
  96. };
  97. self.getUnit();
  98. ///加载表单类别数组
  99. self.formType = [];
  100. self.getFormType = function () {
  101. var postData = {
  102. pkid: self.unit,
  103. includechildren: true
  104. }
  105. $http.post(apiurljs.login + "g2work/formkinds/queryData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  106. .success(function (obj) {
  107. var res = strToJson(s4.decryptData_CBC(obj.data));
  108. if (res.success) {
  109. if (sp.isval(res.data)) {
  110. self.formType = res.data;
  111. if (self.flowid) {
  112. $.each(self.formType, function (index, item) {
  113. if (item.PKID == self.flowid) {
  114. self.active = {
  115. STATUS: index + 1,
  116. TYPE: item.PKID,
  117. CNAME: item.CNAME
  118. }
  119. }
  120. })
  121. } else {
  122. self.active = {
  123. STATUS: parseInt(sp.getUrlName("leftActive")) || 1,
  124. TYPE: sp.getUrlName("leftActiveType") || self.formType[0].PKID,
  125. CNAME: sp.getUrlName("leftActiveName") || self.formType[0].CNAME
  126. }
  127. }
  128. ;
  129. } else {
  130. self.formType = [];
  131. }
  132. self.getFormData();///加载表单数组
  133. } else {
  134. sp.dialog(res.message);
  135. self.formType = [];
  136. self.loading = false;
  137. }
  138. })
  139. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  140. if (textStatus != 200) {
  141. self.loading = false;
  142. }
  143. })
  144. };
  145. ///加载表单数据-start--*******************************************
  146. self.formList = [];
  147. self.formList_search = [];
  148. self.noDataTip = 1; //声明没有数据时变量
  149. self.getFormData = function () {
  150. self.loading = true;
  151. var postData = {
  152. unitid: self.unit,
  153. formkinds: self.active.TYPE
  154. }
  155. $http.post(apiurljs.login + "g2work/form/queryData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  156. .success(function (obj) {
  157. var res = strToJson(s4.decryptData_CBC(obj.data));
  158. self.loading = false;
  159. if (res.success) {
  160. if (sp.isval(res.data)) {
  161. self.formList = res.data;
  162. //console.log(res.data);
  163. angular.forEach(self.formList, function (item) {
  164. if (item.FORMEDIT.length > 0) {
  165. item.FORMEDITSTRING = "总计" + item.FORMEDIT.length + "项";
  166. } else {
  167. item.FORMEDITSTRING = "";
  168. }
  169. angular.forEach(self.formTypeAray, function (item2) {
  170. if (item.CTYPE == item2.cval) {
  171. item.CTYPE_set = item2.cname;
  172. }
  173. //代码表和树状表无法添加视图
  174. if (item.CTYPE == "CODETBL" || item.CTYPE == "TREESTAL") {
  175. item.VIEW_set = true;
  176. } else {
  177. item.VIEW_set = false;
  178. }
  179. });
  180. })
  181. self.noDataTip = 1;
  182. ////从表单设计器页面返回时,打开之前点击的视图层--20230305--zyg
  183. $timeout(function () {
  184. var get_formlistViewIndex = localStorage.getItem("tjJxtGoldenlinkWork-formlistViewIndex");
  185. if (sp.isval(get_formlistViewIndex)) {
  186. self.checkViewDetail(get_formlistViewIndex);//
  187. localStorage.setItem("tjJxtGoldenlinkWork-formlistViewIndex", "");/// 清空--存储表单管理视图点击序号
  188. }
  189. }, 100);
  190. self.formList_search = self.formList;
  191. } else {
  192. self.formList = [];
  193. self.formList_search = [];
  194. self.noDataTip = 0;
  195. }
  196. } else {
  197. sp.dialog(res.message);
  198. }
  199. if (self.CrossPage.type == 0) {
  200. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  201. }
  202. })
  203. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  204. if (textStatus != 200) {
  205. self.loading = false;
  206. }
  207. })
  208. };
  209. ///加载表单数据-end--*******************************************
  210. self.escapeRegExpWildcards=function (searchStr) {
  211. const regExp = /([\(\[\{\\\^\$\}\]\)\?\*\+\.])/img;
  212. if (searchStr && regExp.test(searchStr)) {
  213. return searchStr.replace(regExp, '\\$1');
  214. }
  215. return searchStr;
  216. }
  217. self.searchByKeywords=function (keywords, searchArr) {
  218. const keywordsExp = new RegExp(".*?" + self.escapeRegExpWildcards(keywords) + ".*?", "img");
  219. return searchArr.filter(v => (keywordsExp.test(v.CNAME) || keywordsExp.test(v.CKEY)));
  220. }
  221. self.search_keyword="";
  222. self.btnSearch = function () {
  223. //console.log(JSON.stringify(self.searchByKeywords("党委", self.flowData)));
  224. self.formList_search=self.searchByKeywords(self.search_keyword, self.formList);
  225. };
  226. ////////筛选---start---*******************************************************************
  227. self.search = {
  228. mark: "",
  229. title: "",
  230. type: ""
  231. }
  232. ///打开筛选
  233. self.openSearchLayer = function () {
  234. var time1 = sp.getLocalDate1();
  235. self.ctime = sp.getLocalDate1();
  236. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/form/queryData")
  237. sp.layer('#layer_search')
  238. }
  239. self.btnSearchTrue = function () {
  240. ///确定查询
  241. sp.layerhide();
  242. self.getFormData();
  243. };
  244. self.btnSearchCancel = function () {
  245. //取消查询
  246. self.search = {
  247. mark: "",
  248. title: "",
  249. type: ""
  250. }
  251. sp.layerhide();
  252. };
  253. ////////筛选---end---*******************************************************************
  254. self.showType = "List"; //list or detail
  255. self.formDetailList = [];
  256. self.nowForm = "";
  257. self.nowFormItem = "";
  258. self.checkViewDetail_index = "";
  259. self.checkViewDetail = function (index) {
  260. self.formDetailList = [];
  261. self.nowForm = "";
  262. self.nowFormItem = "";
  263. self.showType = "Detail";
  264. //let newDetailArray = angular.copy(self.formList[index].FORMEDIT);
  265. let newDetailArray = angular.copy(self.formList_search[index].FORMEDIT);
  266. self.formDetailList = newDetailArray;
  267. //self.nowForm = self.formList[index].CNAME;
  268. self.nowForm = self.formList_search[index].CNAME;
  269. //self.nowFormItem = self.formList[index];
  270. self.nowFormItem = self.formList_search[index];
  271. //console.log(self.nowForm);
  272. self.checkViewDetail_index = index;
  273. }
  274. self.goToEliminate = function () {
  275. window.location.href = "eliminate.html?leftActive=" + self.active.STATUS + "&leftActiveType=" + self.active.TYPE + "&leftActiveName=" + self.active.CNAME;
  276. }
  277. self.goToList = function () {
  278. self.showType = "List";
  279. self.getFormData(); //加载表单数组
  280. }
  281. /////表单类别--start---*******************************************************************
  282. ///新增流程类别--声明变量
  283. self.addflow = {
  284. pkid: 0,
  285. cname: "",
  286. ctype: "NORMAL"
  287. };
  288. ///打开新增类别
  289. self.openLayerFormType = function () {
  290. self.addflow = {
  291. pkid: 0,
  292. cname: "",
  293. ctype: "NORMAL"
  294. };
  295. sp.layer("#layer_addFormType");
  296. var time1 = sp.getLocalDate1();
  297. self.ctime = sp.getLocalDate1();
  298. self.journalRecord(time1, sp.getLocalDate1(), "新增类别", "修改日志", window.location.pathname)
  299. };
  300. ///更新流程类别
  301. self.editFormType = function ($item) {
  302. event.preventDefault();
  303. event.stopPropagation();
  304. self.addflow = {
  305. pkid: $item.PKID,
  306. cname: $item.CNAME,
  307. ctype: $item.CTYPE
  308. }
  309. sp.layer("#layer_addFormType");
  310. var time1 = sp.getLocalDate1();
  311. self.ctime = sp.getLocalDate1();
  312. self.journalRecord(time1, sp.getLocalDate1(), "编辑", "修改日志", window.location.pathname)
  313. };
  314. self.btnSubmitFormType = function () {
  315. ///点击确认提交新增流程类别
  316. if (spngvld.submit("#layer_addFormType")) {
  317. if (self.addflow.pkid == 0) {
  318. var postData = {
  319. "cname": self.addflow.cname,
  320. "ctype": self.addflow.ctype,
  321. "parentid": self.unit
  322. };
  323. $http.post(apiurljs.login + "g2work/formkinds/insertData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  324. var res = strToJson(s4.decryptData_CBC(obj.data));
  325. if (res.success) {
  326. sp.layerhide();
  327. sp.dialog("流程新增成功!");
  328. $timeout(function () {
  329. sp.dialoghide();
  330. self.getFormType();
  331. }, 600)
  332. } else {
  333. sp.layerhide();
  334. sp.dialog(res.message);
  335. }
  336. });
  337. } else {
  338. var postData = {
  339. "pkid": self.addflow.pkid,
  340. "cname": self.addflow.cname,
  341. "ctype": self.addflow.ctype
  342. };
  343. $http.post(apiurljs.login + "g2work/formkinds/updateDataByPkid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  344. .success(function (obj) {
  345. var res = strToJson(s4.decryptData_CBC(obj.data));
  346. if (res.success) {
  347. sp.layerhide();
  348. sp.dialog("更新成功!");
  349. $timeout(function () {
  350. sp.dialoghide();
  351. self.getFormType();
  352. }, 600)
  353. } else {
  354. sp.layerhide();
  355. sp.dialog(res.message);
  356. }
  357. });
  358. }
  359. }
  360. };
  361. self.btnCancelFormType = function () {
  362. ///取消操作类别
  363. self.addflow = {
  364. pkid: 0,
  365. cname: "",
  366. ctype: "NORMAL"
  367. };
  368. spngvld.clear("#layer_addFormType")
  369. sp.layerhide();
  370. };
  371. self.delFormType = function ($item) {
  372. event.preventDefault();
  373. event.stopPropagation();
  374. var time1 = sp.getLocalDate1();
  375. self.ctime = sp.getLocalDate1();
  376. self.journalRecord(time1, sp.getLocalDate1(), "删除", "修改日志", window.location.pathname)
  377. ///删除类别
  378. var getDelID = $item.PKID;
  379. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  380. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  381. var dialogFoot = "<div class=\"sp-dialog-foot\"><input data-id=" + getDelID + " id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  382. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  383. sp.openCenter(".sp-dialog");
  384. ///取消按钮
  385. $('.sp-closeDialog').click(function (event) {
  386. sp.closeCenter(".sp-dialog");
  387. event.preventDefault();
  388. event.stopPropagation();
  389. });
  390. //post消息的id
  391. $("#delDataTrue").click(function () {
  392. var getid = $(this).attr("data-id");
  393. sp.dialoghide();
  394. var data = {
  395. pkid: getDelID///角色编码
  396. };
  397. $http.post(apiurljs.login + "g2work/formkinds/deleteByPkid", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  398. .success(function (obj) {
  399. var res = strToJson(s4.decryptData_CBC(obj.data));
  400. if (res.success) {
  401. self.getFormType();
  402. self.getMsgData(0, 0, "全部表单");
  403. sp.dialoghide();
  404. } else {
  405. sp.dialog(res.message);
  406. }
  407. });
  408. });
  409. };
  410. self.openSortFormType = function () {
  411. ///类别排序
  412. sp.layer("#layer_sortFormType");
  413. var time1 = sp.getLocalDate1();
  414. self.ctime = sp.getLocalDate1();
  415. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/form/queryData")
  416. };
  417. self.itemSortup = function ($item, $index) {
  418. var set_index = parseInt($index - 1);
  419. var get_pkid1 = self.formType[set_index].PKID;
  420. self.postSortData(get_pkid1, $item.PKID);
  421. }
  422. self.itemSortdown = function ($item, $index) {
  423. var set_index = parseInt($index + 1);
  424. var get_pkid1 = self.formType[set_index].PKID;
  425. self.postSortData(get_pkid1, $item.PKID);
  426. }
  427. self.postSortData = function (pkid1, pkid2) {
  428. var postData = {
  429. "pkid1": pkid1,
  430. "pkid2": pkid2
  431. }
  432. $http.post(apiurljs.login + "g2work/formkinds/swapSortidByPkid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  433. var res = strToJson(s4.decryptData_CBC(obj.data));
  434. if (res.success) {
  435. self.getFormType();
  436. } else {
  437. sp.layerhide();
  438. sp.dialog(res.message);
  439. }
  440. });
  441. };
  442. /////表单类别--end------*******************************************************************
  443. //**新建表单******* */
  444. self.form = {
  445. formkinds: "",
  446. ckey: "",
  447. cname: "",
  448. ctype: self.formTypeAray[0].cval,
  449. shortname: "",
  450. explain: ""
  451. };
  452. self.openAddLayer = function () {
  453. self.form = {
  454. formkinds: self.active.TYPE == "" ? self.formType[0].PKID : self.active.TYPE,
  455. ckey: "",
  456. cname: "",
  457. ctype: self.formTypeAray[0].cval,
  458. shortname: "",
  459. explain: ""
  460. };
  461. sp.layer("#layer_addForm");
  462. var time1 = sp.getLocalDate1();
  463. self.ctime = sp.getLocalDate1();
  464. self.journalRecord(time1, sp.getLocalDate1(), "新建", "修改日志", window.location.pathname)
  465. };
  466. self.editForm = function ($item) {
  467. };
  468. self.previewForm = function ($item) {
  469. var time1 = sp.getLocalDate1();
  470. self.journalRecord(time1, sp.getLocalDate1(), "查看表单", "接入日志", window.location.pathname)
  471. self.recordCtime()
  472. $timeout(function () {
  473. window.location.href = "formlist-add.html?formid=" + $item.FORMID + "&ctype=" + $item.CTYPE + "&leftActive=" + self.active.STATUS + "&leftActiveType=" + self.active.TYPE + "&leftActiveName=" + self.active.CNAME;;
  474. }, 500)
  475. };
  476. self.addFormTrue = function () {
  477. ///新建表单-提交
  478. if (spngvld.submit("#layer_addForm")) {
  479. if (self.form.formkinds == "") {
  480. sp.layerhide();
  481. sp.dialog("流程类别不能为空!");
  482. return false;
  483. } else {
  484. var postData = {
  485. "formkinds": self.form.formkinds,
  486. "ckey": self.form.ckey,
  487. "cname": self.form.cname,
  488. "ctype": self.form.ctype,
  489. "shortname": self.form.shortname,
  490. "explain": self.form.explain,
  491. "parentid": self.unit
  492. }
  493. $http.post(apiurljs.login + "g2work/form/insertData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  494. var res = strToJson(s4.decryptData_CBC(obj.data));
  495. if (res.success) {
  496. self.getFormData();
  497. sp.layerhide();
  498. } else {
  499. sp.layerhide();
  500. sp.dialog(res.message);
  501. }
  502. });
  503. }
  504. }
  505. };
  506. self.addFormCancel = function () {
  507. ///新建表单-取消
  508. self.form = {
  509. formkinds: self.formType[0].PKID,
  510. ckey: "",
  511. cname: "",
  512. ctype: self.formTypeAray[0].cval,
  513. shortname: "",
  514. explain: ""
  515. };
  516. sp.layerhide();
  517. };
  518. self.delForm = function ($item) {
  519. var time1 = sp.getLocalDate1();
  520. self.ctime = sp.getLocalDate1();
  521. self.journalRecord(time1, sp.getLocalDate1(), "删除类别", "修改日志", window.location.pathname)
  522. ///删除类别
  523. var getDelID = $item.FORMID;
  524. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  525. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  526. var dialogFoot = "<div class=\"sp-dialog-foot\"><input data-id=" + getDelID + " id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  527. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  528. sp.openCenter(".sp-dialog");
  529. ///取消按钮
  530. $('.sp-closeDialog').click(function (event) {
  531. sp.closeCenter(".sp-dialog");
  532. event.preventDefault();
  533. event.stopPropagation();
  534. });
  535. //post消息的id
  536. $("#delDataTrue").click(function () {
  537. var getid = $(this).attr("data-id");
  538. sp.dialoghide();
  539. var data = {
  540. formid: getDelID
  541. };
  542. $http.post(apiurljs.login + "g2work/form/deleteByFormid", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  543. .success(function (obj) {
  544. var res = strToJson(s4.decryptData_CBC(obj.data));
  545. if (res.success) {
  546. self.getFormData();
  547. sp.dialoghide();
  548. } else {
  549. sp.dialog(res.message);
  550. }
  551. });
  552. });
  553. };
  554. self.formSortup = function ($item, $index) {
  555. var time1 = sp.getLocalDate1();
  556. self.ctime = sp.getLocalDate1();
  557. self.journalRecord(time1, sp.getLocalDate1(), "上移", "修改日志", window.location.pathname)
  558. var set_index = parseInt($index - 1);
  559. var get_formid1 = self.formList[set_index].FORMID;
  560. self.postFormSortData(get_formid1, $item.FORMID);
  561. }
  562. self.formSortdown = function ($item, $index) {
  563. var time1 = sp.getLocalDate1();
  564. self.ctime = sp.getLocalDate1();
  565. self.journalRecord(time1, sp.getLocalDate1(), "下移", "修改日志", window.location.pathname)
  566. var set_index = parseInt($index + 1);
  567. var get_formid1 = self.formList[set_index].FORMID;
  568. self.postFormSortData(get_formid1, $item.FORMID);
  569. }
  570. self.postFormSortData = function (formid1, formid2) {
  571. var postData = {
  572. "formid1": formid1,
  573. "formid2": formid2
  574. }
  575. $http.post(apiurljs.login + "g2work/form/swapSortidByFormid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  576. var res = strToJson(s4.decryptData_CBC(obj.data));
  577. if (res.success) {
  578. self.getFormData();
  579. } else {
  580. sp.dialog(res.message);
  581. }
  582. });
  583. };
  584. //打开新增视图弹出层
  585. self.view = {
  586. edit: false,
  587. layertitle: "新建视图",
  588. formid: "",
  589. cname: "",
  590. explain: "",
  591. tempform: "",
  592. usetempform: "1",
  593. formeditid: ""
  594. }
  595. self.openAddView = function (formid,obj) {
  596. var time1 = sp.getLocalDate1();
  597. self.ctime = sp.getLocalDate1();
  598. self.journalRecord(time1, sp.getLocalDate1(), "新建视图", "修改日志", window.location.pathname)
  599. self.view.edit = false;
  600. self.view.layertitle = "新建视图";
  601. self.view.formid = formid;
  602. self.view.cname = "";
  603. self.view.explain = "";
  604. self.view.tempform = "";
  605. self.view.usetempform = "1";
  606. self.view.formeditid = "";
  607. if(obj.FORMEDIT.length>0){
  608. self.view.tempform=obj.FORMEDIT[0].TEMPFORM;
  609. }
  610. sp.layer("#layer_addView");
  611. }
  612. self.openEditView = function (obj) {
  613. var time1 = sp.getLocalDate1();
  614. self.ctime = sp.getLocalDate1();
  615. self.journalRecord(time1, sp.getLocalDate1(), "编辑视图", "修改日志", window.location.pathname)
  616. self.view.edit = true;
  617. self.view.layertitle = "编辑视图";
  618. self.view.formid = obj.FORMID;
  619. self.view.cname = obj.CNAME;
  620. self.view.explain = obj.EXPLAIN;
  621. self.view.tempform = obj.TEMPFORM;
  622. self.view.usetempform = (obj.USETEMPFORM == "true") ? "1" : "0";
  623. self.view.formeditid = obj.FORMEDITID;
  624. sp.layer("#layer_addView");
  625. }
  626. //增加视图或者编辑视图
  627. self.btnSaveView = function () {
  628. if (!self.view.edit) {
  629. var postData = {
  630. formid: self.view.formid,
  631. cname: self.view.cname,
  632. explain: self.view.explain,
  633. tempform: self.view.tempform,
  634. usetempform: (self.view.usetempform == 0) ? false : true
  635. }
  636. $http.post(apiurljs.login + "g2work/formedit/insertData", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  637. var res = strToJson(s4.decryptData_CBC(obj.data));
  638. sp.layerhide();
  639. if (res.success) {
  640. self.getFormData();
  641. } else {
  642. sp.dialog(res.message);
  643. }
  644. });
  645. } else {
  646. var postData = {
  647. formeditid: self.view.formeditid,
  648. cname: self.view.cname,
  649. explain: self.view.explain,
  650. tempform: self.view.tempform,
  651. usetempform: (self.view.usetempform == 0) ? false : true
  652. }
  653. $http.post(apiurljs.login + "g2work/formedit/updateDataByFormEditid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  654. var res = strToJson(s4.decryptData_CBC(obj.data));
  655. sp.layerhide();
  656. if (res.success) {
  657. self.formDetailList.forEach(function (item) {
  658. if (item.FORMEDITID == self.view.formeditid) {
  659. item.CNAME = self.view.cname;
  660. item.EXPLAIN = self.view.explain;
  661. item.USETEMPFORM = (self.view.usetempform == 0) ? false : true;
  662. item.TEMPFORM = self.view.tempform;
  663. }
  664. })
  665. } else {
  666. sp.dialog(res.message);
  667. }
  668. });
  669. }
  670. }
  671. //关闭视图弹出层
  672. self.btnCancelView = function () {
  673. sp.layerhide();
  674. }
  675. //删除视图函数
  676. self.delView = function (code, index) {
  677. var time1 = sp.getLocalDate1();
  678. self.ctime = sp.getLocalDate1();
  679. self.journalRecord(time1, sp.getLocalDate1(), "删除视图", "修改日志", window.location.pathname)
  680. var getDelID = code;
  681. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  682. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  683. var dialogFoot = "<div class=\"sp-dialog-foot\"><input data-id=" + getDelID + " id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  684. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  685. sp.openCenter(".sp-dialog");
  686. ///取消按钮
  687. $('.sp-closeDialog').click(function (event) {
  688. sp.closeCenter(".sp-dialog");
  689. event.preventDefault();
  690. event.stopPropagation();
  691. });
  692. //post消息的id
  693. $("#delDataTrue").click(function () {
  694. var getid = $(this).attr("data-id");
  695. sp.dialoghide();
  696. var data = {
  697. formeditid: getDelID
  698. };
  699. $http.post(apiurljs.login + "g2work/formedit/deleteByFormEditid", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  700. .success(function (obj) {
  701. var res = strToJson(s4.decryptData_CBC(obj.data));
  702. if (res.success) {
  703. sp.dialoghide();
  704. self.formDetailList.splice(index, 1);
  705. $scope.$apply()
  706. } else {
  707. sp.dialog(res.message);
  708. }
  709. });
  710. });
  711. }
  712. //打开编辑视图列函数
  713. self.viewColumnList = [];
  714. self.seletAllESHOW = false;
  715. self.seletAllGSHOW = false;
  716. self.seletAllEREADONLY = false;
  717. self.viewColumn = {
  718. formeditid: "",
  719. billkey: ""
  720. }
  721. self.openViewColumnLayer = function (item, item2) {
  722. var time1 = sp.getLocalDate1();
  723. self.journalRecord(time1, sp.getLocalDate1(), "列设置", "修改日志", window.location.pathname)
  724. self.viewColumnList = [];
  725. self.viewColumn.formeditid = item2.FORMEDITID;
  726. self.viewColumn.billkey = item.CKEY;
  727. self.seletAllESHOW = false;
  728. self.seletAllGSHOW = false;
  729. self.seletAllEREADONLY = false;
  730. var postData = {
  731. formeditid: self.viewColumn.formeditid,
  732. billkey: self.viewColumn.billkey
  733. }
  734. $http.post(apiurljs.login + "g2work/formedit/queryDataFormEditCol", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  735. var res = strToJson(s4.decryptData_CBC(obj.data));
  736. var selectESHOWNum = 0;
  737. var selectGSHOWNum = 0;
  738. var selectEREADONLYNum = 0;
  739. res.data.forEach(function (item) {
  740. item.ESHOW = (item.ESHOW == "false") ? false : true;
  741. item.GSHOW = (item.GSHOW == "false") ? false : true;
  742. item.EREADONLY = (item.EREADONLY == "false") ? false : true;
  743. if (item.ESHOW) {
  744. selectESHOWNum++;
  745. }
  746. if (item.GSHOW) {
  747. selectGSHOWNum++;
  748. }
  749. if (item.EREADONLY) {
  750. selectEREADONLYNum++;
  751. }
  752. })
  753. self.viewColumnList = res.data;
  754. if (selectESHOWNum == self.viewColumnList.length) {
  755. self.seletAllESHOW = true;
  756. }
  757. if (selectGSHOWNum == self.viewColumnList.length) {
  758. self.seletAllGSHOW = true;
  759. }
  760. if (selectEREADONLYNum == self.viewColumnList.length) {
  761. self.seletAllEREADONLY = true;
  762. }
  763. sp.layer("#layer_viewColumn");
  764. });
  765. };
  766. //全选隐藏
  767. self.allSelectESHOW = function () {
  768. var flag = self.seletAllESHOW;
  769. self.viewColumnList.forEach(function (item) {
  770. item.ESHOW = flag;
  771. })
  772. }
  773. //全选必填
  774. self.allSelectGSHOW = function () {
  775. var flag = self.seletAllGSHOW;
  776. self.viewColumnList.forEach(function (item) {
  777. item.GSHOW = flag;
  778. })
  779. }
  780. //全选只读
  781. self.allSelectEREADONLY = function () {
  782. var flag = self.seletAllEREADONLY;
  783. self.viewColumnList.forEach(function (item) {
  784. item.EREADONLY = flag;
  785. })
  786. }
  787. //单选隐藏
  788. self.itemSelectESHOW = function () {
  789. var selectNum = 0;
  790. self.viewColumnList.forEach(function (item) {
  791. if (item.ESHOW) {
  792. selectNum++
  793. }
  794. })
  795. if (selectNum == self.viewColumnList.length) {
  796. self.seletAllESHOW = true;
  797. } else {
  798. self.seletAllESHOW = false;
  799. }
  800. }
  801. //单选必填
  802. self.itemSelectGSHOW = function () {
  803. var selectNum = 0;
  804. self.viewColumnList.forEach(function (item) {
  805. if (item.GSHOW) {
  806. selectNum++
  807. }
  808. })
  809. if (selectNum == self.viewColumnList.length) {
  810. self.seletAllGSHOW = true;
  811. } else {
  812. self.seletAllGSHOW = false;
  813. }
  814. }
  815. //单选只读
  816. self.itemSelectEREADONLY = function () {
  817. var selectNum = 0;
  818. self.viewColumnList.forEach(function (item) {
  819. if (item.EREADONLY) {
  820. selectNum++
  821. }
  822. })
  823. if (selectNum == self.viewColumnList.length) {
  824. self.seletAllEREADONLY = true;
  825. } else {
  826. self.seletAllEREADONLY = false;
  827. }
  828. }
  829. //保存表单列设置
  830. self.btnViewColumnSave = function () {
  831. var resultArray = [];
  832. self.viewColumnList.forEach(function (item) {
  833. var itemResult = {
  834. COLID: item.COLID,
  835. CODE: item.CODE,
  836. CNAME: item.CNAME,
  837. ESHOW: item.ESHOW,
  838. GSHOW: item.GSHOW,
  839. EREADONLY: item.EREADONLY
  840. }
  841. resultArray.push(itemResult);
  842. })
  843. var postData = {
  844. formeditid: self.viewColumn.formeditid,
  845. billkey: self.viewColumn.billkey,
  846. data: JSON.stringify(resultArray)
  847. }
  848. $http.post(apiurljs.login + "g2work/formedit/saveDataFormEditCol", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  849. var res = strToJson(s4.decryptData_CBC(obj.data));
  850. sp.layerhide();
  851. if (res.success) {
  852. sp.dialog("设置成功!");
  853. } else {
  854. sp.dialog("设置失败,请联系管理员!");
  855. }
  856. });
  857. }
  858. //取消保存表单列设置
  859. self.btnViewColumnCancel = function () {
  860. sp.layerhide();
  861. };
  862. //打开功能设置弹出层
  863. self.viewFunc = {
  864. formeditid: "",
  865. billkey: "",
  866. nowFunc: ""
  867. }
  868. //打开设置功能弹出层
  869. self.funcButtonList = [];
  870. self.viewFuncList = [];
  871. self.openViewFuncLayer = function (item, item2) {
  872. var time1 = sp.getLocalDate1();
  873. self.journalRecord(time1, sp.getLocalDate1(), "功能设置", "修改日志", window.location.pathname)
  874. $(".warninfoBox").html("").hide();
  875. self.viewFunc.formeditid = item2.FORMEDITID;
  876. self.viewFunc.billkey = item.CKEY;
  877. self.funcButtonList = [];
  878. self.viewFuncList = [];
  879. var postData = {
  880. formeditid: self.viewFunc.formeditid,
  881. billkey: self.viewFunc.billkey
  882. }
  883. $http.post(apiurljs.login + "g2work/formedit/queryDataFuncButton", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj) {
  884. var res = strToJson(s4.decryptData_CBC(obj.data));
  885. self.funcButtonList = res.data;
  886. self.viewFunc.nowFunc = self.funcButtonList[0].FUNCID;
  887. $http.post(apiurljs.login + "g2work/formedit/queryDataFormEditFunc", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj1) {
  888. var response = strToJson(s4.decryptData_CBC(obj1.data).slice(0, s4.decryptData_CBC(obj1.data).lastIndexOf("}") + 1));
  889. self.viewFuncList = response.data;
  890. sp.layer("#layer_viewFunc");
  891. });
  892. });
  893. };
  894. //保存功能设置
  895. self.saveViewFuncButton = function () {
  896. var canAdd = true;
  897. self.viewFuncList.forEach(function (item) {
  898. if (item.FUNCID == self.viewFunc.nowFunc) {
  899. canAdd = false;
  900. }
  901. })
  902. if (canAdd) {
  903. var postData = {
  904. formeditid: self.viewFunc.formeditid,
  905. billkey: self.viewFunc.billkey,
  906. funcid: self.viewFunc.nowFunc
  907. }
  908. $http.post(apiurljs.login + "g2work/formedit/insertDataFormEditFunc", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj1) {
  909. var response = strToJson(s4.decryptData_CBC(obj1.data).slice(0, s4.decryptData_CBC(obj1.data).lastIndexOf("}") + 1));
  910. if (response.success) {
  911. self.viewFuncList = response.data;
  912. self.addWarning("功能添加成功!");
  913. }
  914. });
  915. } else {
  916. self.addWarning("请勿重复配置功能");
  917. }
  918. }
  919. //删除保存功能
  920. self.deleteViewFunc = function (funcid) {
  921. var postData = {
  922. formeditid: self.viewFunc.formeditid,
  923. billkey: self.viewFunc.billkey,
  924. funcid: funcid
  925. }
  926. $http.post(apiurljs.login + "g2work/formedit/deleteByFormEditFuncid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj1) {
  927. var response = strToJson(s4.decryptData_CBC(obj1.data).slice(0, s4.decryptData_CBC(obj1.data).lastIndexOf("}") + 1));
  928. if (response.success) {
  929. self.viewFuncList = response.data;
  930. self.addWarning("功能删除成功!");
  931. }
  932. });
  933. }
  934. //上移函数
  935. self.upViewFunc = function (index) {
  936. var postData = {
  937. formeditid: self.viewFunc.formeditid,
  938. billkey: self.viewFunc.billkey,
  939. funcid1: self.viewFuncList[index].FUNCID,
  940. funcid2: self.viewFuncList[index - 1].FUNCID
  941. }
  942. $http.post(apiurljs.login + "g2work/formedit/swapSortidByFormEditFuncid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj1) {
  943. var response = strToJson(s4.decryptData_CBC(obj1.data).slice(0, s4.decryptData_CBC(obj1.data).lastIndexOf("}") + 1));
  944. if (response.success) {
  945. self.viewFuncList = response.data;
  946. self.addWarning("功能移动成功!");
  947. }
  948. });
  949. }
  950. //下移函数
  951. self.downViewFunc = function (index) {
  952. var postData = {
  953. formeditid: self.viewFunc.formeditid,
  954. billkey: self.viewFunc.billkey,
  955. funcid1: self.viewFuncList[index].FUNCID,
  956. funcid2: self.viewFuncList[index + 1].FUNCID
  957. }
  958. $http.post(apiurljs.login + "g2work/formedit/swapSortidByFormEditFuncid", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg).success(function (obj1) {
  959. var response = strToJson(s4.decryptData_CBC(obj1.data).slice(0, s4.decryptData_CBC(obj1.data).lastIndexOf("}") + 1));
  960. if (response.success) {
  961. self.viewFuncList = response.data;
  962. self.addWarning("功能移动成功!");
  963. }
  964. });
  965. }
  966. //去除警告
  967. self.removeWarning = function () {
  968. $(".warninfoBox").html("").hide();
  969. }
  970. //给上传弹出层添加警告
  971. self.addWarning = function (content) {
  972. $(".warninfoBox").html("<i class=\"fa fa-exclamation sp-mr-5\"></i>" + content).show();
  973. }
  974. //跳转表单设计页
  975. self.goFormEdit = function ($item) {
  976. var time1 = sp.getLocalDate1();
  977. self.journalRecord(time1, sp.getLocalDate1(), "表单设计", "接入日志", window.location.pathname)
  978. self.recordCtime()
  979. // console.log($item)
  980. // window.parent.sp.addTabNav('FZC99', '表单设计', 'tpl/flowchart_formbuilder/formbuilder.html');
  981. // window.location.href = "../flowchart_formbuilder/formbuilder.html?copyrightid=" + $item.COPYRIGHTID;
  982. $timeout(function () {
  983. window.location.href = "../../" + $item.TEMPFORM;
  984. }, 1)
  985. }
  986. self.recordCtime = function () {
  987. $.cookie("CrossPage-ctime", sp.getLocalDate1(), {path: '/', expires: 1});
  988. $.cookie("CrossPage-title", self.CrossPage.cname, {path: '/', expires: 1});
  989. }
  990. //记录日志
  991. self.journalRecord = function (time1, time2, title, func, url) {
  992. if (!self.CrossPage.cname) {
  993. return;
  994. }
  995. var data = {
  996. tablename: "SYS_CLICKLOG",
  997. data: {
  998. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  999. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  1000. REQUESTURL: url,
  1001. REQUESTHEADERURL: window.location.origin,
  1002. LOGTYPE: func,
  1003. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  1004. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  1005. CLIENTIP: sp.myIP(),
  1006. PCNAME: sp.detectOS(),
  1007. BROWSERNAME: sp.browser(),
  1008. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  1009. USERID: self.userId,
  1010. USERNAME: self.userCName
  1011. }
  1012. }
  1013. $http.post(apiurljs.login + "g2app/DangJian/insertFormData", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  1014. .success(function (res) {
  1015. self.CrossPage.type = 1;
  1016. })
  1017. }
  1018. self.keyLogin = function () {
  1019. if (event.keyCode == 13) //回车键的键值为13
  1020. {
  1021. self.addFormTrue();
  1022. }
  1023. }
  1024. ////跳转入自定义表单设计模块--20230305--zyg
  1025. self.openViewFormbuilder = function (item, item2) {
  1026. //console.log(item);
  1027. //console.log(item2);
  1028. window.location.href = "../flowchart_formbuilder/formbuilder.html?formeditid=" + item2.FORMEDITID + "&routeinfoid=0&routeid=0&id=0&pagefrom=formManageformlist&leftActive=" + self.active.STATUS + "&leftActiveType=" + self.active.TYPE;
  1029. localStorage.setItem("tjJxtGoldenlinkWork-formlistViewIndex", self.checkViewDetail_index);/// 存储表单管理视图点击序号
  1030. };
  1031. }]);