Commit 1af53ca7c80476f4bad2e5ea900ac0e554af4378

Authored by fengwotao
1 parent 46afb285

pref:优化命令记录 命令内容格式

... ... @@ -48,82 +48,100 @@
48 48 </template>
49 49
50 50 <script>
51   -import { formatToDate } from '@/plugins/utils.js';
52   -export default {
53   - data() {
54   - return {
55   - commandDetail: {}
56   - };
57   - },
58   - computed: {
59   - deviceType() {
60   - return this.commandDetail.deviceType === 'DIRECT_CONNECTION'
61   - ? '直连设备'
62   - : this.commandDetail.deviceType === 'GATEWAY'
63   - ? '网关设备'
64   - : this.commandDetail.deviceType === 'SENSOR'
65   - ? '网关子设备'
66   - : '';
67   - }
68   - },
69   - methods: {
70   - format(date) {
71   - return formatToDate(date, 'YYYY-MM-DD HH:mm:ss');
  51 + import {
  52 + formatToDate
  53 + } from '@/plugins/utils.js';
  54 + export default {
  55 + data() {
  56 + return {
  57 + commandDetail: {}
  58 + };
  59 + },
  60 + computed: {
  61 + deviceType() {
  62 + return this.commandDetail.deviceType === 'DIRECT_CONNECTION' ?
  63 + '直连设备' :
  64 + this.commandDetail.deviceType === 'GATEWAY' ?
  65 + '网关设备' :
  66 + this.commandDetail.deviceType === 'SENSOR' ?
  67 + '网关子设备' :
  68 + '';
  69 + }
  70 + },
  71 + methods: {
  72 + format(date) {
  73 + return formatToDate(date, 'YYYY-MM-DD HH:mm:ss');
  74 + },
  75 + formatValue(value) {
  76 + try {
  77 + const val = JSON.parse(value['params']);
  78 + //微信小程序端object无法显示,格式化为字符串
  79 + const stringifyVal = JSON.stringify(val['params'])
  80 + const formatVal = stringifyVal
  81 + .replace(/\\"/g, '"')
  82 + .replace(/]"/g, ']')
  83 + .replace(/"\[/g, '[');
  84 + return formatVal
  85 + } catch (e) {
  86 + console.error("命令记录页面格式化无返回值", e);
  87 + }
  88 +
  89 + }
72 90 },
73   - formatValue(value) {
74   - const val = JSON.stringify(value);
75   - return val
76   - .replace(/\\"/g, '"')
77   - .replace(/]"/g, ']')
78   - .replace(/"\[/g, '[');
  91 + onLoad(options) {
  92 + const {
  93 + data
  94 + } = options;
  95 + this.commandDetail = JSON.parse(data);
79 96 }
80   - },
81   - onLoad(options) {
82   - const { data } = options;
83   - this.commandDetail = JSON.parse(data);
84   - }
85   -};
  97 + };
86 98 </script>
87 99
88 100 <style lang="scss" scoped>
89   -.command-detail {
90   - padding: 0 30rpx;
91   - height: 100vh;
92   - background-color: #f8f9fa;
93   - .detail-top {
94   - height: 118rpx;
95   - width: 690rpx;
96   - display: flex;
97   - align-items: center;
98   - background-color: #fff;
99   - color: #333;
100   - border-radius: 20rpx;
101   - font-size: 15px;
102   - margin-top: 30rpx;
103   - padding: 30rpx;
104   - }
105   - .detail {
106   - background-color: #fff;
107   - margin-top: 30rpx;
108   - border-radius: 20rpx;
109   - width: 690rpx;
110   - .detail-item {
111   - padding: 30rpx;
  101 + .command-detail {
  102 + padding: 0 30rpx;
  103 + height: 100vh;
  104 + background-color: #f8f9fa;
  105 +
  106 + .detail-top {
  107 + height: 118rpx;
  108 + width: 690rpx;
112 109 display: flex;
113 110 align-items: center;
114   - .detail-label {
115   - color: #333;
116   - font-size: 15px;
117   - }
118   - .detail-value {
119   - color: #666;
120   - font-size: 14px;
121   - margin-left: 30rpx;
  111 + background-color: #fff;
  112 + color: #333;
  113 + border-radius: 20rpx;
  114 + font-size: 15px;
  115 + margin-top: 30rpx;
  116 + padding: 30rpx;
  117 + }
  118 +
  119 + .detail {
  120 + background-color: #fff;
  121 + margin-top: 30rpx;
  122 + border-radius: 20rpx;
  123 + width: 690rpx;
  124 +
  125 + .detail-item {
  126 + padding: 30rpx;
  127 + display: flex;
  128 + align-items: center;
  129 +
  130 + .detail-label {
  131 + color: #333;
  132 + font-size: 15px;
  133 + }
  134 +
  135 + .detail-value {
  136 + color: #666;
  137 + font-size: 14px;
  138 + margin-left: 30rpx;
  139 + }
122 140 }
123 141 }
  142 +
  143 + .command {
  144 + margin: 30rpx 0;
  145 + }
124 146 }
125   - .command {
126   - margin: 30rpx 0;
127   - }
128   -}
129 147 </style>
... ...