<!-- 用户列表弹窗 --> <script lang="ts" setup name="selectPerson"> import { ElMessage } from 'element-plus' import { getUserList } from '@/api/system/user' import { getDeptTreeList } from '@/api/system/dept' // import type { TreeStructure } from '@/views/system/user/user-interface' import comTreeSelect from '@/views/system/user/selecTree.vue' import { toTreeList } from '@/utils/structure' import { getEquipmentApplyList } from '@/api/device/checkList' import { SCHEDULE } from '@/utils/scheduleDict' const emits = defineEmits(['add']) const dialogFormVisible = ref(false) // 查询条件 const listQuery = ref({ approvalStatus: '4', formId: SCHEDULE.DEVICE_FIX_APPROVAL, applyName: '', applyNo: '', applyPerson: '', applyType: '7', applyUnit: '', businessKeys: [], createUser: '', endTime: '', ids: [], processResult: '', startTime: '', offset: 1, limit: 20, }) const loadingTable = ref<boolean>(false) const list = ref([]) // 表格数据 const total = ref<number>(0) const select = ref<number>(-1) const columns = ref([ { text: '检修申请编号', value: 'applyNo', align: 'center', }, { text: '检修申请名称', value: 'applyName', align: 'center', }, { text: '申请单位', value: 'applyUnitName', align: 'center', }, { text: '申请人', value: 'applyPersonName', align: 'center', }, { text: '检修时间', value: 'time', align: 'center', }, { text: '备注', value: 'remark', align: 'center', }, { text: '审批状态', value: 'approvalStatusName', align: 'center', }, ]) const deptProps = reactive({ parent: 'pid', value: 'id', label: 'name', children: 'children', }) // 获取部门 const deptIdList = ref([]) const getDeptList = () => { getDeptTreeList().then((res) => { deptIdList.value = toTreeList(res.data, '0', true) }) } // 获取数据列表 const fetchData = () => { select.value = -1 // 获取设备检修列表已完成 getEquipmentApplyList(listQuery.value).then((res) => { list.value = res.data.rows total.value = res.data.total }) } // 搜索 const search = () => { fetchData() } const selectTreeRef = ref() // 重置 const reset = () => { listQuery.value = { approvalStatus: '4', formId: SCHEDULE.DEVICE_FIX_APPROVAL, applyName: '', applyNo: '', applyPerson: '', applyType: '7', applyUnit: '', businessKeys: [], createUser: '', endTime: '', ids: [], processResult: '', startTime: '', offset: 1, limit: 20, } selectTreeRef.value.clearSelected() search() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size?: number;page?: number }) => { if (val && val.size) { listQuery.value.limit = val.size } if (val && val.page) { listQuery.value.offset = val.page } search() } // 点击保存 const submitForm = () => { if (select.value >= 0) { const person = list.value.filter((item, index) => index == select.value)[0] emits('add', person) dialogFormVisible.value = false reset() } else { ElMessage.warning('请先选择人员') } } // 取消 const resetForm = () => { dialogFormVisible.value = false reset() } // 初始化 const initDialog = () => { // reset() dialogFormVisible.value = true getDeptList() fetchData() } defineExpose({ initDialog }) </script> <template> <el-dialog v-model="dialogFormVisible" title="设备检修" width="50%"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model.trim="listQuery.applyNo" placeholder="申请编号" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.applyName" placeholder="申请名称" clearable /> </search-item> </search-area> <!-- 查询结果Table显示 --> <div style="padding: 12px;"> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable" @change="changePage" > <template #preColumns> <el-table-column label="选择" width="55" align="center"> <template #default="scope"> <el-radio v-model="select" :label="scope.$index" class="radio" /> </template> </el-table-column> </template> </normal-table> </div> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="submitForm">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> :deep(.el-radio__label) { display: none; } </style>