Compare commits

...

3 Commits

Author SHA1 Message Date
d9de847fb1 app登录接口联调 2025-07-07 18:57:34 +08:00
ec86798b6c 1 2025-07-05 17:46:16 +08:00
5f30a1fa41 APP用户管理页面 2025-07-05 17:45:52 +08:00
11 changed files with 375 additions and 84 deletions

31
src/api/userApp/index.ts Normal file
View File

@ -0,0 +1,31 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
/**
* 查询设备列表
* @param query
*/
export const userList = (params): AxiosPromise => {
return request({
url: '/app/user/list',
method: 'get',
params
});
};
// 绑定设备列表
export const deviceList = (params): AxiosPromise => {
return request({
url: '/api/app/device',
method: 'get',
params
});
};
// 账号状态
export const userStatus = (data): AxiosPromise => {
return request({
url: '/api/app/device',
method: 'put',
data
});
};
export default { userList,deviceList,userStatus }

16
src/api/userApp/types.ts Normal file
View File

@ -0,0 +1,16 @@
export interface userQuery {
pageNum: number | string | undefined;
pageSize: number | string | undefined;
userName: string;
status: string;
}
export interface userForm {
configId: number | string | undefined;
configName: string;
configKey: string;
configValue: string;
configType: string;
remark: string;
}

BIN
src/assets/images/kfz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 564 KiB

After

Width:  |  Height:  |  Size: 333 KiB

View File

@ -14,47 +14,6 @@
</el-option>
<template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template>
</el-select>
<!-- <search-menu ref="searchMenuRef" />
<el-tooltip content="搜索" effect="dark" placement="bottom">
<div class="right-menu-item hover-effect" @click="openSearchMenu">
<svg-icon class-name="search-icon" icon-class="search" />
</div>
</el-tooltip> -->
<!-- 消息 -->
<!-- <el-tooltip :content="proxy.$t('navbar.message')" effect="dark" placement="bottom">
<div>
<el-popover placement="bottom" trigger="click" transition="el-zoom-in-top" :width="300" :persistent="false">
<template #reference>
<el-badge :value="newNotice > 0 ? newNotice : ''" :max="99">
<div class="right-menu-item hover-effect" style="display: block"><svg-icon icon-class="message" /></div>
</el-badge>
</template>
<template #default>
<notice></notice>
</template>
</el-popover>
</div>
</el-tooltip> -->
<!-- <el-tooltip content="Github" effect="dark" placement="bottom">
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip :content="proxy.$t('navbar.document')" effect="dark" placement="bottom">
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip :content="proxy.$t('navbar.full')" effect="dark" placement="bottom">
<screenfull id="screenfull" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip :content="proxy.$t('navbar.language')" effect="dark" placement="bottom">
<lang-select id="lang-select" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip :content="proxy.$t('navbar.layoutSize')" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip> -->
</template>
<div class="avatar-container">
<el-dropdown class="right-menu-item hover-effect" trigger="click" @command="handleCommand">
@ -69,9 +28,6 @@
<router-link v-if="!dynamic" to="/user/profile">
<el-dropdown-item>{{ proxy.$t('navbar.personalCenter') }}</el-dropdown-item>
</router-link>
<el-dropdown-item v-if="settingsStore.showSettings" command="setLayout">
<span>{{ proxy.$t('navbar.layoutSetting') }}</span>
</el-dropdown-item>
<el-dropdown-item divided command="logout">
<span>{{ proxy.$t('navbar.logout') }}</span>
</el-dropdown-item>

149
src/views/appUser/index.vue Normal file
View File

