Commit 329709ac1628bea2bbb219bd544e00a331862f13

Authored by loveumiko
1 parent ec2d2668

fix: 修改小程序告警和首页看板组态添加组织关系

... ... @@ -10,8 +10,8 @@
10 10 <text class="text-device-muted text-clip alarm-text"
11 11 :style="{color:hasColor.includes(item.label)?'#DE4437':''}">
12 12 {{item.label===hasColor[0]? setAlarmStatus(item.value):item.label===hasColor[1]?setAlarmSeverity(item.value):
13   - item.label==='告警值:'?formatAlarmValueText:item.label==='告警条件:'?formatAlarmConditionText
14   - :item.label==='告警设备:'?formatDeviceText:item.value}}
  13 + item.label==='触发值:'?formatAlarmValueText:item.label==='触发条件:'?formatAlarmConditionText
  14 + :item.label==='触发属性:'?formatAttrText:item.label==='告警设备:'?formatDeviceText:item.value}}
15 15 </text>
16 16 </view>
17 17 <view class="bottom-line"></view>
... ... @@ -42,10 +42,10 @@
42 42 </view>
43 43 <!-- #endif -->
44 44 <view class="bottom-button">
45   - <view v-if="handleText.includes(alarmDetail[7].value)" class="u-flex button-item">
  45 + <view v-if="handleText.includes(alarmDetail[8].value)" class="u-flex button-item">
46 46 <u-button @click="handleSubmit" type="primary" shape="circle" text="处理"></u-button>
47 47 </view>
48   - <view v-if="clearText.includes(alarmDetail[7].value)" class="u-flex button-item">
  48 + <view v-if="clearText.includes(alarmDetail[8].value)" class="u-flex button-item">
49 49 <u-button @click="handleRemove" type="error" shape="circle" text="清除"></u-button>
50 50 </view>
51 51 </view>
... ... @@ -88,18 +88,23 @@
88 88 formatDeviceText: '',
89 89 formatAlarmValueText: '',
90 90 formatAlarmConditionText: '',
  91 + formatAttrText:'',
