故障中文描述缓存到localstroge

This commit is contained in:
fengrong 2024-12-20 17:36:05 +08:00
parent ac1dd150a8
commit d008a10f22
5 changed files with 95 additions and 38 deletions

View File

@ -0,0 +1,18 @@
import { defineStore } from 'pinia'
import type { Faults } from '/@/stores/interface'
export const useFaultsStore = defineStore('faults', {
state: (): Faults => ({
data: {},
keys: []
}),
actions: {
setData(data: Faults['data']) {
this.data = data
},
setKeys(keys: string[]) {
this.keys = keys
}
},
persist: true
})

View File

@ -135,3 +135,9 @@ export interface Enums {
}
keys: string[]
}
export interface Faults {
data: {
[key: string]: { [k: string]: string }
}
keys: string[]
}

View File

@ -58,16 +58,18 @@ import { useRoute } from 'vue-router'
import { getParamList } from '/@/api/backend/SystemParam/request'
import { queryfaultCodeDict } from '/@/api/backend/theoreticalpowerCurve/request'
import { useEnumStore } from '/@/stores/enums'
import { useFaultsStore } from '/@/stores/faults'
import {equipList} from "/@/api/backend/realData/request";
const route = useRoute()
const enumStore = useEnumStore()
const faultCodeDict = useFaultsStore()
const d = new Date()
const { t } = useI18n()
let timer: any = null
let myTable = ref<TableInstance>()
const windList=ref([])
const overviewSlotData= ref('')
@ -235,13 +237,17 @@ const StatusListData = () => {
let color:any=''
const state = getRealTimeState(item.attributeMap)
let firsttriggeredcode=item.attributeMap.firsttriggeredcode
const key = `${item.madeinFactory}-${item.model}`;
if (enumStore.keys.includes('FirstTriggeredCode')) {
firsttriggeredcode = enumStore.data['FirstTriggeredCode'][firsttriggeredcode]
}
/*if (malFunctionKeys.includes('FirstTriggeredCode')) {
firsttriggeredcode = malFunctionEnums?.[firsttriggeredcode] ?? firsttriggeredcode
if (faultCodeDict.keys.includes(key)) {
if (firsttriggeredcode == 0) {
firsttriggeredcode = '';
} else {
firsttriggeredcode = faultCodeDict.data[key][firsttriggeredcode] ?? '';
}
}
*/
paramColorData.value.forEach((item, index) => {
if (item.state == state) {
color = item.color
@ -345,7 +351,6 @@ const StatusListData = () => {
locked: item.attributeMap.locked,
irotorspeed: item.attributeMap.irotorspeed,
firsttriggeredcode:firsttriggeredcode,
//firsttriggeredcode:item.attributeMap.firsttriggeredcode,
},
}
})
@ -358,36 +363,34 @@ const StatusListData = () => {
}
})
}
let malFunctionEnums: any = {}
//
/*const malFunctionEnums = ref<{ [key: string]: { [code: string]: string } }>({});
/*const requestedParams = new Set<string>();
const requestedParams = new Set<string>();
const failedRequests = new Set<string>();
const fetchData = async (item: any) => {
//
const key = `${item.madeinFactory}-${item.model}`;
// Set
if (requestedParams.has(key)) {
console.log('Duplicate request detected, skipping...');
return;
}
// Set
requestedParams.add(key);
try {
console.log({ madeinfactory: item.madeinFactory, model: item.model })
const response = await queryfaultCodeDict({ madeinfactory: item.madeinFactory, model: item.model });
if (response.code === 200) {
const data: any = {};
response.data.forEach((item: any) => {
data[item.code] = item.description;
});
malFunctionEnums = data;
malFunctionEnums.value[key] = data;
} else {
console.warn('查询故障代码字典失败:', response.message);
failedRequests.add(key);
}
} catch (error) {
console.error('请求出错:', error);
failedRequests.add(key);
}
};*/
@ -428,14 +431,6 @@ onMounted(() => {
res.data.map((item: any) => {
deviceCode.value.push(item.code)
})
windList.value=res.data.map((item: any) => {
//fetchData(item)
return {
madeinfactory:item.madeinFactory,
model: item.model ?? '-',
}
})
//getMalfunctionEnums()
})
overviewList()

View File

