fix 基础列表页

This commit is contained in:
Ironsp
2026-05-12 18:01:25 +08:00
parent 3d1bd1612c
commit f88a367372
11 changed files with 154 additions and 76 deletions

View File

View File

View File

@@ -0,0 +1,72 @@
import request from '@/utils/request';
import type { EquipmentList, DeviceInfoForm } from '@/api/equipmentList/types';
/**
* 新增设备
* @param data 设备数据
* @returns AxiosPromise<any>
*/
export const addEquipment = ( )=> {
return request({
url: '/device/info/add',
method: 'post',
});
};
/**
* 查询设备列表
* @param query 查询参数
* @returns AxiosPromise<DemoVO[]>
*/
export const getDevicetList = (query: EquipmentList) => {
return request({
url: '/device/info/list',
method: 'post',
params: query
});
};
/**
* 获取设备详情(路径参数 id
* @param id 设备主键
*/
export const getDeviceInfo = (id: string | number) => {
return request({
url: `/device/info/${id}`,
method: 'get'
});
};
/**
* 删除设备
* @param ids 设备主键列表Queryids=1,2,3
*/
export const delDevice = (ids: Array<string | number>) => {
return request({
url: '/device/info/delete',
method: 'post',
params: { ids: ids.join(',') }
});
};
/**
* 激活设备
* @param ids 设备数组(请求体:{ ids: [...] }
*/
export const actDevice = (ids: Array<string | number>) => {
return request({
url: '/device/info/activate',
method: 'post',
params: { ids: ids.join(',') }
});
};
/**
* 编辑设备
* @param data 设备信息(含 id
*/
export const updateDeviceInfo = (data: DeviceInfoForm) => {
return request({
url: '/device/info/edit',
method: 'post',
data
});
};

View File

@@ -0,0 +1,24 @@
//查询设备列表参数
export interface EquipmentList {
code: string | number;
name: string | number;
monitoringArea: string | number;
status: number;
}
/** 设备编辑 / 新增提交体(与 /device/info/edit 入参一致) */
export interface DeviceInfoForm extends BaseEntity {
id?: string | number;
code?: string;
name?: string;
monitoringArea?: string;
drawArea?: string;
status?: number;
model?: string;
isDrawArea?: number;
isDelete?: number;
/** 若依扩展参数 */
params?: Record<string, Record<string, unknown>>;
}

View File

View File

View File

View File

View File

@@ -1,9 +0,0 @@
<template>
<div class="detail">
<h1>detail</h1>
</div>
</template>
<script setup lang="ts"></script>
<style lang="less" scoped></style>

View File

