forked from dyf/dyf-vue-ui
Compare commits
19 Commits
a01f66dcc4
...
a121e75966
Author | SHA1 | Date | |
---|---|---|---|
a121e75966 | |||
7e26c80ea8 | |||
67e06eb2e4 | |||
f07c7c60af | |||
28fcd65479 | |||
2d0eda83e8 | |||
6a49341c6a | |||
bfa30c67bb | |||
893fac77e6 | |||
dd6cdf01e1 | |||
1db495b08e | |||
e1738a6ea1 | |||
84aa490c20 | |||
fb8bbbf5f5 | |||
a195b3e325 | |||
c1adbbb9fe | |||
ae445e058f | |||
5835c7c3fe | |||
a6b07348a6 |
@ -1,11 +1,17 @@
|
|||||||
# 页面标题
|
# 页面标题
|
||||||
VITE_APP_TITLE = 物联网管理系统
|
VITE_APP_TITLE = 物联网管理系统
|
||||||
|
|
||||||
# 生产环境配置
|
# 生产环境配置 晶全1
|
||||||
VITE_APP_ENV = 'https://fuyuanshen.com/backend'
|
VITE_APP_ENV = 'https://fuyuanshen.com/backend'
|
||||||
|
|
||||||
# 应用访问路径 例如使用前缀 /admin/
|
# 生产环境配置 富源晟2
|
||||||
VITE_APP_CONTEXT_PATH = '/sys/'
|
# VITE_APP_ENV = 'https://fuyuanshen.com/backend-fys'
|
||||||
|
|
||||||
|
# 应用访问路径 晶全1
|
||||||
|
VITE_APP_CONTEXT_PATH = '/jingquan/'
|
||||||
|
|
||||||
|
# 应用访问路径 富源晟2
|
||||||
|
#VITE_APP_CONTEXT_PATH = '/sys/'
|
||||||
|
|
||||||
# 监控地址
|
# 监控地址
|
||||||
VITE_APP_MONITOR_ADMIN = '/admin/applications'
|
VITE_APP_MONITOR_ADMIN = '/admin/applications'
|
||||||
@ -13,9 +19,12 @@ VITE_APP_MONITOR_ADMIN = '/admin/applications'
|
|||||||
# SnailJob 控制台地址
|
# SnailJob 控制台地址
|
||||||
VITE_APP_SNAILJOB_ADMIN = '/snail-job'
|
VITE_APP_SNAILJOB_ADMIN = '/snail-job'
|
||||||
|
|
||||||
# 生产环境
|
# 生产环境 晶全3
|
||||||
VITE_APP_BASE_API = '/backend'
|
VITE_APP_BASE_API = '/backend'
|
||||||
|
|
||||||
|
# 生产环境 富源晟3
|
||||||
|
#VITE_APP_BASE_API = '/backend-fys'
|
||||||
|
|
||||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||||
VITE_BUILD_COMPRESS = gzip
|
VITE_BUILD_COMPRESS = gzip
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"pinia": "3.0.2",
|
"pinia": "3.0.2",
|
||||||
|
"qrcode-vue3": "^1.7.1",
|
||||||
"screenfull": "6.0.2",
|
"screenfull": "6.0.2",
|
||||||
"vue": "3.5.13",
|
"vue": "3.5.13",
|
||||||
"vue-cropper": "1.1.1",
|
"vue-cropper": "1.1.1",
|
||||||
|
63
src/api/equipmentAlarmRecord/index.ts
Normal file
63
src/api/equipmentAlarmRecord/index.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import { AxiosPromise } from 'axios';
|
||||||
|
import { EquipmentAlarmRecordVO, EquipmentAlarmRecordForm, EquipmentAlarmRecordQuery } from '@/api/equipmentAlarmRecord/types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备报警记录列表
|
||||||
|
* @param query
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const listEquipmentAlarmRecord = (query?: EquipmentAlarmRecordQuery): AxiosPromise<EquipmentAlarmRecordVO[]> => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/equipmentAlarmRecord/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备报警记录详细
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
export const getEquipmentAlarmRecord = (id: string | number): AxiosPromise<EquipmentAlarmRecordVO> => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/equipmentAlarmRecord/' + id,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备报警记录
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const addEquipmentAlarmRecord = (data: EquipmentAlarmRecordForm) => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/equipmentAlarmRecord',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备报警记录
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const updateEquipmentAlarmRecord = (data: EquipmentAlarmRecordForm) => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/equipmentAlarmRecord',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备报警记录
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
export const delEquipmentAlarmRecord = (id: string | number | Array<string | number>) => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/equipmentAlarmRecord/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
});
|
||||||
|
};
|
179
src/api/equipmentAlarmRecord/types.ts
Normal file
179
src/api/equipmentAlarmRecord/types.ts
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
export interface EquipmentAlarmRecordVO {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
id: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警设备id
|
||||||
|
*/
|
||||||
|
deviceId: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备IMEI
|
||||||
|
*/
|
||||||
|
deviceImei: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备MAC
|
||||||
|
*/
|
||||||
|
deviceMac: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
deviceName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属代理(客户)
|
||||||
|
*/
|
||||||
|
agent: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定app用户
|
||||||
|
*/
|
||||||
|
bindApp: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警类型
|
||||||
|
*/
|
||||||
|
alarmType: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警编码
|
||||||
|
|
||||||
|
*/
|
||||||
|
alarmCode: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警描述
|
||||||
|
*/
|
||||||
|
alarmDescription: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警时间
|
||||||
|
*/
|
||||||
|
alarmTime: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EquipmentAlarmRecordForm extends BaseEntity {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
id?: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警设备id
|
||||||
|
*/
|
||||||
|
deviceId?: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备IMEI
|
||||||
|
*/
|
||||||
|
deviceImei?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备MAC
|
||||||
|
*/
|
||||||
|
deviceMac?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
deviceName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属代理(客户)
|
||||||
|
*/
|
||||||
|
agent?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定app用户
|
||||||
|
*/
|
||||||
|
bindApp?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警类型
|
||||||
|
*/
|
||||||
|
alarmType?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警编码
|
||||||
|
|
||||||
|
*/
|
||||||
|
alarmCode?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警描述
|
||||||
|
*/
|
||||||
|
alarmDescription?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警时间
|
||||||
|
*/
|
||||||
|
alarmTime?: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EquipmentAlarmRecordQuery extends PageQuery {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警设备id
|
||||||
|
*/
|
||||||
|
deviceId?: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备IMEI
|
||||||
|
*/
|
||||||
|
deviceImei?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备MAC
|
||||||
|
*/
|
||||||
|
deviceMac?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
deviceName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属代理(客户)
|
||||||
|
*/
|
||||||
|
agent?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定app用户
|
||||||
|
*/
|
||||||
|
bindApp?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警类型
|
||||||
|
*/
|
||||||
|
alarmType?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警编码
|
||||||
|
|
||||||
|
*/
|
||||||
|
alarmCode?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警描述
|
||||||
|
*/
|
||||||
|
alarmDescription?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警时间
|
||||||
|
*/
|
||||||
|
alarmTime?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期范围参数
|
||||||
|
*/
|
||||||
|
params?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,12 +72,11 @@ export const userAllCustomerAll = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 解绑
|
// 解绑
|
||||||
|
export const deviceUnbind = (params:any) => {
|
||||||
export const deviceUnbind = (data:any) => {
|
|
||||||
return request({
|
return request({
|
||||||
url: '/api/device/unbind',
|
url: '/api/device/unbind',
|
||||||
method: 'post',
|
method: 'GET',
|
||||||
data
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 撤回
|
// 撤回
|
||||||
|
63
src/api/equipmentManagement/log/index.ts
Normal file
63
src/api/equipmentManagement/log/index.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import { AxiosPromise } from 'axios';
|
||||||
|
import { LogVO, LogForm, LogQuery } from '@/api/equipment/log/types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备日志列表
|
||||||
|
* @param query
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const listLog = (query?: LogQuery): AxiosPromise<LogVO[]> => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/log/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备日志详细
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
export const getLog = (id: string | number): AxiosPromise<LogVO> => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/log/' + id,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备日志
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const addLog = (data: LogForm) => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/log',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备日志
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const updateLog = (data: LogForm) => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/log',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备日志
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
export const delLog = (id: string | number | Array<string | number>) => {
|
||||||
|
return request({
|
||||||
|
url: '/equipment/log/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
});
|
||||||
|
};
|
235
src/api/equipmentManagement/log/index.vue
Normal file
235
src/api/equipmentManagement/log/index.vue
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-2">
|
||||||
|
<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="deviceAction">
|
||||||
|
<el-input v-model="queryParams.deviceAction" placeholder="请输入设备行为" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备名称" prop="deviceName">
|
||||||
|
<el-input v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数据来源" prop="dataSource">
|
||||||
|
<el-input v-model="queryParams.dataSource" 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 shadow="never">
|
||||||
|
<template #header>
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['equipment:log:add']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['equipment:log:edit']">修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['equipment:log:remove']">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['equipment:log:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" border :data="logList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="ID" align="center" prop="id" v-if="true" />
|
||||||
|
<el-table-column label="设备行为" align="center" prop="deviceAction" />
|
||||||
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
||||||
|
<el-table-column label="数据来源" align="center" prop="dataSource" />
|
||||||
|
<el-table-column label="内容" align="center" prop="content" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip content="修改" placement="top">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['equipment:log:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['equipment:log:remove']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</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="logFormRef" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="设备行为" prop="deviceAction">
|
||||||
|
<el-input v-model="form.deviceAction" placeholder="请输入设备行为" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备名称" prop="deviceName">
|
||||||
|
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数据来源" prop="dataSource">
|
||||||
|
<el-input v-model="form.dataSource" placeholder="请输入数据来源" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="内容">
|
||||||
|
<editor v-model="form.content" :min-height="192"/>
|
||||||
|
</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="Log" lang="ts">
|
||||||
|
import { listLog, getLog, delLog, addLog, updateLog } from '@/api/equipment/log';
|
||||||
|
import { LogVO, LogQuery, LogForm } from '@/api/equipment/log/types';
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
|
const logList = ref<LogVO[]>([]);
|
||||||
|
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 logFormRef = ref<ElFormInstance>();
|
||||||
|
|
||||||
|
const dialog = reactive<DialogOption>({
|
||||||
|
visible: false,
|
||||||
|
title: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const initFormData: LogForm = {
|
||||||
|
id: undefined,
|
||||||
|
deviceAction: undefined,
|
||||||
|
deviceName: undefined,
|
||||||
|
dataSource: undefined,
|
||||||
|
content: undefined,
|
||||||
|
}
|
||||||
|
const data = reactive<PageData<LogForm, LogQuery>>({
|
||||||
|
form: {...initFormData},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
deviceAction: undefined,
|
||||||
|
deviceName: undefined,
|
||||||
|
dataSource: undefined,
|
||||||
|
content: undefined,
|
||||||
|
params: {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
id: [
|
||||||
|
{ required: true, message: "ID不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 查询设备日志列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
const res = await listLog(queryParams.value);
|
||||||
|
logList.value = res.rows;
|
||||||
|
total.value = res.total;
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消按钮 */
|
||||||
|
const cancel = () => {
|
||||||
|
reset();
|
||||||
|
dialog.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单重置 */
|
||||||
|
const reset = () => {
|
||||||
|
form.value = {...initFormData};
|
||||||
|
logFormRef.value?.resetFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value?.resetFields();
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 多选框选中数据 */
|
||||||
|
const handleSelectionChange = (selection: LogVO[]) => {
|
||||||
|
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?: LogVO) => {
|
||||||
|
reset();
|
||||||
|
const _id = row?.id || ids.value[0]
|
||||||
|
const res = await getLog(_id);
|
||||||
|
Object.assign(form.value, res.data);
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "修改设备日志";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
const submitForm = () => {
|
||||||
|
logFormRef.value?.validate(async (valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
buttonLoading.value = true;
|
||||||
|
if (form.value.id) {
|
||||||
|
await updateLog(form.value).finally(() => buttonLoading.value = false);
|
||||||
|
} else {
|
||||||
|
await addLog(form.value).finally(() => buttonLoading.value = false);
|
||||||
|
}
|
||||||
|
proxy?.$modal.msgSuccess("操作成功");
|
||||||
|
dialog.visible = false;
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (row?: LogVO) => {
|
||||||
|
const _ids = row?.id || ids.value;
|
||||||
|
await proxy?.$modal.confirm('是否确认删除设备日志编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
|
||||||
|
await delLog(_ids);
|
||||||
|
proxy?.$modal.msgSuccess("删除成功");
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = () => {
|
||||||
|
proxy?.download('equipment/log/export', {
|
||||||
|
...queryParams.value
|
||||||
|
}, `log_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
</script>
|
86
src/api/equipmentManagement/log/types.ts
Normal file
86
src/api/equipmentManagement/log/types.ts
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
export interface LogVO {
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
id: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备行为
|
||||||
|
*/
|
||||||
|
deviceAction: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
deviceName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据来源
|
||||||
|
*/
|
||||||
|
dataSource: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LogForm extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
id?: string | number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备行为
|
||||||
|
*/
|
||||||
|
deviceAction?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
deviceName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据来源
|
||||||
|
*/
|
||||||
|
dataSource?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
content?: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LogQuery extends PageQuery {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备行为
|
||||||
|
*/
|
||||||
|
deviceAction?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
deviceName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据来源
|
||||||
|
*/
|
||||||
|
dataSource?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
content?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期范围参数
|
||||||
|
*/
|
||||||
|
params?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { AxiosPromise } from 'axios';
|
|||||||
* 查询设备列表
|
* 查询设备列表
|
||||||
* @param query
|
* @param query
|
||||||
*/
|
*/
|
||||||
export const userList = (params): AxiosPromise => {
|
export const userList = (params: any): AxiosPromise => {
|
||||||
return request({
|
return request({
|
||||||
url: '/app/user/list',
|
url: '/app/user/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -12,7 +12,7 @@ export const userList = (params): AxiosPromise => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 绑定设备列表
|
// 绑定设备列表
|
||||||
export const deviceList = (params): AxiosPromise => {
|
export const deviceList = (params: any): AxiosPromise => {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/app/device',
|
url: '/api/app/device',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -20,12 +20,24 @@ export const deviceList = (params): AxiosPromise => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 账号状态
|
// 账号状态
|
||||||
export const userStatus = (data): AxiosPromise => {
|
export const userStatus = (data: any): AxiosPromise => {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/app/device',
|
url: '/api/app/device',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data
|
data
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
// 解绑设备
|
||||||
|
export const deviceUnBind = (data: any): AxiosPromise => {
|
||||||
|
return request({
|
||||||
|
url: '/api/app/device/unBind',
|
||||||
|
method: 'delete',
|
||||||
|
data,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data', //设置正确的 Content-Type
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export default { userList,deviceList,userStatus }
|
|
||||||
|
export default { userList, deviceList, userStatus, deviceUnBind }
|
@ -1,29 +1,6 @@
|
|||||||
import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
|
import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
|
||||||
/* Layout */
|
/* Layout */
|
||||||
import Layout from '@/layout/index.vue';
|
import Layout from '@/layout/index.vue';
|
||||||
|
|
||||||
/**
|
|
||||||
* Note: 路由配置项
|
|
||||||
*
|
|
||||||
* hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
|
|
||||||
* alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
|
||||||
* // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
|
|
||||||
* // 若你想不管路由下面的 children 声明的个数都显示你的根路由
|
|
||||||
* // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
|
|
||||||
* redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
|
||||||
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
|
|
||||||
* query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
|
|
||||||
* roles: ['admin', 'common'] // 访问路由的角色权限
|
|
||||||
* permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
|
|
||||||
* meta : {
|
|
||||||
noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
|
|
||||||
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
|
||||||
icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
|
|
||||||
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
|
||||||
activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 公共路由
|
// 公共路由
|
||||||
export const constantRoutes: RouteRecordRaw[] = [
|
export const constantRoutes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" align="center" prop="loginDate" width="180">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span>{{ proxy.parseTime(scope.row.loginDate) }}</span>
|
<span>{{ proxy.parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" fixed="right" align="center">
|
<el-table-column label="操作" fixed="right" align="center">
|
||||||
|
@ -12,23 +12,23 @@
|
|||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
</div>
|
</div>
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<el-table v-loading="bindingLoading" :data="boundDevices" style="width: 100%; margin-top: 20px;" height="400">
|
<el-table v-loading="bindingLoading" :data="boundDevices" style="margin-top: 20px;">
|
||||||
<el-table-column prop="deviceName" label="设备名称" />
|
<el-table-column prop="deviceName" label="设备名称" />
|
||||||
<el-table-column prop="devicePic" label="设备图片">
|
<el-table-column prop="devicePic" label="设备图片">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-image style="width: 40px; height: 40px" :src="scope.row.devicePic"
|
<el-popover placement="right" trigger="click">
|
||||||
:preview-src-list="[scope.row.devicePic]" />
|
<template #reference>
|
||||||
|
<img :src="scope.row.devicePic" style="width: 40px; height: 40px; cursor: pointer;"
|
||||||
|
class="hover:opacity-80 transition-opacity" />
|
||||||
|
</template>
|
||||||
|
<img :src="scope.row.devicePic" />
|
||||||
|
</el-popover>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="deviceMac" label="设备MAC" />
|
<el-table-column prop="deviceMac" label="设备MAC" />
|
||||||
<el-table-column prop="deviceImei" label="设备IMEI" />
|
<el-table-column prop="deviceImei" label="设备IMEI" />
|
||||||
<el-table-column prop="deviceTypeName" label="设备类型" />
|
<el-table-column prop="typeName" label="设备类型" />
|
||||||
<el-table-column prop="deviceStatus" label="状态">
|
<el-table-column prop="bindingTime" label="绑定日期" />
|
||||||
<template #default="scope">
|
|
||||||
<span>{{ scope.row.deviceStatus === 1 ? '正常' : '失效' }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="createTime" label="绑定日期" />
|
|
||||||
<el-table-column label="操作" width="100" align="center">
|
<el-table-column label="操作" width="100" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button type="danger" plain @click="handleUnbind(scope.row)">解绑</el-button>
|
<el-button type="danger" plain @click="handleUnbind(scope.row)">解绑</el-button>
|
||||||
@ -58,8 +58,6 @@ const queryParams = reactive({
|
|||||||
deviceImei: ''
|
deviceImei: ''
|
||||||
})
|
})
|
||||||
function openDialog(row: OperLogForm) {
|
function openDialog(row: OperLogForm) {
|
||||||
console.log(row,'roe11');
|
|
||||||
|
|
||||||
info.value = row;
|
info.value = row;
|
||||||
open.value = true;
|
open.value = true;
|
||||||
getList();
|
getList();
|
||||||
@ -76,27 +74,40 @@ const handleQuery = () => {
|
|||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
const resetQuery = () => {
|
||||||
queryParams.pageNum = 1;
|
queryParams.pageNum = 1;
|
||||||
|
queryParams.deviceImei = '',
|
||||||
|
queryParams.deviceMac = '',
|
||||||
|
queryParams.deviceName = '',
|
||||||
|
getList()
|
||||||
};
|
};
|
||||||
// 列表
|
// 列表
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
bindingLoading.value = true;
|
bindingLoading.value = true;
|
||||||
const res = await api.deviceList(queryParams);
|
let data = {
|
||||||
|
bindingUserId: info.value.userId,
|
||||||
|
pageNum: queryParams.pageNum,
|
||||||
|
pageSize: queryParams.pageSize,
|
||||||
|
deviceName: queryParams.deviceName,
|
||||||
|
deviceMac: queryParams.deviceMac,
|
||||||
|
deviceImei: queryParams.deviceImei
|
||||||
|
|
||||||
|
}
|
||||||
|
const res = await api.deviceList(data);
|
||||||
boundDevices.value = res.rows;
|
boundDevices.value = res.rows;
|
||||||
total.value = res.total;
|
total.value = res.total;
|
||||||
bindingLoading.value = false;
|
bindingLoading.value = false;
|
||||||
};
|
};
|
||||||
// 解绑
|
// 解绑
|
||||||
const handleUnbind = (row) => {
|
const handleUnbind = (row) => {
|
||||||
proxy?.$modal.confirm.confirm('此操作将解绑设备 "' + row.deviceName + '", 是否继续?', '提示', {
|
proxy?.$modal.confirm('此操作将解绑设备 "' + row.deviceName + '", 是否继续?', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const data = {
|
const data = {
|
||||||
deviceMac: row.deviceMac,
|
// deviceMac: row.deviceMac,
|
||||||
customerId: info.value.id
|
id: row.id
|
||||||
}
|
}
|
||||||
api.deviceList(data).then(() => {
|
api.deviceUnBind(data).then(() => {
|
||||||
proxy?.$modal.msgSuccess({ type: 'success', message: '解绑成功!' })
|
proxy?.$modal.msgSuccess({ type: 'success', message: '解绑成功!' })
|
||||||
getList()
|
getList()
|
||||||
})
|
})
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
<el-input v-model="queryParams.blurry" placeholder="请输入客户名称" clearable @keyup.enter="handleQuery" />
|
<el-input v-model="queryParams.blurry" placeholder="请输入客户名称" clearable @keyup.enter="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="客户状态" prop="status">
|
<el-form-item label="客户状态" prop="status">
|
||||||
<el-select v-model="queryParams.enabled" clearable placeholder="客户状态" class="filter-item">
|
<el-select v-model="queryParams.status" clearable placeholder="客户状态" class="filter-item">
|
||||||
<el-option label="全部" :value="''" />
|
<el-option label="全部" :value="''" />
|
||||||
<el-option label="启用" :value="true" />
|
<el-option label="启用" :value="0" />
|
||||||
<el-option label="禁用" :value="false" />
|
<el-option label="禁用" :value="1" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间" style="width: 308px">
|
<el-form-item label="创建时间" style="width: 308px">
|
||||||
@ -53,10 +53,10 @@
|
|||||||
<el-table-column type="selection" width="50" align="center" />
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
<el-table-column label="客户名称" align="center" prop="nickName" />
|
<el-table-column label="客户名称" align="center" prop="nickName" />
|
||||||
<el-table-column label="客户账号" align="center" prop="userName" :show-overflow-tooltip="true" />
|
<el-table-column label="客户账号" align="center" prop="userName" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="客户状态" align="center" prop="enabled">
|
<el-table-column label="客户状态" align="center" prop="status">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div @click="handleStatusChange(scope.row)">
|
<div @click="handleStatusChange(scope.row)">
|
||||||
<el-switch v-model="scope.row.enabled" />
|
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -104,7 +104,7 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item v-if="form.customerId === ''" label="账号密码" prop="password">
|
<el-form-item v-if="form.customerId === ''" label="账号密码" prop="password">
|
||||||
<el-input v-model="form.password" placeholder="请输入账号密码" />
|
<el-input v-model="form.password" placeholder="请输入账号密码" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -121,22 +121,48 @@
|
|||||||
|
|
||||||
<script setup name="User" lang="ts">
|
<script setup name="User" lang="ts">
|
||||||
import api from '@/api/customerManagement';
|
import api from '@/api/customerManagement';
|
||||||
import { UserForm, UserQuery, UserVO } from '@/api/customerManagement/types';
|
|
||||||
import { to } from 'await-to-js';
|
import { to } from 'await-to-js';
|
||||||
|
import { ComponentInternalInstance, getCurrentInstance, onMounted, reactive, ref, toRefs } from 'vue';
|
||||||
|
import { ElDialog, ElForm, ElFormItem, ElInput, ElRow, ElCol, ElButton, ElCard, ElSelect, ElOption, ElDatePicker, ElTable, ElTableColumn, ElTooltip, ElSwitch } from 'element-plus';
|
||||||
|
|
||||||
|
// 定义接口
|
||||||
|
interface UserVO {
|
||||||
|
customerId: string | number;
|
||||||
|
nickName: string;
|
||||||
|
userName: string;
|
||||||
|
status: string;
|
||||||
|
createTime: string;
|
||||||
|
userId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserForm extends UserVO {
|
||||||
|
password?: string;
|
||||||
|
enabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserQuery {
|
||||||
|
pageNum: number;
|
||||||
|
pageSize: number;
|
||||||
|
blurry: string;
|
||||||
|
status: string;
|
||||||
|
enabled: string;
|
||||||
|
}
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
const customerList = ref<UserVO[]>();
|
const customerList = ref<UserVO[]>();
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const showSearch = ref(true);
|
const showSearch = ref(true);
|
||||||
const ids = ref<Array<number | string>>([]);
|
const ids = ref<UserVO[]>([]);
|
||||||
const single = ref(true);
|
const single = ref(true);
|
||||||
const multiple = ref(true);
|
const multiple = ref(true);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
|
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
|
||||||
const initPassword = ref<string>('');
|
const initPassword = ref<string>('');
|
||||||
const queryFormRef = ref<ElFormInstance>();
|
const queryFormRef = ref<InstanceType<typeof ElForm>>();
|
||||||
const userFormRef = ref<ElFormInstance>();
|
const userFormRef = ref<InstanceType<typeof ElForm>>();
|
||||||
const formDialogRef = ref<ElDialogInstance>();
|
const formDialogRef = ref<InstanceType<typeof ElDialog>>();
|
||||||
const loadingIng = ref(false)
|
const loadingIng = ref(false)
|
||||||
|
|
||||||
const dialog = reactive<DialogOption>({
|
const dialog = reactive<DialogOption>({
|
||||||
visible: false,
|
visible: false,
|
||||||
title: ''
|
title: ''
|
||||||
@ -144,19 +170,27 @@ const dialog = reactive<DialogOption>({
|
|||||||
|
|
||||||
const initFormData: UserForm = {
|
const initFormData: UserForm = {
|
||||||
userName: '',
|
userName: '',
|
||||||
nickName: undefined,
|
nickName: '',
|
||||||
password: '',
|
password: '',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
customerId: ''
|
customerId: '',
|
||||||
|
status: '',
|
||||||
|
createTime: '',
|
||||||
|
userId: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const initData: PageData<UserForm, UserQuery> = {
|
const initData: {
|
||||||
|
form: UserForm,
|
||||||
|
queryParams: UserQuery,
|
||||||
|
rules: any
|
||||||
|
} = {
|
||||||
form: { ...initFormData },
|
form: { ...initFormData },
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
blurry: '',
|
blurry: '',
|
||||||
enabled: '',
|
enabled: '',
|
||||||
|
status: ''
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
nickName: [
|
nickName: [
|
||||||
@ -171,14 +205,22 @@ const initData: PageData<UserForm, UserQuery> = {
|
|||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
password: [
|
password: [
|
||||||
{ required: true, message: '请输入账号密码', trigger: 'blur' },
|
{ required: true, message: '请输入账号密码', trigger: 'blur' },
|
||||||
|
{
|
||||||
|
min: 5,
|
||||||
|
max: 20,
|
||||||
|
message: '用户密码长度必须介于 5 和 20 之间',
|
||||||
|
trigger: 'blur'
|
||||||
|
},
|
||||||
|
{ pattern: /^[^<>"'|\\]+$/, message: '不能包含非法字符:< > " \' \\ |', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const data = reactive<PageData<UserForm, UserQuery>>(initData);
|
const data = reactive(initData);
|
||||||
|
|
||||||
const { queryParams, form, rules } = toRefs<PageData<UserForm, UserQuery>>(data);
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
@ -198,28 +240,24 @@ const handleQuery = () => {
|
|||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
const resetQuery = () => {
|
||||||
dateRange.value = ['', ''];
|
dateRange.value = ['', ''];
|
||||||
|
queryFormRef.value?.resetFields();
|
||||||
queryParams.value.pageNum = 1;
|
queryParams.value.pageNum = 1;
|
||||||
|
queryParams.value.status=''
|
||||||
handleQuery();
|
handleQuery();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (row?: UserVO) => {
|
const handleDelete = async (row?: UserVO) => {
|
||||||
// 批量删除逻辑
|
const customerIds = row ? [row.customerId] : ids.value.map(item => item.customerId);
|
||||||
let arrey = ids.value.map((item) => item.customerId);
|
const nickNames = row ? row.nickName : ids.value.map(item => item.nickName).join(',');
|
||||||
if (!row) {
|
const [err] = await to(proxy?.$modal.confirm('是否确认删除"' + nickNames + '"的数据项?', '系统提示', {
|
||||||
const [err] = await to(proxy?.$modal.confirm(`是否确认删除选中的 ${ids.value.length} 条数据?`) as any);
|
confirmButtonText: '确定',
|
||||||
if (!err) {
|
cancelButtonText: '取消',
|
||||||
await api.deleteCustomer(arrey);
|
type: 'warning'
|
||||||
await getList();
|
}) as any);
|
||||||
proxy?.$modal.msgSuccess('删除成功');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 单行删除逻辑
|
|
||||||
const [err] = await to(proxy?.$modal.confirm('是否确认删除"' + row.nickName + '"的数据项?') as any);
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
await api.deleteCustomer([row.customerId]);
|
await api.deleteCustomer(customerIds);
|
||||||
await getList();
|
await getList();
|
||||||
proxy?.$modal.msgSuccess('删除成功');
|
proxy?.$modal.msgSuccess('删除成功');
|
||||||
}
|
}
|
||||||
@ -227,25 +265,33 @@ const handleDelete = async (row?: UserVO) => {
|
|||||||
|
|
||||||
/** 用户状态修改 */
|
/** 用户状态修改 */
|
||||||
const handleStatusChange = async (row: any) => {
|
const handleStatusChange = async (row: any) => {
|
||||||
console.log(row, '33333333');
|
const originalStatus = row.status;
|
||||||
const newStatus = row.enabled; // 获取新的状态值(取反)
|
const actionText = row.status == 0 ? '启用' : '停用';
|
||||||
const text = newStatus ? '启用' : '停用';
|
|
||||||
try {
|
try {
|
||||||
await proxy?.$modal.confirm(`确认要${text}"${row.nickName}"客户吗?`);
|
await proxy?.$modal.confirm(`确认要${actionText}"${row.nickName}"客户吗?`, '系统提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
});
|
||||||
await api.updateCustomer({
|
await api.updateCustomer({
|
||||||
customerId: row.customerId,
|
customerId: row.customerId,
|
||||||
enabled: newStatus
|
enabled: originalStatus == 0 ? true : false
|
||||||
});
|
});
|
||||||
proxy?.$modal.msgSuccess(text + '成功');
|
proxy?.$modal.msgSuccess(actionText + '成功');
|
||||||
await getList();
|
await getList();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
row.enabled = !newStatus; // 回滚状态
|
if (err == 'cancel') {
|
||||||
|
console.log(err, 'errr');
|
||||||
|
proxy?.$modal.msgWarning('操作已取消');
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** 选择条数 */
|
/** 选择条数 */
|
||||||
const handleSelectionChange = (selection: UserVO[]) => {
|
const handleSelectionChange = (selection: UserVO[]) => {
|
||||||
ids.value = selection.map((item) => item);
|
ids.value = selection;
|
||||||
single.value = selection.length != 1;
|
single.value = selection.length != 1;
|
||||||
multiple.value = !selection.length;
|
multiple.value = !selection.length;
|
||||||
};
|
};
|
||||||
@ -277,11 +323,10 @@ const handleUpdate = async (row?: UserForm) => {
|
|||||||
dialog.title = '修改客户';
|
dialog.title = '修改客户';
|
||||||
try {
|
try {
|
||||||
if (row) {
|
if (row) {
|
||||||
// 从行内按钮调用,直接使用行数据
|
|
||||||
Object.assign(form.value, row);
|
Object.assign(form.value, row);
|
||||||
} else {
|
} else {
|
||||||
const customerId = ids.value[0];
|
const selectedId = ids.value[0];
|
||||||
Object.assign(form.value, customerId);
|
Object.assign(form.value, selectedId);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
@ -290,15 +335,17 @@ const handleUpdate = async (row?: UserForm) => {
|
|||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
const submitForm = () => {
|
const submitForm = () => {
|
||||||
|
|
||||||
userFormRef.value?.validate(async (valid: boolean) => {
|
userFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
loadingIng.value = true
|
loadingIng.value = true;
|
||||||
form.value.customerId ? await api.updateCustomer(form.value) : await api.addCustomer(form.value);
|
try {
|
||||||
proxy?.$modal.msgSuccess('操作成功');
|
form.value.customerId ? await api.updateCustomer(form.value) : await api.addCustomer(form.value);
|
||||||
dialog.visible = false;
|
proxy?.$modal.msgSuccess('操作成功');
|
||||||
await getList();
|
dialog.visible = false;
|
||||||
loadingIng.value = false
|
await getList();
|
||||||
|
} finally {
|
||||||
|
loadingIng.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -317,11 +364,10 @@ const closeDialog = () => {
|
|||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
userFormRef.value?.resetFields();
|
userFormRef.value?.resetFields();
|
||||||
userFormRef.value?.clearValidate();
|
userFormRef.value?.clearValidate();
|
||||||
form.value.customerId = undefined;
|
form.value.customerId = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList(); // 初始化列表数据
|
getList(); // 初始化列表数据
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
283
src/views/equipmentAlarmRecord/index.vue
Normal file
283
src/views/equipmentAlarmRecord/index.vue
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-2">
|
||||||
|
<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="deviceName">
|
||||||
|
<el-input v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备MAC" prop="deviceMac">
|
||||||
|
<el-input v-model="queryParams.deviceMac" placeholder="请输入设备MAC" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备IMEI" prop="deviceImei">
|
||||||
|
<el-input v-model="queryParams.deviceImei" placeholder="请输入设备IMEI" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="报警时间" prop="alarmTime">
|
||||||
|
<el-date-picker clearable v-model="queryParams.alarmTime" type="date" value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择报警时间" />
|
||||||
|
</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 shadow="never">
|
||||||
|
<template #header>
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||||
|
v-hasPermi="['equipment:equipmentAlarmRecord:add']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
|
||||||
|
v-hasPermi="['equipment:equipmentAlarmRecord:edit']">修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"
|
||||||
|
v-hasPermi="['equipment:equipmentAlarmRecord:remove']">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||||
|
v-hasPermi="['equipment:equipmentAlarmRecord:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" border :data="equipmentAlarmRecordList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="" align="center" prop="id" v-if="true" />
|
||||||
|
<el-table-column label="报警设备id" align="center" prop="deviceId" />
|
||||||
|
<el-table-column label="设备IMEI" align="center" prop="deviceImei" />
|
||||||
|
<el-table-column label="设备MAC" align="center" prop="deviceMac" />
|
||||||
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
||||||
|
<el-table-column label="所属代理" align="center" prop="agent" />
|
||||||
|
<el-table-column label="绑定app用户" align="center" prop="bindApp" />
|
||||||
|
<el-table-column label="报警类型" align="center" prop="alarmType" />
|
||||||
|
<el-table-column label="报警编码
|
||||||
|
" align="center" prop="alarmCode" />
|
||||||
|
<el-table-column label="报警描述" align="center" prop="alarmDescription" />
|
||||||
|
<el-table-column label="报警时间" align="center" prop="alarmTime" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.alarmTime, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip content="修改" placement="top">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['equipment:equipmentAlarmRecord:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['equipment:equipmentAlarmRecord:remove']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</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="equipmentAlarmRecordFormRef" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item label="报警设备id" prop="deviceId">
|
||||||
|
<el-input v-model="form.deviceId" placeholder="请输入报警设备id" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备IMEI" prop="deviceImei">
|
||||||
|
<el-input v-model="form.deviceImei" placeholder="请输入设备IMEI" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备MAC" prop="deviceMac">
|
||||||
|
<el-input v-model="form.deviceMac" placeholder="请输入设备MAC" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备名称" prop="deviceName">
|
||||||
|
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="所属代理" prop="agent">
|
||||||
|
<el-input v-model="form.agent" placeholder="请输入所属代理" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="绑定app用户" prop="bindApp">
|
||||||
|
<el-input v-model="form.bindApp" placeholder="请输入绑定app用户" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="报警编码
|
||||||
|
" prop="alarmCode">
|
||||||
|
<el-input v-model="form.alarmCode" placeholder="请输入报警编码
|
||||||
|
" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="报警描述" prop="alarmDescription">
|
||||||
|
<el-input v-model="form.alarmDescription" placeholder="请输入报警描述" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="报警时间" prop="alarmTime">
|
||||||
|
<el-date-picker clearable v-model="form.alarmTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
placeholder="请选择报警时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</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="EquipmentAlarmRecord" lang="ts">
|
||||||
|
import { listEquipmentAlarmRecord, getEquipmentAlarmRecord, delEquipmentAlarmRecord, addEquipmentAlarmRecord, updateEquipmentAlarmRecord } from '@/api/equipmentAlarmRecord';
|
||||||
|
import { EquipmentAlarmRecordVO, EquipmentAlarmRecordQuery, EquipmentAlarmRecordForm } from '@/api/equipmentAlarmRecord/types';
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
|
const equipmentAlarmRecordList = ref<EquipmentAlarmRecordVO[]>([]);
|
||||||
|
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 equipmentAlarmRecordFormRef = ref<ElFormInstance>();
|
||||||
|
|
||||||
|
const dialog = reactive<DialogOption>({
|
||||||
|
visible: false,
|
||||||
|
title: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const initFormData: EquipmentAlarmRecordForm = {
|
||||||
|
id: undefined,
|
||||||
|
deviceId: undefined,
|
||||||
|
deviceImei: undefined,
|
||||||
|
deviceMac: undefined,
|
||||||
|
deviceName: undefined,
|
||||||
|
agent: undefined,
|
||||||
|
bindApp: undefined,
|
||||||
|
alarmType: undefined,
|
||||||
|
alarmCode: undefined,
|
||||||
|
alarmDescription: undefined,
|
||||||
|
alarmTime: undefined
|
||||||
|
}
|
||||||
|
const data = reactive<PageData<EquipmentAlarmRecordForm, EquipmentAlarmRecordQuery>>({
|
||||||
|
form: { ...initFormData },
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
deviceImei: undefined,
|
||||||
|
deviceMac: undefined,
|
||||||
|
deviceName: undefined,
|
||||||
|
alarmTime: undefined,
|
||||||
|
params: {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
id: [
|
||||||
|
{ required: true, message: "不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 查询设备报警记录列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
const res = await listEquipmentAlarmRecord(queryParams.value);
|
||||||
|
equipmentAlarmRecordList.value = res.rows;
|
||||||
|
total.value = res.total;
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消按钮 */
|
||||||
|
const cancel = () => {
|
||||||
|
reset();
|
||||||
|
dialog.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单重置 */
|
||||||
|
const reset = () => {
|
||||||
|
form.value = { ...initFormData };
|
||||||
|
equipmentAlarmRecordFormRef.value?.resetFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value?.resetFields();
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 多选框选中数据 */
|
||||||
|
const handleSelectionChange = (selection: EquipmentAlarmRecordVO[]) => {
|
||||||
|
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?: EquipmentAlarmRecordVO) => {
|
||||||
|
reset();
|
||||||
|
const _id = row?.id || ids.value[0]
|
||||||
|
const res = await getEquipmentAlarmRecord(_id);
|
||||||
|
Object.assign(form.value, res.data);
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "修改设备报警记录";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
const submitForm = () => {
|
||||||
|
equipmentAlarmRecordFormRef.value?.validate(async (valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
buttonLoading.value = true;
|
||||||
|
if (form.value.id) {
|
||||||
|
await updateEquipmentAlarmRecord(form.value).finally(() => buttonLoading.value = false);
|
||||||
|
} else {
|
||||||
|
await addEquipmentAlarmRecord(form.value).finally(() => buttonLoading.value = false);
|
||||||
|
}
|
||||||
|
proxy?.$modal.msgSuccess("操作成功");
|
||||||
|
dialog.visible = false;
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (row?: EquipmentAlarmRecordVO) => {
|
||||||
|
const _ids = row?.id || ids.value;
|
||||||
|
await proxy?.$modal.confirm('是否确认删除设备报警记录编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
|
||||||
|
await delEquipmentAlarmRecord(_ids);
|
||||||
|
proxy?.$modal.msgSuccess("删除成功");
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = () => {
|
||||||
|
proxy?.download('system/equipmentAlarmRecord/export', {
|
||||||
|
...queryParams.value
|
||||||
|
}, `equipmentAlarmRecord_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
</script>
|
@ -136,42 +136,58 @@
|
|||||||
|
|
||||||
<script setup name="User" lang="ts">
|
<script setup name="User" lang="ts">
|
||||||
import api from '@/api/equipmentManagement/deviceType/index';
|
import api from '@/api/equipmentManagement/deviceType/index';
|
||||||
import { UserForm, deviceTypeQuery, deviceTypeVO } from '@/api/equipmentManagement/deviceType/types';
|
import { deviceTypeQuery } from '@/api/equipmentManagement/deviceType/types';
|
||||||
import { UserQuery, UserVO } from '@/api/system/user/types';
|
import { to } from 'await-to-js';
|
||||||
|
import { ComponentInternalInstance, getCurrentInstance, onMounted, reactive, ref, toRefs } from 'vue';
|
||||||
|
import { ElDialog, ElForm, ElFormItem, ElInput, ElRow, ElCol, ElButton, ElCard, ElSelect, ElOption, ElDatePicker, ElTable, ElTableColumn, ElTooltip, ElSwitch } from 'element-plus';
|
||||||
|
|
||||||
|
interface deviceTypeVO {
|
||||||
|
id: string | number;
|
||||||
|
typeName: string;
|
||||||
|
isSupportBle: boolean;
|
||||||
|
locateMode: string;
|
||||||
|
communicationMode: string;
|
||||||
|
createTime: string;
|
||||||
|
createByName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DeviceTypeForm extends deviceTypeVO {
|
||||||
|
// 可能有其他字段
|
||||||
|
}
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
const deviceTypeList = ref<deviceTypeVO[]>();
|
const deviceTypeList = ref<deviceTypeVO[]>();
|
||||||
import { to } from 'await-to-js';
|
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const showSearch = ref(true);
|
const showSearch = ref(true);
|
||||||
const ids = ref<Array<number | string>>([]);
|
const ids = ref<deviceTypeVO[]>([]);
|
||||||
const single = ref(true);
|
const single = ref(true);
|
||||||
const multiple = ref(true);
|
const multiple = ref(true);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const initPassword = ref<string>('');
|
const queryFormRef = ref<InstanceType<typeof ElForm>>();
|
||||||
const queryFormRef = ref<ElFormInstance>();
|
const userFormRef = ref<InstanceType<typeof ElForm>>();
|
||||||
const userFormRef = ref<ElFormInstance>();
|
const formDialogRef = ref<InstanceType<typeof ElDialog>>();
|
||||||
const formDialogRef = ref<ElDialogInstance>();
|
|
||||||
const loadingIng = ref(false)
|
const loadingIng = ref(false)
|
||||||
const dialog = reactive<DialogOption>({
|
const dialog = reactive<DialogOption>({
|
||||||
visible: false,
|
visible: false,
|
||||||
title: ''
|
title: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
const initFormData: UserForm = {
|
const initFormData: DeviceTypeForm = {
|
||||||
typeName: '',
|
typeName: '',
|
||||||
isSupportBle: '',
|
isSupportBle: false,
|
||||||
locateMode: '',
|
locateMode: '',
|
||||||
communicationMode: '',
|
communicationMode: '',
|
||||||
id: ''
|
id: '',
|
||||||
|
createTime: '',
|
||||||
|
createByName: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const initData: PageData<UserForm, deviceTypeQuery> = {
|
const initData = {
|
||||||
form: { ...initFormData },
|
form: { ...initFormData },
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
typeName: '',
|
typeName: '',
|
||||||
|
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
typeName: [
|
typeName: [
|
||||||
@ -185,8 +201,15 @@ const initData: PageData<UserForm, deviceTypeQuery> = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const data = reactive<PageData<UserForm, UserQuery>>(initData);
|
|
||||||
const { queryParams, form, rules } = toRefs<PageData<UserForm, UserQuery>>(data);
|
const data = reactive<{
|
||||||
|
form: DeviceTypeForm,
|
||||||
|
queryParams: deviceTypeQuery,
|
||||||
|
rules: any
|
||||||
|
}>(initData);
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@ -196,7 +219,6 @@ const getList = async () => {
|
|||||||
total.value = res.total;
|
total.value = res.total;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
queryParams.value.pageNum = 1;
|
queryParams.value.pageNum = 1;
|
||||||
@ -204,42 +226,34 @@ const handleQuery = () => {
|
|||||||
};
|
};
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
const resetQuery = () => {
|
const resetQuery = () => {
|
||||||
queryParams.value.typeName = ''
|
queryFormRef.value?.resetFields();
|
||||||
queryParams.value.pageNum = 1;
|
queryParams.value.pageNum = 1;
|
||||||
getList();
|
getList();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (row?: UserVO) => {
|
const handleDelete = async (row?: deviceTypeVO) => {
|
||||||
// 批量删除逻辑
|
const deviceTypeIds = row ? [row.id] : ids.value.map(item => item.id);
|
||||||
let arrey = ids.value.map((item) => item.id);
|
const typeNames = row ? row.typeName : ids.value.map(item => item.typeName).join(',');
|
||||||
if (!row) {
|
const [err] = await to(proxy?.$modal.confirm('是否确认删除"' + typeNames + '"的数据项?', '系统提示', {
|
||||||
const [err] = await to(proxy?.$modal.confirm(`是否确认删除选中的 ${ids.value.length} 条数据?`) as any);
|
confirmButtonText: '确定',
|
||||||
if (!err) {
|
cancelButtonText: '取消',
|
||||||
await api.deleteDeviceType(arrey);
|
type: 'warning'
|
||||||
await getList();
|
}) as any);
|
||||||
proxy?.$modal.msgSuccess('删除成功');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 单行删除逻辑
|
|
||||||
const [err] = await to(proxy?.$modal.confirm('是否确认删除"' + row.typeName + '"的数据项?') as any);
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
await api.deleteDeviceType([row.id]);
|
await api.deleteDeviceType(deviceTypeIds);
|
||||||
await getList();
|
await getList();
|
||||||
proxy?.$modal.msgSuccess('删除成功');
|
proxy?.$modal.msgSuccess('删除成功');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 选择条数 */
|
/** 选择条数 */
|
||||||
const handleSelectionChange = (selection: UserVO[]) => {
|
const handleSelectionChange = (selection: deviceTypeVO[]) => {
|
||||||
ids.value = selection.map((item) => item);
|
ids.value = selection;
|
||||||
single.value = selection.length != 1;
|
single.value = selection.length != 1;
|
||||||
multiple.value = !selection.length;
|
multiple.value = !selection.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** 重置操作表单 */
|
/** 重置操作表单 */
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
form.value = { ...initFormData };
|
form.value = { ...initFormData };
|
||||||
@ -256,21 +270,19 @@ const handleAdd = async () => {
|
|||||||
reset();
|
reset();
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
dialog.title = '新增设备类型';
|
dialog.title = '新增设备类型';
|
||||||
form.value.password = initPassword.value.toString();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
const handleUpdate = async (row?: UserForm) => {
|
const handleUpdate = async (row?: DeviceTypeForm) => {
|
||||||
reset();
|
reset();
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
dialog.title = '修改设备类型';
|
dialog.title = '修改设备类型';
|
||||||
try {
|
try {
|
||||||
if (row) {
|
if (row) {
|
||||||
// 从行内按钮调用,直接使用行数据
|
|
||||||
Object.assign(form.value, row);
|
Object.assign(form.value, row);
|
||||||
} else {
|
} else {
|
||||||
const customerId = ids.value[0];
|
const selectedId = ids.value[0];
|
||||||
Object.assign(form.value, customerId);
|
Object.assign(form.value, selectedId);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
@ -282,11 +294,14 @@ const submitForm = () => {
|
|||||||
userFormRef.value?.validate(async (valid: boolean) => {
|
userFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
loadingIng.value = true;
|
loadingIng.value = true;
|
||||||
form.value.id ? await api.updateDeviceType(form.value) : await api.addDeviceType(form.value);
|
try {
|
||||||
proxy?.$modal.msgSuccess('操作成功');
|
form.value.id ? await api.updateDeviceType(form.value) : await api.addDeviceType(form.value);
|
||||||
dialog.visible = false;
|
proxy?.$modal.msgSuccess('操作成功');
|
||||||
await getList();
|
dialog.visible = false;
|
||||||
loadingIng.value = false;
|
await getList();
|
||||||
|
} finally {
|
||||||
|
loadingIng.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -297,7 +312,6 @@ const submitForm = () => {
|
|||||||
const closeDialog = () => {
|
const closeDialog = () => {
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
resetForm();
|
resetForm();
|
||||||
loadingIng.value = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,11 +320,11 @@ const closeDialog = () => {
|
|||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
userFormRef.value?.resetFields();
|
userFormRef.value?.resetFields();
|
||||||
userFormRef.value?.clearValidate();
|
userFormRef.value?.clearValidate();
|
||||||
form.value.customerId = undefined;
|
form.value.id = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList(); // 初始化列表数据
|
getList(); // 初始化列表数据
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -82,10 +82,10 @@
|
|||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-popover placement="right" trigger="click">
|
<el-popover placement="right" trigger="click">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<img :src="scope.row.devicePic" style="width: 40px; height: 40px; cursor: pointer;"
|
<img :src="scope.row.devicePic" style="width: 40px; height: 40px; cursor: pointer; object-fit: contain"
|
||||||
class="hover:opacity-80 transition-opacity" />
|
class="hover:opacity-80 transition-opacity" />
|
||||||
</template>
|
</template>
|
||||||
<img :src="scope.row.devicePic" style="max-width: 600px; max-height: 600px;" />
|
<img :src="scope.row.devicePic" style="max-width: 600px; max-height: 600px; object-fit: contain" />
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -116,7 +116,7 @@
|
|||||||
<el-tooltip v-if="scope.row.id !== 1 && scope.row.deviceStatus == 1" content="修改" placement="top">
|
<el-tooltip v-if="scope.row.id !== 1 && scope.row.deviceStatus == 1" content="修改" placement="top">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip v-if="scope.row.id !== 1" content="删除" placement="top">
|
<el-tooltip v-if="!scope.row.customerName" content="删除" placement="top">
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip v-if="scope.row.deviceStatus == 1 && !scope.row.customerName" content="分配" placement="top">
|
<el-tooltip v-if="scope.row.deviceStatus == 1 && !scope.row.customerName" content="分配" placement="top">
|
||||||
@ -129,6 +129,9 @@
|
|||||||
placement="top">
|
placement="top">
|
||||||
<el-button link type="primary" icon="Refresh" @click="handleUnbind(scope.row)"></el-button>
|
<el-button link type="primary" icon="Refresh" @click="handleUnbind(scope.row)"></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
<el-tooltip v-if="scope.row.deviceImei" content="查看二维码" placement="top">
|
||||||
|
<el-button link type="primary" icon="Postcard" @click="showQrCode(scope.row)"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -161,21 +164,21 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row v-if="showMacField">
|
<el-row v-if="showMacField">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="设备MAC" prop="deviceMac">
|
<el-form-item label="设备MAC" prop="deviceMac" required>
|
||||||
<el-input v-model="form.deviceMac" placeholder="请输入设备MAC" />
|
<el-input v-model="form.deviceMac" placeholder="请输入设备MAC" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row v-if="showMacField">
|
<el-row v-if="showMacField">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="蓝牙名称" prop="bluetoothName">
|
<el-form-item label="蓝牙名称" prop="bluetoothName" required>
|
||||||
<el-input v-model="form.bluetoothName" placeholder="请输入蓝牙名称" />
|
<el-input v-model="form.bluetoothName" placeholder="请输入蓝牙名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row v-if="showImeiField">
|
<el-row v-if="showImeiField">
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="设备IMEI" prop="deviceImei">
|
<el-form-item label="设备IMEI" prop="deviceImei" required>
|
||||||
<el-input v-model="form.deviceImei" placeholder="请输入设备IMEI" />
|
<el-input v-model="form.deviceImei" placeholder="请输入设备IMEI" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -187,7 +190,7 @@
|
|||||||
:http-request="httpRequestImg" :file-list="fileList" :limit="1">
|
:http-request="httpRequestImg" :file-list="fileList" :limit="1">
|
||||||
<i class="el-icon-plus"></i>
|
<i class="el-icon-plus"></i>
|
||||||
<template v-if="form.image && typeof form.image === 'string'">
|
<template v-if="form.image && typeof form.image === 'string'">
|
||||||
<img :src="form.image" class="avatar" style="width:100px; height:100px;" />
|
<img :src="form.image" class="avatar" style="width:100px; height:100px; object-fit: contain" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</el-upload>
|
</el-upload>
|
||||||
@ -271,10 +274,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<!-- IMEI 二维码弹窗 -->
|
||||||
|
<el-dialog v-model="qrCodeDialogVisible" title="设备IMEI二维码" width="20%" append-to-body>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<QRCodeVue3 :value="qrCodeValue" :size="100" />
|
||||||
|
<p style="margin-top: 10px;">{{ qrCodeValue }}</p>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="qrCodeDialogVisible = false">关闭</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="User" lang="ts">
|
<script setup name="User" lang="ts">
|
||||||
|
import QRCodeVue3 from 'qrcode-vue3';
|
||||||
import api from '@/api/equipmentManagement/device/index';
|
import api from '@/api/equipmentManagement/device/index';
|
||||||
import { deviceForm, deviceQuery, deviceVO, deviceTypeOption } from '@/api/equipmentManagement/device/types';
|
import { deviceForm, deviceQuery, deviceVO, deviceTypeOption } from '@/api/equipmentManagement/device/types';
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
@ -305,6 +321,8 @@ const loadingIng = ref(false)
|
|||||||
const assignCustomerId = ref(); //分配客户id
|
const assignCustomerId = ref(); //分配客户id
|
||||||
const batchAssignCustomerId = ref() //批量分配客户id
|
const batchAssignCustomerId = ref() //批量分配客户id
|
||||||
const customerList = ref()
|
const customerList = ref()
|
||||||
|
const qrCodeDialogVisible = ref(false);
|
||||||
|
const qrCodeValue = ref('');
|
||||||
const dialog = reactive<DialogOption>({
|
const dialog = reactive<DialogOption>({
|
||||||
visible: false,
|
visible: false,
|
||||||
title: ''
|
title: ''
|
||||||
@ -340,6 +358,16 @@ const initData: PageData<deviceForm, deviceQuery> = {
|
|||||||
deviceType: [
|
deviceType: [
|
||||||
{ required: true, message: '请选择设备类型', trigger: 'blur' },
|
{ required: true, message: '请选择设备类型', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
|
bluetoothName: [
|
||||||
|
{ required: true, message: '请输入蓝牙名称', trigger: 'blur' },
|
||||||
|
],
|
||||||
|
deviceMac: [
|
||||||
|
{ required: true, message: '请输入设备MAC', trigger: 'blur' },
|
||||||
|
],
|
||||||
|
deviceImei: [
|
||||||
|
{ required: true, message: '请输入设备IMEI', trigger: 'blur' },
|
||||||
|
],
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const data = reactive<PageData<deviceForm, deviceQuery>>(initData);
|
const data = reactive<PageData<deviceForm, deviceQuery>>(initData);
|
||||||
@ -371,7 +399,7 @@ const handleDelete = async (row?: deviceVO) => {
|
|||||||
// 批量删除逻辑
|
// 批量删除逻辑
|
||||||
let arrey = ids.value.map((item) => item.id);
|
let arrey = ids.value.map((item) => item.id);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
const [err] = await to(proxy?.$modal.confirm(`是否确认删除选中的 ${ids.value.length} 条数据?`));
|
const [err] = await to(proxy?.$modal.confirm(`是否确认删除选中的 ${ids.value.length} 条数据?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
await api.deleteDevice(arrey);
|
await api.deleteDevice(arrey);
|
||||||
await getList();
|
await getList();
|
||||||
@ -380,7 +408,7 @@ const handleDelete = async (row?: deviceVO) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 单行删除逻辑
|
// 单行删除逻辑
|
||||||
const [err] = await to(proxy?.$modal.confirm('是否确认删除"' + row.deviceName + '"的数据项?'));
|
const [err] = await to(proxy?.$modal.confirm('是否确认删除"' + row.deviceName + '"的数据项?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
await api.deleteDevice([row.id]);
|
await api.deleteDevice([row.id]);
|
||||||
await getList();
|
await getList();
|
||||||
@ -405,12 +433,15 @@ const handleUnbind = (row) => {
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
api.deviceUnbind(row).then(res => {
|
let data = {
|
||||||
if (res.code === 0) {
|
id: row.id
|
||||||
proxy?.$modal.msgSuccess('解绑成功')
|
}
|
||||||
|
api.deviceUnbind(data).then(res => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
proxy?.$modal.msgSuccess(res.msg)
|
||||||
getList(); // 初始化列表数据
|
getList(); // 初始化列表数据
|
||||||
} else {
|
} else {
|
||||||
proxy?.$modal.msgError(res.msg || '解绑失败')
|
proxy?.$modal.msgError(res.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
@ -425,7 +456,7 @@ const handleWithdraw = (row: any) => {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
api.withdrawDevice([row.id]).then(res => {
|
api.withdrawDevice([row.id]).then(res => {
|
||||||
if (res.code === 0) {
|
if (res.code === 200) {
|
||||||
proxy?.$modal.msgSuccess('撤回成功')
|
proxy?.$modal.msgSuccess('撤回成功')
|
||||||
getList(); // 初始化列表数据
|
getList(); // 初始化列表数据
|
||||||
} else {
|
} else {
|
||||||
@ -480,6 +511,8 @@ const handleUpdate = async (row?: deviceForm) => {
|
|||||||
getDeviceType();
|
getDeviceType();
|
||||||
try {
|
try {
|
||||||
if (row) {
|
if (row) {
|
||||||
|
// 使用 nextTick 确保对话框完全渲染后再设置表单值
|
||||||
|
await nextTick();
|
||||||
Object.assign(form.value, row);
|
Object.assign(form.value, row);
|
||||||
form.value.image = row.devicePic
|
form.value.image = row.devicePic
|
||||||
// 编辑时根据已有值显示字段
|
// 编辑时根据已有值显示字段
|
||||||
@ -510,7 +543,6 @@ const handleDeviceTypeChange = async (deviceTypeId: string | number) => {
|
|||||||
showMacField.value = false;
|
showMacField.value = false;
|
||||||
showImeiField.value = false;
|
showImeiField.value = false;
|
||||||
communicationModeInfo.value = null;
|
communicationModeInfo.value = null;
|
||||||
|
|
||||||
// 编辑时如果有值,根据已有值确定显示哪个字段
|
// 编辑时如果有值,根据已有值确定显示哪个字段
|
||||||
if (form.value.id) {
|
if (form.value.id) {
|
||||||
if (form.value.deviceMac) {
|
if (form.value.deviceMac) {
|
||||||
@ -526,12 +558,12 @@ const handleDeviceTypeChange = async (deviceTypeId: string | number) => {
|
|||||||
isProcessing = true;
|
isProcessing = true;
|
||||||
// 新增或编辑时没有值,根据设备类型获取通讯方式
|
// 新增或编辑时没有值,根据设备类型获取通讯方式
|
||||||
try {
|
try {
|
||||||
userFormRef.value?.clearValidate(['deviceMac', 'deviceImei']);
|
userFormRef.value?.clearValidate(['deviceMac', 'deviceImei','bluetoothName']);
|
||||||
if (!deviceTypeId) {
|
if (!deviceTypeId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await api.getCommunicationMode({ id: deviceTypeId });
|
const res = await api.getCommunicationMode({ id: deviceTypeId });
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code == 200 && res.data) {
|
||||||
communicationModeInfo.value = res.data;
|
communicationModeInfo.value = res.data;
|
||||||
// 根据通讯方式确定显示哪个字段
|
// 根据通讯方式确定显示哪个字段
|
||||||
if (res.data.communicationMode == '1') { // 蓝牙设备 - 显示MAC
|
if (res.data.communicationMode == '1') { // 蓝牙设备 - 显示MAC
|
||||||
@ -542,6 +574,7 @@ const handleDeviceTypeChange = async (deviceTypeId: string | number) => {
|
|||||||
showMacField.value = false;
|
showMacField.value = false;
|
||||||
showImeiField.value = true;
|
showImeiField.value = true;
|
||||||
form.value.deviceMac = ''; // 清空MAC
|
form.value.deviceMac = ''; // 清空MAC
|
||||||
|
form.value.bluetoothName = '' // 清空蓝牙名称
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -551,7 +584,7 @@ const handleDeviceTypeChange = async (deviceTypeId: string | number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 覆盖默认的上传行为,可以自定义上传的实现
|
// 覆盖默认的上传行为,可以自定义上传的实现
|
||||||
const httpRequestImg = (parm): Promise<any> => {
|
const httpRequestImg = (parm): Promise<any> => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
const beforeUpload = (file) => {
|
const beforeUpload = (file) => {
|
||||||
@ -622,7 +655,7 @@ const submitForm = async () => {
|
|||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (res.code == 0) {
|
if (res.code == 200) {
|
||||||
proxy?.$modal.msgSuccess('操作成功');
|
proxy?.$modal.msgSuccess('操作成功');
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
loadingIng.value = false;
|
loadingIng.value = false;
|
||||||
@ -652,6 +685,13 @@ const closeDialog = () => {
|
|||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showQrCode = (row: any) => {
|
||||||
|
if (row.deviceImei) {
|
||||||
|
qrCodeValue.value = row.deviceImei;
|
||||||
|
qrCodeDialogVisible.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置表单
|
* 重置表单
|
||||||
*/
|
*/
|
||||||
@ -663,7 +703,7 @@ const resetForm = () => {
|
|||||||
// 设备类型
|
// 设备类型
|
||||||
const getDeviceType = () => {
|
const getDeviceType = () => {
|
||||||
api.deviceTypeAll().then(res => {
|
api.deviceTypeAll().then(res => {
|
||||||
if (res.code == 0) {
|
if (res.code == 200) {
|
||||||
deviceTypeOptions.value = res.data
|
deviceTypeOptions.value = res.data
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@ -673,7 +713,7 @@ const getDeviceType = () => {
|
|||||||
// 客户下拉框
|
// 客户下拉框
|
||||||
const getAllCustomerAll = () => {
|
const getAllCustomerAll = () => {
|
||||||
api.userAllCustomerAll().then(res => {
|
api.userAllCustomerAll().then(res => {
|
||||||
if (res.code == 0) {
|
if (res.code == 200) {
|
||||||
customerList.value = res.data
|
customerList.value = res.data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -699,7 +739,7 @@ const handleAssignConfirm = () => {
|
|||||||
deviceIds: [assignRow.value.id]
|
deviceIds: [assignRow.value.id]
|
||||||
}
|
}
|
||||||
api.deviceAssignCustomer(data).then((res) => {
|
api.deviceAssignCustomer(data).then((res) => {
|
||||||
if (res.code == 0) {
|
if (res.code == 200) {
|
||||||
loadingIng.value = false;
|
loadingIng.value = false;
|
||||||
const customer = customerList.value.find(c => c.id === assignCustomerId.value)
|
const customer = customerList.value.find(c => c.id === assignCustomerId.value)
|
||||||
const customerName = customer ? customer.nickName : `ID: ${assignCustomerId.value}`
|
const customerName = customer ? customer.nickName : `ID: ${assignCustomerId.value}`
|
||||||
@ -733,7 +773,7 @@ const handleBatchImport = () => {
|
|||||||
const downloadTemplate = () => {
|
const downloadTemplate = () => {
|
||||||
// 这里可用 window.open 或 a 标签下载模板
|
// 这里可用 window.open 或 a 标签下载模板
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = 'http://fuyuanshen.com:81/images/excel/equipmenttemplate.xlsx';
|
link.href = 'https://fuyuanshen.com/fys/Equipmentimporttemplate/EquipmentImportTemplate.xlsx';
|
||||||
link.download = '设备数据导入模板.xlsx'; // 可选:指定下载文件名
|
link.download = '设备数据导入模板.xlsx'; // 可选:指定下载文件名
|
||||||
link.style.display = 'none'; // 隐藏标签
|
link.style.display = 'none'; // 隐藏标签
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
@ -751,7 +791,7 @@ const beforeImportUpload = (file: any) => {
|
|||||||
//添加tokenf方法head_upload 直接返回 getBearerToken()
|
//添加tokenf方法head_upload 直接返回 getBearerToken()
|
||||||
const head_upload = () => getBearerToken();
|
const head_upload = () => getBearerToken();
|
||||||
const handleImportSuccess = (response: any) => {
|
const handleImportSuccess = (response: any) => {
|
||||||
if (response.code === 0) {
|
if (response.code == 200) {
|
||||||
importResult.value.isShow = true
|
importResult.value.isShow = true
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
importResult.value.succeed = response.data.successCount || 0
|
importResult.value.succeed = response.data.successCount || 0
|
||||||
@ -785,7 +825,7 @@ const handleBatchAssignConfirm = () => {
|
|||||||
deviceIds: selectedIds // 选中的设备ID数组
|
deviceIds: selectedIds // 选中的设备ID数组
|
||||||
}
|
}
|
||||||
api.deviceAssignCustomer(data).then((res) => {
|
api.deviceAssignCustomer(data).then((res) => {
|
||||||
if (res.code == 0) {
|
if (res.code == 200) {
|
||||||
batchAssignDialogVisible.value = false
|
batchAssignDialogVisible.value = false
|
||||||
getList();
|
getList();
|
||||||
return proxy?.$modal.msgSuccess(`分配成功`)
|
return proxy?.$modal.msgSuccess(`分配成功`)
|
||||||
|
235
src/views/equipmentManagement/log/index.vue
Normal file
235
src/views/equipmentManagement/log/index.vue
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-2">
|
||||||
|
<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="deviceAction">
|
||||||
|
<el-input v-model="queryParams.deviceAction" placeholder="请输入设备行为" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备名称" prop="deviceName">
|
||||||
|
<el-input v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数据来源" prop="dataSource">
|
||||||
|
<el-input v-model="queryParams.dataSource" 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 shadow="never">
|
||||||
|
<template #header>
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['equipment:log:add']">新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['equipment:log:edit']">修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['equipment:log:remove']">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['equipment:log:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" border :data="logList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="ID" align="center" prop="id" v-if="true" />
|
||||||
|
<el-table-column label="设备行为" align="center" prop="deviceAction" />
|
||||||
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
||||||
|
<el-table-column label="数据来源" align="center" prop="dataSource" />
|
||||||
|
<el-table-column label="内容" align="center" prop="content" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip content="修改" placement="top">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['equipment:log:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['equipment:log:remove']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</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="logFormRef" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="设备行为" prop="deviceAction">
|
||||||
|
<el-input v-model="form.deviceAction" placeholder="请输入设备行为" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备名称" prop="deviceName">
|
||||||
|
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数据来源" prop="dataSource">
|
||||||
|
<el-input v-model="form.dataSource" placeholder="请输入数据来源" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="内容">
|
||||||
|
<editor v-model="form.content" :min-height="192"/>
|
||||||
|
</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="Log" lang="ts">
|
||||||
|
import { listLog, getLog, delLog, addLog, updateLog } from '@/api/equipmentManagement/log';
|
||||||
|
import { LogVO, LogQuery, LogForm } from '@/api/equipmentManagement/log/types';
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
|
const logList = ref<LogVO[]>([]);
|
||||||
|
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 logFormRef = ref<ElFormInstance>();
|
||||||
|
|
||||||
|
const dialog = reactive<DialogOption>({
|
||||||
|
visible: false,
|
||||||
|
title: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const initFormData: LogForm = {
|
||||||
|
id: undefined,
|
||||||
|
deviceAction: undefined,
|
||||||
|
deviceName: undefined,
|
||||||
|
dataSource: undefined,
|
||||||
|
content: undefined,
|
||||||
|
}
|
||||||
|
const data = reactive<PageData<LogForm, LogQuery>>({
|
||||||
|
form: {...initFormData},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
deviceAction: undefined,
|
||||||
|
deviceName: undefined,
|
||||||
|
dataSource: undefined,
|
||||||
|
content: undefined,
|
||||||
|
params: {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
id: [
|
||||||
|
{ required: true, message: "ID不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 查询设备日志列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
const res = await listLog(queryParams.value);
|
||||||
|
logList.value = res.rows;
|
||||||
|
total.value = res.total;
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消按钮 */
|
||||||
|
const cancel = () => {
|
||||||
|
reset();
|
||||||
|
dialog.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单重置 */
|
||||||
|
const reset = () => {
|
||||||
|
form.value = {...initFormData};
|
||||||
|
logFormRef.value?.resetFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value?.resetFields();
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 多选框选中数据 */
|
||||||
|
const handleSelectionChange = (selection: LogVO[]) => {
|
||||||
|
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?: LogVO) => {
|
||||||
|
reset();
|
||||||
|
const _id = row?.id || ids.value[0]
|
||||||
|
const res = await getLog(_id);
|
||||||
|
Object.assign(form.value, res.data);
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "修改设备日志";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
const submitForm = () => {
|
||||||
|
logFormRef.value?.validate(async (valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
buttonLoading.value = true;
|
||||||
|
if (form.value.id) {
|
||||||
|
await updateLog(form.value).finally(() => buttonLoading.value = false);
|
||||||
|
} else {
|
||||||
|
await addLog(form.value).finally(() => buttonLoading.value = false);
|
||||||
|
}
|
||||||
|
proxy?.$modal.msgSuccess("操作成功");
|
||||||
|
dialog.visible = false;
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (row?: LogVO) => {
|
||||||
|
const _ids = row?.id || ids.value;
|
||||||
|
await proxy?.$modal.confirm('是否确认删除设备日志编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
|
||||||
|
await delLog(_ids);
|
||||||
|
proxy?.$modal.msgSuccess("删除成功");
|
||||||
|
await getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = () => {
|
||||||
|
proxy?.download('equipment/log/export', {
|
||||||
|
...queryParams.value
|
||||||
|
}, `log_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
</script>
|
@ -55,9 +55,9 @@
|
|||||||
<el-tab-pane label="修改密码" name="resetPwd">
|
<el-tab-pane label="修改密码" name="resetPwd">
|
||||||
<resetPwd />
|
<resetPwd />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="第三方应用" name="thirdParty">
|
<!-- <el-tab-pane label="第三方应用" name="thirdParty">
|
||||||
<thirdParty :auths="state.auths" />
|
<thirdParty :auths="state.auths" />
|
||||||
</el-tab-pane>
|
</el-tab-pane> -->
|
||||||
<el-tab-pane label="在线设备" name="onlineDevice">
|
<el-tab-pane label="在线设备" name="onlineDevice">
|
||||||
<onlineDevice :devices="state.devices" />
|
<onlineDevice :devices="state.devices" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
Reference in New Issue
Block a user