yuguidang - 副本 .js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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.routeinfoid = sp.getUrlName("routeinfoid");
  11. self.id = sp.getUrlName("id");
  12. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  13. self.info = JSON.parse($.cookie("GlWorkPlatform-gdsp"))
  14. self.guidangList = []
  15. var postCfg = {
  16. headers: {
  17. 'Content-Type': 'application/json',
  18. 'Authorization': "Bearer " + self.get_AccessToken
  19. }
  20. };
  21. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  22. //初始化右上角按钮
  23. self.buttonList = []
  24. self.readonly = {
  25. LC: false,
  26. BT: false,
  27. WH: false,
  28. GDCS: false,
  29. GDRY: false,
  30. CSYJ: false,
  31. BZ: false
  32. }
  33. self.getDpList = function () {
  34. var data = {
  35. unitid: "AA"
  36. }
  37. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  38. .success(function (obj) {
  39. var res = strToJson(s4.decryptData_CBC(obj.data));
  40. self.dpList = [];
  41. res.data.forEach(function (item) {
  42. if (item.CHILD_DATA.length == 0) {
  43. self.dpList.push(item)
  44. } else {
  45. item.CHILD_DATA.forEach(function (item1) {
  46. if (item1.CHILD_DATA.length == 0) {
  47. self.dpList.push(item1)
  48. } else {
  49. item1.CHILD_DATA.forEach(function (item2) {
  50. if (item2.CHILD_DATA.length == 0) {
  51. self.dpList.push(item2)
  52. }
  53. })
  54. }
  55. })
  56. }
  57. })
  58. self.dpList.forEach(function (item) {
  59. item.checked = false;
  60. })
  61. self.DpList = {
  62. GDCS: JSON.parse(JSON.stringify(self.dpList))
  63. }
  64. self.AllCheckedDp = {};
  65. self.DpLength = {};
  66. self.selectDpList = {};
  67. self.getUserList()
  68. })
  69. }
  70. self.getDpList()
  71. self.getUserList = function () {
  72. $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
  73. .success(function (obj) {
  74. var res = strToJson(s4.decryptData_CBC(obj.data));
  75. self.userList = res.data;
  76. self.userList.forEach(function (item) {
  77. item.checked = false;
  78. item.USER.forEach(function (item1) {
  79. item1.checked = false;
  80. item1.USHOWNAME1 = item1.USHOWNAME.length > 3 ? item1.USHOWNAME.slice(0, 3) + "..." : item1.USHOWNAME;
  81. item1.USHOWNAME2 = item1.USHOWNAME.length > 10 ? item1.USHOWNAME.slice(0, 10) + "..." : item1.USHOWNAME
  82. })
  83. })
  84. self.UserList = {
  85. GDRY: JSON.parse(JSON.stringify(self.userList))
  86. };
  87. self.AllChecked = {};
  88. self.UserLength = {};
  89. self.selectList = {};
  90. self.getDP()
  91. })
  92. }
  93. self.getDP = function () {
  94. var data = {
  95. userid: self.userId
  96. }
  97. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  98. .success(function (obj) {
  99. var res = strToJson(s4.decryptData_CBC(obj.data));
  100. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  101. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  102. self.getGDBM();
  103. })
  104. }
  105. self.getGDBM = function () {
  106. var data = {
  107. unitid: "AA"
  108. }
  109. $http.post(apiurljs.login + "g2app/dataabase/queryDanganSectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  110. .success(function (obj) {
  111. var res = strToJson(s4.decryptData_CBC(obj.data));
  112. self.GDBM = res.data;
  113. if (self.routeinfoid == 0) {
  114. self.getWENHAO();
  115. } else {
  116. self.getData();
  117. }
  118. })
  119. }
  120. self.getWENHAO = function () {
  121. var data = {
  122. routeinfoid: self.info.ROUTEINFOID,
  123. flowid:self.info.FLOWID
  124. }
  125. $http.post(apiurljs.login + "g2app/DangAn/queryDataByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  126. .success(function (obj) {
  127. var res = strToJson(s4.decryptData_CBC(obj.data));
  128. if (res.data.length > 0) {
  129. self.WENHAO = res.data[0].WENHAO;
  130. } else {
  131. self.WENHAO = "";
  132. }
  133. self.getData();
  134. })
  135. }
  136. //获取数据
  137. self.getData = function () {
  138. var data = {
  139. tablename: "DA_DAYUGUIDANG",
  140. colums: "*",
  141. order: "ID",
  142. sqlwhere: { ID: self.id },
  143. sqlinwhere: "",
  144. sqllikewhere: ""
  145. }
  146. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  147. .success(function (obj) {
  148. var res = strToJson(s4.decryptData_CBC(obj.data));
  149. if (res.data[0]) {
  150. self.data = {
  151. ID: res.data[0].ID,
  152. LC: res.data[0].LC,
  153. BT: res.data[0].BT,
  154. WH: res.data[0].WH,
  155. GDCS: res.data[0].GDCS,
  156. GDRY: res.data[0].GDRY,
  157. BZ: res.data[0].BZ,
  158. ARCHYEAR: res.data[0].ARCHYEAR,
  159. ORGANIZATIONMA: res.data[0].ORGANIZATIONMA,
  160. WENHAO: res.data[0].WENHAO,
  161. MIJIQIXIAN: res.data[0].MIJIQIXIAN,
  162. DANGANML: res.data[0].DANGANML,
  163. DOCUMENTTYPE: res.data[0].DOCUMENTTYPE,
  164. DOCTITLE: res.data[0].DOCTITLE,
  165. ZRZ: res.data[0].ZRZ,
  166. DOCISSUEDDATE: sp.format(res.data[0].DOCISSUEDDATE),
  167. JIANHAO: res.data[0].JIANHAO,
  168. YESHU: res.data[0].YESHU,
  169. BEIZHU: res.data[0].BEIZHU,
  170. ARCHCODE: res.data[0].ARCHCODE,
  171. DAROUTEINFOID: res.data[0].DAROUTEINFOID,
  172. DPNAME: res.data[0].DPNAME,
  173. DPCODE: res.data[0].DPCODE,
  174. MOBANNAME: res.data[0].MOBANNAME,
  175. TABLENAME: res.data[0].TABLENAME
  176. }
  177. } else {
  178. self.data = {
  179. ID: 0,
  180. LC: self.info.FLOWNAME,
  181. BT: self.info.TITLE,
  182. WH: self.WENHAO,
  183. GDCS: self.userDpName,
  184. GDRY: self.userName,
  185. BZ: "",
  186. ARCHYEAR: sp.currentYear(),
  187. ORGANIZATIONMA: self.userDpCode,
  188. WENHAO: self.WENHAO,
  189. MIJIQIXIAN: "10年",
  190. DANGANML: "文书",
  191. DOCUMENTTYPE: self.info.FLOWNAME,
  192. DOCTITLE: self.info.TITLE,
  193. ZRZ: "",
  194. DOCISSUEDDATE: sp.format(sp.getLocalDate()),
  195. JIANHAO: 1,
  196. YESHU: "",
  197. BEIZHU: "",
  198. ARCHCODE: "",
  199. DAROUTEINFOID: self.info.ROUTEINFOID,
  200. DPNAME: self.userDpName,
  201. DPCODE: self.userDpCode,
  202. MOBANNAME: self.info.MOBANNAME,
  203. TABLENAME: self.info.TABLENAME
  204. }
  205. }
  206. $scope.data = self.data;
  207. var n = {}, all = {};
  208. for (var i in self.UserList) {
  209. self.AllChecked[i] = false;
  210. self.UserLength[i] = 0;
  211. self.selectList[i] = []
  212. n[i] = [];
  213. all[i] = 0;
  214. $.each(self.UserList[i], function (index, item) {
  215. n[i].push(0)
  216. $.each(item.USER, function (index1, item1) {
  217. self.UserLength[i]++
  218. if (self.data.GDRY.indexOf(item1.USHOWNAME) != -1 && i == "GDRY") {
  219. n[i][index]++;
  220. item1.checked = true;
  221. self.selectList[i].push(item1);
  222. }
  223. })
  224. if (n[i][index] == item.USER.length && n[i][index] != 0) {
  225. item.checked = true;
  226. all[i]++;
  227. } else {
  228. item.checked == false;
  229. }
  230. })
  231. if (all[i] == self.UserList[i].length) {
  232. self.AllChecked[i] = true;
  233. } else {
  234. self.AllChecked[i] = false;
  235. }
  236. }
  237. for (var i in self.DpList) {
  238. self.AllCheckedDp[i] = false;
  239. self.DpLength[i] = 0;
  240. self.selectDpList[i] = []
  241. all[i] = 0;
  242. $.each(self.DpList[i], function (index, item) {
  243. self.DpLength[i]++
  244. if (self.data.GDCS.indexOf(item.SECTION) != -1 && i == "GDCS") {
  245. all[i]++;
  246. item.checked = true;
  247. self.selectDpList[i].push(item);
  248. }
  249. })
  250. if (all[i] == self.DpList[i].length) {
  251. self.AllCheckedDp[i] = true;
  252. } else {
  253. self.AllCheckedDp[i] = false;
  254. }
  255. }
  256. })
  257. }
  258. self.openDpList = function (str) {
  259. self.filed = str;
  260. sp.layer("#DpList")
  261. $("#DpList .sp-page").eq(0).scrollTop(0);
  262. }
  263. self.checkAllDp = function () {
  264. self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
  265. $.each(self.DpList[self.filed], function (index, item) {
  266. item.checked = self.AllCheckedDp[self.filed];
  267. })
  268. self.submitDpList(1)
  269. }
  270. self.checkDpItem = function (item) {
  271. item.checked = !item.checked;
  272. var n = 0;
  273. $.each(self.DpList[self.filed], function (index, item) {
  274. if (item.checked == true) {
  275. n++
  276. }
  277. })
  278. if (n == self.DpList[self.filed].length) {
  279. self.AllCheckedDp[self.filed] = true;
  280. } else {
  281. self.AllCheckedDp[self.filed] = false;
  282. }
  283. self.submitDpList(1)
  284. }
  285. self.submitDpList = function (n) {
  286. var AllCheckedLength1 = 0;
  287. self.selectDpList[self.filed] = [];
  288. $.each(self.DpList[self.filed], function (index, item) {
  289. if (item.checked == true) {
  290. AllCheckedLength1++;
  291. self.selectDpList[self.filed].push(item)
  292. }
  293. })
  294. self.data[self.filed] = self.selectDpList[self.filed].map(function (item) {
  295. return item.SECTION
  296. }).join(",")
  297. self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
  298. if (n == 0) {
  299. sp.layerhide();
  300. }
  301. }
  302. self.openUserList = function (str) {
  303. self.filed = str;
  304. sp.layer("#userList")
  305. $("#userList .sp-page").eq(0).scrollTop(0);
  306. }
  307. self.checkAllUser = function () {
  308. self.AllChecked[self.filed] = !self.AllChecked[self.filed];
  309. $.each(self.UserList[self.filed], function (index, item) {
  310. item.checked = self.AllChecked[self.filed];
  311. $.each(item.USER, function (index1, item1) {
  312. item1.checked = self.AllChecked[self.filed];
  313. })
  314. })
  315. self.submitUserList(1)
  316. }
  317. self.checkUserItem = function (item) {
  318. item.checked = !item.checked;
  319. $.each(item.USER, function (index, item1) {
  320. item1.checked = item.checked;
  321. })
  322. var n = 0;
  323. $.each(self.UserList[self.filed], function (index, item) {
  324. if (item.checked == true) {
  325. n++
  326. }
  327. })
  328. if (n == self.UserList[self.filed].length) {
  329. self.AllChecked[self.filed] = true;
  330. } else {
  331. self.AllChecked[self.filed] = false;
  332. }
  333. self.submitUserList(1)
  334. }
  335. self.checkUser = function (item) {
  336. item.checked = !item.checked;
  337. var n = [], all = 0;
  338. $.each(self.UserList[self.filed], function (x, y) {
  339. n.push(0);
  340. $.each(y.USER, function (x1, y1) {
  341. if (y1.checked == true) {
  342. n[x]++
  343. }
  344. })
  345. if (n[x] == y.USER.length && n[x] != 0) {
  346. y.checked = true;
  347. all++
  348. } else {
  349. y.checked = false;
  350. }
  351. })
  352. if (all == self.UserList[self.filed].length) {
  353. self.AllChecked[self.filed] = true;
  354. } else {
  355. self.AllChecked[self.filed] = false;
  356. }
  357. self.submitUserList(1)
  358. }
  359. self.submitUserList = function (n) {
  360. var AllCheckedLength = 0;
  361. self.selectList[self.filed] = [];
  362. $.each(self.UserList[self.filed], function (index, item) {
  363. $.each(item.USER, function (index1, item1) {
  364. if (item1.checked == true) {
  365. AllCheckedLength++;
  366. self.selectList[self.filed].push(item1)
  367. }
  368. })
  369. })
  370. self.data[self.filed] = self.selectList[self.filed].map(function (item) {
  371. return item.USHOWNAME
  372. }).join(",")
  373. if (self.data[self.filed + "ID"] != undefined) {
  374. self.data[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
  375. return item.USERID
  376. }).join(",")
  377. }
  378. self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
  379. if (n == 0) {
  380. sp.layerhide();
  381. }
  382. }
  383. //保存提交
  384. self.btnSave = function (n) {
  385. var data = {
  386. tablename: "DA_DAYUGUIDANG",
  387. id: self.data.ID,
  388. data: {
  389. LC: self.data.LC,
  390. BT: self.data.BT,
  391. WH: self.data.WH,
  392. GDCS: self.data.GDCS,
  393. GDRY: self.data.GDRY,
  394. BZ: self.data.BZ,
  395. ARCHYEAR: self.data.ARCHYEAR,
  396. ORGANIZATIONMA: self.data.ORGANIZATIONMA,
  397. WENHAO: self.data.WENHAO,
  398. MIJIQIXIAN: self.data.MIJIQIXIAN,
  399. DANGANML: self.data.DANGANML,
  400. DOCUMENTTYPE: self.data.DOCUMENTTYPE,
  401. DOCTITLE: self.data.DOCTITLE,
  402. ZRZ: self.data.ZRZ,
  403. DOCISSUEDDATE: self.data.DOCISSUEDDATE,
  404. JIANHAO: self.data.JIANHAO,
  405. YESHU: self.data.YESHU,
  406. BEIZHU: self.data.BEIZHU,
  407. ARCHCODE: self.data.ARCHCODE,
  408. DAROUTEINFOID: self.data.DAROUTEINFOID,
  409. DPNAME: self.data.DPNAME,
  410. DPCODE: self.data.DPCODE,
  411. MOBANNAME: self.data.MOBANNAME,
  412. TABLENAME: self.data.TABLENAME
  413. }
  414. }
  415. $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  416. .success(function (obj) {
  417. var res = strToJson(s4.decryptData_CBC(obj.data));
  418. if (res.code == 0) {
  419. self.id = res.data.ID;
  420. self.getData()
  421. } else {
  422. sp.dialog(res.message)
  423. }
  424. })
  425. }
  426. // 更新数据
  427. self.updateBtn=function(){
  428. console.log("更新---")
  429. }
  430. // 生成归档目录
  431. self.createGuidang = function () {
  432. var data = {
  433. routeinfoid: self.routeinfoid,
  434. }
  435. $http.post(apiurljs.login + "g2app/DangAn/YJYGDMULU", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  436. .success(function (obj) {
  437. var res = strToJson(s4.decryptData_CBC(obj.data));
  438. if (res.code == 0) {
  439. self.guidangList = res.data;
  440. } else {
  441. sp.dialog(res.message)
  442. }
  443. })
  444. }
  445. // 查看文件
  446. self.searchFiles = function (obj) {
  447. var set_convertType = 0;
  448. if (obj.PREFIX == "doc") {
  449. set_convertType = 0;
  450. } else if (obj.PREFIX == "pdf") {
  451. set_convertType = 20;
  452. } else if (obj.PREFIX == "ofd") {
  453. set_convertType = 570;
  454. } else {
  455. set_convertType = 0;
  456. }
  457. let postData = {
  458. convertType: set_convertType,
  459. isSignature: 1,
  460. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.URL.slice(7)
  461. };
  462. var postCfg_transfer = {
  463. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  464. transformRequest: function (data) {
  465. return $.param(data);
  466. }
  467. };
  468. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  469. .success(function (res) {
  470. if (res.errorcode === 0) {
  471. $("#filesId").attr("src", res.data.viewUrl)
  472. } else {
  473. sp.dialog(res.message);
  474. }
  475. });
  476. }
  477. //头部下滚冻结
  478. $(function () {
  479. $(".sp-page-center").css("max-height", $(window).height() - 58).css("height", $(window).height() - 58)
  480. //页面高度撑满
  481. setTimeout(function () {
  482. if ($(".ibox-content").height() < $(window).height() - 31) {
  483. $(".ibox-content").css("height", $(window).height() - 31)
  484. }
  485. }, 1)
  486. })
  487. }])
  488. var parentData = {}
  489. function getData() {
  490. parentData = angular.element(document.getElementById("app")).scope().data
  491. return parentData
  492. }