完成水电表列表
This commit is contained in:
264
src/views/system/Sdb/SdbElectricityDevice/index.vue
Normal file
264
src/views/system/Sdb/SdbElectricityDevice/index.vue
Normal file
@@ -0,0 +1,264 @@
|
||||
<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" :model="queryParams" :inline="true">
|
||||
<el-form-item label="设备编码" prop="deviceCode">
|
||||
<el-input v-model="queryParams.deviceCode" placeholder="请输入设备编码" clearable @keyup.enter="handleQuery" />
|
||||
</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-card class="flex-1" shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button :disabled="true" type="warning" plain @click="handleExport">导入</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="electricityDeviceList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="设备编码" align="center" prop="deviceCode" />
|
||||
<el-table-column label="设备状态" align="center">
|
||||
<template #default="scope">
|
||||
<DictTag :options="com_waterdevice_on_status" :value="scope.row.status"></DictTag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分合状态" align="center">
|
||||
<template #default="scope">
|
||||
<div class="readRecord" v-if="scope.row.electricityRecord">
|
||||
<DictTag :options="com_electricity_readrecord_status" :value="scope.row.electricityRecord.status"></DictTag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="余额" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.electricityRecord">{{ scope.row.electricityRecord.balance }}</span>
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="图片" width="85" align="center" prop="deleted">
|
||||
<template #default="scope">
|
||||
<el-image
|
||||
v-if="scope.row.url && scope.row.url.includes('http')"
|
||||
:src="scope.row.url"
|
||||
:preview-src-list="[scope.row.url]"
|
||||
style="width: 40px; height: 40px; border-radius: 4px; margin-right: 5px"
|
||||
fit="cover"
|
||||
preview-teleported
|
||||
/>
|
||||
<span v-else>暂未生成</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="抄表时间" align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.waterRecord ? scope.row.waterRecord.readTime : '--' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备地址" align="center" prop="address" />
|
||||
<el-table-column label="操作" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="handleProject(scope.row)">生成二维码</el-button>
|
||||
<el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['system:electricityDevice:edit']">修改</el-button>
|
||||
<el-button link type="primary" @click="handleDelete(scope.row)" v-hasPermi="['system:electricityDevice:remove']">删除</el-button>
|
||||
</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>
|
||||
<!-- 添加或修改电设备对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="electricityDeviceFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="设备编码" prop="deviceCode">
|
||||
<el-input v-model="form.deviceCode" placeholder="请输入设备编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="安装地址" prop="address">
|
||||
<el-input v-model="form.address" placeholder="请输入安装地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="0.未删除,1.删除" prop="deleted">
|
||||
<el-input v-model="form.deleted" placeholder="请输入0.未删除,1.删除" />
|
||||
</el-form-item>
|
||||
<el-form-item label="" prop="url">
|
||||
<el-input v-model="form.url" placeholder="请输入" />
|
||||
</el-form-item>
|
||||
<el-form-item label="" prop="openid">
|
||||
<el-input v-model="form.openid" placeholder="请输入" />
|
||||
</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 setup name="ElectricityDevice" lang="ts">
|
||||
import {
|
||||
listElectricityDevice,
|
||||
getElectricityDevice,
|
||||
delElectricityDevice,
|
||||
addElectricityDevice,
|
||||
updateElectricityDevice
|
||||
} from '@/api/system/SdbElectricityDevice/index';
|
||||
import { ElectricityDeviceVO, ElectricityDeviceQuery, ElectricityDeviceForm } from '@/api/system/SdbElectricityDevice/type';
|
||||
import { splitImages } from '@/utils';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_waterdevice_on_status } = toRefs<any>(proxy?.useDict('com_waterdevice_on_status'));
|
||||
const { com_electricity_readrecord_status } = toRefs<any>(proxy?.useDict('com_electricity_readrecord_status'));
|
||||
|
||||
const electricityDeviceList = ref<ElectricityDeviceVO[]>([]);
|
||||
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 electricityDeviceFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ElectricityDeviceForm = {
|
||||
id: undefined,
|
||||
deviceCode: undefined,
|
||||
address: undefined,
|
||||
deleted: undefined,
|
||||
url: undefined,
|
||||
openid: undefined
|
||||
};
|
||||
const data = reactive<PageData<ElectricityDeviceForm, ElectricityDeviceQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
deviceCode: undefined,
|
||||
address: undefined,
|
||||
deleted: undefined,
|
||||
url: undefined,
|
||||
openid: undefined,
|
||||
params: {}
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询电设备列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listElectricityDevice(queryParams.value);
|
||||
electricityDeviceList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
electricityDeviceFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: ElectricityDeviceVO[]) => {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
const router = useRouter();
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
router.push({
|
||||
path: '/sdb/addSdbElectricityDevice'
|
||||
});
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: ElectricityDeviceVO) => {
|
||||
router.push({
|
||||
path: '/sdb/addSdbElectricityDevice',
|
||||
query: { id: row?.id }
|
||||
});
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
electricityDeviceFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.id) {
|
||||
await updateElectricityDevice(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addElectricityDevice(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleProject = (row) => {
|
||||
row.url = 'https://www.bugtc.com/static/dsb/20260107/272d59d5-bff1-49b3-b899-046169c07257.png';
|
||||
};
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: ElectricityDeviceVO) => {
|
||||
const _ids = row?.id || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除电设备编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
|
||||
await delElectricityDevice(_ids);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.$modal.msgError('暂不支持导出功能');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.el-table {
|
||||
height: calc(100% - 80px);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user