<!-- Description: 场站管理-运维管理 Author: 李亚光 Date: 2024-09-05 --> <script lang="ts" setup name="manufacturerOperationRecord"> import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import { getDictByCode } from '@/api/system/dict' import { exportFile } from '@/utils/exportUtils' import { shortcuts } from '@/utils/common' const deviceTypeList = ref<any[]>([]) // 设备类型列表 const repairTypeList = ref<{ id: string; name: string; value: string }[]>([]) // 运维类型 // 表格数据 const list = ref([]) const total = ref(0) // 初始展示列 const columns = ref<any>([ { text: '场站名称', value: 'devcode', align: 'center' }, { text: '管理单位', value: 'deviceTypeName', align: 'center' }, { text: '详细位置', value: 'repairTypeName', align: 'center' }, { text: '维护类型', value: 'ledgerNumber', align: 'center', width: '160' }, { text: '维护内容', value: 'position', align: 'center' }, { text: '维护人员', value: '', align: 'center', width: '130' }, { text: '维护时间', value: 'repairContent', align: 'center', width: '210' }, ]) // 最终展示列 const columnsConfig = ref([]) // 修改列 const editColumns = (data: any) => { columnsConfig.value = data } const loadingTable = ref(true) // 查询条件 const listQuery = ref({ limit: 20, offset: 1, devcode: '', // 设备编号 deviceType: '', // 设备类型 repairType: '', // 运维类型 repairPerson: '', // 运维人员 repairContent: '', // 运维内容 endTime: '', // 结束时间 begTime: '', // 开始时间 }) // 开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { listQuery.value.begTime = '' listQuery.value.endTime = '' if (Array.isArray(newVal)) { if (newVal.length) { listQuery.value.begTime = `${newVal[0]} 00:00:00` listQuery.value.endTime = `${newVal[1]} 23:59:59` } } }) // 查询数据 const fetchData = () => { loadingTable.value = true // getOperationListPage(listQuery.value).then((res) => { // list.value = res.data.rows.map((item: any) => ({ // ...item, // deviceTypeName: deviceTypeList.value.filter((citem: any) => citem.id === item.deviceType)[0].typeName, // repairTypeName: repairTypeList.value.filter((citem: any) => citem.value === item.repairType)[0].name, // })) // total.value = res.data.total // loadingTable.value = false // }).catch(() => { loadingTable.value = false // }) } // 重置查询条件f const reset = () => { datetimerange.value = [] listQuery.value = { limit: 20, offset: 1, devcode: '', // 设备编号 deviceType: '', // 设备类型 repairType: '', // 运维类型 repairPerson: '', // 运维人员 repairContent: '', // 运维内容 endTime: '', // 结束时间 begTime: '', // 开始时间 } fetchData() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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() } // 导出列表 const exportList = () => { if (!list.value.length) { ElMessage.warning('暂无导出数据') } // const loading = ElLoading.service({ // lock: true, // background: 'rgba(255, 255, 255, 0.8)', // }) // exportOperationList(listQuery.value).then((res) => { // exportFile(res.data, '运维记录.xlsx') // loading.close() // }).catch(() => { // loading.close() // }) } // 获取字典 const fetchDict = async () => { // // 获取设备类型 // const res = await getDeviceTypeListPage({ limit: 9999, offset: 1 }) // deviceTypeList.value = res.data.rows // // 运维类型 // getDictByCode('repairType').then((res) => { // repairTypeList.value = res.data // }) } onMounted(async () => { await fetchDict() fetchData() }) const { proxy } = getCurrentInstance() as any </script> <template> <!-- 布局 --> <app-container> <!-- 新建编辑弹窗 --> <edit-dialog ref="editRef" @refresh="fetchData" /> <!-- 筛选条件 --> <search-area :need-clear="true" @search="fetchData" @clear="reset"> <search-item> <el-input v-model="listQuery.devcode" placeholder="场站名称" clearable /> </search-item> <search-item> <el-select v-model="listQuery.deviceType" placeholder="维护类型" clearable filterable class="select" style="width: 192px;" > <el-option v-for="item in []" :key="item.id" :label="item.typeName" :value="item.id" /> </el-select> </search-item> <search-item> <el-input v-model="listQuery.repairPerson" placeholder="运维人员" clearable /> </search-item> <search-item> <el-date-picker v-model="datetimerange" type="datetimerange" format="YYYY-MM-DD HH:mm:ss" :shortcuts="shortcuts" value-format="YYYY-MM-DD HH:mm:ss" range-separator="至" start-placeholder="维护开始时间" end-placeholder="维护结束时间" clearable /> </search-item> </search-area> <!-- 表头标题 --> <table-container :is-config="true" config-title="station-operation" :columns="columns" :config-columns="columnsConfig" :edit="editColumns" > <template #btns-right> <!-- 操作 --> <div> <el-button v-if="proxy.hasPerm('/station/operation/add')" type="primary"> 新增 </el-button> <el-button v-if="proxy.hasPerm('/station/operation/export')" type="primary" @click="exportList"> 导出 </el-button> </div> </template> <!-- 查询结果Table显示 --> <normal-table :data="list" :total="total" :columns="columnsConfig" :query="listQuery" :list-loading="loadingTable" @change="changePage" > <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> </normal-table> </table-container> </app-container> </template>