@@ -29,7 +29,7 @@
<template #header> <template #header>
<el-row :gutter="10" class="flex justify-end mb8"> <el-row :gutter="10" class="flex justify-end mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['demo:demo:add']" type="primary" plain icon="Plus" @click="handleAdd">添加设备</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd">添加设备</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['demo:demo:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" <el-button v-hasPermi="['demo:demo:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
@@ -50,20 +50,21 @@
<el-table v-loading="loading" border :data="demoList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" border :data="demoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column v-if="true" label="主键" align="center" prop="id" /> <el-table-column v-if="true" label="设备编号" align="center" prop="id" />
<el-table-column label="部门id" align="center" prop="deptId" /> <el-table-column label="设备名称" align="center" prop="deptId" />
<el-table-column label="用户id" align="center" prop="userId" /> <el-table-column label="监控区域" align="center" prop="userId" />
<el-table-column label="排序号" align="center" prop="orderNum" /> <el-table-column label="设备状态" align="center" prop="orderNum" />
<el-table-column label="key键" align="center" prop="testKey" /> <el-table-column label="设备型号" align="center" prop="testKey" />
<el-table-column label="" align="center" prop="value" /> <el-table-column label="固件版本" align="center" prop="value" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="是否绘制区域" align="center" prop="value" />
<el-table-column label="绑定时间" align="center" prop="value" />
<el-table-column width="400" label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip content="修改" placement="top"> <el-button type="primary" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-hasPermi="['demo:demo:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button> <el-button type="primary" @click="handleDelete(scope.row)">查看监控</el-button>
</el-tooltip> <el-button type="primary" @click="handleDelete(scope.row)">唤醒设备</el-button>
<el-tooltip content="删除" placement="top"> <el-button type="primary" @click="handleDelete(scope.row)">删除</el-button>
<el-button v-hasPermi="['demo:demo:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
</el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -100,16 +101,16 @@
</template> </template>
<script setup name="Demo" lang="ts"> <script setup name="Demo" lang="ts">
import { listDemo, getDemo, delDemo, addDemo, updateDemo } from '@/api/demo/demo'; import { addEquipment, getDevicetList, getDeviceInfo, delDevice, actDevice, updateDeviceInfo } from '@/api/equipmentList/index';
import { DemoVO, DemoQuery, DemoForm } from '@/api/demo/demo/types'; import { EquipmentList, DeviceInfoForm } from '@/api/equipmentList/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const demoList = ref<DemoVO[]>([]); const demoList = ref([]);
const buttonLoading = ref(false); const buttonLoading = ref(false);
const loading = ref(true); const loading = ref(true);
const showSearch = ref(true); const showSearch = ref(true);
const ids = ref<Array<string | number>>([]); const ids = ref([]);
const single = ref(true); const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
@@ -130,16 +131,15 @@ const initFormData: DemoForm = {
testKey: undefined, testKey: undefined,
value: undefined value: undefined
}; };
const data = reactive<PageData<DemoForm, DemoQuery>>({ const data = reactive({
form: { ...initFormData }, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
deptId: undefined, code: undefined,
userId: undefined, name: undefined,
orderNum: undefined, monitoringArea: undefined,
testKey: undefined, status: undefined
value: undefined
}, },
rules: { rules: {
id: [{ required: true, message: '主键不能为空', trigger: 'blur' }], id: [{ required: true, message: '主键不能为空', trigger: 'blur' }],
@@ -156,7 +156,7 @@ const { queryParams, form, rules } = toRefs(data);
/** 查询测试单列表 */ /** 查询测试单列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await listDemo(queryParams.value); const res = await getDevicetList(queryParams.value);
demoList.value = res.rows; demoList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
@@ -187,7 +187,7 @@ const resetQuery = () => {
}; };
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: DemoVO[]) => { const handleSelectionChange = (selection: any) => {
ids.value = selection.map((item) => item.id); ids.value = selection.map((item) => item.id);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
@@ -201,40 +201,40 @@ const handleAdd = () => {
}; };
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: DemoVO) => { // const handleUpdate = async (row?: any) => {
reset(); // reset();
const _id = row?.id || ids.value[0]; // const _id = row?.id || ids.value[0];
const res = await getDemo(_id); // const res = await getDemo(_id);
Object.assign(form.value, res.data); // Object.assign(form.value, res.data);
dialog.visible = true; // dialog.visible = true;
dialog.title = '修改测试单'; // dialog.title = '修改测试单';
}; // };
/** 提交按钮 */ // /** 提交按钮 */
const submitForm = () => { // const submitForm = () => {
demoFormRef.value?.validate(async (valid: boolean) => { // demoFormRef.value?.validate(async (valid: boolean) => {
if (valid) { // if (valid) {
buttonLoading.value = true; // buttonLoading.value = true;
if (form.value.id) { // if (form.value.id) {
await updateDemo(form.value).finally(() => (buttonLoading.value = false)); // await updateDemo(form.value).finally(() => (buttonLoading.value = false));
} else { // } else {
await addDemo(form.value).finally(() => (buttonLoading.value = false)); // await addDemo(form.value).finally(() => (buttonLoading.value = false));
} // }
proxy?.$modal.msgSuccess('修改成功'); // proxy?.$modal.msgSuccess('修改成功');
dialog.visible = false; // dialog.visible = false;
await getList(); // await getList();
} // }
}); // });
}; // };
/** 删除按钮操作 */ // /** 删除按钮操作 */
const handleDelete = async (row?: DemoVO) => { // const handleDelete = async (row?: DemoVO) => {
const _ids = row?.id || ids.value; // const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除测试单编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false)); // await proxy?.$modal.confirm('是否确认删除测试单编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delDemo(_ids); // await delDemo(_ids);
proxy?.$modal.msgSuccess('删除成功'); // proxy?.$modal.msgSuccess('删除成功');
await getList(); // await getList();
}; // };
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {

View File

@@ -1,9 +0,0 @@
<template>
<div class="stat">
<h1>stat</h1>
</div>
</template>
<script setup lang="ts"></script>
<style lang="less" scoped></style>