多监测点修改

This commit is contained in:
仲么了
2024-02-29 10:31:32 +08:00
parent 0557e71dcb
commit 8175de04bb
4 changed files with 19 additions and 16 deletions

View File

@@ -14,7 +14,7 @@
></el-option> ></el-option>
</el-select> </el-select>
<div style="flex: 1; overflow: hidden"> <div style="flex: 1; overflow: hidden">
<Tree ref="c" :data="tree" style="width: 100%; height: 100%" :canExpand="false" v-bind="$attrs" /> <Tree ref="treeRef" :data="tree" style="width: 100%; height: 100%" :canExpand="false" v-bind="$attrs" />
</div> </div>
</div> </div>
</template> </template>
@@ -37,7 +37,7 @@ const dictData = useDictData()
const config = useConfig() const config = useConfig()
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type']) const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
const tree = ref() const tree = ref()
const treRef = ref() const treeRef = ref()
const formData = ref({ const formData = ref({
deptIndex: adminInfo.$state.deptIndex, deptIndex: adminInfo.$state.deptIndex,
monitorFlag: 2, monitorFlag: 2,
@@ -48,10 +48,10 @@ const formData = ref({
statisticalType: classificationData[2].id, statisticalType: classificationData[2].id,
scale: null scale: null
}) })
const loadData = (val: string) => { const loadData = () => {
let obj = classificationData.find(function (i) { let obj = classificationData.find(function (i) {
return i.id === formData.value.statisticalType return i.id === formData.value.statisticalType
}) }) || { code: '' }
let form = JSON.parse(JSON.stringify(formData.value)) let form = JSON.parse(JSON.stringify(formData.value))
form.statisticalType = classificationData.find((item: any) => item.id == form.statisticalType) form.statisticalType = classificationData.find((item: any) => item.id == form.statisticalType)
let nodeKey = '' let nodeKey = ''
@@ -84,6 +84,7 @@ const loadData = (val: string) => {
nodeKey = item5.id nodeKey = item5.id
emit('init', item5) emit('init', item5)
} }
item5.alias = `${item.name}>${item2.name}>${item3.name}>${item4.name}>${item5.name}`
item5.icon = 'fa-solid fa-location-dot' item5.icon = 'fa-solid fa-location-dot'
item5.color = config.getColorVal('elementUiPrimary') item5.color = config.getColorVal('elementUiPrimary')
if (item5.comFlag === 0) { if (item5.comFlag === 0) {
@@ -101,8 +102,8 @@ const loadData = (val: string) => {
tree.value = res.data tree.value = res.data
if (nodeKey) { if (nodeKey) {
nextTick(() => { nextTick(() => {
treRef.value.treeRef.setCurrentKey(nodeKey) treeRef.value.treeRef.setCurrentKey(nodeKey)
treRef.value.treeRef.setExpandedKeys(nodeKey) treeRef.value.treeRef.setExpandedKeys(nodeKey)
}) })
} }
}) })

View File

@@ -1,6 +1,5 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
interface MonitoringPoint { interface MonitoringPoint {
lineId: string lineId: string
lineName: string lineName: string
@@ -21,9 +20,7 @@ export const useMonitoringPoint = defineStore(
state[key] = val state[key] = val
} }
const setShowCheckBox = (val: boolean) => { const setShowCheckBox = (val: boolean) => {
if (!val) { if (val && state.lineIds.length === 0) {
state.lineIds = []
} else {
state.lineIds = [state.lineId] state.lineIds = [state.lineId]
} }
state.showCheckBox = val state.showCheckBox = val
@@ -31,6 +28,8 @@ export const useMonitoringPoint = defineStore(
return { state, setValue, setShowCheckBox } return { state, setValue, setShowCheckBox }
}, },
{ {
persist: true persist: {
paths: ['state.lineId', 'state.lineName']
}
} }
) )

View File

@@ -39,7 +39,9 @@
<Shishishuju /> <Shishishuju />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<div class="monitoring-point">当前位置{{ monitoringPoint.state.lineName }}</div> <div class="monitoring-point" v-if="!monitoringPoint.state.showCheckBox">
当前位置{{ monitoringPoint.state.lineName }}
</div>
</div> </div>
</pane> </pane>
</splitpanes> </splitpanes>
@@ -80,11 +82,11 @@ onMounted(() => {
const handleNodeClick = (data: any, node: any) => { const handleNodeClick = (data: any, node: any) => {
if (data.level === 6) { if (data.level === 6) {
monitoringPoint.setValue('lineId', data.id) monitoringPoint.setValue('lineId', data.id)
monitoringPoint.setValue('lineName', data.alias)
} }
} }
const handleCheckChange = (data: any, node: any) => { const handleCheckChange = (data: any, node: any) => {
// let checkNodes = pointTree.value.getCheckedNodes() console.log(data)
// console.log(checkNodes)
} }
watch( watch(
() => router.currentRoute.value.query.lineId, () => router.currentRoute.value.query.lineId,

View File

@@ -2,7 +2,7 @@
<div style="display: flex; flex-direction: column; height: 100%"> <div style="display: flex; flex-direction: column; height: 100%">
<el-form :inline="true"> <el-form :inline="true">
<el-form-item label="多监测点"> <el-form-item label="多监测点">
<el-checkbox v-model="checked" @change="checkChange" /> <el-checkbox v-model="checked" @change="checkChange" />
</el-form-item> </el-form-item>
<el-form-item label="日期"> <el-form-item label="日期">
<DatePicker ref="datePickerRef"></DatePicker> <DatePicker ref="datePickerRef"></DatePicker>
@@ -25,7 +25,7 @@ import { getProbabilityDistribution } from '@/api/event-boot/monitor'
const datePickerRef = ref() const datePickerRef = ref()
const monitoringPoint = useMonitoringPoint() const monitoringPoint = useMonitoringPoint()
const checked = ref(false) const checked = ref(monitoringPoint.state.showCheckBox)
const loading = ref(true) const loading = ref(true)
const formData = reactive({ const formData = reactive({
lineIndex: monitoringPoint.state.lineId, lineIndex: monitoringPoint.state.lineId,
@@ -38,6 +38,7 @@ const checkChange = () => {
monitoringPoint.setShowCheckBox(true) monitoringPoint.setShowCheckBox(true)
} else { } else {
monitoringPoint.setShowCheckBox(false) monitoringPoint.setShowCheckBox(false)
init()
} }
} }
const init = () => { const init = () => {