This commit is contained in:
andy 2026-08-01 10:46:21 +08:00
parent 0542bb739e
commit f32d8667f7

View File

@ -112,12 +112,17 @@
/> />
</n-form-item> </n-form-item>
<n-form-item label="所属工段" path="sectionId"> <n-form-item label="所属工段" path="sectionId">
<n-select <!-- <n-select
v-model:value="formData.sectionId" v-model:value="formData.sectionId"
:options="sectionList" :options="sectionList"
placeholder="请选择所属工段" placeholder="请选择所属工段"
clearable clearable
style="width: 200px" style="width: 200px"
/> -->
<n-tree-select
cascade
checkable
:options="sectionList"
/> />
</n-form-item> </n-form-item>
<n-form-item label="设备类型" path="deviceTypeId"> <n-form-item label="设备类型" path="deviceTypeId">
@ -267,12 +272,14 @@ import {deviceApi, type Device} from '@/api/device'
import {dictDataApi} from '@/api/org' import {dictDataApi} from '@/api/org'
import {sectionApi} from '@/api/section' import {sectionApi} from '@/api/section'
import {SysUser, userApi} from '@/api/system' import {deptApi, type SysDept , userApi} from '@/api/system'
import {DeviceAbnormalRecord, deviceAbnormalRecordApi} from "@/api/deviceAbnormalRecord.ts"; import {DeviceAbnormalRecord, deviceAbnormalRecordApi} from "@/api/deviceAbnormalRecord.ts";
import DeviceAbnormalRecordPage from '@/views/biz/device/DeviceAbnomarlRecord.vue' import DeviceAbnormalRecordPage from '@/views/biz/device/DeviceAbnomarlRecord.vue'
import DeviceOperationLogPage from "@/views/biz/device/DeviceOperationLog.vue"; import DeviceOperationLogPage from "@/views/biz/device/DeviceOperationLog.vue";
import DeviceDispatchLogPage from "@/views/biz/device/DeviceDispatchLog.vue"; import DeviceDispatchLogPage from "@/views/biz/device/DeviceDispatchLog.vue";
import { S } from 'vue-router/dist/router-CWoNjPRp.mjs'
const message = useMessage() const message = useMessage()
const dialog = useDialog() const dialog = useDialog()
const router = useRouter() const router = useRouter()
@ -283,8 +290,15 @@ const deviceId = ref<number>(undefined)
// //
const deviceManagerList = ref<{ label: string, value: any }[]>([]) const deviceManagerList = ref<{ label: string, value: any }[]>([])
let sectionList = reactive<{ label: string, value: any }[]>([]) //
interface TreeNode {
label: string;
key: number | string;
children?: TreeNode[];
}
let sectionList = reactive<TreeNode[]>([])
// const sectionList = ref<SysDept[]>([]) //
// //
const deviceErrorLogList = ref<DeviceAbnormalRecord[]>([]) const deviceErrorLogList = ref<DeviceAbnormalRecord[]>([])
const deviceAbnormalRecordDrawerVisible = ref<Boolean>(false) // const deviceAbnormalRecordDrawerVisible = ref<Boolean>(false) //
@ -664,11 +678,26 @@ async function loadDictOptions() {
} }
} }
// //
async function loadSection() { async function loadSection() {
const data = await sectionApi.listNoParam() const data = await deptApi.tree()
sectionList = data.map((d: any) => ({label: d.sectionName, value: (Number(d.id) || d.id)})) sectionList = buildOptions(data);
}
function buildOptions(d: any[]): TreeNode[] {
return d.map(item => {
// id0||
const idNum = Number(item.id);
const key = !isNaN(idNum) ? idNum : item.id;
return {
label: item.deptName,
key,
//
children: Array.isArray(item.children) && item.children.length
? buildOptions(item.children)
: undefined
};
});
} }
// //