list.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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: "tab1",
  10. dotype: 1, //0 or 1
  11. type: "todo", //todo or done
  12. pageno: 1,
  13. itemsPerPage: 10,
  14. totalCount: 0,
  15. flowId: "AA88|AA89|AA46|AA22|AA54|AA58",
  16. dataList: [],
  17. noDataTip: 1
  18. },
  19. methods: {
  20. getData: () => {
  21. let methodName = "";
  22. if (_this.nowTab == 'tab1') {
  23. methodName = "g2work/routeinfo/queryDataTodoWithPage";
  24. } else if (_this.nowTab == 'tab2') {
  25. methodName = "g2work/routeinfo/queryDataDoneWithPage";
  26. }
  27. let postData = {
  28. flowid: _this.flowId,
  29. userid: _this.userId,
  30. pageno: _this.pageno,
  31. pagesize: _this.itemsPerPage
  32. }
  33. $http({
  34. method: 'post',
  35. baseURL: _this.apiurl,
  36. url: methodName,
  37. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  38. headers: {
  39. 'Content-Type': 'application/json',
  40. 'Authorization': "Bearer " + _this.token
  41. }
  42. }).then(res => {
  43. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  44. response.data.forEach(function (item) {
  45. item.RECEIVEDATE = _this.dateFtt("yyyy-MM-dd hh:mm", new Date(item.RECEIVEDATE));
  46. if (item.FILEN != "") {
  47. item.FILEN = item.FILEN.indexOf("dotype") > -1 ? item.FILEN.replace("dotype=1", "dotype=" + _this.dotype) + "&type=" + _this.type : item.FILEN + "&dotype=" + _this.dotype + "&type=" + _this.type ;
  48. } else {
  49. item.FILEN = "#";
  50. }
  51. _this.dataList.push(item);
  52. })
  53. console.log(_this.dataList);
  54. if (_this.dataList.length == 0) {
  55. _this.noDataTip = 0;
  56. } else {
  57. _this.noDataTip = 1;
  58. }
  59. _this.totalCount = response.totalCount;
  60. })
  61. },
  62. dateFtt: (fmt, date) => {
  63. var o = {
  64. "M+": date.getMonth() + 1, //月份
  65. "d+": date.getDate(), //日
  66. "h+": date.getHours(), //小时
  67. "m+": date.getMinutes(), //分
  68. "s+": date.getSeconds(), //秒
  69. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  70. "S": date.getMilliseconds() //毫秒
  71. };
  72. if (/(y+)/.test(fmt))
  73. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  74. for (var k in o)
  75. if (new RegExp("(" + k + ")").test(fmt))
  76. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  77. return fmt;
  78. },
  79. changeTab: (tabCode) => {
  80. _this.pageno = 1;
  81. _this.dataList = [];
  82. _this.totalCount = 0;
  83. _this.nowTab = tabCode;
  84. if (_this.nowTab == "tab1") {
  85. _this.dotype = 1;
  86. _this.type = "todo";
  87. } else {
  88. _this.dotype = 0;
  89. _this.type = "done";
  90. }
  91. _this.getData();
  92. },
  93. loadMore: () => {
  94. _this.pageno++;
  95. _this.getData();
  96. },
  97. toDetail:(item)=>{
  98. location.href = item.FILEN;
  99. }
  100. },
  101. created: function () {
  102. _this = this;
  103. let token = localStorage.getItem("mobile-token", _this.token);
  104. let userName = localStorage.getItem("mobile-userName", _this.userName);
  105. let userId = localStorage.getItem("mobile-userId", _this.userId);
  106. _this.userId = userId;
  107. _this.token = token;
  108. _this.userName = userName;
  109. },
  110. mounted: function () {
  111. _this.getData();
  112. }
  113. })