This commit is contained in:
sjl
2025-01-16 14:24:55 +08:00
parent 891c6d8e93
commit 55ae64b3e1
8 changed files with 113 additions and 32 deletions

View File

@@ -62,6 +62,7 @@ export namespace Dict {
name: string; // 名称 name: string; // 名称
code: string; // 编码 code: string; // 编码
sort: number; // 排序 sort: number; // 排序
openValue?: number | null;
level?: number | null; // 事件等级0-普通1-中等2-严重 (默认为0) level?: number | null; // 事件等级0-普通1-中等2-严重 (默认为0)
algoDescribe?: number | null; // 与高级算法内部Id描述对应 algoDescribe?: number | null; // 与高级算法内部Id描述对应
value?: string | null; // 字典针对电压等级 value?: string | null; // 字典针对电压等级

View File

@@ -142,21 +142,21 @@
</el-dropdown> </el-dropdown>
</div> --> </div> -->
<el-button <!-- <el-button
type='primary' type='primary'
link link
:icon='Download' :icon='Download'
@click="openDrawer('报告下载', scope.row)" @click="openDrawer('报告下载', scope.row)"
v-if='form.activeTabs === 3 && form.activeChildTabs === 0 && scope.row.reportState === 1' v-if='form.activeTabs === 3 && form.activeChildTabs === 0 && scope.row.reportState === 1'
>报告下载 >报告下载
</el-button> </el-button> -->
<el-button <el-button
type='primary' type='primary'
link link
:icon='Postcard' :icon='Postcard'
@click="openDrawer('报告生成', scope.row)" @click="openDrawer('报告生成', scope.row)"
v-if='form.activeTabs === 3 && scope.row.reportState !== 1' v-if='form.activeTabs === 3 '
>报告生成 >报告生成
</el-button> </el-button>
<!-- <el-button <!-- <el-button
@@ -477,6 +477,7 @@ const getTableList = async (params: any) => {
} else { } else {
checkStateList.value = checkStateTable.value checkStateList.value = checkStateTable.value
} }
console.log('tablegetBoundPqDevList')
return getBoundPqDevList({ return getBoundPqDevList({
'planId': props.id, 'planId': props.id,
'checkStateList': checkStateList.value, 'checkStateList': checkStateList.value,
@@ -659,10 +660,12 @@ const handleSelectionChange = (selection: any[]) => {
//查询 //查询
const handleSearch = () => { const handleSearch = () => {
console.log('handleSearchgetBoundPqDevList')
proTable.value?.getTableList() proTable.value?.getTableList()
} }
//重置 //重置
const handleRefresh = () => { const handleRefresh = () => {
console.log('handleRefreshgetBoundPqDevList')
form.value.search = null form.value.search = null
form.value.checkStatus = null form.value.checkStatus = null
form.value.checkResult = null form.value.checkResult = null
@@ -772,7 +775,11 @@ function tableHeaderInit(val: number) {
break break
} }
//console.log("test",columns); //console.log("test",columns);
handleRefresh() form.value.search = null
form.value.checkStatus = null
form.value.checkResult = null
form.value.checkReportStatus = null
//handleRefresh()
} }
function refreshStatusList() { function refreshStatusList() {
@@ -980,7 +987,7 @@ const handleTest = async (val: string) => {
const data = reactive({ const data = reactive({
socketServe: socketClient.Instance, socketServe: socketClient.Instance,
}); });
const url = 'ws://localhost:7777/hello?name=cdf'; const url = 'ws://192.168.1.127:7777/hello?name=cdf';
socketClient.Instance.connect(url); socketClient.Instance.connect(url);
data.socketServe = socketClient.Instance; data.socketServe = socketClient.Instance;
data.socketServe.registerCallBack('aaa', (res: { code: number; }) => { data.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
@@ -1034,6 +1041,8 @@ const handleTest = async (val: string) => {
ElMessage.success('归档成功!') ElMessage.success('归档成功!')
} }
}) })
emit('batchGenerateClicked') // 触发事件
} }

View File

@@ -56,6 +56,7 @@ const searchForm = ref({
}) })
const defaultChecked = ref<string[]>([]) // 明确类型为 number[] const defaultChecked = ref<string[]>([]) // 明确类型为 number[]
const getTreeData = (val: any) => { const getTreeData = (val: any) => {
defaultChecked.value = [] defaultChecked.value = []
data.value = val data.value = val
if (data.value.length > 0 && data.value[0].children.length > 0) { if (data.value.length > 0 && data.value[0].children.length > 0) {
@@ -76,6 +77,30 @@ const getTreeData = (val: any) => {
} }
//点击表格后左侧树刷新,高亮显示对应节点
const clickTableToTree = (val: any,id:any) => {
defaultChecked.value = []
data.value = val
let node = ref('')
if (data.value.length > 0) {
for (let i = 0; i < data.value.length; i++){
for (let j = 0; j < data.value[i].children.length; j++) {
if (data.value[i].children[j].id == id) {
node.value = data.value[i].children[j].id
break;
}
}
}
// 使用 nextTick 确保在 DOM 更新后调用 setCurrentKey
nextTick(() => {
treeRef.value?.setCurrentKey(node.value);
idd.value = node.value
});
}
}
const {updateSelectedTreeNode} = defineProps<{ const {updateSelectedTreeNode} = defineProps<{
updateSelectedTreeNode:Function; updateSelectedTreeNode:Function;
}>(); }>();
@@ -123,7 +148,7 @@ const detail = () => {
onMounted(() => { onMounted(() => {
// console.log() // console.log()
}) })
defineExpose({ getTreeData }) defineExpose({ getTreeData ,clickTableToTree})
</script> </script>

View File

@@ -4,7 +4,8 @@
<el-row :gutter='10'> <el-row :gutter='10'>
<el-col :lg='4' :xl='4' :md='4' :sm='4'> <el-col :lg='4' :xl='4' :md='4' :sm='4'>
<div class='left_tree'> <div class='left_tree'>
<tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' /> <!-- <tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' /> -->
<tree ref='treeRef' :updateSelectedTreeNode='updateData|| (() => {})' />
</div> </div>
</el-col> </el-col>
<el-col :lg='20' :xl='20' :md='20' :sm='20'> <el-col :lg='20' :xl='20' :md='20' :sm='20'>
@@ -266,16 +267,10 @@ const findPlanById = (plans: Plan.ReqPlan[], id: string): Plan.ReqPlan | undefin
return undefined return undefined
} }
const getPieData = async (id: string) => {
currentId.value = id // 设置当前ID const updateData = (id: string) => {
// 初始化计数对象 getPieData(id);//刷新饼图
const checkStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0, 3: 0 }
const checkResultCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
if (id) {
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const plan = findPlanById(planList.value?.data || [], id)
planName.value = '所选计划:' + plan.name
//获取点击树的父节点名字 //获取点击树的父节点名字
const parentNodeName = ref('') const parentNodeName = ref('')
for (let i = 0; i < planList.value.data.length; i++) { for (let i = 0; i < planList.value.data.length; i++) {
@@ -293,6 +288,19 @@ const getPieData = async (id: string) => {
}else{ }else{
handleCheckFunction(0) handleCheckFunction(0)
} }
}
const getPieData = async (id: string) => {
currentId.value = id // 设置当前ID
// 初始化计数对象
const checkStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0, 3: 0 }
const checkResultCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
const reportStateCount: { [key: number]: number } = { 0: 0, 1: 0, 2: 0 }
if (id) {
const boundPqDevList = ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const plan = findPlanById(planList.value?.data || [], id)
planName.value = '所选计划:' + plan.name
select_Plan.value = plan select_Plan.value = plan
if (plan) { if (plan) {
@@ -302,6 +310,7 @@ const getPieData = async (id: string) => {
// 处理未找到计划的情况 // 处理未找到计划的情况
isTimeCheck.value = false // 或者其他默认值 isTimeCheck.value = false // 或者其他默认值
} }
console.log('饼图getBoundPqDevList')
const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] }) const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] })
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[] boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]
// 遍历 boundPqDevList 并更新计数对象 // 遍历 boundPqDevList 并更新计数对象
@@ -431,7 +440,8 @@ const resizeObserver = new ResizeObserver(entries => {
} }
}) })
onBeforeMount(async () => {
const initPlan = async () => {
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
const reqPlan: Plan.ReqPlan = { const reqPlan: Plan.ReqPlan = {
pattern: patternId, pattern: patternId,
@@ -455,8 +465,10 @@ onBeforeMount(async () => {
state: 0, state: 0,
} }
planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]> planList.value = (await getPlanListByPattern(reqPlan)) as ResultData<Plan.ReqPlan[]>
}
console.log(planList.value.data) onBeforeMount(async () => {
await initPlan()
for (let i = 0; i < planList.value.data.length; i++) { for (let i = 0; i < planList.value.data.length; i++) {
if (Array.isArray(planList.value.data[i].children) && planList.value.data[i].children.length > 0) { if (Array.isArray(planList.value.data[i].children) && planList.value.data[i].children.length > 0) {
currentId.value = planList.value.data[i].children[0].id; // 直接赋值第一个 children 的 id currentId.value = planList.value.data[i].children[0].id; // 直接赋值第一个 children 的 id
@@ -483,9 +495,11 @@ onUnmounted(() => {
} }
}) })
const handleBatchGenerate = () => { const handleBatchGenerate = async () => {
console.log('批量生成按钮被点击了'); console.log('批量生成按钮被点击了');
// 在这里添加其他逻辑,比如显示对话框、更新状态等 // 在这里添加其他逻辑,比如显示对话框、更新状态等
await initPlan()
treeRef.value.clickTableToTree(planList.value.data,currentId.value)
getPieData(currentId.value) getPieData(currentId.value)
if (form.value.activeTabs === 0)//设备检测 if (form.value.activeTabs === 0)//设备检测

View File

@@ -344,6 +344,13 @@ const rules = computed(() => {
{ {
formContent.value.arrivedDate = dayjs(formContent.value.arrivedDate).format('YYYY-MM-DD'); formContent.value.arrivedDate = dayjs(formContent.value.arrivedDate).format('YYYY-MM-DD');
} }
//保存时判是否加密,把识别码密钥字段清空
if(formContent.value.encryptionFlag === 0){
formContent.value.series = null
formContent.value.devKey = null
}
if (formContent.value.id) { if (formContent.value.id) {
await updatePqDev(formContent.value); await updatePqDev(formContent.value);
ElMessage.success({ message: `${dialogTitle.value}成功!` }) ElMessage.success({ message: `${dialogTitle.value}成功!` })

View File

@@ -12,10 +12,16 @@
<el-form-item label="编码" :label-width="100" prop="code"> <el-form-item label="编码" :label-width="100" prop="code">
<el-input v-model="formContent.code" placeholder="请输入" autocomplete="off"/> <el-input v-model="formContent.code" placeholder="请输入" autocomplete="off"/>
</el-form-item> </el-form-item>
<el-form-item label="" :label-width="100" prop="dictValue"> <el-form-item label="开启值描述" :label-width="100" >
<el-input v-model="formContent.dictValue" placeholder="请输入" autocomplete="off"/> <el-radio-group v-model="formContent.openValue" @change="handleOpenValueChange">
<el-radio-button label="开启" :value="1"></el-radio-button>
<el-radio-button label="关闭" :value="0"></el-radio-button>
</el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="事件等级" :label-width="100" prop="level"> <el-form-item label="" :label-width="100" prop="value" v-if="formContent.openValue==1">
<el-input v-model="formContent.value" placeholder="请输入" autocomplete="off"/>
</el-form-item>
<el-form-item label="事件等级" :label-width="100" prop="level" v-if="false">
<el-select v-model.number="formContent.level"> <el-select v-model.number="formContent.level">
<el-option label="普通" :value="0"/> <el-option label="普通" :value="0"/>
<el-option label="中等" :value="1"/> <el-option label="中等" :value="1"/>
@@ -42,7 +48,7 @@ import {dialogSmall} from "@/utils/elementBind";
import {addDictData, updateDictData} from "@/api/system/dictionary/dictData/index.ts"; import {addDictData, updateDictData} from "@/api/system/dictionary/dictData/index.ts";
import {Dict} from "@/api/system/dictionary/interface"; import {Dict} from "@/api/system/dictionary/interface";
import {ElMessage, FormItemRule} from "element-plus"; import {ElMessage, FormItemRule} from "element-plus";
import type {Ref} from "vue"; import {computed, Ref} from "vue";
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({ const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
name: [{required: true, message: '类型名称必填!', trigger: 'blur'}], name: [{required: true, message: '类型名称必填!', trigger: 'blur'}],
@@ -63,10 +69,11 @@ function useMetaInfo() {
name: "", name: "",
code: "", code: "",
value: "", value: "",
dictValue: "", //dictValue: "",
level: 0, level: 0,
sort: 100, sort: 100,
state: 1, state: 1,
openValue:0
}) })
return {dialogVisible, titleType, formContent, dictTypeName}; return {dialogVisible, titleType, formContent, dictTypeName};
@@ -83,10 +90,18 @@ const resetFormContent = () => {
name: "", name: "",
code: "", code: "",
value: "", value: "",
dictValue: "", //dictValue: "",
level: 0, level: 0,
sort: 100, sort: 100,
state: 1, state: 1,
openValue:0
}
}
const handleOpenValueChange = ()=> {
if(formContent.value.openValue == 0){
formContent.value.value = null
} }
} }
@@ -106,15 +121,18 @@ const open = (sign: string, typeId: string, name: string, data: Dict.ResDictData
dialogVisible.value = true dialogVisible.value = true
if (data.id) { if (data.id) {
formContent.value = {...data} formContent.value = {...data}
formContent.value.dictValue = data.value //formContent.value.dictValue = data.value
} }
} }
const save = () => { const save = () => {
try { try {
dialogFormRef.value?.validate(async (valid: boolean) => { dialogFormRef.value?.validate(async (valid: boolean) => {
if(formContent.value.openValue === 0){
formContent.value.value = null
}
if (valid) { if (valid) {
formContent.value.value = formContent.value.dictValue
if (formContent.value.id) { if (formContent.value.id) {
await updateDictData(formContent.value) await updateDictData(formContent.value)
} else { } else {

View File

@@ -33,6 +33,7 @@ import {useHandleData} from '@/hooks/useHandleData'
import {deleteDictData, getDictDataListByTypeId, exportDictData} from "@/api/system/dictionary/dictData/index"; import {deleteDictData, getDictDataListByTypeId, exportDictData} from "@/api/system/dictionary/dictData/index";
import {useDownload} from "@/hooks/useDownload"; import {useDownload} from "@/hooks/useDownload";
import {exportDictType} from "@/api/system/dictionary/dictType"; import {exportDictType} from "@/api/system/dictionary/dictType";
import { isShallow } from 'vue';
defineOptions({ defineOptions({
name: 'dict' name: 'dict'
}) })
@@ -80,7 +81,13 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
{ {
prop: 'value', prop: 'value',
label: '值', label: '值',
minWidth: 180 minWidth: 180,
render: (scope) => {
if (scope.row.openValue === 0 || scope.row.value === null || scope.row.value === '') {
return <span>/</span>; // 使用 JSX 返回 VNode
}
return <span>{scope.row.value}</span>; // 使用 JSX 返回 VNode
}
}, },
{ {
prop: 'level', prop: 'level',

View File

@@ -8,13 +8,13 @@
<el-form-item label='类型编码' :label-width='100' prop='code'> <el-form-item label='类型编码' :label-width='100' prop='code'>
<el-input v-model='formContent.code' placeholder='请输入' autocomplete='off' /> <el-input v-model='formContent.code' placeholder='请输入' autocomplete='off' />
</el-form-item> </el-form-item>
<el-form-item label="开启等级" :label-width="100"> <el-form-item label="开启等级" :label-width="100" v-if="false">
<el-radio-group v-model="formContent.openLevel" > <el-radio-group v-model="formContent.openLevel" >
<el-radio-button label="开启" :value="1"></el-radio-button> <el-radio-button label="开启" :value="1"></el-radio-button>
<el-radio-button label="关闭" :value="0"></el-radio-button> <el-radio-button label="关闭" :value="0"></el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="开启描述" :label-width="100"> <el-form-item label="开启描述" :label-width="100" v-if="false">
<el-radio-group v-model="formContent.openDescribe" > <el-radio-group v-model="formContent.openDescribe" >
<el-radio-button label="开启" :value="1"></el-radio-button> <el-radio-button label="开启" :value="1"></el-radio-button>
<el-radio-button label="关闭" :value="0"></el-radio-button> <el-radio-button label="关闭" :value="0"></el-radio-button>