<!-- 选择标准装置配套设备 --> <script lang="ts" setup name="SelectEquipmentDialog"> import { ElMessage } from 'element-plus' import type { Ref } from 'vue' import { ref } from 'vue' import dayjs from 'dayjs' import type { DateModelType } from 'element-plus' import { getEquipmentList } from '@/api/equipment/standard/book' import type { TableColumn } from '@/components/NormalTable/table_interface' import { SCHEDULE } from '@/utils/scheduleDict' import { getDeptTreeList } from '@/api/system/dept' import { getStaffList } from '@/api/resource/register' import { toTreeList } from '@/utils/structure' import type { deptType } from '@/global' const props = defineProps({ isMulti: { // 是否多选 type: Boolean, default: false, // 默认单选 }, }) const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) const standardId = ref('') // 标准装置id // 查询条件 const listQuery = ref({ equipmentNo: '', // 统一编号 equipmentName: '', // 设备名称 traceCompany: '', // 溯源单位 manufactureNo: '', // 出厂编号 directorId: '', // 负责人 measureValidDateEnd: '', // 检定有效期(结束) measureValidDateStart: '', // 检定有效期(结束) standardId: '', offset: 1, limit: props.isMulti ? 5 : 20, }) // 多选选中的内容 const checkoutList = ref([]) const loadingTable = ref(false) const list = ref([]) // 表格数据 const total = ref(0) const columns = ref<TableColumn[]>([ { text: '统一编号', value: 'equipmentNo', align: 'center', width: '160' }, { text: '计量标准的主标准器及配套设备名称', value: 'equipmentName', align: 'center' }, { text: '规格型号', value: 'model', align: 'center' }, // { text: '测量范围', value: 'measureRange', align: 'center' }, // { text: '不确定度或允许误差极限或准确度等级', value: 'uncertainty', align: 'center' }, ]) const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 // -----------------------------------------字典-------------------------------------------------------------- const useDeptList = ref<deptType[]>([]) // 所属部门列表 const userList = ref<{ [key: string]: string }[]>([]) // 用户列表 // 查询字典 const getDict = async () => { // 获取部门列表 getDeptTreeList().then((res) => { // 转成树结构 useDeptList.value = toTreeList(res.data, '0', true) }) // 获取用户列表 getStaffList({ offset: 1, limit: 999999 }).then((res: any) => { userList.value = res.data.rows }) } // -------------------------------------------------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getEquipmentList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: { id: string }) => { return { ...item, equipmentId: item.id, delId: '', // 删除使用的id } }) total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { equipmentNo: '', // 统一编号 equipmentName: '', // 设备名称 traceCompany: '', // 溯源单位 manufactureNo: '', // 出厂编号 directorId: '', // 负责人 measureValidDateEnd: '', // 检定有效期(结束) measureValidDateStart: '', // 检定有效期(结束) standardId: '', offset: 1, limit: props.isMulti ? 5 : 20, } dateRange.value = ['', ''] fetchData() } // 搜索 const search = () => { fetchData(true) } // 多选选中 const handleSelectionChange = (val: any) => { checkoutList.value = val } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 confirmSelect = () => { if (!checkoutList.value.length) { ElMessage.warning('请选择设备') } else { emits('confirm', checkoutList.value) dialogFormVisible.value = false } } // 取消 const resetForm = () => { dialogFormVisible.value = false clearList() } // 初始化 const initDialog = async (id: string) => { await getDict() listQuery.value.standardId = id // id dialogFormVisible.value = true fetchData() } defineExpose({ initDialog }) </script> <template> <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择标准装置配套设备" width="65%"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="clearList"> <search-item> <el-input v-model.trim="listQuery.equipmentNo" placeholder="统一编号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.equipmentName" placeholder="设备名称" class="short-input" clearable /> </search-item> <!-- <search-item> <el-input v-model.trim="listQuery.manufactureNo" placeholder="出厂编号" class="short-input" clearable /> </search-item> --> <!-- <search-item> <dept-select v-model="listQuery.deptId" :data="useDeptList" placeholder="所属部门" class="short-input" /> </search-item> --> <!-- <search-item> <el-select v-model="listQuery.directorId" placeholder="负责人" class="short-input" filterable > <el-option v-for="item in userList" :key="item.id" :label="item.staffName" :value="item.id" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.traceCompany" placeholder="溯源单位" class="short-input" clearable /> </search-item> <search-item> <el-date-picker v-model="dateRange" class="short-input" type="daterange" range-separator="至" format="YYYY-MM-DD" value-format="YYYY-MM-DD" start-placeholder="检定有效期(开始)" end-placeholder="检定有效期(结束)" /> </search-item> --> </search-area> <!-- 查询结果Table显示 --> <div style="padding: 12px;"> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" is-showmulti-select :list-loading="loadingTable" :is-multi="props.isMulti" :height="260" @change="changePage" @multi-select="handleSelectionChange" > <!-- 序号 --> <template #preColumns> <el-table-column label="#" width="55" align="center" fixed> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> </normal-table> </div> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="confirmSelect">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> :deep(.el-radio__label) { display: none; } </style>