开发公摊电表管理、统计汇总,删除设备管理下不用的列表

This commit is contained in:
zhouyanli
2026-10-20 17:05:58 +08:00
parent c2e2509c94
commit 9c22d0c475
22 changed files with 595 additions and 1763 deletions

View File

@@ -0,0 +1,80 @@
<template>
<div class="p-2">
<PageHeader title="公摊电表配置详情" />
<el-card v-loading="loading" class="mt-4" shadow="never">
<template #header>
<span>基础信息</span>
</template>
<el-descriptions :column="3" border>
<el-descriptions-item label="项目">{{ detailData?.villageName || '--' }}</el-descriptions-item>
<el-descriptions-item label="公摊电表设备编码">{{ detailData?.deviceCode || '--' }}</el-descriptions-item>
<!-- <el-descriptions-item label="分摊方式">{{ shareModeLabel }}</el-descriptions-item> -->
<!-- <el-descriptions-item label="状态">{{ statusLabel }}</el-descriptions-item> -->
<el-descriptions-item label="分摊房屋数量">{{ detailData?.houseCount ?? '--' }}</el-descriptions-item>
<el-descriptions-item label="建筑面积合计">{{ detailData?.totalArea || '--' }}</el-descriptions-item>
<!-- <el-descriptions-item label="创建时间">{{ detailData?.createTime || '--' }}</el-descriptions-item> -->
<el-descriptions-item label="备注" :span="2">{{ detailData?.remark || '--' }}</el-descriptions-item>
</el-descriptions>
<div class="mb-2 mt-6 font-bold">分摊房屋明细</div>
<el-table :data="detailData?.houseList || []" border>
<el-table-column label="房屋名称" prop="houseName" align="center" />
<el-table-column label="建筑面积" prop="houseArea" align="center" />
<!-- <el-table-column label="分摊比例" prop="shareRatio" align="center" /> -->
<!-- <el-table-column label="分摊金额" align="center">
<template #default="scope">{{ scope.row.shareAmount ?? '--' }}</template>
</el-table-column> -->
</el-table>
<div class="mt-6 flex justify-center">
<el-button @click="goBack">返 回</el-button>
</div>
</el-card>
</div>
</template>
<script setup name="ElectricityShareDetail" lang="ts">
import PageHeader from '@/components/Pageheader/index.vue';
import { getElectricityShare } from '@/api/system/electricityShare/index';
import { ElectricityShareVO } from '@/api/system/electricityShare/types';
const route = useRoute();
const router = useRouter();
const loading = ref(false);
const detailData = ref<ElectricityShareVO | null>(null);
/** 分摊方式展示 */
const shareModeLabel = computed(() => {
if (detailData.value?.shareMode == null) return '--';
return detailData.value.shareMode === '1' ? '按建筑面积' : detailData.value.shareMode;
});
/** 状态展示 */
const statusLabel = computed(() => {
if (detailData.value?.status == null) return '--';
return detailData.value.status === '0' ? '正常' : detailData.value.status === '1' ? '停用' : detailData.value.status;
});
/** 获取详情 */
const getDetail = async () => {
const id = route.query.id;
if (!id) return;
loading.value = true;
try {
const res = await getElectricityShare(id as string);
detailData.value = res.data;
} finally {
loading.value = false;
}
};
/** 返回 */
const goBack = () => {
router.back();
};
onMounted(() => {
getDetail();
});
</script>

View File

@@ -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>

View File