91 92 };
92 93 },
93   - onLoad(e) {
  94 + async onLoad(e) {
94 95 if (e.data !== null) {
95 96 let params = JSON.parse(decodeURIComponent(e.data));
96 97 const {deviceName,severity,organizationName,details,type,createdTime,status,id} = params
97 98
98 99 this.detailId = id
99   - this.alarmDetail = [{label: '告警场景:',value: type},{label: '告警级别:',value: severity},{label: '所属组织:',value: organizationName},{label: '告警设备:',value: ''},{label: '告警条件:',value: ''},{label: '告警值:',value: ''},{label: '告警时间:',value: createdTime},{label: '告警状态:',value: status},]
100   - this.formatAlarmDevice(details)
101   - this.formatAlarmValue(details)
102   - this.formatAlarmCondition(details)
  100 + this.alarmDetail = [{label: '告警场景:',value: type},{label: '告警级别:',value: severity},{label: '所属组织:',value: organizationName},{label: '告警设备:',value: ''},{label:'触发属性:',value:''},{label: '触发条件:',value: ''},{label: '触发值:',value: ''},{label: '告警时间:',value: createdTime},{label: '告警状态:',value: status},]
  101 +
  102 + const keys = Object.keys(details)
  103 + const dataFormat = await this.handleAlarmDetailFormat(keys);
  104 + this.formatAlarmDevice(details,dataFormat)
  105 + this.formatAlarmValue(details,dataFormat)
  106 + this.formatAlarmCondition(details,dataFormat)
  107 + this.formatAttr(details,dataFormat)
103 108 }
104 109 // 隐藏原生的tabbar
105 110 uni.hideTabBar();
... ... @@ -143,18 +148,16 @@
143 148 }, 500);
144 149 }
145 150 },
146   - //告警值处理
147   - async formatAlarmValue(e) {
  151 + //触发值处理
  152 + formatAlarmValue(e,dataFormat) {
148 153 const keys = Object.keys(e)
149   - const dataFormat = await this.handleAlarmDetailFormat(keys);
150 154 const values = keys.reduce((acc, curr) => {
151 155 const items = e[curr]?.triggerData
152 156 dataFormat.forEach((dataItem => {
153 157 if (dataItem.tbDeviceId === curr) {
154   - const findAttribute = dataItem.attribute.find(findItem => findItem.identifier === items?.key)
155   - if(!items?.realValue && !findAttribute.name) return
  158 + if(!items?.realValue) return
156 159 acc.push(
157   - `${findAttribute.name}:${items.realValue}${!findAttribute.detail?.dataType?.specs?.unit?.key?'':findAttribute.detail?.dataType?.specs?.unit?.key}`
  160 + `${items.realValue}`
158 161 )
159 162 }
160 163 }))
... ... @@ -162,7 +165,7 @@
162 165 }, [])
163 166 this.formatAlarmValueText = values.join(',')
164 167 },
165   - //告警条件处理
  168 + //触发条件处理
166 169 formatAlarmCondition(e) {
167 170 const keys = Object.keys(e)
168 171 const values = keys.reduce((acc, curr) => {
... ... @@ -179,10 +182,24 @@
179 182 })
180 183 this.formatAlarmConditionText = format.filter(Boolean).join(',')
181 184 },
182   - //告警设备处理
183   - async formatAlarmDevice(e) {
  185 + // 触发属性
  186 + formatAttr(e,dataFormat){
184 187 const keys = Object.keys(e)
185   - const dataFormat = await this.handleAlarmDetailFormat(keys);
  188 + const values = keys.reduce((acc, curr) => {
  189 + const items = e[curr]?.triggerData
  190 + dataFormat.forEach((dataItem => {
  191 + if (dataItem.tbDeviceId === curr) {
  192 + const findAttribute = dataItem.attribute.find(findItem => findItem.identifier === items?.key)
  193 + if(!findAttribute?.name && !items?.key) return
  194 + acc.push(`${findAttribute?.name || items?.key || ' '}`)
  195 + }
  196 + }))
  197 + return acc
  198 + }, [])
  199 + this.formatAttrText = values.join(',')
  200 + },
  201 + //告警设备处理
  202 + async formatAlarmDevice(e,dataFormat) {
186 203 if (!dataFormat) this.formatDeviceText = ''
187 204 if (Array.isArray(dataFormat) && dataFormat.length === 0) this.formatDeviceText = ''
188 205 this.formatDeviceText = dataFormat.map(item => item.name).join(',')
... ...
... ... @@ -6,7 +6,7 @@
6 6 .alarm-detail-column {
7 7 border-radius: 10px;
8 8 width: 688rpx;
9   - height: 688rpx;
  9 + height: 780rpx;
10 10 background-color: #ffffff;
11 11 .detail-column {
12 12 width:750rpx;
... ... @@ -84,4 +84,4 @@
84 84 .button-item{
85 85 width: 260rpx;
86 86 }
87   -}
\ No newline at end of file
  87 +}
... ...
1 1 <template>
2   - <view class="header-org">
3   - <view @click="$emit('openOrg')" class="org-item">
  2 + <view class="header-org" @click="$emit('openOrg')">
  3 + <view class="org-item">
4 4 <view class="u-flex org-contact"><text class="text">组织关系</text></view>
5 5 <view class="u-flex org-device">
6 6 <image class="device-image" :src="imageSrc"></image>
7   - <text class="device-text">摄像头数:{{ total }}</text>
  7 + <text class="device-text">{{title}} {{ total }}</text>
8 8 </view>
9 9 </view>
10 10 <view class="org-item">
... ... @@ -17,7 +17,8 @@
17 17 export default {
18 18 props: {
19 19 total: Number,
20   - imageSrc: String
  20 + imageSrc: String,
  21 + title:String
21 22 }
22 23 }
23 24 </script>
... ... @@ -32,8 +33,8 @@
32 33 flex-direction: row;
33 34 justify-content: space-between;
34 35 position: fixed;
35   - z-index: 999999;
36   - top: -1rpx;
  36 + // z-index: 999999;
  37 + // top: 75rpx;
37 38
38 39 .org-item {
39 40 width: 350rpx;
... ... @@ -78,4 +79,4 @@
78 79 }
79 80 }
80 81 }
81   -</style>
\ No newline at end of file
  82 +</style>
... ...
... ... @@ -62,6 +62,7 @@
62 62 },
63 63 conditions: {},
64 64 ordId: '',
  65 + paramsStaus:null
65 66 };
66 67 },
67 68 onShow() {
... ... @@ -75,7 +76,11 @@
75 76 this.conditions = {
76 77 organizationId: this.ordId
77 78 }
  79 + return
78 80 }
  81 + this.loadData(1, {
  82 + status:this.paramsStaus
  83 + });
