JYJL.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("taizhangCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.search = {
  19. DATE1: "",
  20. DATE2: ""
  21. }
  22. self.info = {
  23. CPH: "",
  24. CX: "",
  25. CX1: "",
  26. CLYS: "",
  27. XH: ""
  28. }
  29. //获取车型,分类,状态代码表
  30. self.cxList = [];
  31. self.getCxList = function () {
  32. var postData = {
  33. tablename: "CODE_CXDMB"
  34. }
  35. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  36. .success(function (obj) {
  37. var res = strToJson(s4.decryptData_CBC(obj.data));
  38. self.cxList = angular.copy(res.data);
  39. self.getCPH()
  40. })
  41. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  42. })
  43. }
  44. self.getCxList();
  45. self.getCPH = function () {
  46. var data = {
  47. tablename: "SX_CLGLB",
  48. colums: "*",
  49. order: "ID",
  50. sqlwhere: "",
  51. sqlinwhere: "",
  52. sqllikewhere: ""
  53. }
  54. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  55. .success(function (obj) {
  56. var res = strToJson(s4.decryptData_CBC(obj.data));
  57. self.CPHlist = res.data;
  58. console.log(res.data)
  59. self.CPHlist.forEach(function (item) {
  60. self.cxList.forEach(function (item1) {
  61. if (item.CX == item1.CODE) {
  62. item.CX1 = item1.CNAME;
  63. }
  64. })
  65. })
  66. self.info = {
  67. CPH: self.CPHlist[0].CPH,
  68. CX: self.CPHlist[0].CX,
  69. CX1: self.CPHlist[0].CX1,
  70. CLYS: self.CPHlist[0].CLYS,
  71. XH: self.CPHlist[0].XH
  72. }
  73. self.getData()
  74. })
  75. }
  76. self.getData = function () {
  77. var data = {
  78. tablename: "SX_CLJYJLB",
  79. colums: "*",
  80. order: "ID",
  81. sqlwhere: " and CPH = '" + self.info.CPH + "'" + (self.search.DATE1 != "" ? " and CTIME BETWEEN '" + self.search.DATE1 + " 00:00:00' AND '" + (self.search.DATE2 != "" ? self.search.DATE2 : self.search.DATE1) + " 23:59:59'" : "")
  82. }
  83. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColStr", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  84. .success(function (obj) {
  85. var res = strToJson(s4.decryptData_CBC(obj.data));
  86. self.list = res.data;
  87. self.addFlag = false;
  88. self.editFlag = false;
  89. self.list.forEach(function (item) {
  90. item.editFlag = false;
  91. item.CTIME1 = item.CTIME;
  92. item.JYADDR1 = item.JYADDR;
  93. item.ZLCS1 = item.ZLCS;
  94. item.JYSL1 = item.JYSL;
  95. item.JYDJ1 = item.JYDJ;
  96. item.JYRXM1 = item.JYRXM;
  97. item.REMARK1 = item.REMARK;
  98. })
  99. })
  100. }
  101. self.insertData = [];
  102. self.addItemData = function () {
  103. self.addFlag = true;
  104. self.insertData.push({
  105. CPH: self.info.CPH,
  106. CX: self.info.CX,
  107. CLYS: self.info.CLYS,
  108. XH: self.info.XH,
  109. CTIME: sp.getLocalDate(),
  110. JYADDR: "",
  111. ZLCS: "",
  112. JYSL: "",
  113. JYRXM: "",
  114. REMARK: "",
  115. JYDJ: ""
  116. });
  117. }
  118. self.editItem = function (obj) {
  119. self.editFlag = true;
  120. obj.editFlag = true;
  121. }
  122. self.delItem = function (item) {
  123. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  124. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  125. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  126. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  127. sp.openCenter(".sp-dialog");
  128. ///取消按钮
  129. $('.sp-closeDialog').click(function (event) {
  130. sp.closeCenter(".sp-dialog");
  131. event.preventDefault();
  132. event.stopPropagation();
  133. });
  134. //post消息的id
  135. $("#delDataTrue").click(function () {
  136. var data = {
  137. tablename: "SX_CLJYJLB",
  138. id: item.ID
  139. };
  140. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  141. .success(function (obj) {
  142. var res = strToJson(s4.decryptData_CBC(obj.data));
  143. sp.dialoghide();
  144. if (res.success) {
  145. self.getData();
  146. } else {
  147. sp.dialog("删除失败,请联系管理员!");
  148. }
  149. });
  150. });
  151. }
  152. self.saveData = function () {
  153. var n1 = true, n2 = true;
  154. if (self.insertData.length > 0) {
  155. n1 = false;
  156. var addData = {
  157. tablename: "SX_CLJYJLB",
  158. data: []
  159. }
  160. self.insertData.forEach(function (item) {
  161. addData.data.push({
  162. CPH: item.CPH,
  163. CLYS: item.CLYS,
  164. XH: item.XH,
  165. CX: item.CX,
  166. CTIME: item.CTIME,
  167. JYADDR: item.JYADDR,
  168. ZLCS: item.ZLCS,
  169. JYSL: item.JYSL,
  170. JYRXM: item.JYRXM,
  171. REMARK: item.REMARK,
  172. JYDJ: item.JYDJ,
  173. USERID: self.userId,
  174. CDATE: sp.getLocalDate()
  175. });
  176. });
  177. $http.post(apiurljs.login + "g2app/dataabase/insertDataList", { data: s4.encryptData_CBC(JSON.stringify(addData)) }, postCfg)
  178. .success(function (obj) {
  179. sp.closeCenter('.sp-layer');
  180. var res = strToJson(s4.decryptData_CBC(obj.data));
  181. if (res.success) {
  182. n1 = true;
  183. var editData = {
  184. entity: "SX_CLJYJLB",
  185. data: [],
  186. setwhere: []
  187. }
  188. self.list.forEach(function (item) {
  189. if (item.editFlag == true) {
  190. editData.data.push({
  191. CTIME: item.CTIME1,
  192. JYADDR: item.JYADDR1,
  193. ZLCS: item.ZLCS1,
  194. JYSL: item.JYSL1,
  195. JYRXM: item.JYRXM1,
  196. REMARK: item.REMARK1,
  197. JYDJ: item.JYDJ1
  198. })
  199. editData.setwhere.push({ ID: item.ID })
  200. }
  201. })
  202. if (editData.data.length > 0) {
  203. n2 = false;
  204. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(editData)) }, postCfg)
  205. .success(function (obj) {
  206. var res = strToJson(s4.decryptData_CBC(obj.data));
  207. if (res.success == true) {
  208. self.childSaveFlag = false;
  209. n2 = true;
  210. if (n1 == true && n2 == true) {
  211. self.getData();
  212. }
  213. } else {
  214. sp.dialog(res.message)
  215. }
  216. })
  217. } else {
  218. if (n1 == true && n2 == true) {
  219. self.getData();
  220. }
  221. }
  222. } else {
  223. sp.dialog(res.message);
  224. }
  225. })
  226. } else {
  227. n2 = false;
  228. var editData = {
  229. entity: "SX_CLJYJLB",
  230. data: [],
  231. setwhere: []
  232. }
  233. self.list.forEach(function (item) {
  234. if (item.editFlag == true) {
  235. editData.data.push({
  236. CTIME: item.CTIME1,
  237. JYADDR: item.JYADDR1,
  238. ZLCS: item.ZLCS1,
  239. JYSL: item.JYSL1,
  240. JYRXM: item.JYRXM1,
  241. REMARK: item.REMARK1,
  242. JYDJ: item.JYDJ1
  243. })
  244. editData.setwhere.push({ ID: item.ID })
  245. }
  246. })
  247. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(editData)) }, postCfg)
  248. .success(function (obj) {
  249. var res = strToJson(s4.decryptData_CBC(obj.data));
  250. if (res.success == true) {
  251. n2 = true;
  252. if (n1 == true && n2 == true) {
  253. self.getData();
  254. }
  255. } else {
  256. sp.dialog(res.message)
  257. }
  258. })
  259. }
  260. }
  261. self.cancal = function () {
  262. self.addFlag = false;
  263. self.editFlag = false
  264. self.list.forEach(function (item) {
  265. item.editFlag = false;
  266. })
  267. }
  268. self.openLayer = function () {
  269. sp.layer("#Search")
  270. }
  271. self.doSearch = function () {
  272. self.getData();
  273. sp.layerhide()
  274. }
  275. }])