list.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. let s4 = new SM4Util();
  2. let listVue = new Vue({
  3. el: "#listBox",
  4. data: {
  5. apiurl: apiurl, //基础的页面请求地址
  6. userId: "", //用户id
  7. userName: "", //用户中文名
  8. token: "",
  9. nowTab: "tab2",
  10. type: "todo", //todo or done
  11. pageno: 1,
  12. itemsPerPage: 10,
  13. totalCount: 0,
  14. dataList: [],
  15. noDataTip: 1,
  16. tableName: "WJFB_CB",
  17. sqlWhere: {LX: "C09", FBZT: "1"},
  18. typeList: [],
  19. keyWord: ""
  20. },
  21. methods: {
  22. getData: () => {
  23. let postData = {
  24. tablename: _this.tableName,
  25. pagesize: _this.itemsPerPage,
  26. pageno: _this.pageno,
  27. colums: "*",
  28. order: "ID",
  29. sqlwhere: _this.sqlWhere,
  30. sqlorwhere: "",
  31. sqlinwhere: "",
  32. sqllikewhere: ""
  33. }
  34. if (_this.keyWord.trim() != "") {
  35. if (_this.tableName == "WJFB_CB") {
  36. postData.sqllikewhere = {WJBT: _this.keyWord}
  37. } else if (_this.tableName == "SX_TZGG") {
  38. postData.sqllikewhere = {GGBT: _this.keyWord}
  39. }
  40. }
  41. $http({
  42. method: 'post',
  43. baseURL: _this.apiurl,
  44. url: "g2app/dataabase/queryDataByColWithPage",
  45. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  46. headers: {
  47. 'Content-Type': 'application/json',
  48. 'Authorization': "Bearer " + _this.token
  49. }
  50. }).then(res => {
  51. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  52. response.data.forEach(function (item) {
  53. item.BT = item.WJBT ? item.WJBT : item.GGBT;
  54. item.FBRQ = item.FBRQ ? item.FBRQ : item.FBSJ;
  55. item.FBRQ = _this.dateFtt("yyyy-MM-dd", new Date(item.FBRQ));
  56. _this.typeList.forEach(function (item1) {
  57. if (item.FBBM == item1.CODE) {
  58. item.FBBM = item1.CNAME;
  59. }
  60. })
  61. _this.dataList.push(item);
  62. })
  63. if (_this.dataList.length == 0) {
  64. _this.noDataTip = 0;
  65. } else {
  66. _this.noDataTip = 1;
  67. }
  68. _this.totalCount = response.totalCount;
  69. })
  70. },
  71. dateFtt: (fmt, date) => {
  72. var o = {
  73. "M+": date.getMonth() + 1, //月份
  74. "d+": date.getDate(), //日
  75. "h+": date.getHours(), //小时
  76. "m+": date.getMinutes(), //分
  77. "s+": date.getSeconds(), //秒
  78. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  79. "S": date.getMilliseconds() //毫秒
  80. };
  81. if (/(y+)/.test(fmt))
  82. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  83. for (var k in o)
  84. if (new RegExp("(" + k + ")").test(fmt))
  85. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  86. return fmt;
  87. },
  88. changeTab: (tabCode, tabName) => {
  89. _this.pageno = 1;
  90. _this.dataList = [];
  91. _this.totalCount = 0;
  92. _this.nowTab = tabCode;
  93. _this.tableName = tabName;
  94. if (_this.nowTab == "tab2") {
  95. _this.sqlWhere = {LX: "C09", FBZT: "1"};
  96. } else if (_this.nowTab == "tab3") {
  97. _this.sqlWhere = {GGBK: "C05", FBZT: "1"};
  98. } else if (_this.nowTab == "tab4") {
  99. _this.sqlWhere = {GGBK: "C08", FBZT: "1"};
  100. } else if (_this.nowTab == "tab5") {
  101. _this.sqlWhere = {LX: "C06", FBZT: "1"};
  102. } else if (_this.nowTab == "tab6") {
  103. _this.sqlWhere = {GGBK: "C02", FBZT: "1"};
  104. } else if (_this.nowTab == "tab7") {
  105. _this.sqlWhere = {LX: "C01", FBZT: "1"};
  106. } else if (_this.nowTab == "tab8") {
  107. _this.sqlWhere = {LX: "C02", FBZT: "1"};
  108. } else if (_this.nowTab == "tab9") {
  109. _this.sqlWhere = {LX: "C03", FBZT: "1"};
  110. } else if (_this.nowTab == "tab10") {
  111. _this.sqlWhere = {LX: "C04", FBZT: "1"};
  112. } else if (_this.nowTab == "tab11") {
  113. _this.sqlWhere = {LX: "C05", FBZT: "1"};
  114. } else if (_this.nowTab == "tab12") {
  115. _this.sqlWhere = {GGBK: "C03", FBZT: "1"};
  116. } else if (_this.nowTab == "tab13") {
  117. _this.sqlWhere = {GGBK: "C04", FBZT: "1"};
  118. } else if (_this.nowTab == "tab14") {
  119. _this.sqlWhere = {GGBK: "C07", FBZT: "1"};
  120. } else if (_this.nowTab == "tab15") {
  121. _this.sqlWhere = {LX: "C08", FBZT: "1"};
  122. } else if (_this.nowTab == "tab16") {
  123. _this.sqlWhere = {GGBK: "C06", FBZT: "1"};
  124. } else if (_this.nowTab == "tab17") {
  125. _this.sqlWhere = {LX: "C10", FBZT: "1"};
  126. } else if (_this.nowTab == "tab18") {
  127. _this.sqlWhere = {LX: "C11", FBZT: "1"};
  128. } else if (_this.nowTab == "tab19") {
  129. _this.sqlWhere = {LX: "C12", FBZT: "1"};
  130. }
  131. _this.getData();
  132. },
  133. loadMore: () => {
  134. _this.pageno++;
  135. _this.getData();
  136. },
  137. getType: () => {
  138. let postData = {
  139. ckey: "CODE_ZRBM",
  140. routeinfoid: ""
  141. }
  142. $http({
  143. method: 'post',
  144. baseURL: _this.apiurl,
  145. url: "g2app/abase/queryDataCode",
  146. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  147. headers: {
  148. 'Content-Type': 'application/json',
  149. 'Authorization': "Bearer " + _this.token
  150. }
  151. }).then(res => {
  152. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  153. _this.typeList = response.data.CODE_ZRBM;
  154. _this.getData();
  155. })
  156. },
  157. goUrl: (obj) => {
  158. if (_this.tableName == "SX_TZGG") {
  159. location.href = "detail.html?id=" + obj.ID + "&tablename=" + _this.tableName + "&departname=" + obj.FBBM;
  160. } else if (_this.tableName == "WJFB_CB") {
  161. location.href = "detail2.html?id=" + obj.ID + "&tablename=" + _this.tableName + "&departname=" + obj.FBBM;
  162. }
  163. },
  164. searchKey: () => {
  165. _this.pageno = 1;
  166. _this.dataList = [];
  167. _this.totalCount = 0;
  168. _this.getData();
  169. }
  170. },
  171. created: function () {
  172. _this = this;
  173. let token = localStorage.getItem("mobile-token", _this.token);
  174. let userName = localStorage.getItem("mobile-userName", _this.userName);
  175. let userId = localStorage.getItem("mobile-userId", _this.userId);
  176. _this.userId = userId;
  177. _this.token = token;
  178. _this.userName = userName;
  179. },
  180. mounted: function () {
  181. _this.getType();
  182. }
  183. })