formedit1.js 37 KB

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