@ -11,7 +11,6 @@
'': item.standard==0,
'wind-offline': item.attributeMap.processedoperationmode == 33
}">
<div class="fanlist-top">
<span :class="item.standard == 1 ? 'wind-mark-icon' : 'fanlist-icon'">
<img :class="item.standard == 1 ? '' : 'wind-picture'" src="~assets/dashboard/biaogan.png" alt="" />
@ -69,12 +68,12 @@
</el-row>
</div>
<div class="fanlist-bottom">
<!-- <span :style="item.attributeMap.locked == 1 ? 'max-width:120px;' : 'max-width:150px;'">
{{ item.attributeMap.firsttriggeredcode }}
</span>-->
<span :style="item.attributeMap.locked == 1 ? 'max-width:120px;' : 'max-width:150px;'">
{{ getFaultDescription(item) }}
{{ item.attributeMap.firsttriggeredcode }}
</span>
<!-- <span :style="item.attributeMap.locked == 1 ? 'max-width:120px;' : 'max-width:150px;'">
{{ getFaultDescription(item) }}
</span>-->
<!-- <el-tag class="tag-panel is-danger">已锁定</el-tag>-->
<el-tag v-if="item.attributeMap.locked === 1" class="tag-panel is-danger">已锁定</el-tag>
</div>
@ -412,13 +411,7 @@ const getSafeImagePath = (item, type) => {
};
const getFaultDescription=(item)=>{
/*fetchData(item)
let firsttriggeredcode=item.attributeMap.firsttriggeredcode
if (malFunctionKeys.includes('FirstTriggeredCode')) {
firsttriggeredcode = malFunctionEnums?.[firsttriggeredcode] ?? firsttriggeredcode
}
return firsttriggeredcode*/
/*const getFaultDescription=(item)=>{
const key = `${item.madeinFactory}-${item.model}`;
if (failedRequests.has(key)) {
return '';
@ -459,17 +452,15 @@ const fetchData = async (item: any) => {
response.data.forEach((item: any) => {
data[item.code] = item.description;
});
//malFunctionEnums = data;
malFunctionEnums[key] = data;
} else {
console.warn('查询故障代码字典失败:', response.message);
failedRequests.add(key);
}
} catch (error) {
//console.error('', error);
failedRequests.add(key);
}
};
};*/
</script>

View File

@ -92,6 +92,7 @@ import { editDefaultLang } from '/@/lang/index'
import { useConfig } from '/@/stores/config'
import { useAdminInfo } from '/@/stores/adminInfo'
import { useEnumStore } from '/@/stores/enums'
import {useFaultsStore} from "/@/stores/faults"
import { login } from '/@/api/backend'
import { buildValidatorData } from '/@/utils/validate'
import router from '/@/router'
@ -100,11 +101,15 @@ import toggleDark from '/@/utils/useDark'
import { fullUrl } from '/@/utils/common'
import { adminBaseRoutePath } from '/@/router/static/adminBase'
import { getAllEnumData } from '/@/api/backend/Enumeration/request'
import {equipList} from "/@/api/backend/realData/request";
import { queryfaultCodeDict } from '/@/api/backend/theoreticalpowerCurve/request'
let timer: number
const config = useConfig()
const adminInfo = useAdminInfo()
const enumsStore = useEnumStore()
const FaultsStore = useFaultsStore()
const isSmall = ref(window.screen.width < 620 ? true : false)
@ -192,7 +197,6 @@ const load = () => {
state.captcha = 'data:image\/png;base64,' + res.data.img
})
}
const getEnumsData = () => {
getAllEnumData().then((res) => {
if (res.success) {
@ -213,6 +217,49 @@ const getEnumsData = () => {
}
})
}
equipList({ objectType: 10002 }).then((res) => {
res.data.map((item: any) => {
fetchData(item)
return {
madeinfactory:item.madeinFactory,
model: item.model ?? '-',
}
})
})
const malFunctionEnums = ref<{ [key: string]: { [code: string]: string } }>({});
const requestedParams = new Set<string>();
const failedRequests = new Set<string>();
const fetchData = async (item: any) => {
const key = `${item.madeinFactory}-${item.model}`;
if (requestedParams.has(key)) {
return;
}
requestedParams.add(key);
const keys = requestedParams;
const response = await queryfaultCodeDict({ madeinfactory: item.madeinFactory, model: item.model });
if (response.code === 200) {
const data: any = {};
response.data.forEach((item: any) => {
data[item.code] = item.description;
});
malFunctionEnums.value[key] = data;
const datas=malFunctionEnums.value
sessionStorage.setItem(
'faultCodeDict',
JSON.stringify({
datas,
keys:Array.from(requestedParams),
})
)
FaultsStore.setKeys(Array.from(requestedParams))
FaultsStore.setData(datas)
} else {
console.warn('查询故障代码字典失败:', response.message);
failedRequests.add(key);
}
};
const onSubmit = () => {
state.submitLoading = true