detail.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. let s4 = new SM4Util();
  2. let base64 = new Base64(); //声明base解码和编码类
  3. let listVue = new Vue({
  4. el: "#detailBox",
  5. data: {
  6. apiurl:apiurl, //基础的页面请求地址
  7. userId: "", //用户id
  8. userName: "", //用户中文名
  9. token: "",
  10. id:"",
  11. tablename:"",
  12. departname:"",
  13. detail:{
  14. },
  15. array:[]
  16. },
  17. methods: {
  18. dateFtt: (fmt, date) => {
  19. var o = {
  20. "M+": date.getMonth() + 1, //月份
  21. "d+": date.getDate(), //日
  22. "h+": date.getHours(), //小时
  23. "m+": date.getMinutes(), //分
  24. "s+": date.getSeconds(), //秒
  25. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  26. "S": date.getMilliseconds() //毫秒
  27. };
  28. if (/(y+)/.test(fmt))
  29. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  30. for (var k in o)
  31. if (new RegExp("(" + k + ")").test(fmt))
  32. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  33. return fmt;
  34. },
  35. getDetail: () => {
  36. let postData ={
  37. tablename: _this.tablename,
  38. colums: "*",
  39. order: "ID",
  40. sqlwhere: { ID: _this.id },
  41. sqlinwhere: "",
  42. sqllikewhere: ""
  43. }
  44. $http({
  45. method: 'post',
  46. baseURL: _this.apiurl,
  47. url: "g2app/dataabase/queryDataByCol",
  48. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  49. headers: {
  50. 'Content-Type': 'application/json',
  51. 'Authorization': "Bearer " + _this.token
  52. }
  53. }).then(res => {
  54. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  55. _this.detail = {
  56. ID: response.data[0].ID,
  57. GGBK: response.data[0].GGBK,
  58. FBBM: response.data[0].FBBM,
  59. FBSJ: _this.dateFtt("yyyy-MM-dd",new Date(response.data[0].FBSJ)),
  60. FBFW: response.data[0].FBFW,
  61. GGNR: (response.data[0].GGNR!=""&&response.data[0].GGNR!=undefined&&response.data[0].GGNR!=null)?base64.decode(response.data[0].GGNR):"",
  62. GGBT: response.data[0].GGBT
  63. }
  64. if (response.data[0].FJSC && response.data[0].FJSC != "") {
  65. _this.array = JSON.parse(response.data[0].FJSC);
  66. _this.array.forEach(function (item) {
  67. item.FILEURL = _this.apiurl + "/g2work" + item.FILEURL;
  68. })
  69. }
  70. })
  71. },
  72. },
  73. created: function () {
  74. _this = this;
  75. let token = localStorage.getItem("mobile-token", _this.token);
  76. let userName = localStorage.getItem("mobile-userName", _this.userName);
  77. let userId = localStorage.getItem("mobile-userId", _this.userId);
  78. _this.userId = userId;
  79. _this.token = token;
  80. _this.userName = userName;
  81. _this.id = _this.utils.getUrlName("id");
  82. _this.tablename = _this.utils.getUrlName("tablename");
  83. _this.departname = decodeURI(_this.utils.getUrlName("departname"));
  84. },
  85. mounted: function () {
  86. console.log(_this.id);
  87. console.log(_this.tablename);
  88. _this.getDetail();
  89. }
  90. })