开发公摊电表管理、统计汇总,删除设备管理下不用的列表
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-row :gutter="10" class="mb8" justify="end">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['electricityShare:electricityShare:add']">新增</el-button>
|
||||
</el-col>
|
||||
@@ -29,9 +29,9 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['electricityShare:electricityShare:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['electricityShare:electricityShare:export']">导出</el-button>
|
||||
</el-col>
|
||||
</el-col> -->
|
||||
<!-- <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> -->
|
||||
</el-row>
|
||||
</template>
|
||||
@@ -42,11 +42,14 @@
|
||||
<!-- <el-table-column label="小区id" align="center" prop="villageId" /> -->
|
||||
<!-- <el-table-column label="公摊电表设备id" align="center" prop="deviceId" /> -->
|
||||
<el-table-column label="公摊电表设备编码" align="center" prop="deviceCode" />
|
||||
<el-table-column label="分摊方式" align="center" prop="shareMode" />
|
||||
<el-table-column label="状态" align="center" prop="status" />
|
||||
<el-table-column label="分摊房屋数量" align="center" prop="houseCount" />
|
||||
<el-table-column label="建筑面积合计" align="center" prop="totalArea" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="详情" placement="top">
|
||||
<el-button link type="primary" icon="View" @click="handleView(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['electricityShare:electricityShare:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
@@ -61,21 +64,17 @@
|
||||
</el-card>
|
||||
<!-- 添加或修改公摊电表配置对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="electricityShareFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="小区id" prop="villageId">
|
||||
<el-input v-model="form.villageId" placeholder="请输入小区id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="公摊电表设备id" prop="deviceId">
|
||||
<el-input v-model="form.deviceId" placeholder="请输入公摊电表设备id" />
|
||||
</el-form-item>
|
||||
<el-form ref="electricityShareFormRef" :model="form" :rules="rules" label-width="150px">
|
||||
<el-form-item label="公摊电表设备编码" prop="deviceCode">
|
||||
<el-input v-model="form.deviceCode" placeholder="请输入公摊电表设备编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分摊方式" prop="shareMode">
|
||||
<el-input v-model="form.shareMode" placeholder="请输入分摊方式" />
|
||||
<el-form-item label="分摊房间" prop="houseIds">
|
||||
<el-select v-model="form.houseIds" multiple filterable collapse-tags collapse-tags-tooltip placeholder="请选择分摊房间" style="width: 100%">
|
||||
<el-option v-for="item in houseList" :key="item.houseId" :label="item.houseName" :value="String(item.houseId)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -91,10 +90,14 @@
|
||||
<script setup name="ElectricityShare" lang="ts">
|
||||
import { listElectricityShare, getElectricityShare, delElectricityShare, addElectricityShare, updateElectricityShare } from '@/api/system/electricityShare/index';
|
||||
import { ElectricityShareVO, ElectricityShareQuery, ElectricityShareForm } from '@/api/system/electricityShare/types';
|
||||
import { getHouseListByVillageAPI } from '@/api/system/house';
|
||||
import { HouseOptionVO } from '@/api/system/house/type';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const router = useRouter();
|
||||
|
||||
const electricityShareList = ref<ElectricityShareVO[]>([]);
|
||||
const houseList = ref<HouseOptionVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
@@ -113,11 +116,8 @@ const dialog = reactive<DialogOption>({
|
||||
|
||||
const initFormData: ElectricityShareForm = {
|
||||
id: undefined,
|
||||
villageId: undefined,
|
||||
deviceId: undefined,
|
||||
deviceCode: undefined,
|
||||
shareMode: undefined,
|
||||
status: undefined,
|
||||
houseIds: [],
|
||||
remark: undefined,
|
||||
}
|
||||
const data = reactive<PageData<ElectricityShareForm, ElectricityShareQuery>>({
|
||||
@@ -128,26 +128,31 @@ const data = reactive<PageData<ElectricityShareForm, ElectricityShareQuery>>({
|
||||
// villageId: undefined,
|
||||
// deviceId: undefined,
|
||||
deviceCode: undefined,
|
||||
// shareMode: undefined,
|
||||
status: undefined,
|
||||
houseCount: undefined,
|
||||
totalArea: undefined,
|
||||
params: {
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
id: [
|
||||
{ required: true, message: "主键不能为空", trigger: "blur" }
|
||||
deviceCode: [
|
||||
{ required: true, message: "公摊电表设备编码不能为空", trigger: "blur" }
|
||||
],
|
||||
villageId: [
|
||||
{ required: true, message: "小区id不能为空", trigger: "blur" }
|
||||
],
|
||||
deviceId: [
|
||||
{ required: true, message: "公摊电表设备id不能为空", trigger: "blur" }
|
||||
houseIds: [
|
||||
{ required: true, type: "array", message: "请选择分摊房间", trigger: "change" }
|
||||
],
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询当前小区房屋列表(分摊房间下拉) */
|
||||
const getHouseList = async () => {
|
||||
const villageId = localStorage.getItem('villageid');
|
||||
if (!villageId || villageId === 'null') return;
|
||||
const res = await getHouseListByVillageAPI(villageId);
|
||||
houseList.value = res.data || [];
|
||||
}
|
||||
|
||||
/** 查询公摊电表配置列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
@@ -165,7 +170,7 @@ const cancel = () => {
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = {...initFormData};
|
||||
form.value = {...initFormData, houseIds: []};
|
||||
electricityShareFormRef.value?.resetFields();
|
||||
}
|
||||
|
||||
@@ -188,6 +193,16 @@ const handleSelectionChange = (selection: ElectricityShareVO[]) => {
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 查看详情按钮操作 */
|
||||
const handleView = (row: ElectricityShareVO) => {
|
||||
router.push({
|
||||
path: '/electricityShareDetail',
|
||||
query: {
|
||||
id: row.id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
@@ -200,7 +215,16 @@ const handleUpdate = async (row?: ElectricityShareVO) => {
|
||||
reset();
|
||||
const _id = row?.id || ids.value[0]
|
||||
const res = await getElectricityShare(_id);
|
||||
Object.assign(form.value, res.data);
|
||||
// houseCount、totalArea 由后端根据分摊房屋计算,不参与表单编辑与提交
|
||||
const { houseList: shareHouseList, houseCount: _houseCount, totalArea: _totalArea, ...shareData } = res.data;
|
||||
if (!houseList.value.length) {
|
||||
await getHouseList();
|
||||
}
|
||||
// 详情接口返回 houseList,取其中 houseId 回显下拉
|
||||
const houseIds = shareHouseList?.length
|
||||
? shareHouseList.map((item) => String(item.houseId))
|
||||
: (res.data.houseIds || []).map(String);
|
||||
Object.assign(form.value, shareData, { houseIds });
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改公摊电表配置";
|
||||
}
|
||||
@@ -240,5 +264,6 @@ const handleExport = () => {
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
getHouseList();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user