@ -0,0 +1,149 @@
<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="APP账号" prop="userName">
<el-input v-model="queryParams.userName" placeholder="请输入APP账号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="账号状态" prop="status">
<el-select v-model="queryParams.status" clearable placeholder="账号状态"
class="filter-item">
<el-option label="启用" :value="0" />
<el-option label="禁用" :value="1" />
</el-select>
</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="hover">
<el-table ref="operLogTableRef" v-loading="loading" :data="operlogList" border>
<el-table-column label="APP账号" align="center" prop="userName" />
<el-table-column label="账号状态" align="center" prop="status">
<template #default="scope">
<div @click="handleStatusChange(scope.row)">
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1" />
</div>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="loginDate" width="180">
<template #default="scope">
<span>{{ proxy.parseTime(scope.row.loginDate) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center">
<template #default="scope">
<el-tooltip content="查看绑定设备" placement="top">
<el-button link type="primary" icon="View" @click="handleView(scope.row)"> </el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
:total="total" @pagination="getList" />
</el-card>
<!-- 操作日志详细 -->
<userInfoDialog ref="userInfoDialogRef" />
</div>
</template>
<script setup name="userApp" lang="ts">
import api from '@/api/userApp';
import { userQuery, userForm } from '@/api/userApp/types';
import UserInfoDialog from './user-info-dialog.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const operlogList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);
const userInfoDialogRef = ref<ElTableInstance>();
const queryFormRef = ref<ElFormInstance>();
const data = reactive<PageData<userForm, userQuery>>({
form: {
operId: undefined,
tenantId: undefined,
title: '',
businessType: 0,
businessTypes: undefined,
method: '',
requestMethod: '',
operatorType: 0,
operName: '',
deptName: '',
operUrl: '',
operIp: '',
operLocation: '',
operParam: '',
jsonResult: '',
status: 0,
errorMsg: '',
operTime: '',
costTime: 0
},
queryParams: {
pageNum: 1,
pageSize: 10,
userName: '',
status: ''
},
rules: {}
});
const { queryParams } = toRefs(data);
/** 查询登录日志 */
const getList = async () => {
loading.value = true;
const res = await api.userList(queryParams.value);
operlogList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields();
handleQuery()
};
/** 详细按钮操作 */
const handleView = (row: any) => {
userInfoDialogRef.value.openDialog(row);
};
const handleStatusChange = (row: any) => {
const text = row.status == 0 ? '启用' : '禁用'
proxy?.$modal.confirm('此操作将 "' + text + '" ' + row.userName + ', 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
api.userStatus(row).then(res => {
if (res.code == 200) {
proxy?.$modal.msgSuccess(text + '成功')
getList();
}
}).catch(() => {
row.status = !row.status
})
}).catch(() => {
row.status = !row.status
})
};
onMounted(() => {
getList();
});
</script>

View File

@ -0,0 +1,148 @@
<template>
<el-dialog v-model="open" title="绑定设备列表" width="50%" append-to-body close-on-click-modal @closed="info = null">
<!-- 搜索栏 -->
<div class="head-container">
<el-input v-model="queryParams.deviceName" clearable placeholder="请输入设备名称" style="width: 200px;"
class="filter-item" />
<el-input v-model="queryParams.deviceMac" clearable placeholder="请输入设备MAC" style="width: 200px;"
class="filter-item" />
<el-input v-model="queryParams.deviceImei" clearable placeholder="请输入设备IMEI" style="width: 200px;"
class="filter-item" />
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</div>
<!-- 表格 -->
<el-table v-loading="bindingLoading" :data="boundDevices" style="width: 100%; margin-top: 20px;" height="400">
<el-table-column prop="deviceName" label="设备名称" />
<el-table-column prop="devicePic" label="设备图片">
<template #default="scope">
<el-image style="width: 40px; height: 40px" :src="scope.row.devicePic"
:preview-src-list="[scope.row.devicePic]" />
</template>
</el-table-column>
<el-table-column prop="deviceMac" label="设备MAC" />
<el-table-column prop="deviceImei" label="设备IMEI" />
<el-table-column prop="deviceTypeName" label="设备类型" />
<el-table-column prop="deviceStatus" 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">
<template #default="scope">
<el-button type="danger" plain @click="handleUnbind(scope.row)">解绑</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
:total="total" @pagination="getList" />
</el-dialog>
</template>
<script setup lang="ts">
import type { OperLogForm } from '@/api/monitor/operlog/types';
import 'vue-json-pretty/lib/styles.css';
import api from '@/api/userApp';
const open = ref(false);
const info = ref<OperLogForm | null>(null);
const total = ref(0);
const boundDevices = ref()
const bindingLoading = ref(true)
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
deviceName: '',
deviceMac: '',
deviceImei: ''
})
function openDialog(row: OperLogForm) {
info.value = row;
open.value = true;
getList();
}
function closeDialog() {
open.value = false;
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryParams.pageNum = 1;
};
// 列表
const getList = async () => {
bindingLoading.value = true;
const res = await api.deviceList(queryParams);
boundDevices.value = res.rows;
total.value = res.total;
bindingLoading.value = false;
};
// 解绑
const handleUnbind = (row) => {
proxy?.$modal.confirm.confirm('此操作将解绑设备 "' + row.deviceName + '", 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const data = {
deviceMac: row.deviceMac,
customerId: info.value.id
}
api.deviceList(data).then(() => {
proxy?.$modal.msgSuccess({ type: 'success', message: '解绑成功!' })
getList()
})
}).catch(() => { })
}
defineExpose({
openDialog,
closeDialog
});
/**
* json转为对象
* @param data 原始数据
*/
function formatToJsonObject(data: string) {
try {
return JSON.parse(data);
} catch (error) {
return data;
}
}
/**
* 字典信息
*/
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_oper_type } = toRefs<any>(proxy?.useDict('sys_oper_type'));
const typeFormat = (row: OperLogForm) => {
return proxy?.selectDictLabel(sys_oper_type.value, row.businessType);
};
</script>
<style lang="scss" scoped>
/**
label宽度固定
*/
:deep(.el-descriptions__label) {
min-width: 100px;
}
/**
文字超过 换行显示
*/
:deep(.el-descriptions__content) {
max-width: 300px;
}
.filter-item {
margin-right: 10px;
}
</style>

