<template> <div class="removalRate"> <div class="top"> <el-form ref="ruleForm" inline :model="form"> <el-form-item label="使用状态:" prop="status"> <el-select v-model="form.status" placeholder="使用状态"> <el-option label="全部" value="" /> <el-option label="启用" value="1" /> <el-option label="停用" value="0" /> </el-select> </el-form-item> <el-form-item label="时间:" prop="time"> <el-date-picker v-model="form.time" type="daterange" range-separator="~" start-placeholder="开始时间" end-placeholder="结束时间" format="YYYY-MM-DD" value-format="YYYY-MM-DD" /> </el-form-item> <el-form-item> <el-button type="primary" icon="Search" @click="search"> 查询</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-row class="mb8"> <el-button type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增</el-button> </el-row> </div> <el-table :data="tableData" v-loading="loading" :max-height="600"> <el-table-column type="index" width="55" label="序号" /> <el-table-column label="记录名称" prop="configName" show-overflow-tooltip width="200"> <template #default="{ row }"> <span style="color: #409eef">{{ row.configName }}</span> </template> </el-table-column> <el-table-column label="启用时间" prop="startDatetime" show-overflow-tooltip /> <el-table-column label="停用时间" prop="endDatetime" show-overflow-tooltip /> <el-table-column label="修改人" prop="updateNickName" show-overflow-tooltip /> <el-table-column label="修改日期" prop="updateTime" show-overflow-tooltip /> <el-table-column label="使用状态" prop="status" show-overflow-tooltip> <template #default="{ row }"> <el-tag :type="statusMap.get(row.status).type" v-if="row.status">{{ statusMap.get(row.status).text }}</el-tag> </template> </el-table-column> <el-table-column label="操作" show-overflow-tooltip width="254"> <template #default="{ row }"> <el-button type="primary" link @click="copy(row)">复制</el-button> <el-button type="primary" link @click="enable(row)" :disabled="row.status === '1'">启用</el-button> <el-button type="primary" link @click="openDialog(row, 'view')">查看</el-button> <el-button type="primary" link @click="openDialog(row, 'edit')">修改</el-button> <el-button type="danger" link @click="del(row)">删除</el-button> </template> </el-table-column> </el-table> <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" /> <el-dialog class="dialog" v-model="visible" :title="`${opts.text}建议污染去除率`" :close-on-click-modal="false" width="70%" :before-close="close" > <tableDalgo v-if="visible" ref="tableDalgoRef" :id="row.id || ''" :status="row.status" :opts="opts.type" @close="close"></tableDalgo> </el-dialog> </div> </template> <script setup> import tableDalgo from './tableDalgo.vue'; import { reactive, ref, onMounted, computed } from 'vue'; import { optTextMap, statusMap } from '@/utils/map'; import { getFacilitiesPolluteRemoveConfigPage, facilitiesPolluteRemoveConfigDel, facilitiesPolluteRemoveConfigCopy, facilitiesPolluteRemoveConfigEnable, } from '@/api/preassess/removalRate.js'; import { usePagination } from '@/hooks'; const { proxy } = getCurrentInstance(); const form = reactive({ status: '', time: [], }); const params = computed(() => { const args = JSON.parse(JSON.stringify(form)); const { time } = args; delete args.time; return { ...args, startDatetime: time[0] || '', endDatetime: time[1] || '', }; }); const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getFacilitiesPolluteRemoveConfigPage, params); const visible = ref(false); const row = ref({}); const opts = reactive({ type: '', text: '', }); const search = () => { pageNum.value = 1; getTableList(); }; const resetQuery = () => { proxy.$refs.ruleForm.resetFields(); search(); }; const openDialog = (data, type) => { visible.value = true; opts.type = type; opts.text = optTextMap.get(type); row.value = data; }; const close = type => { visible.value = false; opts.type = ''; opts.text = ''; row.value = {}; if (type === 'add') search(); if (type && ['add', 'edit'].includes(type)) proxy.$modal.msgSuccess('操作成功!'); }; const del = row => { proxy.$modal .confirm('是否确认删除?') .then(async () => { const res = await facilitiesPolluteRemoveConfigDel(row.id); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); getTableList(); }) .catch(() => {}); }; const copy = row => { proxy.$modal .confirm('是否确认复制?') .then(async () => { const res = await facilitiesPolluteRemoveConfigCopy({ id: row.id }); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); getTableList(); }) .catch(() => {}); }; const enable = row => { proxy.$modal .confirm('是否确认启用?') .then(async () => { const res = await facilitiesPolluteRemoveConfigEnable(row.id); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); getTableList(); }) .catch(() => {}); }; onMounted(() => { getTableList(); }); </script> <style lang="scss" scoped> .removalRate { padding: 20px; height: 90vh; overflow-y: hidden; .top { margin-bottom: 15px; } } :deep(.dialog) { .el-dialog__body { padding-bottom: 20px !important; } .el-dialog__footer { padding-top: 0 !important; } .innerDialog { .el-dialog__body { padding-bottom: 0 !important; } } } </style>