Commit f045c1321dc344d0a8c005079dd2688c9619587a

Authored by sqy
1 parent 5a6097fd

fix:调整设备详情的命令记录

... ... @@ -4,7 +4,7 @@
4 4 <view class="detail">
5 5 <view class="detail-item">
6 6 <view class="detail-label">设备类型</view>
7   - <view class="detail-value">{{ commandDetail.deviceType }}</view>
  7 + <view class="detail-value">{{ deviceType }}</view>
8 8 </view>
9 9 <u-line length="90%" margin="0 auto"></u-line>
10 10 <view class="detail-item">
... ... @@ -19,7 +19,7 @@
19 19 <u-line length="90%" margin="0 auto"></u-line>
20 20 <view class="detail-item">
21 21 <view class="detail-label">命令下发时间</view>
22   - <view class="detail-value">{{ commandDetail.createTime }}</view>
  22 + <view class="detail-value">{{ format(commandDetail.createTime) }}</view>
23 23 </view>
24 24 <u-line length="90%" margin="0 auto"></u-line>
25 25 <view class="detail-item" v-if="commandDetail.additionalInfo.cmdType">
... ... @@ -29,31 +29,51 @@
29 29 <u-line length="90%" margin="0 auto" v-if="commandDetail.additionalInfo.cmdType"></u-line>
30 30 <view class="detail-item">
31 31 <view class="detail-label">响应类型</view>
32   - <view class="detail-value"></view>
  32 + <view class="detail-value">{{commandDetail.request.oneway?'oneway':'towway'}}</view>
33 33 </view>
34 34 <u-line length="90%" margin="0 auto"></u-line>
35 35 <view class="detail-item">
36 36 <view class="detail-label">下发结果</view>
37   - <view class="detail-value">成功</view>
  37 + <view class="detail-value">{{commandDetail.status==='SUCCESSFUL'?'成功':'失败'}}</view>
38 38 </view>
39 39 <u-line length="90%" margin="0 auto"></u-line>
40 40 <view class="detail-item">
41 41 <view class="detail-label">响应结果</view>
42   - <view class="detail-value">成功</view>
  42 + <view class="detail-value">{{commandDetail.response?'成功':'失败'}}</view>
43 43 </view>
44 44 </view>
45 45 <view class="command">命令内容</view>
46   - <u-textarea></u-textarea>
  46 + <u-textarea :value="formatValue(commandDetail.request.body)" disabled></u-textarea>
47 47 </view>
48 48 </template>
49 49
50 50 <script>
  51 +import { formatToDate } from '@/plugins/utils.js';
51 52 export default {
52 53 data() {
53 54 return {
54 55 commandDetail: {}
55 56 };
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');
  72 + },
  73 + formatValue(value){
  74 + return JSON.stringify(value)
  75 + }
  76 + },
57 77 onLoad(options) {
58 78 const { data } = options;
59 79 this.commandDetail = JSON.parse(data);
... ...
... ... @@ -16,7 +16,8 @@
16 16 <view class="item">
17 17 <view class="item-first">
18 18 <text>{{ item.deviceName }}</text>
19   - <!-- <view class="item-right">响应成功</view> -->
  19 + <view class="item-right item-success" v-if="item.response">响应成功</view>
  20 + <view class="item-right item-fail" v-else>响应失败</view>
20 21 </view>
21 22 <view v-if="item.additionalInfo.cmdType">
22 23 命令类型:
... ... @@ -35,7 +36,6 @@
35 36 <view class="filter">
36 37 <view class="filter-title"><text>筛选条件</text></view>
37 38 <FilterItem :filterList="issueStatus" title="下发状态" @clickTag="currentIndex => handleClickTag(currentIndex, issueStatus)"></FilterItem>
38   - <FilterItem :filterList="responseWay" title="响应方式" @clickTag="currentIndex => handleClickTag(currentIndex, responseWay)"></FilterItem>
39 39 <view class="button-group">
40 40 <view><u-button :customStyle="{ color: '#333' }" color="#e3e3e5" shape="circle" text="重置" @click="resetFilter"></u-button></view>
41 41 <view><u-button color="#3388ff" shape="circle" text="确认" @click="confirmFilter"></u-button></view>
... ... @@ -96,23 +96,6 @@ export default {
96 96 type: 'fail'
97 97 }
98 98 ],
99   - responseWay: [
100   - {
101   - checked: true,
102   - name: '全部',
103   - type: ''
104   - },
105   - {
106   - checked: false,
107   - name: 'OneWay',
108   - type: 'OneWay'
109   - },
110   - {
111   - checked: false,
112   - name: 'TowWay',
113   - type: 'TowWay'
114   - }
115   - ],
116 99 downOption: {
117 100 auto: false //是否在初始化后,自动执行downCallback; 默认true
118 101 },
... ... @@ -180,8 +163,8 @@ export default {
180 163 });
181 164 },
182 165 resetFilter() {
183   - const { issueStatus, responseWay } = this;
184   - [issueStatus, responseWay].forEach(item => item.map((item, index) => (item.checked = index === 0)));
  166 + const { issueStatus } = this;
  167 + issueStatus.forEach(item => item.map((item, index) => (item.checked = index === 0)));
185 168 },
186 169 close() {
187 170 this.show = false;
... ... @@ -198,10 +181,8 @@ export default {
198 181 },
199 182 confirmFilter() {
200 183 const issueStatus = this.issueStatus.find(item => item.checked);
201   - const responseWay = this.responseWay.find(item => item.checked);
202 184 this.loadData(1, {
203 185 status: issueStatus.type ? issueStatus.type : undefined,
204   - responseWay: responseWay.type ? responseWay.type : undefined,
205 186 deviceId: this.deviceId
206 187 });
207 188 this.show = false;
... ... @@ -273,13 +254,19 @@ export default {
273 254 display: flex;
274 255 justify-content: center;
275 256 align-items: center;
276   - color: #00c9a7;
277 257 width: 104rpx;
278 258 height: 36rpx;
279 259 font-size: 20rpx;
280   - background-color: #00c9a725;
281 260 border-radius: 20rpx;
282 261 }
  262 + .item-fail {
  263 + color: #848383;
  264 + background-color: #84838325;
  265 + }
  266 + .item.success {
  267 + color: #00c9a7;
  268 + background-color: #00c9a725;
  269 + }
283 270 }
284 271 }
285 272 }
... ...
... ... @@ -127,7 +127,12 @@ export default {
127 127 },
128 128 async confirmCommand() {
129 129 try {
130   - await issueCommand(this.commandType, this.deviceDetail.tbDeviceId, JSON.parse(this.commandValue));
  130 + const commandValue = JSON.parse(this.commandValue);
  131 + commandValue.persistent = true;
  132 + commandValue.additionalInfo = {
  133 + cmdType: 'API'
  134 + };
  135 + await issueCommand(this.commandType, this.deviceDetail.tbDeviceId,commandValue);
131 136 this.hiddenModal();
132 137 } catch (e) {
133 138 uni.$u.toast('下发失败~');
... ...
... ... @@ -19,7 +19,7 @@ const GlobalOption = {
19 19 },
20 20 empty: {
21 21 use: true, // 是否显示空布局
22   - icon: "../../../../../static/empty-data.png" // 图标路径 (建议放入static目录, 如 /static/img/mescroll-empty.png )
  22 + icon: "../../../../../static/empty.png" // 图标路径 (建议放入static目录, 如 /static/img/mescroll-empty.png )
23 23 }
24 24 },
25 25 // 国际化配置
... ...