79 84 },
80 85 onHide() {
81 86 this.ordId = ''
... ... @@ -85,18 +90,16 @@
85 90 this.loadData(1);
86 91 } else {
87 92 let params = JSON.parse(e.type);
88   - let status = null
  93 + this.parmasStatus = null
89 94 if (Array.isArray(params)) {
90   - status = params.join(',');
  95 + this.paramsStaus = params.join(',');
91 96 } else {
92   - status = params;
  97 + this.paramsStaus = params;
93 98 }
94 99 this.conditions = {
95   - status
  100 + status:this.paramsStaus
96 101 }
97   - this.loadData(1, {
98   - status
99   - });
  102 +
100 103 }
101 104 // 隐藏原生的tabbar
102 105 uni.hideTabBar();
... ... @@ -229,4 +232,4 @@
229 232 height: 100%;
230 233 width: 100%;
231 234 }
232   -</style>
\ No newline at end of file
  235 +</style>
... ...
... ... @@ -6,7 +6,13 @@
6 6 <text class="text-bold">{{ item.deviceAlias || item.deviceName || '暂无数据' }}</text>
7 7 </view>
8 8 <view class="item-text text-clip">
9   - <text class="text-muted">{{ item.details == null ? '暂无数据' : formatDetailText(item.details) }}</text>
  9 + <text class="text-muted">{{ item.details == null ? '暂无数据' : getAttrText(item.details) }}</text>
  10 + </view>
  11 + <view class="item-text text-clip">
  12 + <text class="text-muted">{{ item.details == null ? '暂无数据' : getConditionText(item.details) }}</text>
  13 + </view>
  14 + <view class="item-text text-clip">
  15 + <text class="text-muted">{{ item.details == null ? '暂无数据' : getValuesText(item.details) }}</text>
