mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-09-14 16:17:31 +08:00
Pre Merge pull request !281 from dq334/5.X
This commit is contained in:
commit
e8c75a3809
47
src/api/dataCollection/powerPlant.ts
Normal file
47
src/api/dataCollection/powerPlant.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { AxiosPromise } from 'axios';
|
||||||
|
|
||||||
|
/** 电厂信息 */
|
||||||
|
export interface PowerPlantInfo {
|
||||||
|
plantId?: number;
|
||||||
|
plantCode: string;
|
||||||
|
plantName: string;
|
||||||
|
plantShortName?: string;
|
||||||
|
plantType?: string;
|
||||||
|
installedCapacity?: number;
|
||||||
|
address?: string;
|
||||||
|
ownerUnit?: string;
|
||||||
|
operationDate?: string;
|
||||||
|
remark?: string;
|
||||||
|
createTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页查询 */
|
||||||
|
export function listPowerPlant(query: any) {
|
||||||
|
return request({ url: '/dataCollection/powerPlant/list', method: 'get', params: query });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询详情 */
|
||||||
|
export function getPowerPlant(plantId: number) {
|
||||||
|
return request({ url: '/dataCollection/powerPlant/' + plantId, method: 'get' });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增 */
|
||||||
|
export function addPowerPlant(data: PowerPlantInfo) {
|
||||||
|
return request({ url: '/dataCollection/powerPlant', method: 'post', data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改 */
|
||||||
|
export function updatePowerPlant(data: PowerPlantInfo) {
|
||||||
|
return request({ url: '/dataCollection/powerPlant', method: 'put', data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
export function delPowerPlant(plantIds: number | number[]) {
|
||||||
|
return request({ url: '/dataCollection/powerPlant/' + plantIds, method: 'delete' });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出 */
|
||||||
|
export function exportPowerPlant(query: any) {
|
||||||
|
return request({ url: '/dataCollection/powerPlant/export', method: 'post', params: query, responseType: 'blob' });
|
||||||
|
}
|
||||||
314
src/views/phaseOne/dataCollection/powerPlant/index.vue
Normal file
314
src/views/phaseOne/dataCollection/powerPlant/index.vue
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-2">
|
||||||
|
<!-- 搜索栏 -->
|
||||||
|
<el-card shadow="hover" class="mb-[10px]">
|
||||||
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||||
|
<el-form-item label="电厂编码" prop="plantCode">
|
||||||
|
<el-input v-model="queryParams.plantCode" placeholder="请输入电厂编码" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电厂名称" prop="plantName">
|
||||||
|
<el-input v-model="queryParams.plantName" placeholder="请输入电厂名称" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电厂类型" prop="plantType">
|
||||||
|
<el-select v-model="queryParams.plantType" placeholder="全部" clearable style="width:140px">
|
||||||
|
<el-option
|
||||||
|
v-for="item in dictOptions.sys_plant_type"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 表格 + 按钮 -->
|
||||||
|
<el-card shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<el-row :gutter="10">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['dataCollection:powerPlant:add']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" plain icon="Delete" :disabled="selectedIds.length === 0" @click="handleDelete" v-hasPermi="['dataCollection:powerPlant:remove']">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['dataCollection:powerPlant:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="tableData" border @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column label="电厂编码" prop="plantCode" width="120" align="center" />
|
||||||
|
<el-table-column label="电厂名称" prop="plantName" min-width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column label="电厂简称" prop="plantShortName" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column label="电厂类型" prop="plantType" width="110" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<dict-tag :options="dictOptions.sys_plant_type" :value="row.plantType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="装机容量(MW)" prop="installedCapacity" width="130" align="right" />
|
||||||
|
<el-table-column label="业主单位" prop="ownerUnit" min-width="140" show-overflow-tooltip />
|
||||||
|
<el-table-column label="投运日期" prop="operationDate" width="120" align="center" />
|
||||||
|
<el-table-column label="创建时间" prop="createTime" width="160" align="center" />
|
||||||
|
<el-table-column label="操作" width="160" align="center" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleEdit(row)" v-hasPermi="['dataCollection:powerPlant:edit']">修改</el-button>
|
||||||
|
<el-button link type="primary" icon="View" @click="handleDetail(row)">详情</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
v-model:page="queryParams.pageNum"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
:total="total"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 新增/编辑对话框 -->
|
||||||
|
<el-dialog :title="dialogTitle" v-model="dialogVisible" width="600px">
|
||||||
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px">
|
||||||
|
<el-form-item label="电厂编码" prop="plantCode">
|
||||||
|
<el-input v-model="form.plantCode" placeholder="请输入电厂编码" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电厂名称" prop="plantName">
|
||||||
|
<el-input v-model="form.plantName" placeholder="请输入电厂名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电厂简称" prop="plantShortName">
|
||||||
|
<el-input v-model="form.plantShortName" placeholder="请输入电厂简称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电厂类型" prop="plantType">
|
||||||
|
<el-select v-model="form.plantType" placeholder="请选择电厂类型" style="width:100%">
|
||||||
|
<el-option
|
||||||
|
v-for="item in dictOptions.sys_plant_type"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="装机容量(MW)" prop="installedCapacity">
|
||||||
|
<el-input-number v-model="form.installedCapacity" :precision="3" :step="0.1" :min="0" style="width:100%" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="详细地址" prop="address">
|
||||||
|
<el-input v-model="form.address" placeholder="请输入详细地址" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="业主单位" prop="ownerUnit">
|
||||||
|
<el-input v-model="form.ownerUnit" placeholder="请输入业主单位" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="投运日期" prop="operationDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="form.operationDate"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="date"
|
||||||
|
placeholder="请选择投运日期"
|
||||||
|
style="width:100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="submitForm" :loading="submitting">确定</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 详情对话框 -->
|
||||||
|
<el-dialog title="电厂详情" v-model="detailVisible" width="550px">
|
||||||
|
<el-descriptions :column="2" border>
|
||||||
|
<el-descriptions-item label="电厂编码">{{ detail.plantCode }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="电厂名称">{{ detail.plantName }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="电厂简称">{{ detail.plantShortName }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="电厂类型">
|
||||||
|
<dict-tag :options="dictOptions.sys_plant_type" :value="detail.plantType" />
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="装机容量(MW)">{{ detail.installedCapacity }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="投运日期">{{ detail.operationDate }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="业主单位" :span="2">{{ detail.ownerUnit }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="详细地址" :span="2">{{ detail.address }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="备注" :span="2">{{ detail.remark }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="创建时间">{{ detail.createTime }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, onMounted, getCurrentInstance } from 'vue';
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
|
import { listPowerPlant, getPowerPlant, addPowerPlant, updatePowerPlant, delPowerPlant, exportPowerPlant } from '@/api/dataCollection/powerPlant';
|
||||||
|
import type { PowerPlantInfo } from '@/api/dataCollection/powerPlant';
|
||||||
|
|
||||||
|
// 字典数据
|
||||||
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
const dictOptions = reactive({
|
||||||
|
sys_plant_type: [] as { label: string; value: string }[]
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 加载字典 */
|
||||||
|
async function loadDicts() {
|
||||||
|
const res: any = await proxy.getDicts('sys_plant_type');
|
||||||
|
dictOptions.sys_plant_type = res.data || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
plantCode: '',
|
||||||
|
plantName: '',
|
||||||
|
plantType: ''
|
||||||
|
});
|
||||||
|
const queryFormRef = ref();
|
||||||
|
|
||||||
|
// 表格
|
||||||
|
const loading = ref(false);
|
||||||
|
const tableData = ref<PowerPlantInfo[]>([]);
|
||||||
|
const total = ref(0);
|
||||||
|
const selectedIds = ref<number[]>([]);
|
||||||
|
|
||||||
|
// 对话框
|
||||||
|
const dialogVisible = ref(false);
|
||||||
|
const dialogTitle = ref('');
|
||||||
|
const submitting = ref(false);
|
||||||
|
const formRef = ref();
|
||||||
|
const form = reactive<PowerPlantInfo>({
|
||||||
|
plantCode: '',
|
||||||
|
plantName: '',
|
||||||
|
plantShortName: '',
|
||||||
|
plantType: '',
|
||||||
|
installedCapacity: undefined,
|
||||||
|
address: '',
|
||||||
|
ownerUnit: '',
|
||||||
|
operationDate: '',
|
||||||
|
remark: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
plantCode: [{ required: true, message: '电厂编码不能为空', trigger: 'blur' }],
|
||||||
|
plantName: [{ required: true, message: '电厂名称不能为空', trigger: 'blur' }]
|
||||||
|
};
|
||||||
|
|
||||||
|
// 详情
|
||||||
|
const detailVisible = ref(false);
|
||||||
|
const detail = reactive<PowerPlantInfo>({});
|
||||||
|
|
||||||
|
/** 获取列表 */
|
||||||
|
async function getList() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await listPowerPlant(queryParams);
|
||||||
|
tableData.value = res.rows || [];
|
||||||
|
total.value = res.total || 0;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置 */
|
||||||
|
function resetQuery() {
|
||||||
|
queryParams.plantCode = '';
|
||||||
|
queryParams.plantName = '';
|
||||||
|
queryParams.plantType = '';
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 多选 */
|
||||||
|
function handleSelectionChange(selection: any[]) {
|
||||||
|
selectedIds.value = selection.map((r: any) => r.plantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增 */
|
||||||
|
function handleAdd() {
|
||||||
|
dialogTitle.value = '新增电厂';
|
||||||
|
resetForm();
|
||||||
|
dialogVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑 */
|
||||||
|
async function handleEdit(row: PowerPlantInfo) {
|
||||||
|
dialogTitle.value = '修改电厂';
|
||||||
|
const res: any = await getPowerPlant(row.plantId!);
|
||||||
|
const data = res.data || res;
|
||||||
|
Object.assign(form, data);
|
||||||
|
dialogVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 详情 */
|
||||||
|
async function handleDetail(row: PowerPlantInfo) {
|
||||||
|
const res: any = await getPowerPlant(row.plantId!);
|
||||||
|
const data = res.data || res;
|
||||||
|
Object.assign(detail, data);
|
||||||
|
detailVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
function resetForm() {
|
||||||
|
Object.assign(form, {
|
||||||
|
plantId: undefined,
|
||||||
|
plantCode: '',
|
||||||
|
plantName: '',
|
||||||
|
plantShortName: '',
|
||||||
|
plantType: '',
|
||||||
|
installedCapacity: undefined,
|
||||||
|
address: '',
|
||||||
|
ownerUnit: '',
|
||||||
|
operationDate: '',
|
||||||
|
remark: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
async function submitForm() {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
submitting.value = true;
|
||||||
|
try {
|
||||||
|
if (form.plantId) {
|
||||||
|
await updatePowerPlant({ ...form } as any);
|
||||||
|
ElMessage.success('修改成功');
|
||||||
|
} else {
|
||||||
|
await addPowerPlant({ ...form } as any);
|
||||||
|
ElMessage.success('新增成功');
|
||||||
|
}
|
||||||
|
dialogVisible.value = false;
|
||||||
|
getList();
|
||||||
|
} finally {
|
||||||
|
submitting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
async function handleDelete() {
|
||||||
|
await ElMessageBox.confirm('确认删除所选电厂信息?', '提示', { type: 'warning' });
|
||||||
|
await delPowerPlant(selectedIds.value);
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出 */
|
||||||
|
function handleExport() {
|
||||||
|
exportPowerPlant(queryParams);
|
||||||
|
ElMessage.success('导出请求已发送');
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadDicts();
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user