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

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

View File

@@ -56,6 +56,7 @@ const searchForm = ref({
})
const defaultChecked = ref<string[]>([]) // 明确类型为 number[]
const getTreeData = (val: any) => {
defaultChecked.value = []
data.value = val
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<{
updateSelectedTreeNode:Function;
}>();
@@ -123,7 +148,7 @@ const detail = () => {
onMounted(() => {
// console.log()
})
defineExpose({ getTreeData })
defineExpose({ getTreeData ,clickTableToTree})
</script>

View File

@@ -4,7 +4,8 @@
<el-row :gutter='10'>
<el-col :lg='4' :xl='4' :md='4' :sm='4'>
<div class='left_tree'>
<tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' />
<!-- <tree ref='treeRef' :updateSelectedTreeNode='getPieData || (() => {})' /> -->
<tree ref='treeRef' :updateSelectedTreeNode='updateData|| (() => {})' />
</div>
</el-col>
<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
}
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
const updateData = (id: string) => {
getPieData(id);//刷新饼图
//获取点击树的父节点名字
const parentNodeName = ref('')
for (let i = 0; i < planList.value.data.length; i++) {
@@ -293,6 +288,19 @@ const getPieData = async (id: string) => {
}else{
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
if (plan) {
@@ -302,6 +310,7 @@ const getPieData = async (id: string) => {
// 处理未找到计划的情况
isTimeCheck.value = false // 或者其他默认值
}
console.log('饼图getBoundPqDevList')
const pqDevList_Result2 = await getBoundPqDevList({ 'planId': id, 'checkStateList': [0, 1, 2, 3] })
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[]
// 遍历 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 reqPlan: Plan.ReqPlan = {
pattern: patternId,
@@ -455,8 +465,10 @@ onBeforeMount(async () => {
state: 0,
}
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++) {
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
@@ -483,11 +495,13 @@ onUnmounted(() => {
}
})
const handleBatchGenerate = () => {
const handleBatchGenerate = async () => {
console.log('批量生成按钮被点击了');
// 在这里添加其他逻辑,比如显示对话框、更新状态等
await initPlan()
treeRef.value.clickTableToTree(planList.value.data,currentId.value)
getPieData(currentId.value)
if (form.value.activeTabs === 0)//设备检测
{
const tabledata = deviceData.filter((item) => item.document_State === '未归档')