<!-- 管线占压数据管理 --> <script name="DatabaseManage" setup lang="ts"> import { getCurrentInstance, onMounted, ref, watch } from 'vue' import type { Ref } from 'vue' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import type { DateModelType } from 'element-plus' import detailDialog from './detail.vue' import type { dictType } from '@/global' import { getDictByCode } from '@/api/system/dict' import { exportFile } from '@/utils/exportUtils' import type { TableColumn } from '@/components/NormalTable/table_interface' const $router = useRouter() const { proxy } = getCurrentInstance() as any // 查询条件 const listQuery = ref({ recognitionCode: '', // 第三方code offset: 1, limit: 20, }) const total = ref(0) // 数据条数 const loadingTable = ref(false) // 表格loading // 表头 const columns = ref<TableColumn[]>([ { text: '序号', value: 'recognitionCode', align: 'center', width: '160' }, { text: '隐患编号', value: 'recognitionType', align: 'center' }, { text: '一级分类', value: 'recognitionTime', align: 'center' }, { text: '二级分类', value: 'loglat', align: 'center' }, { text: '地点', value: 'position', align: 'center' }, { text: '发现时间', value: 'recognitionPrecision', align: 'center' }, { text: '隐患等级', value: 'recognitionLevel', align: 'center' }, { text: '管理责任企业', value: 'taskName', align: 'center' }, { text: '责任人', value: 'taskName', align: 'center' }, { text: '治理情况', value: 'taskName', align: 'center' }, { text: '消除时间', value: 'taskName', align: 'center' }, ]) const list = ref([]) // 表格数据 // 筛选时间段数据 const dateRange = ref<[DateModelType, DateModelType]>(['', '']) // 选中的内容 const checkoutList = ref<string[]>([]) // 时间变更 watch(dateRange, (val) => { if (val) { listQuery.value.beginDate = `${val[0]}` listQuery.value.endDate = `${val[1]}` } else { listQuery.value.beginDate = '' listQuery.value.endDate = '' } }) // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } // getIdentifyListPage(listQuery.value).then((res) => { // console.log(res.data, '第三方') // list.value = res.data.rows // total.value = parseInt(res.data.total) // loadingTable.value = false // }).catch(() => { list.value = [{}] loadingTable.value = false // }) } // 搜索 const searchList = () => { fetchData(true) } // 重置 const reset = () => { listQuery.value = { alarmCode: '', // 报警编号 beginDate: '', // 报警开始时间 endDate: '', // 报警结束时间 alarmType: '1', taskName: '', // 巡检任务名称 // position: '', // 报警位置 alarmStatus: '', // 报警状态 offset: 1, limit: 20, } dateRange.value = ['', ''] // 时间清空 fetchData(true) } // 多选发生改变时 function handleSelectionChange(e: any) { checkoutList.value = e.map((item: { id: string }) => item.id) } // 导出 const exportList = () => { const loading = ElLoading.service({ lock: true, text: '下载中请稍后', background: 'rgba(255, 255, 255, 0.8)', }) if (list.value.length > 0) { } else { ElMessage.warning('无数据可导出数据') } loading.close() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 } fetchData(true) } // 编辑 const handlerRef = ref() const handler = (type: string, row: any) => { handlerRef.value.initDialog(type, row) } // 处置报警 const alarmRef = ref() const handlerAlarm = (row: IList) => { alarmRef.value.initDialog(row) } const alarmStatusMap = ref<dictType[]>([]) // 报警状态 // 查询字典 const getDict = async () => { // 巡检状态 getDictByCode('alarmStatus').then((response) => { alarmStatusMap.value = response.data }) } onMounted(async () => { await getDict() fetchData(true) // 获取数据 }) </script> <template> <!-- 布局 --> <app-container> <!-- 编辑操作 --> <detail-dialog ref="handlerRef" /> <search-area :need-clear="true" @search="searchList" @clear="reset"> <search-item> <el-input v-model.trim="listQuery.recognitionCode" placeholder="隐患编号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.recognitionCode" placeholder="一级分类" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.recognitionCode" placeholder="二级分类" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.recognitionCode" placeholder="隐患描述" class="short-input" clearable /> </search-item> <search-item> <el-select v-model="listQuery.alarmStatus" class="short-input" placeholder="隐患等级" clearable> <el-option v-for="item in alarmStatusMap" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.recognitionCode" placeholder="管理责任公司" class="short-input" clearable /> </search-item> <search-item> <el-date-picker v-model="listQuery.value1" type="date" placeholder="发现时间" style="width: 100%;" /> </search-item> <search-item> <el-select v-model="listQuery.alarmStatus" class="short-input" placeholder="是否进行治理" clearable> <el-option v-for="item in alarmStatusMap" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> </search-area> <table-container> <template #btns-right> <icon-button icon="icon-add" title="新增" type="primary" @click="handler('create', {})" /> <icon-button icon="icon-delete" title="删除" type="primary" /> <icon-button icon="icon-template" title="模板下载" type="primary" /> <icon-button icon="icon-import" title="导入" type="primary" /> <icon-button icon="icon-export" title="导出" type="primary" @click="exportList" /> </template> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange" > <template #preColumns> <el-table-column label="序号" width="55" align="center"> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> <template #columns> <el-table-column label="操作" align="center" fixed="right" width="120"> <template #default="{ row }"> <el-button size="small" link type="primary" @click="handler('detail', row)"> 详情 </el-button> <el-button size="small" link type="primary" @click="handler('update', row)"> 编辑 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template> <style lang="scss" scoped> // 样式 </style>