0906
This commit is contained in:
@ -34,13 +34,7 @@
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.8">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="User"
|
||||
:disabled="single"
|
||||
@click="handleBindUser()"
|
||||
v-hasPermi="['gps:equipment:unbindManmachine', 'gps:equipment:bindManmachine']"
|
||||
<el-button type="primary" plain icon="User" :disabled="single" @click="handleBindUser()" v-hasPermi="['gps:equipment:bindManmachine']"
|
||||
>绑定用户</el-button
|
||||
>
|
||||
</el-col>
|
||||
@ -97,11 +91,11 @@
|
||||
type="primary"
|
||||
icon="User"
|
||||
@click="scope.row.type === 1 ? handleUnbindUser(scope.row) : handleBindUser(scope.row)"
|
||||
v-hasPermi="['gps:equipment:unbindManmachine', 'gps:equipment:bindManmachine']"
|
||||
v-hasPermi="scope.row.type === 1 ? ['gps:equipment:unbindManmachine'] : ['gps:equipment:bindManmachine']"
|
||||
>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<!-- 新增:跳转空页面按钮 -->
|
||||
|
||||
<el-tooltip content="足迹" placement="top">
|
||||
<el-button
|
||||
link
|
||||
@ -113,7 +107,14 @@
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="历史记录" placement="top">
|
||||
<el-button link type="primary" icon="Clock" @click="handleOpenHistoryUser(scope.row.clientId, scope.row.userId)"> </el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Clock"
|
||||
@click="handleOpenHistoryUser(scope.row.clientId, scope.row.userId)"
|
||||
v-hasPermi="['gps:equipment:getUserList']"
|
||||
>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -146,9 +147,6 @@
|
||||
<el-option v-for="project in projectList" :key="project.projectId" :label="project.projectName" :value="project.projectId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="deviceName">
|
||||
<el-input v-model="bindForm.deviceName" disabled placeholder="设备名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选择用户" prop="userId" required>
|
||||
<el-select v-model="bindForm.userId" placeholder="请选择用户" clearable>
|
||||
<el-option v-for="user in userList" :key="user.sysUserId" :label="user.userName" :value="user.sysUserId" />
|
||||
@ -175,6 +173,7 @@
|
||||
>
|
||||
<el-table-column label="序号" type="index" width="60" align="center" />
|
||||
<el-table-column label="用户名" align="center" prop="userName" />
|
||||
<el-table-column label="项目名称" align="center" prop="projectName" />
|
||||
<el-table-column label="状态" align="center" width="120">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.type === 0 ? 'success' : 'info'" size="small">
|
||||
@ -182,6 +181,19 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="足迹" placement="top">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
icon="Location"
|
||||
v-hasPermi="['gps:equipmentSon:getList']"
|
||||
@click="handleGoToEmptyPage(scope.row.userId, scope.row.projectId, currentHistoryClientId)"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div v-if="!historyUserLoading && historyUserList.length === 0" style="text-align: center; padding: 50px 0">
|
||||
@ -479,6 +491,8 @@ const handleViewAll = () => {
|
||||
};
|
||||
|
||||
const handleGoToEmptyPage = (userId: any, projectId: any, clientId: any) => {
|
||||
console.log('userId:', userId, 'projectId:', projectId, 'clientId:', clientId);
|
||||
|
||||
router.push({
|
||||
path: './equipmentGPS',
|
||||
query: {
|
||||
@ -578,41 +592,53 @@ const handleDelete = async (row?: ExtendedEquipmentVO) => {
|
||||
};
|
||||
|
||||
/** 绑定用户按钮操作 */
|
||||
const handleBindUser = async (row?: EquipmentVO) => {
|
||||
Object.assign(bindForm, {
|
||||
id: undefined,
|
||||
projectId: undefined,
|
||||
userId: undefined,
|
||||
clientId: row?.clientId,
|
||||
deviceName: undefined
|
||||
});
|
||||
bindUserFormRef.value?.resetFields();
|
||||
userList.value = [];
|
||||
|
||||
const _id = row?.id || ids.value[0];
|
||||
const handleBindUser = async (row: ExtendedEquipmentVO) => {
|
||||
try {
|
||||
const res = await getEquipment(_id);
|
||||
const equipmentData = res.data;
|
||||
bindForm.id = equipmentData.id;
|
||||
bindForm.deviceName = equipmentData.deviceName;
|
||||
bindForm.clientId = row?.clientId || equipmentData.clientId;
|
||||
if (!row) {
|
||||
proxy?.$modal.msgWarning('未获取到设备信息');
|
||||
return;
|
||||
}
|
||||
|
||||
if (row.id === undefined || row.id === null || row.id === '') {
|
||||
proxy?.$modal.msgWarning('设备ID不能为空');
|
||||
return;
|
||||
}
|
||||
const deviceId = Number(row.id);
|
||||
if (isNaN(deviceId) || deviceId <= 0) {
|
||||
proxy?.$modal.msgWarning(`设备ID格式错误,必须是正整数,当前值: ${row.id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!row.clientId || typeof row.clientId !== 'string' || row.clientId.trim() === '') {
|
||||
proxy?.$modal.msgWarning(`设备标识clientId格式错误,必须是非空字符串,当前值: ${row.clientId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化表单
|
||||
Object.assign(bindForm, {
|
||||
id: deviceId,
|
||||
projectId: undefined,
|
||||
userId: undefined,
|
||||
clientId: row.clientId,
|
||||
deviceName: row.deviceName || '未知设备'
|
||||
});
|
||||
bindUserFormRef.value?.resetFields();
|
||||
userList.value = [];
|
||||
|
||||
// 加载项目和用户数据
|
||||
if (projectList.value.length === 0) {
|
||||
await getProjects();
|
||||
}
|
||||
|
||||
if (equipmentData.projectId) {
|
||||
bindForm.projectId = equipmentData.projectId;
|
||||
await getUsersByProjectId(equipmentData.projectId);
|
||||
} else if (currentProject.value?.id) {
|
||||
if (currentProject.value?.id) {
|
||||
bindForm.projectId = currentProject.value.id;
|
||||
await getUsersByProjectId(currentProject.value.id);
|
||||
}
|
||||
|
||||
bindDialogVisible.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取绑定用户信息失败:', error);
|
||||
proxy?.$modal.msgError('获取数据失败,请重试');
|
||||
console.error('打开绑定用户对话框失败:', error);
|
||||
proxy?.$modal.msgError('操作失败,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
@ -628,17 +654,9 @@ const submitBindUser = () => {
|
||||
|
||||
bindButtonLoading.value = true;
|
||||
try {
|
||||
const bindData = {
|
||||
id: bindForm.id,
|
||||
projectId: bindForm.projectId,
|
||||
userId: bindForm.userId,
|
||||
clientId: bindForm.clientId,
|
||||
deviceName: bindForm.deviceName
|
||||
};
|
||||
|
||||
console.log('提交绑定用户参数:', bindData);
|
||||
|
||||
await bindUser(bindData);
|
||||
// 直接使用bindForm数据调用bindUser接口
|
||||
console.log('提交绑定用户参数:', bindForm);
|
||||
await bindUser(bindForm);
|
||||
proxy?.$modal.msgSuccess('用户绑定成功');
|
||||
bindDialogVisible.value = false;
|
||||
await getList();
|
||||
@ -718,6 +736,8 @@ const handleOpenHistoryUser = async (clientId: string | number | undefined, curr
|
||||
historyUserDialogVisible.value = true;
|
||||
historyUserLoading.value = true;
|
||||
historyUserList.value = [];
|
||||
// 保存当前clientId用于足迹操作
|
||||
currentHistoryClientId.value = clientId;
|
||||
|
||||
try {
|
||||
const res = await gethistroyUser({
|
||||
@ -742,6 +762,27 @@ const handleOpenHistoryUser = async (clientId: string | number | undefined, curr
|
||||
}
|
||||
};
|
||||
|
||||
/** 历史弹窗中的足迹操作 */
|
||||
const handleFootprintOperation = () => {
|
||||
if (!historyUserList.value || historyUserList.value.length === 0) {
|
||||
proxy?.$modal.msgWarning('暂无用户数据,无法查看足迹');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取第一个用户的数据(通常是当前绑定用户)
|
||||
const firstUser = historyUserList.value[0];
|
||||
if (!firstUser.sysUserId) {
|
||||
proxy?.$modal.msgWarning('用户ID不存在,无法查看足迹');
|
||||
return;
|
||||
}
|
||||
|
||||
// 跳转到足迹页面
|
||||
handleGoToEmptyPage(firstUser.sysUserId, firstUser.projectId || currentProject.value?.id, currentHistoryClientId.value);
|
||||
};
|
||||
|
||||
// 当前历史弹窗的clientId
|
||||
const currentHistoryClientId = ref('');
|
||||
|
||||
/** 页面挂载时初始化 */
|
||||
onMounted(() => {
|
||||
getList();
|
||||
|
Reference in New Issue
Block a user