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