View File

@ -58,7 +58,6 @@
<div @click="handleStatusChange(scope.row)">
<el-switch v-model="scope.row.enabled" />
</div>
</template>
</el-table-column>

View File

@ -687,10 +687,11 @@ const handleAssignConfirm = () => {
getList();
assignDialogVisible.value = false
return proxy?.$modal.msgSuccess(`设备已分配给客户: ${customerName}`)
} else {
loadingIng.value = false;
}
}).catch(()=>{
loadingIng.value = false;
})
};
const importUpload = ref()
@ -757,9 +758,8 @@ const handleBatchAssignConfirm = () => {
if (!batchAssignCustomerId.value) {
return proxy?.$modal.msgError('请选择客户')
}
// 这里可以调用批量分配API传递 crud.selections 和 batchAssignCustomerId
// 提取选中设备的 ID 数组
const selectedIds = ids.value.map((item) => item.id)
const selectedIds = ids.value.map((item:any) => item.id)
// 构造请求数据
const data = {
customerId: batchAssignCustomerId.value, // 目标客户ID
@ -771,11 +771,11 @@ const handleBatchAssignConfirm = () => {
getList();
return proxy?.$modal.msgSuccess(`分配成功`)
}
}).catch(()=>{
})
};
watch(() => form.value.deviceType, (newVal) => {
if (dialog.title === '新增设备') { // Only for add form
handleDeviceTypeChange(newVal);

View File

@ -1,23 +1,36 @@
<template>
<div class="app-container home">
<el-row :gutter="20">
<el-col :sm="24" :lg="12" style="padding-left: 20px">
</el-col>
<el-col :sm="24" :lg="12" style="padding-left: 20px">
<el-col :sm="24" :lg="12">
<div class="kfzIMG">
<img src="@/assets/images/kfz.png" alt="" class="kfIMG">
<p>功能开发中....敬请期待</p>
</div>
</el-col>
</el-row>
<el-divider />
</div>
</template>
<script setup name="Index" lang="ts">
const goTarget = (url: string) => {
window.open(url, '__blank');
};
</script>
<style lang="scss" scoped>
.home {
.kfzIMG {
left: 50%;
top: 50%;
position: absolute;
transform: translate(-50%, 100%);
text-align: center;
}
.kfIMG {
width: 60%;
}
}
.el-divider--horizontal{
border: none;
}
</style>

View File

@ -3,7 +3,6 @@
<el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
<div class="title-box">
<h3 class="title">{{ title }}</h3>
<lang-select />
</div>
<el-form-item v-if="tenantEnabled" prop="tenantId">
<el-select v-model="loginForm.tenantId" filterable :placeholder="proxy.$t('login.selectPlaceholder')"
@ -15,18 +14,18 @@
</el-form-item>
<el-form-item prop="username">
<el-input v-model="loginForm.username" type="text" size="large" auto-complete="off"
:placeholder="proxy.$t('login.username')">
placeholder="账号">
<template #prefix><svg-icon icon-class="user" class="el-input__icon input-icon" /></template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="loginForm.password" type="password" size="large" auto-complete="off"
:placeholder="proxy.$t('login.password')" @keyup.enter="handleLogin">
placeholder="密码" @keyup.enter="handleLogin">
<template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
</el-input>
</el-form-item>
<el-form-item v-if="captchaEnabled" prop="code">
<el-input v-model="loginForm.code" size="large" auto-complete="off" :placeholder="proxy.$t('login.code')"
<el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码"
style="width: 63%" @keyup.enter="handleLogin">
<template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>
</el-input>
@ -34,24 +33,6 @@
<img :src="codeUrl" class="login-code-img" @click="getCode" />
</div>
</el-form-item>
<!-- <el-checkbox v-model="loginForm.rememberMe" style="margin: 0 0 25px 0">{{ proxy.$t('login.rememberPassword') }}</el-checkbox>
<el-form-item style="float: right">
<el-button circle :title="proxy.$t('login.social.wechat')" @click="doSocialLogin('wechat')">
<svg-icon icon-class="wechat" />
</el-button>
<el-button circle :title="proxy.$t('login.social.maxkey')" @click="doSocialLogin('maxkey')">
<svg-icon icon-class="maxkey" />
</el-button>
<el-button circle :title="proxy.$t('login.social.topiam')" @click="doSocialLogin('topiam')">
<svg-icon icon-class="topiam" />
</el-button>
<el-button circle :title="proxy.$t('login.social.gitee')" @click="doSocialLogin('gitee')">
<svg-icon icon-class="gitee" />
</el-button>
<el-button circle :title="proxy.$t('login.social.github')" @click="doSocialLogin('github')">
<svg-icon icon-class="github" />
</el-button>
</el-form-item> -->
<el-form-item style="width: 100%">
<el-button :loading="loading" size="large" type="primary" style="width: 100%" @click.prevent="handleLogin">
<span v-if="!loading">{{ proxy.$t('login.login') }}</span>
@ -72,14 +53,12 @@ import { useUserStore } from '@/store/modules/user';
import { LoginData, TenantVO } from '@/api/types';
import { to } from 'await-to-js';
import { HttpStatus } from '@/enums/RespEnum';
import { useI18n } from 'vue-i18n';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const title = import.meta.env.VITE_APP_TITLE;
const userStore = useUserStore();
const router = useRouter();
const { t } = useI18n();
const loginForm = ref<LoginData>({
tenantId: '000000',
@ -91,10 +70,10 @@ const loginForm = ref<LoginData>({
} as LoginData);
const loginRules: ElFormRules = {
tenantId: [{ required: true, trigger: 'blur', message: t('login.rule.tenantId.required') }],
username: [{ required: true, trigger: 'blur', message: t('login.rule.username.required') }],
password: [{ required: true, trigger: 'blur', message: t('login.rule.password.required') }],
code: [{ required: true, trigger: 'change', message: t('login.rule.code.required') }]
tenantId: [{ required: true, trigger: 'blur', message: '请输入您的租户编号'}],
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
password: [{ required: true, trigger: 'blur', message: '请输入您的密码'}],
code: [{ required: true, trigger: 'change', message: '请输入验证码'}]
};
const codeUrl = ref('');