flowchart.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. var app = angular.module('app', ["angularUtils.directives.dirPagination"]);
  2. app.controller("flowchartCtrl", ["$scope", "$http", "$compile", "$timeout", function ($scope, $http, $compile, $timeout) {
  3. var self = this;
  4. var s4 = new SM4Util();
  5. sp.fitHeight("#flowTypePart", 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. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.CrossPage = window.parent.CrossPage;
  18. self.loading = false;
  19. self.sortClose = 0;
  20. self.active = {
  21. STATUS: 0,
  22. TYPE: "",
  23. CNAME:""
  24. };
  25. ///激活状态的设置,考虑上来就加载和从详情页面返回的两种情况
  26. self.setMsgActive = function () {
  27. $(".sp-msg-left-bottom .sp-msg-left-lh").removeClass("sp-msg-left-active");
  28. $(".sp-msg-left-bottom .sp-msg-left-lh:eq(" + self.active.STATUS + ")").addClass("sp-msg-left-active");
  29. };
  30. setTimeout(function () {
  31. self.setMsgActive();
  32. }, 800);
  33. self.getMsgData = function (str, PKID, CNAME) {
  34. var time1 = sp.getLocalDate1();
  35. self.ctime = sp.getLocalDate1();
  36. self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/flow/queryData")
  37. if (str == 0) {
  38. self.active = {
  39. STATUS: str,
  40. TYPE: "",
  41. CNAME: CNAME
  42. };
  43. } else {
  44. self.active = {
  45. STATUS: str,
  46. TYPE: PKID,
  47. CNAME: CNAME
  48. };
  49. }
  50. $(".sp-msg-left-bottom .sp-msg-left-lh").removeClass("sp-msg-left-active");
  51. $(".sp-msg-left-bottom .sp-msg-left-lh:eq(" + str + ")").addClass("sp-msg-left-active");
  52. self.getFlowData();///加载流程
  53. };
  54. ///加载机构
  55. self.unitList = []; ///数组
  56. self.unit = ""; ///机构名称
  57. self.getUnit = function () {
  58. self.loading = true;
  59. $http.post(apiurljs.login + "g2work/sect/querySectAdmin", { data: s4.encryptData_CBC("") }, postCfg)
  60. .success(function (obj) {
  61. var res = strToJson(s4.decryptData_CBC(obj.data));
  62. ///console.log(res);
  63. if (res.success) {
  64. if (sp.isval(res.data)) {
  65. self.unitList = res.data;
  66. self.unit = res.data[0].CODE;
  67. self.getFlowType();///加载流程类别
  68. } else {
  69. self.unitList = [];
  70. self.loading = false;
  71. }
  72. } else {
  73. sp.dialog(res.message);
  74. self.unitList = [];
  75. self.loading = false;
  76. }
  77. })
  78. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  79. if (textStatus != 200) {
  80. self.loading = false;
  81. }
  82. })
  83. };
  84. self.getUnit();
  85. ///加载流程类别数组
  86. self.flowType = [];
  87. self.flowType_left = [];
  88. self.getFlowType = function () {
  89. var postData = {
  90. pkid: self.unit,
  91. includechildren: true
  92. }
  93. $http.post(apiurljs.login + "g2work/flowkinds/queryData", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  94. var res = strToJson(s4.decryptData_CBC(obj.data));
  95. ///console.log(res);
  96. if (res.success) {
  97. if (sp.isval(res.data)) {
  98. self.flowType = res.data;
  99. //console.log(JSON.stringify(self.flowType));
  100. angular.forEach(self.flowType,function(item){
  101. self.flowType_left.push(item);
  102. });
  103. var set_json={"PKID":"withDelete", "CNAME":"流程回收站" }
  104. self.flowType_left.push(set_json);
  105. //console.log(JSON.stringify(self.flowType_left));
  106. if (self.flowid) {
  107. $.each(self.flowType_left, function (index, item) {
  108. if (item.PKID == self.flowid) {
  109. self.active = {
  110. STATUS: index + 1,
  111. TYPE: item.PKID,
  112. CNAME: item.CNAME
  113. }
  114. }
  115. })
  116. } else {
  117. self.active = {
  118. STATUS: parseInt(sp.getUrlName("leftActive")) || 1,
  119. TYPE: sp.getUrlName("leftActiveType") || self.flowType_left[0].PKID,
  120. CNAME: sp.getUrlName("leftActiveName") || self.flowType_left[0].CNAME
  121. }
  122. };
  123. self.getCodeTableOption(); //加载关联表的来源
  124. self.getFlowData();///加载流程
  125. } else {
  126. self.flowType = [];
  127. self.flowType_left=[];
  128. self.loading = false;
  129. }
  130. } else {
  131. sp.dialog(res.message);
  132. self.flowType = [];
  133. self.loading = false;
  134. }
  135. })
  136. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  137. if (textStatus != 200) {
  138. self.loading = false;
  139. }
  140. })
  141. };
  142. //加载关联表和列的数据
  143. self.codeTableOption = [];
  144. self.codeColumnOption = [];
  145. self.getCodeTableOption = function () {
  146. $http.post(apiurljs.login + "g2work/billcol/queryDataInitvalT", { data: s4.encryptData_CBC("") }, postCfg)
  147. .success(function (obj) {
  148. var res = strToJson(s4.decryptData_CBC(obj.data));
  149. if (res.success) {
  150. if (sp.isval(res.data)) {
  151. self.codeTableOption = res.data;
  152. self.codeColumnOption = [];
  153. } else {
  154. self.codeTableOption = [];
  155. self.codeColumnOption = [];
  156. }
  157. } else {
  158. sp.dialog(res.message);
  159. }
  160. //self.getFlowData();///加载流程
  161. })
  162. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  163. if (textStatus != 200) {
  164. self.loading = false;
  165. }
  166. })
  167. }
  168. self.changeCodeTable = function () {
  169. if (self.info.codetable == "") {
  170. self.codeColumnOption = [];
  171. self.info.codecolumn = "";
  172. } else {
  173. var data = {
  174. billkey: self.info.codetable
  175. }
  176. $http.post(apiurljs.login + "g2work/billcol/queryDataByParam", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  177. .success(function (obj) {
  178. var res = strToJson(s4.decryptData_CBC(obj.data));
  179. self.info.codecolumn = "";
  180. self.codeColumnOption = res.data[0].COLS;
  181. })
  182. //self.codeTableOption.forEach(function (item) {
  183. // if (item.BILLKEY == self.info.codetable) {
  184. // self.codeColumnOption = item.COLS;
  185. // self.info.codecolumn = "";
  186. // }
  187. //})
  188. }
  189. }
  190. ///新增流程类别--声明变量
  191. self.addflow = {
  192. pkid: 0,
  193. cname: "",
  194. ctype: "NORMAL"
  195. };
  196. ///打开新增类别
  197. self.openLayerFlowType = function () {
  198. self.addflow = {
  199. pkid: 0,
  200. cname: "",
  201. ctype: "WITHNO"
  202. };
  203. sp.layer("#layer_addFlowType");
  204. var time1 = sp.getLocalDate1();
  205. self.ctime = sp.getLocalDate1();
  206. self.journalRecord(time1, sp.getLocalDate1(), "新增类别", "修改日志", window.location.pathname)
  207. };
  208. ///更新流程类别
  209. self.editFlowType = function ($item) {
  210. event.preventDefault();
  211. event.stopPropagation();
  212. self.addflow = {
  213. pkid: $item.PKID,
  214. cname: $item.CNAME,
  215. ctype: $item.CTYPE
  216. }
  217. sp.layer("#layer_addFlowType");
  218. var time1 = sp.getLocalDate1();
  219. self.ctime = sp.getLocalDate1();
  220. self.journalRecord(time1, sp.getLocalDate1(), "编辑类别", "修改日志", window.location.pathname)
  221. };
  222. ///点击确认提交新增流程类别
  223. self.btnSubmitFlowType = function () {
  224. if (spngvld.submit("#layer_addFlowType")) {
  225. if (self.addflow.pkid == 0) {
  226. var postData = {
  227. "cname": self.addflow.cname,
  228. "ctype": self.addflow.ctype,
  229. "parentid": self.unit
  230. };
  231. $http.post(apiurljs.login + "g2work/flowkinds/insertData", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  232. var res = strToJson(s4.decryptData_CBC(obj.data));
  233. ///console.log(res);
  234. if (res.success) {
  235. sp.layerhide();
  236. sp.dialog("流程新增成功!");
  237. $timeout(function () {
  238. sp.dialoghide();
  239. self.getFlowType();
  240. }, 600)
  241. } else {
  242. sp.layerhide();
  243. sp.dialog(res.message);
  244. }
  245. });
  246. } else {
  247. var postData = {
  248. "pkid": self.addflow.pkid,
  249. "cname": self.addflow.cname,
  250. "ctype": self.addflow.ctype
  251. };
  252. $http.post(apiurljs.login + "g2work/flowkinds/updateDataByPkid", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  253. .success(function (obj) {
  254. var res = strToJson(s4.decryptData_CBC(obj.data));
  255. ///console.log(res);
  256. if (res.success) {
  257. sp.layerhide();
  258. sp.dialog("更新成功!");
  259. $timeout(function () {
  260. sp.dialoghide();
  261. self.getFlowType();
  262. }, 600)
  263. } else {
  264. sp.layerhide();
  265. sp.dialog(res.message);
  266. }
  267. });
  268. }
  269. }
  270. };
  271. ///取消操作类别
  272. self.btnCancelFlowType = function () {
  273. self.addflow = {
  274. pkid: 0,
  275. cname: "",
  276. ctype: "WITHNO"
  277. };
  278. spngvld.clear("#layer_addFlowType")
  279. sp.layerhide();
  280. };
  281. ///删除类别
  282. self.delFlowType = function ($item) {
  283. event.preventDefault();
  284. event.stopPropagation();
  285. var time1 = sp.getLocalDate1();
  286. self.ctime = sp.getLocalDate1();
  287. self.journalRecord(time1, sp.getLocalDate1(), "删除类别", "修改日志", window.location.pathname)
  288. var getDelID = $item.PKID;
  289. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  290. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  291. 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>";
  292. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  293. sp.openCenter(".sp-dialog");
  294. ///取消按钮
  295. $('.sp-closeDialog').click(function (event) {
  296. sp.closeCenter(".sp-dialog");
  297. event.preventDefault();
  298. event.stopPropagation();
  299. });
  300. //post消息的id
  301. $("#delDataTrue").click(function () {
  302. var getid = $(this).attr("data-id");
  303. sp.dialoghide();
  304. var data = {
  305. pkid: getDelID///角色编码
  306. };
  307. $http.post(apiurljs.login + "g2work/flowkinds/deleteByPkid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  308. .success(function (obj) {
  309. var res = strToJson(s4.decryptData_CBC(obj.data));
  310. if (res.success) {
  311. self.getFlowType();
  312. sp.dialoghide();
  313. } else {
  314. sp.dialog(res.message);
  315. }
  316. });
  317. });
  318. };
  319. ///类别排序
  320. self.openSortType = function () {
  321. self.sortClose = 1;
  322. sp.layer("#layer_sortFlowType");
  323. var time1 = sp.getLocalDate1();
  324. self.ctime = sp.getLocalDate1();
  325. self.journalRecord(time1, sp.getLocalDate1(), "类别排序", "修改日志", window.location.pathname)
  326. };
  327. self.itemSortup = function ($item, $index) {
  328. var set_index = parseInt($index - 1);
  329. var get_pkid1 = self.flowType[set_index].PKID;
  330. self.postSortData(get_pkid1, $item.PKID);
  331. }
  332. self.itemSortdown = function ($item, $index) {
  333. var set_index = parseInt($index + 1);
  334. var get_pkid1 = self.flowType[set_index].PKID;
  335. self.postSortData(get_pkid1, $item.PKID);
  336. }
  337. self.postSortData = function (pkid1, pkid2) {
  338. var postData = {
  339. "pkid1": pkid1,
  340. "pkid2": pkid2
  341. }
  342. $http.post(apiurljs.login + "g2work/flowkinds/swapSortidByPkid", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  343. var res = strToJson(s4.decryptData_CBC(obj.data));
  344. ///console.log(res);
  345. if (res.success) {
  346. self.getFlowType();
  347. } else {
  348. sp.layerhide();
  349. sp.dialog(res.message);
  350. }
  351. });
  352. };
  353. ///处理流程--开始--start//////////////////////////////////////////////////////////////////////////////////////////////////////
  354. var colors = [
  355. "#093", "#5151cb", "#67379a", "#0e39de", "#cd435c", "#f1a73a",
  356. "#b0cb26", "#4fb2e3", "#95a5a6", "#66cc80", "#ee4444", "#f39c12",
  357. "#60bf78", "#30bfbf", "#bf3995", "#4d6240", "#995e2e", "#323159",
  358. "#666666", "#4a90e2", "#d94141", "#ed8824", "#ff8080", "#906edb",
  359. "#d3a269", "#008be6", "#5c1446", "#88b876", "#a50872", "#4b90e2"
  360. ];
  361. self.flowData = [];
  362. self.flowData_search = [];
  363. self.getFlowData = function () {
  364. self.loading = true;
  365. var postData ={};
  366. var postUrl="";
  367. if(self.active.TYPE=="withDelete"){
  368. postData = {
  369. unitid: "AA",
  370. flowkinds: ""
  371. }
  372. postUrl=apiurljs.login + "g2work/flow/queryDataWithDelete";
  373. }else{
  374. postData = {
  375. unitid: self.unit,
  376. flowkinds: self.active.TYPE
  377. }
  378. postUrl=apiurljs.login + "g2work/flow/queryData";
  379. }
  380. //console.log(postData);
  381. $http.post(postUrl, { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  382. .success(function (obj) {
  383. var res = strToJson(s4.decryptData_CBC(obj.data));
  384. self.loading = false;
  385. ///console.log(res);
  386. if (res.success) {
  387. if (sp.isval(res.data)) {
  388. self.flowData = res.data;
  389. //console.log(JSON.stringify(self.flowData));
  390. self.flowData.forEach(function (item, index) {
  391. item.color = colors[index];
  392. item.firstname = item.CNAME.substr(0, 1);
  393. //if (item.CODETABLE != "") {
  394. // self.codeTableOption.forEach(function (item2) {
  395. // if (item2.BILLKEY == item.CODETABLE) {
  396. // item.CODETABLENAME = item2.CNAME;
  397. // item.CODECOLUMNNAME = item2.CODECNAME;
  398. // //item2.COLS.forEach(function (item3) {
  399. // // if (item3.CODE == item.CODECOLUMN) {
  400. // // item.CODECOLUMNNAME = item3.CNAME;
  401. // // }
  402. // //})
  403. // }
  404. // })
  405. //}
  406. });
  407. //如果流程列表有数据,判断全部流程的正确的性
  408. self.checkFlowList();
  409. self.flowData_search = self.flowData;
  410. } else {
  411. self.flowData = [];
  412. self.flowData_search=[];
  413. }
  414. } else {
  415. sp.dialog(res.message);
  416. self.flowData = [];
  417. self.flowData_search=[];
  418. }
  419. if (self.CrossPage.type == 0) {
  420. self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname)
  421. }
  422. })
  423. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  424. if (textStatus != 200) {
  425. self.loading = false;
  426. }
  427. })
  428. };
  429. ////前端检索关键字--start
  430. self.searchByKeywords=function (keywords, searchArr) {
  431. var search_array=[];
  432. if(sp.isval(keywords)){
  433. angular.forEach(searchArr,function(item){
  434. if(item.CNAME.indexOf(keywords)!=-1 || item.FLOWID.indexOf(keywords)!=-1){
  435. search_array.push(item);
  436. }
  437. });
  438. }else{
  439. search_array=searchArr;
  440. }
  441. return search_array;
  442. }
  443. self.search_keyword="";
  444. self.btnSearch = function () {
  445. //console.log(JSON.stringify(self.searchByKeywords("党委", self.flowData)));
  446. self.flowData_search=self.searchByKeywords(self.search_keyword, self.flowData);
  447. };
  448. ////前端检索关键字--end
  449. self.info = {
  450. add: true,
  451. layertitle: "新建流程",
  452. type: "",
  453. copyrightid: 0,
  454. ckey: "",
  455. cname: "",
  456. timelimit: "",
  457. explain: "",
  458. codetable: "",
  459. codecolumn: ""
  460. };
  461. self.openFlowLayer = function () {
  462. self.SubmitFlowFlag = false;
  463. var time1 = sp.getLocalDate1();
  464. self.ctime = sp.getLocalDate1();
  465. self.journalRecord(time1, sp.getLocalDate1(), "新建流程", "修改日志", window.location.pathname)
  466. //打开添加流程layer层--新建
  467. // self.info = {
  468. // "add": true,
  469. // "layertitle": "新建流程",
  470. // "copyrightid": 0,
  471. // "ckey": "",
  472. // "cname": "",
  473. // "timelimit": "",
  474. // "explain": "",
  475. // "codetable":"",
  476. // "codecolumn":""
  477. // };
  478. self.info.add = true;
  479. self.info.layertitle = "新建流程";
  480. self.info.copyrightid = 0;
  481. self.info.type = self.active.TYPE == "" ? self.flowType[0].PKID : self.active.TYPE;
  482. self.info.ckey = "";
  483. self.info.cname = "";
  484. self.info.timelimit = "";
  485. self.info.explain = "";
  486. self.info.codetable = "";
  487. self.info.codecolumn = "";
  488. self.codeColumnOption = [];
  489. sp.layer("#layer_addFlow");
  490. };
  491. self.editFlow = function ($item) {
  492. self.SubmitFlowFlag = false;
  493. var time1 = sp.getLocalDate1();
  494. self.ctime = sp.getLocalDate1();
  495. self.journalRecord(time1, sp.getLocalDate1(), "编辑流程", "修改日志", window.location.pathname)
  496. self.info.add = false;
  497. self.info.layertitle = "编辑流程";
  498. self.info.type = $item.FLOWKINDS
  499. self.info.copyrightid = $item.COPYRIGHTID;
  500. self.info.ckey = $item.CKEY;
  501. self.info.cname = $item.CNAME;
  502. self.info.timelimit = $item.TIMELIMIT;
  503. self.info.explain = $item.EXPLAIN;
  504. self.info.codetable = $item.CODETABLE;
  505. if ($item.CODETABLE != "") {
  506. var data = {
  507. billkey: self.info.codetable
  508. }
  509. $http.post(apiurljs.login + "g2work/billcol/queryDataByParam", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  510. .success(function (obj) {
  511. var res = strToJson(s4.decryptData_CBC(obj.data));
  512. self.codeColumnOption = res.data[0].COLS;
  513. $timeout(function () {
  514. self.info.codecolumn = $item.CODECOLUMN;
  515. sp.layer("#layer_addFlow");
  516. }, 1)
  517. })
  518. } else {
  519. self.codeColumnOption = [];
  520. self.info.codecolumn = $item.CODECOLUMN;
  521. sp.layer("#layer_addFlow");
  522. }
  523. };
  524. self.SubmitFlowFlag = false;
  525. self.btnSubmitFlow = function () {
  526. ////新建流程-提交按钮
  527. if (spngvld.submit("#layer_addFlow")) {
  528. self.SubmitFlowFlag = true;
  529. if (self.info.copyrightid == 0) {
  530. var data = {
  531. tablename: "SYS_FLOW",
  532. colums: "*",
  533. order: "CKEY",
  534. sqlwhere: { CKEY: self.info.ckey },
  535. sqlinwhere: "",
  536. sqllikewhere: ""
  537. }
  538. $http.post(apiurljs.login + "g2app/DangJian/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  539. .success(function (obj) {
  540. var res = strToJson(s4.decryptData_CBC(obj.data));
  541. if (res.data.length > 0) {
  542. sp.layerhide();
  543. sp.dialog("流程已存在!");
  544. return
  545. } else {
  546. // if (self.active.TYPE == "") {
  547. // sp.layerhide();
  548. // sp.dialog("流程类别不能为空!");
  549. // return false;
  550. // }
  551. var postData = {
  552. "flowkinds": self.info.type,
  553. "ckey": self.info.ckey,
  554. "cname": self.info.cname,
  555. "timelimit": self.info.timelimit,
  556. "explain": self.info.explain,
  557. "parentid": self.unit,
  558. "codetable": self.info.codetable,
  559. "codecolumn": self.info.codecolumn
  560. };
  561. $http.post(apiurljs.login + "g2work/flow/insertData", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  562. var res = strToJson(s4.decryptData_CBC(obj.data));
  563. self.SubmitFlowFlag = false;
  564. ///console.log(res);
  565. if (res.success) {
  566. sp.layerhide();
  567. sp.dialog(res.message);
  568. $timeout(function () {
  569. sp.dialoghide();
  570. self.getMsgData(self.active.STATUS, self.active.TYPE, self.active.CNAME);
  571. }, 600)
  572. } else {
  573. sp.layerhide();
  574. sp.dialog(res.message);
  575. }
  576. });
  577. }
  578. })
  579. } else {
  580. var data = {
  581. tablename: "SYS_FLOW",
  582. colums: "*",
  583. order: "CKEY",
  584. sqlwhere: { CKEY: self.info.ckey },
  585. sqlinwhere: "",
  586. sqllikewhere: ""
  587. }
  588. $http.post(apiurljs.login + "g2app/DangJian/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  589. .success(function (obj) {
  590. var res = strToJson(s4.decryptData_CBC(obj.data));
  591. if (res.data.length > 1) {
  592. sp.layerhide();
  593. sp.dialog("流程已存在!");
  594. return
  595. } else {
  596. var postData = {
  597. "copyrightid": self.info.copyrightid,
  598. "ckey": self.info.ckey,
  599. "cname": self.info.cname,
  600. "timelimit": self.info.timelimit,
  601. "explain": self.info.explain,
  602. "codetable": self.info.codetable,
  603. "codecolumn": self.info.codecolumn,
  604. "flowkinds": self.info.type
  605. };
  606. $http.post(apiurljs.login + "g2work/flow/updateDataByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  607. var res = strToJson(s4.decryptData_CBC(obj.data));
  608. self.SubmitFlowFlag = false;
  609. ///console.log(res);
  610. if (res.success) {
  611. sp.layerhide();
  612. sp.dialog(res.message);
  613. $timeout(function () {
  614. sp.dialoghide();
  615. //self.getCodeTableOption();
  616. self.getFlowData();///加载流程
  617. }, 600)
  618. } else {
  619. sp.layerhide();
  620. sp.dialog(res.message);
  621. }
  622. });
  623. }
  624. })
  625. }
  626. }
  627. };
  628. self.btnCancelFlow = function () {
  629. ///取消新建流程按钮事件
  630. spngvld.clear("#layer_addFlow");
  631. self.info = {
  632. "layertitle": "新建流程",
  633. "copyrightid": 0,
  634. "ckey": "",
  635. "cname": "",
  636. "timelimit": "",
  637. "explain": "",
  638. };
  639. sp.layerhide();
  640. };
  641. self.delFlow = function ($item) {
  642. var time1 = sp.getLocalDate1();
  643. self.ctime = sp.getLocalDate1();
  644. self.journalRecord(time1, sp.getLocalDate1(), "删除流程--移入流程回收站", "修改日志", window.location.pathname)
  645. // console.log($item);
  646. var getDelID = $item.COPYRIGHTID;
  647. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  648. var dialogBody = "<div class=\"sp-dialog-body\">删除后将移入“流程回收站”,您确认要删除吗?</div>";
  649. 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>";
  650. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  651. sp.openCenter(".sp-dialog");
  652. ///取消按钮
  653. $('.sp-closeDialog').click(function (event) {
  654. sp.closeCenter(".sp-dialog");
  655. event.preventDefault();
  656. event.stopPropagation();
  657. });
  658. //post消息的id
  659. $("#delDataTrue").click(function () {
  660. var getid = $(this).attr("data-id");
  661. sp.dialoghide();
  662. var data = {
  663. copyrightid: getDelID///角色编码
  664. };
  665. $http.post(apiurljs.login + "g2work/flow/deleteByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  666. .success(function (obj) {
  667. var res = strToJson(s4.decryptData_CBC(obj.data));
  668. if (res.success) {
  669. //self.getCodeTableOption();
  670. self.getFlowData();///加载流程
  671. sp.dialoghide();
  672. } else {
  673. sp.dialog(res.message);
  674. }
  675. });
  676. });
  677. };
  678. self.delFlowWithDelete = function ($item) {
  679. ////删除流程---流程回收站中的
  680. var time1 = sp.getLocalDate1();
  681. self.ctime = sp.getLocalDate1();
  682. self.journalRecord(time1, sp.getLocalDate1(), "删除流程", "修改日志", window.location.pathname)
  683. // console.log($item);
  684. var getDelID = $item.COPYRIGHTID;
  685. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  686. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  687. 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>";
  688. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  689. sp.openCenter(".sp-dialog");
  690. ///取消按钮
  691. $('.sp-closeDialog').click(function (event) {
  692. sp.closeCenter(".sp-dialog");
  693. event.preventDefault();
  694. event.stopPropagation();
  695. });
  696. //post消息的id
  697. $("#delDataTrue").click(function () {
  698. var getid = $(this).attr("data-id");
  699. sp.dialoghide();
  700. var data = {
  701. copyrightid: getDelID///角色编码
  702. };
  703. $http.post(apiurljs.login + "g2work/flow/deleteByCopyrightidWithDelete", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  704. .success(function (obj) {
  705. var res = strToJson(s4.decryptData_CBC(obj.data));
  706. if (res.success) {
  707. //self.getCodeTableOption();
  708. self.getFlowData();///加载流程
  709. sp.dialoghide();
  710. } else {
  711. sp.dialog(res.message);
  712. }
  713. });
  714. });
  715. };
  716. self.restoreFlowWithDelete = function ($item) {
  717. ////还原流程---流程回收中的
  718. var time1 = sp.getLocalDate1();
  719. self.ctime = sp.getLocalDate1();
  720. self.journalRecord(time1, sp.getLocalDate1(), "还原流程", "修改日志", window.location.pathname)
  721. // console.log($item);
  722. var getDelID = $item.COPYRIGHTID;
  723. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  724. var dialogBody = "<div class=\"sp-dialog-body\">您确认要还原吗?</div>";
  725. 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>";
  726. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  727. sp.openCenter(".sp-dialog");
  728. ///取消按钮
  729. $('.sp-closeDialog').click(function (event) {
  730. sp.closeCenter(".sp-dialog");
  731. event.preventDefault();
  732. event.stopPropagation();
  733. });
  734. //post消息的id
  735. $("#delDataTrue").click(function () {
  736. var getid = $(this).attr("data-id");
  737. sp.dialoghide();
  738. var data = {
  739. copyrightid: getDelID///角色编码
  740. };
  741. $http.post(apiurljs.login + "g2work/flow/restoreByCopyrightidWithDelete", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  742. .success(function (obj) {
  743. var res = strToJson(s4.decryptData_CBC(obj.data));
  744. if (res.success) {
  745. //self.getCodeTableOption();
  746. self.getFlowData();///加载流程
  747. sp.dialoghide();
  748. } else {
  749. sp.dialog(res.message);
  750. }
  751. });
  752. });
  753. };
  754. self.openSortFlow = function () {
  755. ///流程排序打开div层
  756. self.sortClose = 2;
  757. sp.layer("#layer_sortFlow");
  758. var time1 = sp.getLocalDate1();
  759. self.ctime = sp.getLocalDate1();
  760. self.journalRecord(time1, sp.getLocalDate1(), "流程排序", "修改日志", window.location.pathname)
  761. };
  762. self.flowSortup = function ($item, $index) {
  763. var set_index = parseInt($index - 1);
  764. var get_copyrightid1 = self.flowData[set_index].COPYRIGHTID;
  765. self.postSortFlowData(get_copyrightid1, $item.COPYRIGHTID);
  766. }
  767. self.flowSortdown = function ($item, $index) {
  768. var set_index = parseInt($index + 1);
  769. var get_copyrightid1 = self.flowData[set_index].COPYRIGHTID;
  770. self.postSortFlowData(get_copyrightid1, $item.COPYRIGHTID);
  771. }
  772. self.postSortFlowData = function (copyrightid1, copyrightid2) {
  773. var postData = {
  774. "copyrightid1": copyrightid1,
  775. "copyrightid2": copyrightid2
  776. }
  777. $http.post(apiurljs.login + "g2work/flow/swapSortidByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  778. var res = strToJson(s4.decryptData_CBC(obj.data));
  779. ///console.log(res);
  780. if (res.success) {
  781. self.getMsgData(self.active.STATUS, self.active.TYPE, self.active.CNAME);
  782. } else {
  783. sp.layerhide();
  784. sp.dialog(res.message);
  785. }
  786. });
  787. };
  788. self.goTableFormDesign = function ($item, type) {
  789. var time1 = sp.getLocalDate1();
  790. self.recordCtime()
  791. ///跳转表单设计
  792. // console.log($item);
  793. // window.location.href="../flowchart_formbuilder/list.html";
  794. if (type == "add") {
  795. // alert($item.COPYRIGHTID);
  796. self.journalRecord(time1, sp.getLocalDate1(), "新建视图", "修改日志", window.location.pathname)
  797. window.location.href = "../flowchart_formbuilder/formbuilder.html?copyrightid=" + $item.COPYRIGHTID;
  798. } else {
  799. self.journalRecord(time1, sp.getLocalDate1(), "编辑视图", "修改日志", window.location.pathname)
  800. $timeout(function () {
  801. window.parent.CrossPage = {
  802. cname: "系统管理/流程管理",
  803. ctime: sp.getLocalDate1(),
  804. type: 0
  805. }
  806. window.location.href = $item.URL;
  807. }, 1)
  808. }
  809. };
  810. self.goFlowChartDesign = function ($item, type) {
  811. var time1 = sp.getLocalDate1();
  812. self.recordCtime()
  813. if (type == "add") {
  814. self.journalRecord(time1, sp.getLocalDate1(), "新建流程", "修改日志", window.location.pathname)
  815. $timeout(function () {
  816. window.location.href = "../../bpmn/modeler.html?copyrightid=" + $item.COPYRIGHTID + "&flowName=" + $item.CNAME + "&leftActive=" + self.active.STATUS + "&leftActiveType=" + self.active.TYPE + "&leftActiveName=" + self.active.CNAME;
  817. }, 1)
  818. } else {
  819. self.journalRecord(time1, sp.getLocalDate1(), "编辑流程", "修改日志", window.location.pathname)
  820. $item.URL = $item.URL + "&flowName=" + $item.CNAME + "&leftActive=" + self.active.STATUS + "&leftActiveType=" + self.active.TYPE + "&leftActiveName=" + self.active.CNAME;
  821. $timeout(function () {
  822. window.parent.CrossPage = {
  823. cname: "系统管理/流程管理",
  824. ctime: sp.getLocalDate1(),
  825. type: 0
  826. }
  827. window.location.href = $item.URL;
  828. }, 1)
  829. }
  830. };
  831. //检查整个流程列表的问题
  832. self.checkFlowList = function () {
  833. if (self.sortClose != 0) {
  834. return;
  835. }
  836. self.flowData.forEach(function (item, index) {
  837. var postData = {
  838. copyrightid: item.COPYRIGHTID,
  839. }
  840. $http.post(apiurljs.login + "g2work/flow/queryWorkflowErrors", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg).success(function (obj) {
  841. var res = strToJson(s4.decryptData_CBC(obj.data));
  842. self.flowData[index].errorData = res.data;
  843. });
  844. })
  845. }
  846. //复制流程
  847. self.copy = {
  848. layertitle: "流程另存为",
  849. flowkinds: "",
  850. copyrightid: "",
  851. ckey: "",
  852. cname: ""
  853. }
  854. self.openCopyFlow = function (obj) {
  855. spngvld.clear("#layer_copyFlow");
  856. self.copy.flowkinds = obj.FLOWKINDS;
  857. self.copy.copyrightid = obj.COPYRIGHTID;
  858. self.copy.ckey = obj.CKEY + "1";
  859. self.copy.cname = obj.CNAME + "1";
  860. sp.layer("#layer_copyFlow");
  861. var time1 = sp.getLocalDate1();
  862. self.ctime = sp.getLocalDate1();
  863. self.journalRecord(time1, sp.getLocalDate1(), "另存流程", "修改日志", window.location.pathname)
  864. }
  865. self.btnCopyFlow = function () {
  866. if (spngvld.submit("#layer_copyFlow")) {
  867. var data = {
  868. flowkinds: self.copy.flowkinds,
  869. copyrightid: self.copy.copyrightid,
  870. ckey: self.copy.ckey,
  871. cname: self.copy.cname
  872. }
  873. $http.post(apiurljs.login + "g2work/flow/saveasByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  874. .success(function (obj) {
  875. var res = strToJson(s4.decryptData_CBC(obj.data));
  876. sp.layerhide();
  877. if (res.success) {
  878. //self.getCodeTableOption();
  879. self.getFlowData();///加载流程
  880. } else {
  881. sp.dialog(res.message);
  882. }
  883. });
  884. };
  885. };
  886. $(function () {
  887. $("body").bind("click", function () {
  888. setTimeout(function () {
  889. if ($("#layer_sortFlowType").css("display") == "none" && self.sortClose == 1) {
  890. self.sortClose = 0;
  891. self.getFlowType();
  892. }
  893. if ($("#layer_sortFlow").css("display") == "none" && self.sortClose == 2) {
  894. self.sortClose = 0;
  895. self.getMsgData(self.active.STATUS, self.active.TYPE, self.active.CNAME);
  896. }
  897. },500)
  898. });
  899. })
  900. self.recordCtime = function () {
  901. $.cookie("CrossPage-ctime", sp.getLocalDate1(), { path: '/', expires: 1 });
  902. $.cookie("CrossPage-title", self.CrossPage.cname, { path: '/', expires: 1 });
  903. }
  904. //记录日志
  905. self.journalRecord = function (time1, time2, title, func, url) {
  906. if (!self.CrossPage.cname) { return; }
  907. var data = {
  908. tablename: "SYS_CLICKLOG",
  909. data: {
  910. CTIME: time1 == null ? sp.getLocalDate1() : time1,
  911. TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname),
  912. REQUESTURL: url,
  913. REQUESTHEADERURL: window.location.origin,
  914. LOGTYPE: func,
  915. USERTYPE: $.cookie("GlWorkPlatform-userType"),
  916. ADMIN: $.cookie("GlWorkPlatform-userTypeEng"),
  917. CLIENTIP: sp.myIP(),
  918. PCNAME: sp.detectOS(),
  919. BROWSERNAME: sp.browser(),
  920. RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2,
  921. USERID: self.userId,
  922. USERNAME: self.userCName
  923. }
  924. }
  925. $http.post(apiurljs.login + "g2app/DangJian/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  926. .success(function (res) {
  927. self.CrossPage.type = 1;
  928. })
  929. }
  930. }]);