formedit.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", "$sce", function ($scope, $http, $timeout, $sce) {
  5. var self = this;
  6. var s4 = new SM4Util();
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.routeid = sp.getUrlName("routeid");
  11. self.routeinfoid = sp.getUrlName("routeinfoid");
  12. self.directionid = sp.getUrlName("directionid");
  13. self.formeditid = sp.getUrlName("formeditid");
  14. self.mbid = sp.getUrlName("mbid");
  15. self.fjid = sp.getUrlName("fjid");
  16. self.docmode = sp.getUrlName("docmode");
  17. self.dotype = sp.getUrlName("dotype");
  18. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  19. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  20. self.get_type = sp.getUrlName("type");
  21. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  22. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  23. var postCfg = {
  24. headers: {
  25. 'Content-Type': 'application/json',
  26. 'Authorization': "Bearer " + self.get_AccessToken
  27. }
  28. };
  29. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  30. //初始化右上角按钮
  31. self.buttonList = []
  32. self.readonly = {
  33. SQBM: false,
  34. SQRQ: false,
  35. SQR: false,
  36. LXDH: false,
  37. BGLX: false,
  38. BGYY: false,
  39. BGNR: false,
  40. BMFZR: false,
  41. FGWLD: false,
  42. WZYLD: false,
  43. XTZGBMYJ: false,
  44. XTGLYCZJL: false
  45. }
  46. self.getSwenList = function (n) {
  47. self.SwenList = [];
  48. var data = {
  49. directionid: self.directionid,
  50. userid: self.userId,
  51. routeinfoid: self.routeinfoid,
  52. routeid: self.routeid,
  53. formeditid: ""
  54. }
  55. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  56. .success(function (obj) {
  57. var res = strToJson(s4.decryptData_CBC(obj.data));
  58. $.each(res.data.LINKS, function (index, item) {
  59. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  60. self.Title = item.VNAME;
  61. }
  62. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  63. if (item.TEMPFORM.indexOf("attachlist") > -1) {
  64. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  65. } else {
  66. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  67. }
  68. } else {
  69. item.TEMPFORM = "#";
  70. }
  71. self.SwenList.push(item)
  72. })
  73. self.SwenList.push({
  74. VNAME: "流程图",
  75. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  76. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  77. })
  78. if (n == 0) {
  79. self.getBGLX()
  80. } else {
  81. self.getData()
  82. }
  83. })
  84. }
  85. self.getSwenList(0)
  86. self.getBGLX = function () {
  87. var data = {
  88. ckey: "CODE_BGLX",
  89. routeinfoid: self.routeinfoid
  90. }
  91. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  92. .success(function (obj) {
  93. var res = strToJson(s4.decryptData_CBC(obj.data));
  94. self.BGLX = res.data.CODE_BGLX;
  95. self.getDpList()
  96. })
  97. }
  98. self.getDpList = function () {
  99. var data = {
  100. unitid: "AA"
  101. }
  102. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  103. .success(function (obj) {
  104. var res = strToJson(s4.decryptData_CBC(obj.data));
  105. self.dpList = [];
  106. res.data.forEach(function (item) {
  107. if (item.CHILD_DATA.length == 0) {
  108. self.dpList.push(item)
  109. } else {
  110. item.CHILD_DATA.forEach(function (item1) {
  111. if (item1.CHILD_DATA.length == 0) {
  112. self.dpList.push(item1)
  113. } else {
  114. item1.CHILD_DATA.forEach(function (item2) {
  115. if (item2.CHILD_DATA.length == 0) {
  116. self.dpList.push(item2)
  117. }
  118. })
  119. }
  120. })
  121. }
  122. })
  123. self.dpList.forEach(function (item) {
  124. item.checked = false;
  125. })
  126. self.DpList = {
  127. SQBM: JSON.parse(JSON.stringify(self.dpList))
  128. }
  129. self.AllCheckedDp = {};
  130. self.DpLength = {};
  131. self.selectDpList = {};
  132. self.getUserList()
  133. })
  134. }
  135. self.getUserList = function () {
  136. $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
  137. .success(function (obj) {
  138. var res = strToJson(s4.decryptData_CBC(obj.data));
  139. self.userList = res.data;
  140. self.userList.forEach(function (item) {
  141. item.checked = false;
  142. item.USER.forEach(function (item1) {
  143. item1.checked = false;
  144. item1.USHOWNAME1 = item1.USHOWNAME.length > 3 ? item1.USHOWNAME.slice(0, 3) + "..." : item1.USHOWNAME;
  145. item1.USHOWNAME2 = item1.USHOWNAME.length > 10 ? item1.USHOWNAME.slice(0, 10) + "..." : item1.USHOWNAME
  146. })
  147. })
  148. self.UserList = {
  149. SQR: JSON.parse(JSON.stringify(self.userList)),
  150. BMFZR: JSON.parse(JSON.stringify(self.userList)),
  151. FGWLD: JSON.parse(JSON.stringify(self.userList)),
  152. WZYLD: JSON.parse(JSON.stringify(self.userList))
  153. };
  154. self.AllChecked = {};
  155. self.UserLength = {};
  156. self.selectList = {};
  157. self.getData()
  158. })
  159. }
  160. //获取数据
  161. self.getData = function () {
  162. var data = {
  163. ckey: "SX_OABGD",
  164. id: 0,
  165. directionid: self.directionid,
  166. formeditid: self.formeditid,
  167. routeid: self.routeid,
  168. routeinfoid: self.routeinfoid
  169. }
  170. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  171. .success(function (obj) {
  172. var res = strToJson(s4.decryptData_CBC(obj.data));
  173. self.data = {
  174. ID: res.data.SX_OABGD.ID,
  175. APPCODE: res.data.SX_OABGD.APPCODE,
  176. SQBM: res.data.SX_OABGD.SQBM,
  177. SQRQ: res.data.SX_OABGD.SQRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_OABGD.SQRQ),
  178. SQR: res.data.SX_OABGD.SQR,
  179. LXDH: res.data.SX_OABGD.LXDH,
  180. BGLX: res.data.SX_OABGD.BGLX == "" ? self.BGLX[0].CODE : res.data.SX_OABGD.BGLX,
  181. BGYY: res.data.SX_OABGD.BGYY,
  182. BGNR: res.data.SX_OABGD.BGNR,
  183. BMFZR: res.data.SX_OABGD.BMFZR,
  184. FGWLD: res.data.SX_OABGD.FGWLD,
  185. WZYLD: res.data.SX_OABGD.WZYLD,
  186. XTZGBMYJ: res.data.SX_OABGD.XTZGBMYJ,
  187. XTGLYCZJL: res.data.SX_OABGD.XTGLYCZJL
  188. }
  189. self.readonly = {
  190. SQBM: res.data.SX_OABGD["SQBM.EREADONLY"] == "true",
  191. SQRQ: res.data.SX_OABGD["SQRQ.EREADONLY"] == "true",
  192. SQR: res.data.SX_OABGD["SQR.EREADONLY"] == "true",
  193. LXDH: res.data.SX_OABGD["LXDH.EREADONLY"] == "true",
  194. BGLX: res.data.SX_OABGD["BGLX.EREADONLY"] == "true",
  195. BGYY: res.data.SX_OABGD["BGYY.EREADONLY"] == "true",
  196. BGNR: res.data.SX_OABGD["BGNR.EREADONLY"] == "true",
  197. BMFZR: res.data.SX_OABGD["BMFZR.EREADONLY"] == "true",
  198. FGWLD: res.data.SX_OABGD["FGWLD.EREADONLY"] == "true",
  199. WZYLD: res.data.SX_OABGD["WZYLD.EREADONLY"] == "true",
  200. XTZGBMYJ: res.data.SX_OABGD["XTZGBMYJ.EREADONLY"] == "true",
  201. XTGLYCZJL: res.data.SX_OABGD["XTGLYCZJL.EREADONLY"] == "true"
  202. }
  203. if (self.data.ID == 0) {
  204. self.filedChange = true;
  205. } else {
  206. self.filedChange = false;
  207. }
  208. self.buttonList = res.data["SX_OABGD.FUNCLIST"];
  209. var n = {}, all = {};
  210. for (var i in self.UserList) {
  211. self.AllChecked[i] = false;
  212. self.UserLength[i] = 0;
  213. self.selectList[i] = []
  214. n[i] = [];
  215. all[i] = 0;
  216. $.each(self.UserList[i], function (index, item) {
  217. n[i].push(0)
  218. $.each(item.USER, function (index1, item1) {
  219. self.UserLength[i]++
  220. if (self.data.SQR.indexOf(item1.USHOWNAME) != -1 && i == "SQR") {
  221. n[i][index]++;
  222. item1.checked = true;
  223. self.selectList[i].push(item1);
  224. }
  225. })
  226. if (n[i][index] == item.USER.length && n[i][index] != 0) {
  227. item.checked = true;
  228. all[i]++;
  229. } else {
  230. item.checked == false;
  231. }
  232. })
  233. if (all[i] == self.UserList[i].length) {
  234. self.AllChecked[i] = true;
  235. } else {
  236. self.AllChecked[i] = false;
  237. }
  238. }
  239. for (var i in self.DpList) {
  240. self.AllCheckedDp[i] = false;
  241. self.DpLength[i] = 0;
  242. self.selectDpList[i] = []
  243. all[i] = 0;
  244. $.each(self.DpList[i], function (index, item) {
  245. self.DpLength[i]++
  246. if (self.data.SQBM.indexOf(item.SECTION) != -1 && i == "SQBM") {
  247. all[i]++;
  248. item.checked = true;
  249. self.selectDpList[i].push(item);
  250. }
  251. })
  252. if (all[i] == self.DpList[i].length) {
  253. self.AllCheckedDp[i] = true;
  254. } else {
  255. self.AllCheckedDp[i] = false;
  256. }
  257. }
  258. self.getOpinion('XTZGBMYJ')
  259. //watermark({
  260. // "watermarl_element": "app",
  261. // "watermark_txt": "测试水印内容",
  262. // "watermark_width": 150,
  263. // "watermark_height": 110,
  264. // "watermark_angle": 345
  265. //})
  266. })
  267. }
  268. //获取意见
  269. self.getOpinion = function (str) {
  270. var data = {
  271. cmanid: self.userId,
  272. routeinfoid: self.routeinfoid,
  273. routeid: "",//self.routeid,
  274. tableid: "SX_OABGD",
  275. colid: str,
  276. opiniontype: 0,
  277. orderbycol: "CDATE desc"
  278. }
  279. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  280. .success(function (obj) {
  281. var res = strToJson(s4.decryptData_CBC(obj.data));
  282. if (res.success == true) {
  283. self.YJ[str] = res.data;
  284. self.YJ[str + "STATUS"] = false;
  285. self.YJ[str].forEach(function (item) {
  286. item.CDATE = sp.datefmt("yyyy-MM-dd HH:mm", item.CDATE);
  287. if (item.ROUTEID == self.routeid) {
  288. self.YJ[str + "STATUS"] = true;
  289. }
  290. })
  291. } else {
  292. sp.dialog(res.message)
  293. }
  294. })
  295. }
  296. //判断页面字段是否只读readonly、是否隐藏show
  297. self.hide = function (type, field) {
  298. if (self.dotype == 0 && type == "readonly") {
  299. return true;
  300. } else {
  301. if (self[type][field] == true) {
  302. return true;
  303. } else {
  304. return false;
  305. }
  306. }
  307. }
  308. //右上角按钮调用方法
  309. self.btnEvent = function (item) {
  310. switch (item.CODE) {
  311. case "SAVEITEM": self.btnSave(0); break;
  312. case "PRINTITEM": self.btnPrint(); break;
  313. case "MEETITEM": self.Meet(); break;
  314. case "SENDLOG": self.RouteList(); break;
  315. default: self.forward(item); break;
  316. }
  317. }
  318. self.openDpList = function (str) {
  319. if (self.hide("readonly", str) == true) {
  320. return
  321. } else {
  322. self.filed = str;
  323. //self.AllCheckedDp = false;
  324. sp.layer("#DpList")
  325. $("#DpList .sp-page").eq(0).scrollTop(0);
  326. }
  327. }
  328. self.checkAllDp = function () {
  329. self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
  330. $.each(self.DpList[self.filed], function (index, item) {
  331. item.checked = self.AllCheckedDp[self.filed];
  332. })
  333. self.submitDpList(1)
  334. }
  335. self.checkDpItem = function (item) {
  336. item.checked = !item.checked;
  337. var n = 0;
  338. $.each(self.DpList[self.filed], function (index, item) {
  339. if (item.checked == true) {
  340. n++
  341. }
  342. })
  343. if (n == self.DpList[self.filed].length) {
  344. self.AllCheckedDp[self.filed] = true;
  345. } else {
  346. self.AllCheckedDp[self.filed] = false;
  347. }
  348. self.submitDpList(1)
  349. }
  350. self.submitDpList = function (n) {
  351. var AllCheckedLength1 = 0;
  352. self.selectDpList[self.filed] = [];
  353. $.each(self.DpList[self.filed], function (index, item) {
  354. if (item.checked == true) {
  355. AllCheckedLength1++;
  356. self.selectDpList[self.filed].push(item)
  357. }
  358. })
  359. self.data[self.filed] = self.selectDpList[self.filed].map(function (item) {
  360. return item.SECTION
  361. }).join(",")
  362. self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
  363. self.changeFiled(self.filed)
  364. if (n == 0) {
  365. sp.layerhide();
  366. }
  367. }
  368. self.openUserList = function (str) {
  369. if (self.hide("readonly", str) == true) {
  370. return
  371. } else {
  372. self.filed = str;
  373. //self.AllChecked[self.filed] = false;
  374. sp.layer("#userList")
  375. $("#userList .sp-page").eq(0).scrollTop(0);
  376. }
  377. }
  378. self.checkAllUser = function () {
  379. self.AllChecked[self.filed] = !self.AllChecked[self.filed];
  380. $.each(self.UserList[self.filed], function (index, item) {
  381. item.checked = self.AllChecked[self.filed];
  382. $.each(item.USER, function (index1, item1) {
  383. item1.checked = self.AllChecked[self.filed];
  384. })
  385. })
  386. self.submitUserList(1)
  387. }
  388. self.checkUserItem = function (item) {
  389. item.checked = !item.checked;
  390. $.each(item.USER, function (index, item1) {
  391. item1.checked = item.checked;
  392. })
  393. var n = 0;
  394. $.each(self.UserList[self.filed], function (index, item) {
  395. if (item.checked == true) {
  396. n++
  397. }
  398. })
  399. if (n == self.UserList[self.filed].length) {
  400. self.AllChecked[self.filed] = true;
  401. } else {
  402. self.AllChecked[self.filed] = false;
  403. }
  404. self.submitUserList(1)
  405. }
  406. self.checkUser = function (item) {
  407. item.checked = !item.checked;
  408. var n = [], all = 0;
  409. $.each(self.UserList[self.filed], function (x, y) {
  410. n.push(0);
  411. $.each(y.USER, function (x1, y1) {
  412. if (y1.checked == true) {
  413. n[x]++
  414. }
  415. })
  416. if (n[x] == y.USER.length && n[x] != 0) {
  417. y.checked = true;
  418. all++
  419. } else {
  420. y.checked = false;
  421. }
  422. })
  423. if (all == self.UserList[self.filed].length) {
  424. self.AllChecked[self.filed] = true;
  425. } else {
  426. self.AllChecked[self.filed] = false;
  427. }
  428. self.submitUserList(1)
  429. }
  430. self.submitUserList = function (n) {
  431. var AllCheckedLength = 0;
  432. self.selectList[self.filed] = [];
  433. $.each(self.UserList[self.filed], function (index, item) {
  434. $.each(item.USER, function (index1, item1) {
  435. if (item1.checked == true) {
  436. AllCheckedLength++;
  437. self.selectList[self.filed].push(item1)
  438. }
  439. })
  440. })
  441. self.data[self.filed] = self.selectList[self.filed].map(function (item) {
  442. return item.USHOWNAME
  443. }).join(",")
  444. if (self.data[self.filed + "ID"] != undefined) {
  445. self.data[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
  446. return item.USERID
  447. }).join(",")
  448. }
  449. self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
  450. self.changeFiled(self.filed)
  451. if (n == 0) {
  452. sp.layerhide();
  453. }
  454. }
  455. //保存提交
  456. self.btnSave = function (n) {
  457. if (spngvld.submit(".sp-page-center")) {
  458. var dataArray = [];
  459. self.data.XTZGBMYJ = "";
  460. dataArray.push(self.data);
  461. var data = {
  462. ckey: "SX_OABGD",
  463. id: self.data.ID,
  464. routeid: self.routeid,
  465. routeinfoid: self.routeinfoid,
  466. routeinfotitle: self.data.SQR + "的申请",//self.data.BT,
  467. directionid: self.directionid,
  468. formeditid: self.formeditid,
  469. data: JSON.stringify(dataArray)
  470. }
  471. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  472. .success(function (obj) {
  473. var res = strToJson(s4.decryptData_CBC(obj.data));
  474. if (res.code == 0) {
  475. self.data.ID = res.data.ID;
  476. self.routeid = res.data.ROUTEID;
  477. self.routeinfoid = res.data.ROUTEINFOID;
  478. self.filedChange = false;
  479. if (n == 0) {
  480. sp.dialog("保存成功!");
  481. $timeout(function () {
  482. sp.dialoghide()
  483. }, 1500)
  484. self.getSwenList(1)
  485. } else if (n == 1) {
  486. self.forward(self.btnItem);
  487. } else {
  488. self.sendAll();
  489. }
  490. } else {
  491. sp.dialog(res.message)
  492. }
  493. })
  494. }
  495. }
  496. //打印
  497. self.btnPrint = function () {
  498. // 创建隐藏的可下载链接
  499. var eleLink = document.createElement('a');
  500. eleLink.download = "";
  501. eleLink.style.display = 'none';
  502. eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=XZGZDT.ftl&tablename=SX_OABGD&outfilepath=/tmp/oa变更单.wps&prtdate=RIQI&routeinfoid=" + self.routeinfoid));
  503. // 触发点击
  504. document.body.appendChild(eleLink);
  505. eleLink.click();
  506. // 然后移除
  507. document.body.removeChild(eleLink);
  508. //window.open(apiurljs.login + "g2app/shouwen/PrintWord?templatefilename=shouwen.ftl&tablename=SX_OABGD&outfilepath=" + apiurljs.print + "&routeinfoid=" + self.routeinfoid)
  509. }
  510. //下载附件
  511. self.download = function (item) {
  512. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  513. }
  514. //删除附件
  515. self.deleteFile = function (item, str) {
  516. var data = {
  517. tablename: "SX_OABGD",
  518. column: str,
  519. routeinfoid: self.routeinfoid,
  520. fileid: item.FILEID,
  521. filenames: item.FILEOLDNAME
  522. }
  523. $http.post(apiurljs.login + "g2app/abase/deleteUploadFileName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  524. .success(function (obj) {
  525. var res = strToJson(s4.decryptData_CBC(obj.data));
  526. if (res.success == true) {
  527. self.arrayFile = res.data;
  528. } else {
  529. sp.dialog(res.message)
  530. }
  531. })
  532. }
  533. //签写意见编辑状态
  534. self.opinion = {
  535. XTZGBMYJ: false,
  536. XTZGBMYJImg: false
  537. }
  538. self.YJ = {
  539. XTZGBMYJ: [],
  540. XTZGBMYJSTATUS: false
  541. }
  542. //下载意见表附件
  543. self.downLoadOption = function (item) {
  544. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  545. }
  546. //删除意见表附件
  547. self.deleteOptionFile = function (file, str) {
  548. var data = {
  549. routeid: file.ROUTEID,
  550. tableid: "SX_OABGD",
  551. colid: str,
  552. fileid: file.FILEID
  553. };
  554. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  555. .success(function (obj) {
  556. var res = strToJson(s4.decryptData_CBC(obj.data));
  557. sp.dialoghide();
  558. if (res.success) {
  559. self.getOpinion(str);
  560. } else {
  561. sp.dialog("删除失败,请联系管理员!");
  562. }
  563. });
  564. }
  565. //意见附件(上表)
  566. self.upload2 = function (str) {
  567. $('#fileupload-' + str).fileupload({
  568. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  569. dataType: 'json',
  570. beforeSend: function (xhr, data) {
  571. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  572. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  573. + ",routeid=" + self.routeid + ",tableid=SX_OABGD,colid=" + str));
  574. },
  575. // 上传完成后的执行逻辑
  576. done: function (e, data) {
  577. self.uploading1 = false;
  578. self.getOpinion(str)
  579. }
  580. })
  581. }
  582. //签写意见
  583. self.openOpinion = function (str) {
  584. if (self.routeinfoid == 0 && self.routeid == 0) {
  585. sp.dialog("请先保存!")
  586. return;
  587. }
  588. self.opinion[str] = true;
  589. }
  590. //修改意见
  591. self.changeOpinion = function (str) {
  592. self.data[str] = self.YJ[str][0].OPINION;
  593. self.opinion[str] = true;
  594. }
  595. self.changeOpinionItem = function (str, item) {
  596. if (item.OPINIONIMAGE != "") {
  597. self.QianZi(str);
  598. self.opinion[str + "Img"] = true;
  599. }
  600. self.data[str] = item.OPINION;
  601. self.opinion[str] = true;
  602. }
  603. //提交意见
  604. self.Sopinion = function (str) {
  605. if (self.opinion[str + "Img"] == true) {
  606. self.data[str] = $("#" + str + "QZ").find("canvas")[0].toDataURL();
  607. } else {
  608. self.data[str] = $("#" + str).val();
  609. }
  610. var data = {
  611. cmanid: self.userId,
  612. routeinfoid: self.routeinfoid,
  613. routeid: self.routeid,
  614. tableid: "SX_OABGD",
  615. colid: str,
  616. opiniontype: 0,
  617. cresult: "",
  618. opinion: self.opinion[str + "Img"] == false ? self.data[str] : "",
  619. opinionimage: self.opinion[str + "Img"] == true ? self.data[str] : ""
  620. }
  621. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  622. .success(function (obj) {
  623. var res = strToJson(s4.decryptData_CBC(obj.data));
  624. if (res.success == true) {
  625. sp.dialog("保存成功!");
  626. self.getOpinion(str);
  627. self.opinion[str] = false;
  628. self.opinion[str + "Img"] = false;
  629. self.data[str] = "";
  630. self.changeFiled(str)
  631. } else {
  632. sp.dialog(res.message)
  633. }
  634. })
  635. }
  636. //删除意见
  637. self.Dopinion = function (str, item) {
  638. var data = {
  639. cmanid: self.userId,
  640. routeid: self.routeid,
  641. tableid: "SX_OABGD",
  642. colid: str,
  643. }
  644. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  645. .success(function (obj) {
  646. var res = strToJson(s4.decryptData_CBC(obj.data));
  647. if (res.success == true) {
  648. self.getOpinion(str);
  649. self.changeFiled(str)
  650. } else {
  651. sp.dialog(res.message)
  652. }
  653. })
  654. }
  655. self.phraseText = "";//添加常用语
  656. self.phraseList = []//常用语列表
  657. //获取常用语库
  658. self.phrase = function (colid) {
  659. sp.layer("#phrase");
  660. self.colid = colid;
  661. self.getPhrase();
  662. }
  663. //添加常用语到常用语库
  664. self.Aphrase = function () {
  665. if (self.phraseText == "") {
  666. return;
  667. }
  668. var data = {
  669. cmanid: self.userId,
  670. tableid: "SX_OABGD",
  671. colid: self.colid,
  672. contents: self.phraseText
  673. }
  674. $http.post(apiurljs.login + "g2app/abase/insertDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  675. .success(function (obj) {
  676. var res = strToJson(s4.decryptData_CBC(obj.data));
  677. if (res.success == true) {
  678. self.phraseText = "";
  679. self.getPhrase();
  680. } else {
  681. sp.dialog(res.message)
  682. }
  683. })
  684. }
  685. //获取常用语库
  686. self.getPhrase = function () {
  687. var data = {
  688. cmanid: self.userId,
  689. tableid: "SX_OABGD",
  690. colid: self.colid
  691. }
  692. $http.post(apiurljs.login + "g2app/abase/queryDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  693. .success(function (obj) {
  694. var res = strToJson(s4.decryptData_CBC(obj.data));
  695. self.phraseList = res.data;
  696. self.phraseSelect = self.phraseList[0].CONTENTS;
  697. })
  698. }
  699. //从常用语库删除
  700. self.Dphrase = function () {
  701. var id = null;
  702. $.each(self.phraseList, function (index, item) {
  703. if (item.CONTENTS == self.phraseSelect) {
  704. id = item.ID;
  705. }
  706. })
  707. var data = {
  708. id: id
  709. }
  710. $http.post(apiurljs.login + "g2app/abase/deleteDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  711. .success(function (obj) {
  712. var res = strToJson(s4.decryptData_CBC(obj.data));
  713. self.getPhrase();
  714. })
  715. }
  716. //常用语确认为意见
  717. self.btnPhrase = function () {
  718. if (!self.colid) {
  719. self.nulla = self.phraseSelect;
  720. } else {
  721. self.data[self.colid] = self.phraseSelect;
  722. }
  723. sp.layerhide();
  724. }
  725. //签字—手写
  726. self.QianZi = function (str) {
  727. self.opinion[str + "Img"] = true;
  728. setTimeout(function () {
  729. new lineCanvas(str + "QZ")
  730. }, 1)
  731. }
  732. //清除手写
  733. self.canvasClear = function (str) {
  734. var cxt = $("#" + str + "QZ").find("canvas")[0].getContext("2d");
  735. cxt.clearRect(0, 0, $("#" + str + "QZ").find("canvas")[0].width, $("#" + str + "QZ").find("canvas")[0].height)
  736. }
  737. //发生修改
  738. self.changeFiled = function (str) {
  739. self.filedChange = true;
  740. }
  741. //转发
  742. self.forward = function (obj) {
  743. self.btnItem = obj;
  744. if (self.filedChange == true) {
  745. self.btnSave(1)
  746. } else {
  747. $("#forwardWin").attr("src", "../../forward/forward.html?routeid=" + self.routeid + "&routeinfoid=" + self.routeinfoid + "&copyrightid=" + self.copyrightid + "&directionid=" + self.directionid + "&formeditid=" + self.formeditid + "&codefuncbutton=" + obj.CODE + "&directionidtarget=" + obj.DIRECTIONIDTARGET + "&cookie=oabgmgr")
  748. sp.layer("#forward")
  749. }
  750. }
  751. //查看流转记录
  752. self.RouteList = function () {
  753. if (self.deviceType == "pad") {
  754. window.location.href = "../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  755. } else {
  756. sp.openNewWindow("../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1], "流程图")
  757. }
  758. //var data = {
  759. // directionid: self.directionid,
  760. // userid: self.userId,
  761. // routeid: self.routeid,
  762. // routeinfoid: self.routeinfoid,
  763. //}
  764. //$http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  765. //.success(function (obj) {
  766. // var res = strToJson(s4.decryptData_CBC(obj.data));
  767. // self.routeList = res.data;
  768. // $.each(self.routeList, function (index, item) {
  769. // item.mainUser = [];
  770. // item.copyUsers = [];
  771. // $.each(item.USERS, function (index1, item1) {
  772. // if (item1.KIND == 0) {
  773. // item.mainUser.push(item1.USERNAME);
  774. // } else {
  775. // item.copyUsers.push(item1.USERNAME);
  776. // }
  777. // })
  778. // item.mainUser = item.mainUser.join(",");
  779. // item.copyUsers = item.copyUsers.join(",");
  780. // })
  781. // setTimeout(function (item) {
  782. // sp.layer("#RouteList");
  783. // }, 100);
  784. //})
  785. }
  786. //头部下滚冻结
  787. $(function () {
  788. $(".sp-page-center").eq(0).css("max-height", $(window).height() - 160).css("height", $(window).height() - 160)
  789. //$("body").bind("scroll", function () {
  790. // var scrollTop = $("body").scrollTop();
  791. // if (scrollTop == 0) {
  792. // $(".FixTop").removeClass("FixTop");
  793. // }
  794. // if (scrollTop > 35) {
  795. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  796. // }
  797. //});
  798. //页面高度撑满
  799. setTimeout(function () {
  800. if ($(".ibox-content").height() < $(window).height() - 31) {
  801. $(".ibox-content").css("height", $(window).height() - 31)
  802. }
  803. }, 1)
  804. sp.drag("#leftPart")
  805. })
  806. }])
  807. app.filter('trustHtml', function ($sce) {
  808. return function (input) {
  809. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  810. };
  811. });
  812. //canvas画布签字
  813. function lineCanvas(obj) {
  814. var self = this;
  815. self.linewidth = 1;
  816. self.color = "#000000";
  817. self.background = "#ffffff";
  818. self.canvas = document.createElement("canvas");
  819. document.getElementById(obj).appendChild(self.canvas);
  820. self.cxt = self.canvas.getContext("2d");
  821. self.canvas.width = document.getElementById(obj).clientWidth;
  822. self.canvas.height = document.getElementById(obj).scrollHeight;
  823. self.cxt.fillStyle = self.background;
  824. self.cxt.fillRect(0, 0, self.canvas.width, self.canvas.width);
  825. self.cxt.strokeStyle = self.color;
  826. self.cxt.lineWidth = self.linewidth;
  827. self.cxt.lineCap = "round";
  828. //开始绘制
  829. self.canvas.addEventListener("mousedown", function (e) {
  830. self.cxt.beginPath();
  831. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  832. self.canvas.addEventListener("mousemove", move)
  833. }.bind(self), false);
  834. //绘制中
  835. function move() {
  836. var e = window.event;
  837. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  838. self.cxt.stroke();
  839. }
  840. //结束绘制
  841. self.canvas.addEventListener("mouseup", up)
  842. function up() {
  843. self.cxt.closePath();
  844. self.canvas.removeEventListener("mousemove", move)
  845. }
  846. };