修改关键指标概览 已选指标
This commit is contained in:
@@ -23,6 +23,7 @@ export const queryByCode = (code) => {
|
||||
return request({
|
||||
url: '/system-boot/dictTree/queryByCode',
|
||||
method: 'post',
|
||||
debounce: false,
|
||||
data: {
|
||||
code,
|
||||
},
|
||||
@@ -34,6 +35,7 @@ export const queryCsDictTree = (pid) => {
|
||||
return request({
|
||||
url: '/system-boot/dictTree/query',
|
||||
method: 'post',
|
||||
debounce: false,
|
||||
data: {
|
||||
pid,
|
||||
},
|
||||
|
||||
@@ -7,5 +7,6 @@ export default {
|
||||
dictData: 'dictData', // 字典数据
|
||||
messageCount: 'messageCount', // 消息数量
|
||||
serverConfig: 'serverConfig', // 服务内容配置
|
||||
monitorSelectedIndicators: 'monitorSelectedIndicators', // 监测点已选展示指标
|
||||
monitorSelectedIndicators: 'monitorSelectedIndicators', // 非治理监测点已选展示指标
|
||||
monitorSelectedIndicatorsPqCom: 'monitorSelectedIndicatorsPqCom', // 治理监测点已选展示指标
|
||||
}
|
||||
|
||||
@@ -28,21 +28,41 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="indicators-card card">
|
||||
<view class="indicator-group">
|
||||
<text class="indicator-group-title">治理监测点指标</text>
|
||||
<view class="indicator-tags">
|
||||
<view
|
||||
v-for="(tag, idx) in selectedIndicators"
|
||||
:key="tag"
|
||||
v-for="(tag, idx) in selectedIndicatorsPqCom"
|
||||
:key="'governance-' + tag"
|
||||
class="indicator-tag indicator-tag--active"
|
||||
@click="removeIndicator(idx)"
|
||||
@click="removeIndicator(idx, 'governance')"
|
||||
>
|
||||
<text class="indicator-tag-text">{{ formatIndicatorTag(tag) }}</text>
|
||||
<uni-icons type="closeempty" size="12" color="#376cf3" />
|
||||
</view>
|
||||
<view class="indicator-tag indicator-tag--add" @click="openIndicatorPopup">
|
||||
<view class="indicator-tag indicator-tag--add" @click="openIndicatorPopup('governance')">
|
||||
<text>+添加指标</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="indicator-group">
|
||||
<text class="indicator-group-title">非治理监测点指标</text>
|
||||
<view class="indicator-tags">
|
||||
<view
|
||||
v-for="(tag, idx) in selectedIndicators"
|
||||
:key="'normal-' + tag"
|
||||
class="indicator-tag indicator-tag--active"
|
||||
@click="removeIndicator(idx, 'normal')"
|
||||
>
|
||||
<text class="indicator-tag-text">{{ formatIndicatorTag(tag) }}</text>
|
||||
<uni-icons type="closeempty" size="12" color="#376cf3" />
|
||||
</view>
|
||||
<view class="indicator-tag indicator-tag--add" @click="openIndicatorPopup('normal')">
|
||||
<text>+添加指标</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="monitor-section">
|
||||
<view class="monitor-section-header">
|
||||
@@ -153,17 +173,22 @@
|
||||
<view class="indicator-popup">
|
||||
<view class="indicator-popup-header" @touchmove.stop.prevent>
|
||||
<text class="indicator-popup-cancel" @click="closeIndicatorPopup">取消</text>
|
||||
<text class="indicator-popup-title">{{ indicatorPopupSubtitle }}</text>
|
||||
<text class="indicator-popup-confirm" @click="confirmIndicatorPopup">确定</text>
|
||||
</view>
|
||||
<scroll-view class="indicator-popup-list" scroll-y :show-scrollbar="false" @touchmove.stop>
|
||||
<view v-if="targetLists.length === 0" class="indicator-popup-empty">
|
||||
<view class="indicator-popup-section">
|
||||
<!-- <text class="indicator-popup-subtitle">{{ indicatorPopupSubtitle }}</text> -->
|
||||
<view v-if="currentPopupTargetLists.length === 0" class="indicator-popup-empty">
|
||||
<text>暂无指标数据</text>
|
||||
</view>
|
||||
<view
|
||||
v-for="item in targetLists"
|
||||
v-for="item in currentPopupTargetLists"
|
||||
:key="item.id || item.name"
|
||||
class="indicator-popup-item"
|
||||
:class="{ 'indicator-popup-item--active': popupSelectedIndicators.includes(item.name) }"
|
||||
:class="{
|
||||
'indicator-popup-item--active': popupSelectedIndicators.includes(item.name),
|
||||
}"
|
||||
@click="togglePopupIndicator(item.name)"
|
||||
>
|
||||
<text>{{ item.name }}</text>
|
||||
@@ -174,6 +199,7 @@
|
||||
color="#376cf3"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
@@ -188,13 +214,15 @@ import { getDevCount } from '@/common/api/device.js'
|
||||
/** 无本地缓存时的默认展示指标:电压、电流 */
|
||||
const DEFAULT_INDICATOR_CODES = ['Key_Power_Quality_V', 'Key_Power_Quality_I']
|
||||
|
||||
/** 治理测点(lineType=0)卡片默认展示的指标 */
|
||||
const GOVERNANCE_DEFAULT_INDICATORS = ['电网电流', '电网电压', '负载电流', '总输出电流']
|
||||
/** 治理测点无缓存时的默认展示指标 */
|
||||
const GOVERNANCE_DEFAULT_INDICATOR_CODES = ['0', '1']
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
targetLists: [],
|
||||
targetListsPqCom: [],
|
||||
indicatorPopupType: 'governance',
|
||||
popupSelectedIndicators: [],
|
||||
engineeringName: '',
|
||||
engineeringId: '',
|
||||
@@ -204,6 +232,7 @@ export default {
|
||||
{ label: '监测点总数', value: 0 },
|
||||
],
|
||||
selectedIndicators: [],
|
||||
selectedIndicatorsPqCom: [],
|
||||
phaseColors: [
|
||||
{ name: 'A相', color: '#DAA520' },
|
||||
{ name: 'B相', color: '#2E8B57' },
|
||||
@@ -219,6 +248,12 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
indicatorPopupSubtitle() {
|
||||
return this.indicatorPopupType === 'governance' ? '治理监测点指标' : '非治理监测点指标'
|
||||
},
|
||||
currentPopupTargetLists() {
|
||||
return this.indicatorPopupType === 'governance' ? this.targetListsPqCom : this.targetLists
|
||||
},
|
||||
filteredMonitoringPoints() {
|
||||
const keyword = (this.filterKeyword || '').trim().toLowerCase()
|
||||
if (!keyword) return this.monitoringPoints
|
||||
@@ -249,18 +284,21 @@ export default {
|
||||
this.info()
|
||||
}
|
||||
}
|
||||
if (this.targetLists.length && !skipRefresh) {
|
||||
if ((this.targetLists.length || this.targetListsPqCom.length) && !skipRefresh) {
|
||||
this.loadSelectedIndicators()
|
||||
}
|
||||
},
|
||||
// 加载电能质量指标字典
|
||||
created() {
|
||||
queryByCode('Key_Power_Quality').then((res) => {
|
||||
queryCsDictTree(res.data.id).then((resp) => {
|
||||
this.targetLists = (resp.data || []).slice().reverse()
|
||||
const loadDictTree = (code) => queryByCode(code).then((res) => queryCsDictTree(res.data.id))
|
||||
|
||||
Promise.all([loadDictTree('Key_Power_Quality'), loadDictTree('Key_Power_Quality_Pq_Com')]).then(
|
||||
([normalResp, pqComResp]) => {
|
||||
this.targetLists = (normalResp.data || []).slice().reverse()
|
||||
this.targetListsPqCom = (pqComResp.data || []).slice().reverse()
|
||||
this.loadSelectedIndicators()
|
||||
})
|
||||
})
|
||||
},
|
||||
)
|
||||
},
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
@@ -347,7 +385,7 @@ export default {
|
||||
return order.map((key) => map[key])
|
||||
},
|
||||
formatPhaseValue(value) {
|
||||
if (value === null || value === undefined || value === '') return '-'
|
||||
if (value === null || value === undefined || value === '' || value === 3.14159) return '-'
|
||||
const num = Number(value)
|
||||
if (Number.isNaN(num)) return String(value)
|
||||
return num.toFixed(2)
|
||||
@@ -377,8 +415,13 @@ export default {
|
||||
const selectedBase = (selected || '').replace(/\(.*\)/, '').trim()
|
||||
return base === selectedBase
|
||||
},
|
||||
// 从缓存读取已选指标,无缓存时使用默认电压/电流指标
|
||||
// 从缓存读取已选指标,无缓存时使用默认指标
|
||||
loadSelectedIndicators() {
|
||||
this.loadNormalSelectedIndicators()
|
||||
this.loadGovernanceSelectedIndicators()
|
||||
},
|
||||
loadNormalSelectedIndicators() {
|
||||
if (!this.targetLists.length) return
|
||||
const cached = uni.getStorageSync(this.$cacheKey.monitorSelectedIndicators)
|
||||
if (Array.isArray(cached) && cached.length) {
|
||||
const valid = cached.filter((name) =>
|
||||
@@ -392,35 +435,68 @@ export default {
|
||||
this.selectedIndicators = this.getDefaultIndicatorsByCode()
|
||||
this.saveSelectedIndicators()
|
||||
},
|
||||
loadGovernanceSelectedIndicators() {
|
||||
if (!this.targetListsPqCom.length) return
|
||||
const cached = uni.getStorageSync(this.$cacheKey.monitorSelectedIndicatorsPqCom)
|
||||
if (Array.isArray(cached) && cached.length) {
|
||||
const valid = cached.filter((name) =>
|
||||
this.targetListsPqCom.some((item) => this.matchIndicator(item.name, name)),
|
||||
)
|
||||
if (valid.length) {
|
||||
this.selectedIndicatorsPqCom = valid
|
||||
return
|
||||
}
|
||||
}
|
||||
this.selectedIndicatorsPqCom = this.getDefaultGovernanceIndicators()
|
||||
this.saveSelectedIndicatorsPqCom()
|
||||
},
|
||||
getDefaultIndicatorsByCode() {
|
||||
return this.targetLists
|
||||
.filter((item) => DEFAULT_INDICATOR_CODES.includes(item.code) && item.name)
|
||||
.map((item) => item.name)
|
||||
},
|
||||
getDefaultGovernanceIndicators() {
|
||||
return this.targetListsPqCom
|
||||
.filter((item) => GOVERNANCE_DEFAULT_INDICATOR_CODES.includes(item.code) && item.name)
|
||||
.map((item) => item.name)
|
||||
},
|
||||
saveSelectedIndicators() {
|
||||
uni.setStorageSync(this.$cacheKey.monitorSelectedIndicators, this.selectedIndicators)
|
||||
},
|
||||
saveSelectedIndicatorsPqCom() {
|
||||
uni.setStorageSync(this.$cacheKey.monitorSelectedIndicatorsPqCom, this.selectedIndicatorsPqCom)
|
||||
},
|
||||
// 跳转切换工程
|
||||
switchEngineering() {
|
||||
uni.navigateTo({ url: '/pages/home/selectEngineering' })
|
||||
},
|
||||
// 移除已选指标
|
||||
removeIndicator(idx) {
|
||||
if (this.selectedIndicators.length <= 1) {
|
||||
removeIndicator(idx, type = 'normal') {
|
||||
const isGovernance = type === 'governance'
|
||||
const selected = isGovernance ? this.selectedIndicatorsPqCom : this.selectedIndicators
|
||||
if (selected.length <= 1) {
|
||||
uni.showToast({ title: '至少保留一个指标', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.selectedIndicators.splice(idx, 1)
|
||||
selected.splice(idx, 1)
|
||||
if (isGovernance) {
|
||||
this.saveSelectedIndicatorsPqCom()
|
||||
} else {
|
||||
this.saveSelectedIndicators()
|
||||
}
|
||||
},
|
||||
// 打开指标选择弹窗
|
||||
openIndicatorPopup() {
|
||||
if (!this.targetLists.length) {
|
||||
openIndicatorPopup(type = 'governance') {
|
||||
const isGovernance = type === 'governance'
|
||||
const targetLists = isGovernance ? this.targetListsPqCom : this.targetLists
|
||||
const selected = isGovernance ? this.selectedIndicatorsPqCom : this.selectedIndicators
|
||||
if (!targetLists.length) {
|
||||
uni.showToast({ title: '暂无指标数据', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.popupSelectedIndicators = this.targetLists
|
||||
.filter((item) => this.selectedIndicators.some((name) => this.matchIndicator(item.name, name)))
|
||||
this.indicatorPopupType = type
|
||||
this.popupSelectedIndicators = targetLists
|
||||
.filter((item) => selected.some((name) => this.matchIndicator(item.name, name)))
|
||||
.map((item) => item.name)
|
||||
this.$refs.indicatorPopup.open()
|
||||
},
|
||||
@@ -428,6 +504,7 @@ export default {
|
||||
closeIndicatorPopup() {
|
||||
this.$refs.indicatorPopup.close()
|
||||
this.popupSelectedIndicators = []
|
||||
this.indicatorPopupType = 'governance'
|
||||
},
|
||||
onIndicatorPopupChange(e) {
|
||||
this.indicatorPopupShow = !!e.show
|
||||
@@ -447,8 +524,13 @@ export default {
|
||||
uni.showToast({ title: '至少保留一个指标', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.indicatorPopupType === 'governance') {
|
||||
this.selectedIndicatorsPqCom = [...this.popupSelectedIndicators]
|
||||
this.saveSelectedIndicatorsPqCom()
|
||||
} else {
|
||||
this.selectedIndicators = [...this.popupSelectedIndicators]
|
||||
this.saveSelectedIndicators()
|
||||
}
|
||||
this.closeIndicatorPopup()
|
||||
},
|
||||
// 跳转指标详情页,展示该监测点全部指标
|
||||
@@ -463,17 +545,13 @@ export default {
|
||||
url: '/pages/index/comp/targetInfo',
|
||||
})
|
||||
},
|
||||
// 治理测点默认 4 项;普通测点按顶部已选指标过滤
|
||||
// 按监测点类型取对应已选指标过滤展示
|
||||
getDisplayChildren(point) {
|
||||
const children = point.children || []
|
||||
if (point.lineType === 0) {
|
||||
return GOVERNANCE_DEFAULT_INDICATORS.map((name) =>
|
||||
children.find((child) => this.matchIndicator(child.name, name)),
|
||||
).filter(Boolean)
|
||||
}
|
||||
return children.filter((child) =>
|
||||
this.selectedIndicators.some((name) => this.matchIndicator(child.name, name)),
|
||||
)
|
||||
const selected = point.lineType === 0 ? this.selectedIndicatorsPqCom : this.selectedIndicators
|
||||
return selected
|
||||
.map((name) => children.find((child) => this.matchIndicator(child.name, name)))
|
||||
.filter(Boolean)
|
||||
},
|
||||
// 有指标数据时显示「更多指标」
|
||||
shouldShowMoreBtn(point) {
|
||||
@@ -639,6 +717,21 @@ export default {
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.indicator-group {
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.indicator-group-title {
|
||||
display: block;
|
||||
margin-bottom: 12rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.section-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -919,6 +1012,14 @@ export default {
|
||||
min-width: 80rpx;
|
||||
}
|
||||
|
||||
.indicator-popup-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.indicator-popup-confirm {
|
||||
font-size: 28rpx;
|
||||
color: #376cf3;
|
||||
@@ -928,12 +1029,23 @@ export default {
|
||||
|
||||
.indicator-popup-list {
|
||||
height: 60vh;
|
||||
padding: 16rpx 0;
|
||||
padding: 8rpx 0 16rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.indicator-popup-section {
|
||||
padding-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.indicator-popup-subtitle {
|
||||
display: block;
|
||||
padding: 16rpx 32rpx 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.indicator-popup-empty {
|
||||
padding: 80rpx 0;
|
||||
padding: 40rpx 0;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
@@ -943,8 +1055,8 @@ export default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 28rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 20rpx 32rpx;
|
||||
font-size: 26rpx;
|
||||
color: #333333;
|
||||
|
||||
&--active {
|
||||
|
||||
Reference in New Issue
Block a user