@@ -1,247 +0,0 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<el-form-item label="设备分类" prop="categoryId">
<el-select v-model="form.categoryId">
<el-option v-for="(item, index) in deviceCategoryList" :key="index" :value="item.id" :label="item.categoryName"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input maxlength="20" v-model.trim="form.deviceName" placeholder="请输入设备名称" />
</el-form-item>
<el-form-item label="设备唯一编号" prop="deviceCode">
<el-input maxlength="20" v-model.trim="form.deviceCode" placeholder="请输入设备唯一编号" />
</el-form-item>
<el-form-item label="设备型号" prop="deviceModel">
<el-input maxlength="20" v-model.trim="form.deviceModel" placeholder="请输入设备型号" />
</el-form-item>
<el-form-item label="位置区域" prop="area">
<el-input maxlength="100" show-word-limit type="textarea" :rows="2" v-model.trim="form.area" placeholder="请输入位置区域" />
</el-form-item>
<el-form-item label="维护人员" prop="maintainUserIds">
<repairUser
userType="repair"
:userid="checkoutUseId"
ref="repairUserRef"
returnvalue="*"
:is-multiple="true"
title-name="维护人员"
@change="handleCheckoutUser"
>
<template #default>
<div class="checkoutUserBox flex flex-items-center justify-around" v-for="(item, index) in checkoutUser" :key="index">
<span>{{ item.nickName }}</span>
<div @click="handleDelete(item.id)">
<el-icon>
<Delete></Delete>
</el-icon>
</div>
</div>
<div class="checkoutUserBox add flex flex-items-center justify-center" @click="() => repairUserRef.open()">
<el-icon>
<Plus></Plus>
</el-icon>
<span>添加</span>
</div>
</template>
</repairUser>
</el-form-item>
<el-form-item label="设备状态" prop="status">
<el-radio-group v-model.trim="form.status">
<el-radio v-for="(item, index) in com_equipment_archive_status" :value="item.value" :label="item.label" :key="index"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="设备保质期" prop="shelfLife">
<el-input maxlength="20" v-model.trim="form.shelfLife" placeholder="请输入" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input maxlength="200" show-word-limit type="textarea" :row="5" v-model.trim="form.remark" placeholder="请输入" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import repairUser from '@/components/Holder/repairUser.vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { listDeviceCategory } from '@/api/system/equipment/Category';
import { addDevice, getDevice, updateDevice } from '@/api/system/equipment/archive';
import { Delete, Plus } from '@element-plus/icons-vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_equipment_archive_status } = toRefs<any>(proxy?.useDict('com_equipment_archive_status'));
const router = useRouter();
const route = useRoute();
const formRef = ref();
const repairUserRef = ref();
const form = ref({
id: null,
categoryId: '', // 分类id、
deviceName: '', // 设备名称
deviceCode: '', // 编号
deviceModel: '', // 型号
area: '', // 区域
status: '0', // 区域
shelfLife: '', // 设备保质期
maintainUserIds: '', // 设备维护人员
remark: '' // 备注
});
const rules = ref({
categoryId: [{ required: true, message: '请选择 设备类型', trigger: 'blur' }],
deviceCode: [{ required: true, message: '请选择 设备唯一编号', trigger: 'blur' }],
deviceName: [{ required: true, message: '请输入 设备名称', trigger: 'blur' }]
});
const userid = ref(null);
const deviceCategoryList = ref([]);
function init() {
listDeviceCategory().then((res) => {
deviceCategoryList.value = res.rows;
});
if (route.query.id) {
userid.value = route.query.id;
getDevice(userid.value).then((res) => {
form.value = {
id: res.data.id,
categoryId: res.data.categoryId,
deviceName: res.data.deviceName,
deviceCode: res.data.deviceCode,
deviceModel: res.data.deviceModel,
area: res.data.area,
shelfLife: res.data.shelfLife,
status: res.data.status,
maintainUserIds: res.data.maintainUserIds,
remark: res.data.remark
};
checkoutUser.value = [];
checkoutUser.value = res.data.maintainUserList ?? [];
});
}
}
init();
const checkoutUseId = computed(() => {
return checkoutUser.value
.map((item) => item.userId)
.filter((item) => item)
.join(',');
});
const checkoutUser = ref([]);
function handleCheckoutUser(row: string[]) {
checkoutUser.value = row;
}
function handleDelete(id: string) {
checkoutUser.value = checkoutUser.value.filter((item) => item.id !== id);
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
form.value.maintainUserIds = checkoutUser.value
.map((item) => item.userId)
.filter((item) => item)
.join(',');
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateDevice(form.value).then(() => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addDevice(form.value).then(() => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 650px;
margin: 0 auto;
.checkoutUserBox {
width: 120px;
margin: 5px;
border: 1px solid #ccc;
padding: 5px 10px;
border-radius: 5px;
&.add {
cursor: pointer;
border-style: dashed;
&:hover {
color: #409eff;
border-color: #409eff;
}
}
& > div {
cursor: pointer;
&:hover {
color: red;
}
}
}
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,249 +0,0 @@
<template>
<div class="flex flex-col h-full p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :inline="true" :model="queryParams" @submit.prevent="handleQuery">
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="queryParams.deviceName" clearable maxlength="20" placeholder="请输入设备名称" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="设备编号" prop="deviceCode">
<el-input v-model="queryParams.deviceCode" clearable maxlength="20" placeholder="请输入设备编号" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<right-toolbar
:disable-delete="multiple"
:disable-edit="single"
:show-add="checkPermi(['warehouse:device:add'])"
:show-delete="checkPermi(['warehouse:device:remove'])"
:show-edit="checkPermi(['warehouse:device:edit'])"
@update:add="handleAdd"
@update:edit="handleUpdate()"
@update:delete="handleDelete()"
></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" :data="deviceList" border @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="设备分类" prop="categoryName" width="100" />
<el-table-column align="center" label="设备名称" prop="deviceName" />
<el-table-column align="center" label="设备编号" prop="deviceCode" />
<el-table-column align="center" label="品牌型号" prop="deviceModel" />
<el-table-column align="center" label="所在区域" prop="area" show-overflow-tooltip />
<el-table-column align="center" label="设备状态" prop="status" width="80">
<template #default="scope">
<dict-tag :options="com_equipment_archive_status" :value="scope.row.status"></dict-tag>
</template>
</el-table-column>
<el-table-column align="center" label="维护人员" prop="maintainUserListName" show-overflow-tooltip />
<el-table-column align="center" label="备注" prop="remark" show-overflow-tooltip />
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作" width="180">
<template #default="scope">
<el-button v-has-permi="['warehouse:device:query']" link type="primary" @click="handleMain(scope.row)">查看详情</el-button>
<el-button v-has-permi="['warehouse:device:edit']" link type="primary" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-has-permi="['warehouse:device:remove']" link type="primary" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:limit="queryParams.pageSize" v-model:page="queryParams.pageNum" :total="total" @pagination="getList" />
</el-card>
</div>
</template>
<script lang="ts" name="Device" setup>
import { listDevice, delDevice, addDevice, updateDevice } from '@/api/system/equipment/archive';
import { DeviceVO, DeviceQuery, DeviceForm } from '@/api/system/equipment/archive/type';
import { checkPermi } from '@/utils/permission';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_equipment_archive_status } = toRefs<any>(proxy?.useDict('com_equipment_archive_status'));
interface tableType extends DeviceVO {
maintainUserListName?: string;
}
const deviceList = ref<tableType[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const deviceFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: DeviceForm = {
id: undefined,
categoryId: undefined,
deviceName: undefined,
deviceCode: undefined,
deviceModel: undefined,
area: undefined,
maintainUserIds: undefined,
status: undefined,
remark: undefined
};
const data = reactive<PageData<DeviceForm, DeviceQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
categoryId: undefined,
deviceName: undefined,
deviceCode: undefined,
deviceModel: undefined,
area: undefined,
maintainUserIds: undefined,
status: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
categoryId: [{ required: true, message: '设备分类ID不能为空', trigger: 'blur' }],
deviceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询设备列表 */
const getList = async () => {
loading.value = true;
const res = await listDevice(queryParams.value);
deviceList.value = res.rows;
deviceList.value.forEach((item) => {
if (item.maintainUserList && item.maintainUserList.length > 0) {
item.maintainUserListName = item.maintainUserList
.map((it) => (it.nickName ? it.nickName : null))
.filter((it) => it !== null)
.join(',');
}
});
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
deviceFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: DeviceVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/equipment/addArchive'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: DeviceVO) => {
const _ids = row?.id || ids.value;
router.push({
path: '/equipment/editArchive',
query: {
id: _ids
}
});
};
/** 详情按钮操作 */
const handleMain = async (row?: DeviceVO) => {
router.push({
path: '/equipment/archiveMain',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
deviceFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateDevice(form.value).finally(() => (buttonLoading.value = false));
} else {
await addDevice(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: DeviceVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除该设备?').finally(() => (loading.value = false));
await delDevice(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'system/device/export',
{
...queryParams.value
},
`device_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -1,265 +0,0 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title flex flex-items-center justify-between">
<div>
<span>基本信息</span>
<el-button class="ml-10px" link type="primary" @click="editDevice"> 编辑</el-button>
</div>
<el-button @click="cancelForm"> 返回</el-button>
</div>
<div class="addBuildingFormBody">
<div class="infobox">
<div class="info_item">
<div class="label">设备分类:</div>
<span class="value">{{ form.categoryName }}</span>
</div>
<div class="info_item">
<div class="label">设备名称:</div>
<span class="value">{{ form.deviceName }}</span>
</div>
<div class="info_item">
<div class="label">设备编号:</div>
<span class="value">{{ form.deviceCode }}</span>
</div>
<div class="info_item">
<div class="label">品牌型号:</div>
<span class="value">{{ form.deviceModel }}</span>
</div>
<div class="info_item">
<div class="label">所在区域:</div>
<span class="value">{{ form.area }}</span>
</div>
<div class="info_item">
<div class="label">设备状态:</div>
<dict-tag :options="com_equipment_archive_status" :value="form.status"></dict-tag>
</div>
<div class="info_item">
<div class="label">维护人员:</div>
<span class="value">{{ form.maintainUserListName }}</span>
</div>
<div class="info_item">
<div class="label">设备保质期:</div>
<span class="value">{{ form.shelfLife }}</span>
</div>
<div class="info_item">
<div class="label">添加时间:</div>
<span class="value">{{ form.createTime }}</span>
</div>
<div class="info_item">
<div class="label">备注:</div>
<span class="value">{{ form.remark }}</span>
</div>
</div>
</div>
</div>
<div class="AddBuildingBody">
<div class="title">维修记录</div>
<div class="addBuildingFormBody">
<el-table v-loading="loading" :data="deviceRepairList">
<el-table-column align="center" type="index" />
<el-table-column align="center" label="设备名称" prop="deviceName" />
<el-table-column align="center" label="设备编号" prop="deviceCode" />
<el-table-column align="center" label="维修人员" prop="maintainUserNames" />
<el-table-column align="center" label="故障描述" prop="faultDesc" />
<el-table-column align="center" label="维修结果" prop="repairResult">
<template #default="scope">
<dict-tag :options="com_equipment_repair_status" :value="scope.row.repairResult"></dict-tag>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作">
<template #default="scope">
<el-button link type="primary" @click="handleMain(scope.row)">详情</el-button>
<el-button link type="primary" @click="handleEdit(scope.row)">编辑</el-button>
<el-button link type="primary" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:limit="queryParams.pageSize" v-model:page="queryParams.pageNum" :total="total" @pagination="getList" />
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { getDevice } from '@/api/system/equipment/archive';
import { DeviceRepairVO } from '@/api/system/equipment/Repair/type';
import { delDeviceRepair, listDeviceRepair } from '@/api/system/equipment/Repair';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_equipment_repair_status } = toRefs<any>(proxy?.useDict('com_equipment_repair_status'));
const { com_equipment_archive_status } = toRefs<any>(proxy?.useDict('com_equipment_archive_status'));
const router = useRouter();
const route = useRoute();
const form = ref({
id: null,
categoryName: '', // 分类id、
deviceName: '', // 设备名称
deviceCode: '', // 编号
deviceModel: '', // 型号
area: '', // 区域
status: '0', // 区域
shelfLife: '', // 设备保质期
maintainUserIds: '', // 设备维护人员
maintainUserListName: '', // 设备维护人员
createTime: '', // 设备维护人员
remark: '' // 备注
});
const userid = ref(null);
const total = ref(0);
const loading = ref(false);
type DeviceRepairVOList = DeviceRepairVO & {
maintainUserNames?: string;
};
const deviceRepairList = ref<DeviceRepairVOList[]>([]);
const queryParams = ref({
pageNum: 1,
pageSize: 10
});
function init() {
if (route.query.id) {
userid.value = route.query.id;
getDevice(userid.value).then(async (res) => {
form.value = {
id: res.data.id,
categoryName: res.data.categoryName,
deviceName: res.data.deviceName,
shelfLife: res.data.shelfLife,
deviceCode: res.data.deviceCode,
deviceModel: res.data.deviceModel,
area: res.data.area,
status: res.data.status,
maintainUserIds: res.data.maintainUserIds,
remark: res.data.remark,
createTime: res.data.createTime,
maintainUserListName: ''
};
if (res.data.maintainUserList && res.data.maintainUserList.length > 0) {
form.value.maintainUserListName = res.data.maintainUserList
.map((it) => (it.nickName ? it.nickName : null))
.filter((it) => it !== null)
.join(',');
}
getList();
});
}
}
init();
function getList() {
loading.value = true;
listDeviceRepair({
deviceId: form.value.id,
pageNum: queryParams.value.pageNum,
pageSize: queryParams.value.pageSize
})
.then((rows) => {
deviceRepairList.value = rows.rows;
deviceRepairList.value.forEach((item) => {
item.maintainUserNames = item.maintainUserList
.map((i) => i.nickName)
.filter((i) => i)
.join(',');
});
total.value = rows.total;
})
.finally(() => {
loading.value = false;
});
}
function editDevice() {
router.push({
path: '/equipment/editArchive',
query: {
id: form.value.id
}
});
}
/** 删除按钮操作 */
const handleDelete = async (row?: DeviceRepairVO) => {
const _ids = row?.id;
await proxy?.$modal.confirm('是否确认删除维修工单?');
await delDeviceRepair(_ids);
proxy?.$modal.msgSuccess('删除成功');
getList();
};
const handleMain = (row: DeviceRepairVO) => {
router.push({
path: '/equipment/equipmentRepairMain',
query: {
id: row.id
}
});
};
const handleEdit = (row: DeviceRepairVO) => {
router.push({
path: '/equipment/editEquipmentRepair',
query: {
id: row.id
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style lang="scss" scoped>
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 30px;
}
.addBuildingFormBody {
padding-left: 20px;
.infobox {
display: grid;
gap: 20px;
grid-template-columns: repeat(3, 1fr);
.info_item {
display: flex;
align-items: center;
font-size: 15px;
.label {
width: 100px;
min-width: 100px;
text-align: right;
}
.value {
font-weight: normal;
white-space: wrap;
word-break: break-word;
font-size: 14px;
}
}
}
}
}
</style>

View File

@@ -1,236 +0,0 @@
<template>
<div class="p-2 flex flex-col h-full">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :inline="true" :model="queryParams" label-width="100">
<el-form-item label="设备分类名称" prop="categoryName">
<el-input v-model="queryParams.categoryName" clearable maxlength="20" placeholder="请输入设备分类名称" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<right-toolbar
:disable-delete="multiple"
:disable-edit="single"
:show-add="checkPermi(['warehouse:deviceCategory:add'])"
:show-delete="checkPermi(['warehouse:deviceCategory:remove'])"
:show-edit="false"
@update:add="handleAdd"
@update:edit="handleUpdate()"
@update:delete="handleDelete()"
></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" :data="deviceCategoryList" border @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="设备分类名称" prop="categoryName" />
<el-table-column align="center" label="状态" prop="status">
<template #default="scope">
<el-switch
v-model="scope.row.status"
:active-value="0"
:before-change="() => updateDeviceSwitch(scope.row)"
:inactive-value="1"
></el-switch>
</template>
</el-table-column>
<el-table-column align="center" label="添加时间" prop="createTime" />
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作">
<template #default="scope">
<el-button v-has-permi="['warehouse:deviceCategory:edit']" link type="primary" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-has-permi="['warehouse:deviceCategory:remove']" link type="primary" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:limit="queryParams.pageSize" v-model:page="queryParams.pageNum" :total="total" @pagination="getList" />
</el-card>
<!-- 添加或修改设备分类对话框 -->
<el-dialog v-model="dialog.visible" :title="dialog.title" append-to-body width="500px">
<el-form ref="deviceCategoryFormRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="设备分类名称" prop="categoryName">
<el-input v-model="form.categoryName" maxlength="20" placeholder="请输入设备分类名称" show-word-limit />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script lang="ts" name="DeviceCategory" setup>
import { listDeviceCategory, delDeviceCategory, addDeviceCategory, updateDeviceCategory } from '@/api/system/equipment/Category';
import { DeviceCategoryVO, DeviceCategoryQuery, DeviceCategoryForm } from '@/api/system/equipment/Category/type';
import { checkPermi } from '@/utils/permission';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const deviceCategoryList = ref<DeviceCategoryVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const deviceCategoryFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: DeviceCategoryForm = {
id: undefined,
categoryName: '',
status: 0,
remark: ''
};
const data = reactive<PageData<DeviceCategoryForm, DeviceCategoryQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
categoryName: undefined
},
rules: {
categoryName: [{ required: true, message: '设备分类名称不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询设备分类列表 */
const getList = async () => {
loading.value = true;
listDeviceCategory(queryParams.value)
.then((res) => {
deviceCategoryList.value = res.rows;
total.value = res.total;
})
.finally(() => {
loading.value = false;
});
};
function updateDeviceSwitch(row: DeviceCategoryVO): Promise<boolean> {
return new Promise((resolve, reject) => {
const obj = {
id: row.id,
status: row.status === 1 ? 0 : 1
};
updateDeviceCategory(obj)
.then(() => {
resolve(true);
})
.catch(() => {
reject(false);
});
});
}
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
deviceCategoryFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: DeviceCategoryVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加设备分类';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: DeviceCategoryVO) => {
reset();
Object.assign(form.value, {
id: row.id,
categoryName: row.categoryName,
status: row.status,
remark: row.remark
});
dialog.visible = true;
dialog.title = '修改设备分类';
};
/** 提交按钮 */
const submitForm = () => {
deviceCategoryFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateDeviceCategory(form.value).finally(() => (buttonLoading.value = false));
} else {
await addDeviceCategory(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: DeviceCategoryVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除该设备分类编号?').finally(() => (loading.value = false));
await delDeviceCategory(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -1,278 +0,0 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form ref="formRef" :model="form" :rules="rules" class="formBody" label-position="right" label-width="130px">
<el-form-item label="设备分类" prop="categoryId">
<el-select v-model="form.categoryId" @change="handleCategoryIdChange">
<el-option
v-for="(item, index) in deviceCategoryList"
:key="index"
:disabled="item.status === 1"
:label="item.categoryName"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备名称" prop="deviceId">
<el-select v-model="form.deviceId" filterable @change="handleDeviceChange">
<el-option v-for="(item, index) in deviceList" :key="index" :label="item.deviceName" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备编号" prop="deviceCode">
<el-input v-model.trim="form.deviceCode" disabled maxlength="20" placeholder="请输入设备编号" />
</el-form-item>
<el-form-item label="设备型号" prop="deviceModel">
<el-input v-model.trim="form.deviceModel" disabled maxlength="20" placeholder="请输入设备型号" />
</el-form-item>
<el-form-item label="位置区域" prop="area">
<el-input v-model.trim="form.area" :rows="2" maxlength="100" placeholder="请输入位置区域" show-word-limit type="textarea" />
</el-form-item>
<el-form-item label="维护人员" prop="maintainUserIds">
<repairUser
ref="repairUserRef"
:is-multiple="true"
:userid="checkoutUseId"
returnvalue="*"
title-name="维护人员"
userType="repair"
@change="handleCheckoutUser"
>
<template #default>
<div v-for="(item, index) in checkoutUser" :key="index" class="checkoutUserBox flex flex-items-center justify-around">
<span>{{ item.nickName }}</span>
<div @click="handleDelete(item.id)">
<el-icon>
<Delete></Delete>
</el-icon>
</div>
</div>
<div class="checkoutUserBox add flex flex-items-center justify-center" @click="() => repairUserRef.open()">
<el-icon>
<Plus></Plus>
</el-icon>
<span>添加</span>
</div>
</template>
</repairUser>
</el-form-item>
<el-form-item label="故障描述" prop="faultDesc">
<el-input v-model.trim="form.faultDesc" :rows="2" maxlength="100" placeholder="请输入" show-word-limit type="textarea" />
</el-form-item>
<el-form-item label="维修结果" prop="repairResult">
<el-radio-group v-model.trim="form.repairResult">
<el-radio v-for="(item, index) in com_equipment_repair_status" :key="index" :label="item.label" :value="item.value"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model.trim="form.remark" :rows="5" maxlength="200" placeholder="请输入" show-word-limit type="textarea" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import repairUser from '@/components/Holder/repairUser.vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { listDeviceCategory } from '@/api/system/equipment/Category';
import { Delete, Plus } from '@element-plus/icons-vue';
import { addDeviceRepair, getDeviceRepair, updateDeviceRepair } from '@/api/system/equipment/Repair';
import { listDevice } from '@/api/system/equipment/archive';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_equipment_repair_status } = toRefs<any>(proxy?.useDict('com_equipment_repair_status'));
const router = useRouter();
const route = useRoute();
const formRef = ref();
const repairUserRef = ref();
const form = ref({
id: null,
categoryId: '', // 分类id、
deviceId: '', // 设备id
deviceName: '', // 设备名称
deviceCode: '', // 编号
deviceModel: '', // 型号
area: '', // 区域
faultDesc: '', // 区域
repairResult: '0', // 区域
maintainUserIds: '', // 设备维护人员
remark: '' // 备注
});
const rules = ref({
categoryId: [{ required: true, message: '请选择 设备分类', trigger: 'blur' }],
deviceId: [{ required: true, message: '请选择 设备', trigger: 'blur' }],
deviceName: [{ required: true, message: '请输入 设备名称', trigger: 'blur' }],
faultDesc: [{ required: true, message: '请输入 故障描述', trigger: 'blur' }],
maintainUserIds: [{ required: true, message: '请选择 维修人员', trigger: 'blur' }]
});
const userid = ref(null);
// 设备列表
const deviceList = ref([]);
// 分类列表
const deviceCategoryList = ref([]);
function handleCategoryIdChange(val: string) {
listDevice({ categoryId: val, pageNum: 1, pageSize: undefined }).then((res) => {
deviceList.value = res.rows;
});
}
function handleDeviceChange(val: string) {
const find = deviceList.value.find((item) => item.id === val);
if (find) {
form.value.deviceName = find.deviceName;
form.value.deviceCode = find.deviceCode;
form.value.deviceModel = find.deviceModel;
}
}
function init() {
listDeviceCategory().then((res) => {
deviceCategoryList.value = res.rows;
});
if (route.query.id) {
userid.value = route.query.id;
getDeviceRepair(userid.value).then((res) => {
form.value = {
categoryId: res.data.categoryId,
id: res.data.id,
deviceName: res.data.deviceName,
deviceCode: res.data.deviceCode,
deviceModel: res.data.deviceModel,
deviceId: res.data.deviceId, // 设备分类id
maintainUserIds: res.data.maintainUserIds,
area: res.data.area,
faultDesc: res.data.faultDesc,
repairResult: res.data.repairResult,
remark: res.data.remark
};
// 根据 分类id 回显设备
handleCategoryIdChange(res.data.categoryId);
checkoutUser.value = [];
checkoutUser.value = res.data.maintainUserList ?? [];
});
}
}
init();
// 用于回显维修人员
const checkoutUseId = computed(() => {
return checkoutUser.value
.map((item) => item.userId)
.filter((item) => item)
.join(',');
});
// 选择维修人员
const checkoutUser = ref([]);
function handleCheckoutUser(row: any[]) {
checkoutUser.value = row;
}
function handleDelete(id: string) {
checkoutUser.value = checkoutUser.value.filter((item) => item.id !== id);
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
form.value.maintainUserIds = checkoutUser.value
.map((item) => item.userId)
.filter((item) => item)
.join(',');
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateDeviceRepair(form.value).then(() => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addDeviceRepair(form.value).then(() => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style lang="scss" scoped>
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 650px;
margin: 0 auto;
.checkoutUserBox {
margin: 5px;
border: 1px solid #ccc;
padding: 5px 10px;
border-radius: 5px;
min-width: 100px;
&.add {
cursor: pointer;
border-style: dashed;
&:hover {
color: #409eff;
border-color: #409eff;
}
}
& > div {
cursor: pointer;
margin-left: 10px;
&:hover {
color: red;
}
}
}
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,227 +0,0 @@
<template>
<div class="h-full flex flex-col p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :inline="true" :model="queryParams" label-width="100">
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="queryParams.deviceName" clearable maxlength="20" placeholder="请输入设备名称" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="设备编号" prop="deviceCode">
<el-input v-model="queryParams.deviceCode" clearable maxlength="20" placeholder="请输入设备编号" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<right-toolbar
:disable-delete="multiple"
:disable-edit="single"
:show-add="checkPermi(['warehouse:deviceRepair:add'])"
:show-delete="checkPermi(['warehouse:deviceRepair:remove'])"
:show-edit="checkPermi(['warehouse:deviceRepair:edit'])"
@update:add="handleAdd"
@update:edit="handleUpdate()"
@update:delete="handleDelete()"
></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" :data="deviceRepairList" border @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="设备名称" prop="deviceName" />
<el-table-column align="center" label="设备编号" prop="deviceCode" />
<el-table-column align="center" label="品牌型号" prop="deviceModel" />
<el-table-column align="center" label="维护人员" prop="maintainUserNames" />
<el-table-column align="center" label="故障描述" prop="faultDesc" />
<el-table-column align="center" label="维修结果" prop="repairResult">
<template #default="scope">
<dict-tag :options="com_equipment_repair_status" :value="scope.row.repairResult"></dict-tag>
</template>
</el-table-column>
<el-table-column align="center" label="备注" prop="remark" />
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作" min-width="160">
<template #default="scope">
<el-button v-has-permi="['warehouse:deviceRepair:query']" link type="primary" @click="handleMain(scope.row)">查看详情</el-button>
<el-button v-has-permi="['warehouse:deviceRepair:edit']" link type="primary" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-has-permi="['warehouse:deviceRepair:remove']" link type="primary" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:limit="queryParams.pageSize" v-model:page="queryParams.pageNum" :total="total" @pagination="getList" />
</el-card>
</div>
</template>
<script lang="ts" name="DeviceRepair" setup>
import { listDeviceRepair, delDeviceRepair } from '@/api/system/equipment/Repair';
import { DeviceRepairVO, DeviceRepairQuery, DeviceRepairForm } from '@/api/system/equipment/Repair/type';
import { checkPermi } from '@/utils/permission';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_equipment_repair_status } = toRefs<any>(proxy?.useDict('com_equipment_repair_status'));
interface tableType extends DeviceRepairVO {
maintainUserNames?: string;
}
const deviceRepairList = ref<tableType[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const deviceRepairFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: DeviceRepairForm = {
id: undefined,
deviceId: undefined,
deviceName: undefined,
deviceCode: undefined,
deviceModel: undefined,
area: undefined,
maintainUserIds: undefined,
faultDesc: undefined,
repairResult: undefined,
repairTime: undefined,
remark: undefined
};
const data = reactive<PageData<DeviceRepairForm, DeviceRepairQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
deviceId: undefined,
deviceName: undefined,
deviceCode: undefined,
deviceModel: undefined,
area: undefined,
maintainUserIds: undefined,
faultDesc: undefined,
repairResult: undefined,
repairTime: undefined,
params: {}
}
});
const { queryParams, form } = toRefs(data);
/** 查询维修工单列表 */
// TODO 设备维修记录 用户id有,用户信息没有
const getList = async () => {
loading.value = true;
listDeviceRepair(queryParams.value)
.then((res) => {
deviceRepairList.value = res.rows;
deviceRepairList.value.forEach((item) => {
if (item.maintainUserList && item.maintainUserList.length > 0) {
item.maintainUserNames = item.maintainUserList
.map((i) => i.nickName)
.filter((i) => i)
.join(',');
}
});
total.value = res.total;
})
.finally(() => {
loading.value = false;
});
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
deviceRepairFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: DeviceRepairVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/equipment/addEquipmentRepair'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: DeviceRepairVO) => {
const _ids = row?.id || ids.value[0];
router.push({
path: '/equipment/editEquipmentRepair',
query: {
id: _ids
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: DeviceRepairVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除维修工单?').finally(() => (loading.value = false));
await delDeviceRepair(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
const handleMain = (row) => {
router.push({
path: '/equipment/equipmentRepairMain',
query: {
id: row.id
}
});
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -1,186 +0,0 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title flex flex-items-center justify-between">
<div class="flex flex-items-center">
<h5>设备信息</h5>
<div style="font-size: 0.9rem; margin-left: 20px" class="mr-5px">{{ form.id }}</div>
<el-button class="ml-10px" link type="primary" @click="editDeviceRecode"> 编辑</el-button>
</div>
<el-button @click="cancelForm"> 返回</el-button>
</div>
<div class="addBuildingFormBody">
<div class="infobox">
<!-- <div class="info_item">-->
<!-- <div class="label">设备分类:</div>-->
<!-- <span class="value">{{ form.categoryName }}</span>-->
<!-- </div>-->
<div class="info_item">
<div class="label">设备名称:</div>
<span class="value">{{ form.deviceName }}</span>
</div>
<div class="info_item">
<div class="label">设备编号:</div>
<span class="value">{{ form.deviceCode }}</span>
</div>
<div class="info_item">
<div class="label">品牌型号:</div>
<span class="value">{{ form.deviceModel }}</span>
</div>
<div class="info_item">
<div class="label">所在区域:</div>
<span class="value">{{ form.area }}</span>
</div>
<div class="info_item">
<div class="label">维护人员:</div>
<span class="value">{{ form.maintainUserListName }}</span>
</div>
</div>
<div class="infobox">
<div class="info_item">
<div class="label">故障描述:</div>
<span class="value">{{ form.faultDesc }}</span>
</div>
</div>
<div class="infobox">
<div class="info_item">
<div class="label">维修结果:</div>
<DictTag :options="com_equipment_repair_status" :value="form.repairResult"></DictTag>
</div>
<div class="info_item">
<div class="label">维修时间:</div>
<span class="value">{{ form.repairTime }}</span>
</div>
<div></div>
<div class="info_item">
<div class="label">备注:</div>
<span class="value">{{ form.remark }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { getDeviceRepair } from '@/api/system/equipment/Repair';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_equipment_repair_status } = toRefs<any>(proxy?.useDict('com_equipment_repair_status'));
const router = useRouter();
const route = useRoute();
const form = ref({
id: null,
deviceId: '', // 分类id、
categoryName: '', // 分类id、
deviceName: '', // 设备名称
deviceCode: '', // 编号
deviceModel: '', // 型号
area: '', // 区域
maintainUserListName: '', // 区域
maintainUserIds: '', // 设备维护人员
repairResult: '', // 设备维护人员
faultDesc: '', // 设备维护人员
createTime: '', // 设备维护人员
repairTime: '', // 设备维护人员
remark: '' // 备注
});
const userid = ref(null);
function init() {
if (route.query.id) {
userid.value = route.query.id;
getDeviceRepair(userid.value).then(async (res) => {
form.value = {
id: res.data.id,
deviceId: res.data.deviceId,
faultDesc: res.data.faultDesc,
categoryName: res.data.categoryName,
repairResult: res.data.repairResult,
deviceName: res.data.deviceName,
deviceCode: res.data.deviceCode,
deviceModel: res.data.deviceModel,
area: res.data.area,
maintainUserIds: res.data.maintainUserIds,
remark: res.data.remark,
createTime: res.data.createTime,
repairTime: res.data.repairTime,
maintainUserListName: ''
};
if (res.data.maintainUserList && res.data.maintainUserList.length > 0) {
form.value.maintainUserListName = res.data.maintainUserList
.map((it) => (it.nickName ? it.nickName : null))
.filter((it) => it !== null)
.join(',');
}
});
}
}
init();
function editDeviceRecode() {
router.push({
path: '/equipment/editEquipmentRepair',
query: {
id: form.value.id
}
});
}
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 30px;
}
.addBuildingFormBody {
padding-left: 20px;
.infobox {
display: grid;
gap: 20px;
margin-bottom: 20px;
grid-template-columns: repeat(3, 1fr);
.info_item {
display: flex;
align-items: center;
font-size: 15px;
.label {
width: 120px;
text-align: right;
}
.value {
font-weight: normal;
}
}
}
}
}
</style>

View File

@@ -66,23 +66,23 @@
</el-row>
<el-table v-loading="loading" :data="houseList" border class="tablebox" @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="房间号" min-width="100" prop="houseNo" />
<el-table-column align="center" label="楼层" prop="floorNo" width="80" />
<el-table-column align="center" label="房间号" prop="houseNo" />
<el-table-column align="center" label="楼层" prop="floorNo" />
<!-- <el-table-column align="center" label="房屋类型" min-width="100" prop="houseType" /> -->
<el-table-column align="center" label="建筑面积(㎡)" min-width="110" prop="houseArea" />
<el-table-column align="center" label="套内面积(㎡)" min-width="110" prop="internalArea" />
<el-table-column align="center" label="公摊面积(㎡)" min-width="110" prop="shareArea" />
<el-table-column align="center" label="房东" min-width="100" prop="landlordName" />
<el-table-column align="center" label="房东电话" min-width="120" prop="landlordPhone" />
<el-table-column align="center" label="承租方" min-width="100" prop="lesseeName" />
<el-table-column align="center" label="承租方电话" min-width="120" prop="lesseePhone" />
<el-table-column align="center" label="建筑面积(㎡)" prop="houseArea" />
<el-table-column align="center" label="套内面积(㎡)" prop="internalArea" />
<el-table-column align="center" label="公摊面积(㎡)" prop="shareArea" />
<el-table-column align="center" label="房东" prop="landlordName" />
<el-table-column align="center" label="房东电话" prop="landlordPhone" />
<el-table-column align="center" label="承租方" prop="lesseeName" />
<el-table-column align="center" label="承租方电话" prop="lesseePhone" />
<!-- <el-table-column align="center" label="状态" prop="status" width="120">
<template #default="scope">
<DictTag :options="com_review" :value="scope.row.status"></DictTag>
</template>
</el-table-column> -->
<el-table-column align="center" label="备注" min-width="120" prop="remark" show-overflow-tooltip />
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作" min-width="160">
<el-table-column align="center" label="备注" prop="remark" show-overflow-tooltip />
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作" >
<template #default="scope">
<el-button v-has-permi="['system:house:ByIdList']" link type="primary" @click="handleMain(scope.row)">详情</el-button>
<el-button v-has-permi="['system:house:edit']" link type="primary" @click="handleUpdate(scope.row)">编辑</el-button>

View File

@@ -1,10 +1,167 @@
<template>
<div class="h-full flex flex-col p-2">
<pageheader></pageheader>
<el-card class="flex-1 mt-2" shadow="never">
<!-- TODO: 统计汇总 -->
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="90px">
<el-form-item label="时间范围">
<el-date-picker
v-model="dateRange"
type="daterange"
value-format="YYYY-MM-DD"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
unlink-panels
@change="handleDateRangeChange"
/>
</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>
</div>
</transition>
<el-row :gutter="12" class="mb-[10px]">
<el-col v-for="item in summaryCards" :key="item.label" :span="6">
<el-card shadow="hover">
<div class="flex flex-col">
<span class="text-[13px] opacity-60">{{ item.label }}</span>
<span class="mt-1 text-[22px] font-bold">{{ item.value }}</span>
</div>
</el-card>
</el-col>
</el-row>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row justify="end">
<el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button>
</el-row>
</template>
<el-table v-loading="loading" border :data="list">
<el-table-column label="项目" prop="villageName" align="center" min-width="100" />
<el-table-column label="房号" prop="houseNo" align="center" min-width="90" />
<el-table-column label="房屋名称" prop="houseName" align="center" min-width="120" show-overflow-tooltip />
<el-table-column label="承租方" align="center" min-width="100">
<template #default="scope">{{ scope.row.lesseeName || '--' }}</template>
</el-table-column>
<el-table-column label="联系电话" align="center" min-width="120">
<template #default="scope">{{ scope.row.lesseePhone || '--' }}</template>
</el-table-column>
<el-table-column label="设备编码" prop="deviceCodes" align="center" min-width="160" show-overflow-tooltip />
<el-table-column label="设备数量" prop="deviceCount" align="center" width="90" />
<el-table-column label="用电量" align="center" width="110">
<template #default="scope">{{ formatNumber(scope.row.usageEnergy) }}</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
</template>
<script setup lang="ts" name="StatisticsSummary"></script>
<script setup name="StatisticsSummary" lang="ts">
import { listStatisticsSummary, getStatisticsSummaryTotal } from '@/api/system/statisticsSummary';
import { StatisticsSummaryVO, StatisticsSummaryTotal } from '@/api/system/statisticsSummary/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const loading = ref(false);
const showSearch = ref(true);
const list = ref<StatisticsSummaryVO[]>([]);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const getInitSummary = (): StatisticsSummaryTotal => ({
houseCount: 0,
houseUsageTotal: '0',
shareUsageTotal: '0',
totalUsage: '0'
});
const queryParams = ref({
pageNum: 1,
pageSize: 10,
beginTime: undefined as string | undefined,
endTime: undefined as string | undefined
});
/** 查询时间段 */
const dateRange = ref<[string, string] | null>(null);
const summary = ref<StatisticsSummaryTotal>(getInitSummary());
/** 时间段变化 */
const handleDateRangeChange = (val: [string, string] | null) => {
queryParams.value.beginTime = val?.[0];
queryParams.value.endTime = val?.[1];
};
/** 数值格式化(保留两位小数) */
const formatNumber = (value?: string | number | null) => {
if (value === null || value === undefined || value === '') return '--';
const num = Number(value);
return Number.isNaN(num) ? String(value) : num.toFixed(2);
};
/** 顶部合计卡片 */
const summaryCards = computed(() => [
{ label: '房屋数量', value: summary.value.houseCount ?? 0 },
{ label: '房屋用电合计', value: formatNumber(summary.value.houseUsageTotal) },
{ label: '公摊用电合计', value: formatNumber(summary.value.shareUsageTotal) },
{ label: '用电总计', value: formatNumber(summary.value.totalUsage) }
]);
/** 查询统计汇总列表 */
const getList = async () => {
loading.value = true;
try {
const [listRes, totalRes] = await Promise.all([
listStatisticsSummary(queryParams.value),
getStatisticsSummaryTotal({ beginTime: queryParams.value.beginTime, endTime: queryParams.value.endTime })
]);
list.value = listRes.rows || [];
total.value = listRes.total || 0;
summary.value = totalRes.data || getInitSummary();
} finally {
loading.value = false;
}
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'statisticsSummary/export',
{
beginTime: queryParams.value.beginTime,
endTime: queryParams.value.endTime
},
`statisticsSummary_${new Date().getTime()}.xlsx`
);
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
dateRange.value = null;
queryParams.value.beginTime = undefined;
queryParams.value.endTime = undefined;
handleQuery();
};
onMounted(() => {
getList();
});
</script>