list.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. nowSort: "ID",
  10. type: "todo", //todo or done
  11. pageno: 1,
  12. itemsPerPage: 10,
  13. totalCount: 0,
  14. dataList: [],
  15. noDataTip: 1,
  16. tableName: "MOBILE_TZGG_VIEW",
  17. sqlWhere: {GGBK: "C01", 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: _this.nowSort,
  29. sqlwhere: _this.sqlWhere,
  30. sqlorwhere: "",
  31. sqlinwhere: "",
  32. sqllikewhere: ""
  33. }
  34. if (_this.keyWord.trim() != "") {
  35. if (_this.tableName == "SX_TZGG") {
  36. postData.sqllikewhere = {GGBT: _this.keyWord}
  37. }
  38. }
  39. $http({
  40. method: 'post',
  41. baseURL: _this.apiurl,
  42. url: "g2app/dataabase/queryDataByColWithPage",
  43. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  44. headers: {
  45. 'Content-Type': 'application/json',
  46. 'Authorization': "Bearer " + _this.token
  47. }
  48. }).then(res => {
  49. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  50. response.data.forEach(function (item) {
  51. item.BT = item.WJBT ? item.WJBT : item.GGBT;
  52. item.FBRQ = item.FBRQ ? item.FBRQ : item.FBSJ;
  53. item.FBRQ = _this.dateFtt("yyyy-MM-dd", new Date(item.FBRQ));
  54. _this.typeList.forEach(function (item1) {
  55. if (item.FBBM == item1.CODE) {
  56. item.FBBM = item1.CNAME;
  57. }
  58. })
  59. _this.dataList.push(item);
  60. })
  61. if (_this.dataList.length == 0) {
  62. _this.noDataTip = 0;
  63. } else {
  64. _this.noDataTip = 1;
  65. }
  66. console.log(_this.dataList);
  67. _this.totalCount = response.totalCount;
  68. })
  69. },
  70. dateFtt: (fmt, date) => {
  71. var o = {
  72. "M+": date.getMonth() + 1, //月份
  73. "d+": date.getDate(), //日
  74. "h+": date.getHours(), //小时
  75. "m+": date.getMinutes(), //分
  76. "s+": date.getSeconds(), //秒
  77. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  78. "S": date.getMilliseconds() //毫秒
  79. };
  80. if (/(y+)/.test(fmt))
  81. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  82. for (var k in o)
  83. if (new RegExp("(" + k + ")").test(fmt))
  84. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  85. return fmt;
  86. },
  87. loadMore: () => {
  88. _this.pageno++;
  89. _this.getData();
  90. },
  91. getType: () => {
  92. let postData = {
  93. ckey: "CODE_ZRBM",
  94. routeinfoid: ""
  95. }
  96. $http({
  97. method: 'post',
  98. baseURL: _this.apiurl,
  99. url: "g2app/abase/queryDataCode",
  100. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  101. headers: {
  102. 'Content-Type': 'application/json',
  103. 'Authorization': "Bearer " + _this.token
  104. }
  105. }).then(res => {
  106. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  107. _this.typeList = response.data.CODE_ZRBM;
  108. _this.getData();
  109. })
  110. },
  111. goUrl: (obj) => {
  112. location.href = "detail.html?id=" + obj.ID + "&tablename=" + _this.tableName + "&departname=" + obj.FBBM + "&plnum=" + obj.PL + "&dznum=" + obj.DZ;
  113. },
  114. searchKey: () => {
  115. _this.pageno = 1;
  116. _this.dataList = [];
  117. _this.totalCount = 0;
  118. _this.getData();
  119. },
  120. changeSort: (code) => {
  121. _this.nowSort = code;
  122. _this.pageno = 1;
  123. _this.dataList = [];
  124. _this.totalCount = 0;
  125. _this.getData();
  126. }
  127. },
  128. created: function () {
  129. _this = this;
  130. let token = localStorage.getItem("mobile-token", _this.token);
  131. let userName = localStorage.getItem("mobile-userName", _this.userName);
  132. let userId = localStorage.getItem("mobile-userId", _this.userId);
  133. _this.userId = userId;
  134. _this.token = token;
  135. _this.userName = userName;
  136. },
  137. mounted: function () {
  138. _this.getType();
  139. }
  140. })