formedit.js 37 KB

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