detail2.js 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. array: []
  15. },
  16. methods: {
  17. dateFtt: (fmt, date) => {
  18. var o = {
  19. "M+": date.getMonth() + 1, //月份
  20. "d+": date.getDate(), //日
  21. "h+": date.getHours(), //小时
  22. "m+": date.getMinutes(), //分
  23. "s+": date.getSeconds(), //秒
  24. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  25. "S": date.getMilliseconds() //毫秒
  26. };
  27. if (/(y+)/.test(fmt))
  28. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  29. for (var k in o)
  30. if (new RegExp("(" + k + ")").test(fmt))
  31. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  32. return fmt;
  33. },
  34. getDetail: () => {
  35. let postData = {
  36. tablename: _this.tablename,
  37. colums: "*",
  38. order: "ID",
  39. sqlwhere: {ID: _this.id},
  40. sqlinwhere: "",
  41. sqllikewhere: ""
  42. }
  43. $http({
  44. method: 'post',
  45. baseURL: _this.apiurl,
  46. url: "g2app/dataabase/queryDataByCol",
  47. data: {data: s4.encryptData_CBC(JSON.stringify(postData))},
  48. headers: {
  49. 'Content-Type': 'application/json',
  50. 'Authorization': "Bearer " + _this.token
  51. }
  52. }).then(res => {
  53. let response = _this.utils.strToJson(s4.decryptData_CBC(res.data.data));
  54. console.log(response);
  55. _this.detail = {
  56. ID: response.data[0].ID,
  57. WJBH: response.data[0].WJBH,
  58. FBR: response.data[0].FBR,
  59. FBNR: (response.data[0].FBNR != "" && response.data[0].FBNR != undefined && response.data[0].FBNR != null) ? base64.decode(response.data[0].FBNR) : "",
  60. FBRQ: _this.dateFtt("yyyy-MM-dd", new Date(response.data[0].FBRQ)),
  61. LX: response.data[0].LX,
  62. FBBM: response.data[0].FBBM,
  63. FJ: response.data[0].FJ,
  64. WJBT: response.data[0].WJBT
  65. }
  66. if (response.data[0].FJ && response.data[0].FJ != "") {
  67. _this.array = JSON.parse(response.data[0].FJ);
  68. _this.array.forEach(function (item) {
  69. item.FILEURL = _this.apiurl + "/g2work" + item.FILEURL;
  70. })
  71. }
  72. })
  73. },
  74. },
  75. created: function () {
  76. _this = this;
  77. let token = localStorage.getItem("mobile-token", _this.token);
  78. let userName = localStorage.getItem("mobile-userName", _this.userName);
  79. let userId = localStorage.getItem("mobile-userId", _this.userId);
  80. _this.userId = userId;
  81. _this.token = token;
  82. _this.userName = userName;
  83. _this.id = _this.utils.getUrlName("id");
  84. _this.tablename = _this.utils.getUrlName("tablename");
  85. _this.departname = decodeURI(_this.utils.getUrlName("departname"));
  86. },
  87. mounted: function () {
  88. console.log(_this.id);
  89. console.log(_this.tablename);
  90. _this.getDetail();
  91. }
  92. })