detail.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: 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. }
  67. console.log(_this.array);
  68. console.log(_this.detail);
  69. })
  70. },
  71. },
  72. created: function () {
  73. _this = this;
  74. let token = localStorage.getItem("mobile-token", _this.token);
  75. let userName = localStorage.getItem("mobile-userName", _this.userName);
  76. let userId = localStorage.getItem("mobile-userId", _this.userId);
  77. _this.userId = userId;
  78. _this.token = token;
  79. _this.userName = userName;
  80. _this.id = _this.utils.getUrlName("id");
  81. _this.tablename = _this.utils.getUrlName("tablename");
  82. _this.departname = decodeURI(_this.utils.getUrlName("departname"));
  83. },
  84. mounted: function () {
  85. console.log(_this.id);
  86. console.log(_this.tablename);
  87. _this.getDetail();
  88. }
  89. })