10 16 </view>
11 17 <view class="item-text">
12 18 <text class="text-muted">
... ... @@ -68,13 +74,29 @@
68 74 bindImageUrl(e) {
69 75 return this.alarmSeverity.find(item => item.value === e).icon
70 76 },
71   - formatDetailText(details) {
  77 +
  78 + getAttrText(details){
  79 + return this.formatDetailText(details,0)
  80 + },
  81 + getConditionText(detail){
  82 + return this.formatDetailText(detail,1)
  83 + },
  84 + getValuesText(detail){
  85 + return this.formatDetailText(detail,2)
  86 + },
  87 + formatDetailText(details,type) {
72 88 const deviceIdKeys = Object.keys(details)
73 89 if(!deviceIdKeys) return
74 90 const values = deviceIdKeys.reduce((acc, curr) => {
75 91 const items = details[curr]?.triggerData
76 92 if(items?.key && items?.logicValue && items.realValue){
77   - acc.push(`触发属性:${items.key ||'暂无数据'}, 触发条件:${findLogin(items)+items.logicValue || '暂无数据'}, 触发值:${items?.realValue || '暂无数据'} `)
  93 + if(type==0){
  94 + acc.push(`触发属性:${items.key ||'暂无数据'}`)
  95 + }else if (type ==1){
  96 + acc.push(`触发条件:${findLogin(items)+items.logicValue || '暂无数据'}`)
  97 + }else if(type==2){
  98 + acc.push(`触发值:${items?.realValue || '暂无数据'}`)
  99 + }
78 100 }
79 101 return acc
80 102 }, [])
... ... @@ -93,7 +115,7 @@
93 115
94 116 .list-item {
95 117 width: 713rpx;
96   - height: 233rpx;
  118 + height: 340rpx;
97 119 background-color: #fff;
98 120 margin-top: 24rpx;
99 121 display: flex;
... ... @@ -105,7 +127,7 @@
105 127 justify-content: flex-start;
106 128 flex-direction: column;
107 129 align-items: center;
108   - height: 211rpx;
  130 + height: 311rpx;
109 131 margin-top: 8rpx;
110 132 margin-left: 20rpx;
111 133
... ...
... ... @@ -2,7 +2,7 @@
2 2 <view class="camera-page">
3 3 <!-- 公共组件-每个页面必须引入 -->
4 4 <public-module></public-module>
5   - <header-org @openOrg="openOrg" :total="cameraTotal" :imageSrc="imageSrc"></header-org>
  5 + <header-org @openOrg="openOrg" :total="cameraTotal" title="摄像头数:" :imageSrc="imageSrc"></header-org>
6 6 <view style="height: 150rpx;"></view>
7 7 <!-- 自带分页组件 -->
8 8 <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback"
... ...
... ... @@ -8,14 +8,15 @@
8 8 shape="circle"></u--input>
9 9 </view>
10 10 </view>
  11 + <header-org @openOrg="openOrg" :total="total" title="组态数:" :imageSrc="imageSrc"></header-org>
11 12 </view>
12   - <view style="height:35rpx"></view>
  13 + <view style="height:128rpx"></view>
13 14 <!-- 公共组件-每个页面必须引入 -->
14 15 <public-module></public-module>
15 16 <!-- 自带分页组件 -->
16 17 <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback"
17 18 @up="upCallback">
18   - <view class="configuation-container">
  19 + <view class="configuation-container" v-if="list.length">
19 20 <view class="configuation-item">
20 21 <view @click="openConfigDetail(item)" v-for="(item, index) in list" :key="index" class="item">
21 22 <image class="image" :src="item.icon || defaultConfigImage"></image>
... ... @@ -23,7 +24,7 @@
23 24 </view>
24 25 </view>
25 26 </view>
26   - <mescroll-empty v-if="!list.length" />
  27 + <!-- <mescroll-empty v-if="!list.length" /> -->
27 28 </mescroll-body>
28 29 <!-- 自带分页组件 -->
29 30 <view style="height: 60rpx;"></view>
... ... @@ -36,12 +37,20 @@
36 37 import {
37 38 createScadaPageLink
38 39 } from '../config/help.js';
  40 + import headerOrg from '@/components/common/header-org.vue'
  41 + import {
  42 + useNavigateTo
  43 + } from '@/plugins/utils.js'
39 44
40 45 export default {
41 46 mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  47 + components:{
  48 + headerOrg
  49 + },
42 50 data() {
43 51 return {
44 52 defaultConfigImage: '../../../../static/test.png',
  53 + imageSrc:'/static/status.png',
45 54 page: {
46 55 num: 0,
47 56 size: 10
... ... @@ -52,7 +61,9 @@
52 61 upOption: {
53 62 auto: false // 不自动加载
54 63 },
55   - list: []
  64 + list: [],
  65 + total:0,
  66 + ordId:''
56 67 };
57 68 },
58 69 onLoad() {
... ... @@ -62,6 +73,14 @@
62 73 isConfiguration: false
63 74 });
64 75 },
  76 + onShow() {
  77 + if (this.ordId) {
  78 + this.loadData(1,null, this.ordId);
  79 + }
  80 + },
  81 + onHide() {
  82 + this.ordId = '';
  83 + },
65 84 onUnload() {
66 85 uni.setStorageSync('getConfiguration', {
67 86 isConfiguration: false
... ... @@ -91,11 +110,12 @@
91 110 this.page.num += 1;
92 111 this.loadData(this.page.num);
93 112 },
94   - async loadData(pageNo, organizationV) {
  113 + async loadData(pageNo, name,organizationId) {
95 114 let httpData = {
96 115 page: pageNo,
97 116 pageSize: 10,
98   - name: organizationV,
  117 + name,
  118 + organizationId,
99 119 platform: 'phone',
100 120 isTemplate:0
101 121 };
... ... @@ -108,13 +128,16 @@
108 128 if (res) {
109 129 uni.stopPullDownRefresh();
110 130 this.mescroll.endByPage(res.items.length, res.total);
111   - this.cameraTotal = res.total;
  131 + this.total = res.total;
112 132 if (pageNo == 1) {
113 133 this.list = res.items;
114 134 } else {
115 135 this.list = this.list.concat(res.items);
116 136 }
117 137 }
  138 + },
  139 + openOrg() {
  140 + useNavigateTo('/pages/organization/organization')
118 141 }
119 142 }
120 143 };
... ... @@ -122,4 +145,4 @@
122 145
123 146 <style lang="scss" scoped>
124 147 @import '../../static/configuration.scss';
125   -</style>
\ No newline at end of file
  148 +</style>
... ...
... ... @@ -8,8 +8,9 @@
8 8 shape="circle"></u--input>
9 9 </view>
10 10 </view>
  11 + <header-org @openOrg="openOrg" :total="total" title="看板数:" :imageSrc="imageSrc"></header-org>
11 12 </view>
12   - <view style="height:35rpx"></view>
  13 + <view style="height:128rpx"></view>
13 14 <!-- 公共组件-每个页面必须引入 -->
14 15 <public-module></public-module>
15 16 <!-- 自带分页组件 -->
... ... @@ -33,15 +34,20 @@
33 34 <script>
34 35 import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
35 36 import api from '@/api/index.js'
  37 + import headerOrg from '@/components/common/header-org.vue'
36 38 import {
37   - createScadaPageLink
38   - } from '../config/help.js';
  39 + useNavigateTo
  40 + } from '@/plugins/utils.js'
39 41
40 42 export default {
41 43 mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  44 + components:{
  45 + headerOrg
  46 + },
42 47 data() {
43 48 return {
44 49 defaultConfigImage: '../../../../static/test.png',
  50 + imageSrc:'/static/visual-board.png',
45 51 page: {
46 52 num: 0,
47 53 size: 10
... ... @@ -52,7 +58,9 @@
52 58 upOption: {
53 59 auto: false // 不自动加载
54 60 },
55   - list: []
  61 + list: [],
  62 + total:0,
  63 + ordId:''
56 64 };
57 65 },
58 66 onLoad() {
... ... @@ -62,6 +70,14 @@
62 70 isConfiguration: false
63 71 });
64 72 },
  73 + onShow() {
  74 + if (this.ordId) {
  75 + this.loadData(1,null, this.ordId);
  76 + }
  77 + },
  78 + onHide() {
  79 + this.ordId = '';
  80 + },
65 81 onUnload() {
66 82 uni.setStorageSync('getConfiguration', {
67 83 isConfiguration: false
... ... @@ -74,7 +90,6 @@
74 90 this.loadData(1, e);
75 91 },
76 92 openConfigDetail(e) {
77   - console.log(e,'e')
78 93 uni.navigateTo({
79 94 url: 'detail?id=' + e.id
80 95 });
... ... @@ -91,11 +106,12 @@
91 106 this.page.num += 1;
92 107 this.loadData(this.page.num);
93 108 },
94   - async loadData(pageNo, name) {
  109 + async loadData(pageNo, name,organizationId) {
95 110 let httpData = {
96 111 page: pageNo,
97 112 pageSize: 10,
98 113 name,
  114 + organizationId,
99 115 platform: 'phone'
100 116 };
101 117 const res = await api.homeApi.getVisualBoardApi({
... ... @@ -107,13 +123,16 @@
107 123 if (res) {
108 124 uni.stopPullDownRefresh();
109 125 this.mescroll.endByPage(res.items.length, res.total);
110   - this.cameraTotal = res.total;
  126 + this.total = res.total;
111 127 if (pageNo == 1) {
112 128 this.list = res.items;
113 129 } else {
114 130 this.list = this.list.concat(res.items);
115 131 }
116 132 }
  133 + },
  134 + openOrg() {
  135 + useNavigateTo('/pages/organization/organization')
117 136 }
118 137 }
119 138 };
... ...
1 1 .configuation-page {
2 2 background: #f8f9fa;
3   - padding: 15rpx 15rpx;
4 3 min-height: 100vh;
5 4 .configuation-header{
6   - margin-left:15rpx;
7   - background-color: #f8f9fa;
  5 + background-color: #fff;
8 6 position:fixed;
9 7 top:0rpx;
10 8 z-index: 99999;
... ... @@ -16,19 +14,22 @@
16 14 justify-content: space-between;
17 15 flex-direction: row;
18 16 .search-main {
19   - width: 700rpx;
  17 + background: #fff;
  18 + width: 750rpx;
  19 + padding:0 25rpx;
20 20 margin-top: -34rpx;
21 21 }
22 22 }
23 23 }
24 24
25 25 .configuation-container {
  26 + padding: 15rpx 15rpx;
26 27 .configuation-item {
27 28 width: 750rpx;
28 29 display: flex;
29 30 justify-content: space-between;
30 31 flex-wrap: wrap;
31   - margin: 58rpx 0rpx 0rpx 6rpx;
  32 + margin: 128rpx 0rpx 0rpx 6rpx;
32 33 .item {
33 34 width: 330rpx;
34 35 height: 288rpx;
... ... @@ -59,4 +60,4 @@
59 60 .configuation-detail-page {
60 61 background: #f8f9fa;
61 62 min-height: 100vh;
62   - }
\ No newline at end of file
  63 + }
... ...