隐患详情重新设计,检查计划重新设计成做题排查式

This commit is contained in:
王利强
2026-06-21 16:30:12 +08:00
parent 1fe87ec438
commit cc94d3e3e9
256 changed files with 12542 additions and 5956 deletions

View File

@@ -39,7 +39,7 @@
<!-- 添加成员按钮 -->
<view class="add-btn-wrapper">
<button class="add-btn" @click="showPopup = true">
<button class="add-btn" @click="openAddMemberPopup">
<text class="cuIcon-add"></text>
<text>添加成员</text>
</button>
@@ -89,6 +89,17 @@
<text class="cuIcon-unfold"></text>
</view>
</view>
<!-- 岗位 -->
<view class="form-item">
<view class="form-label">岗位</view>
<view class="form-select" @click="openPostPicker">
<text :class="selectedPostName ? '' : 'text-gray'">
{{ selectedPostName || postPlaceholder }}
</text>
<text class="cuIcon-unfold"></text>
</view>
</view>
<!-- 占位空白防止被底部按钮遮挡 -->
<view style="height: 40rpx;"></view>
@@ -101,6 +112,14 @@
</view>
</u-popup>
<up-picker
:show="showPostPicker"
:columns="postColumns"
@confirm="onPostConfirm"
@cancel="showPostPicker = false"
@close="showPostPicker = false"
></up-picker>
<up-picker
:show="showRolePicker"
:columns="roleColumns"
@@ -115,7 +134,7 @@
<script setup>
import { ref, reactive, computed, onMounted } from 'vue';
import { addMember, getMemberList, lockOrUnlockMember } from '@/request/api.js';
import { addMember, getMemberList, lockOrUnlockMember, getSystemUserFormOptions, listPostByDeptId } from '@/request/api.js';
// 用户信息从storage获取
const userInfo = ref({
@@ -170,7 +189,9 @@ const fetchMemberList = async () => {
// 弹窗控制
const showPopup = ref(false);
const showRolePicker = ref(false);
const showPostPicker = ref(false);
const selectedRoleName = ref('');
const selectedPostName = ref('');
// 表单数据
const formData = reactive({
@@ -178,29 +199,93 @@ const formData = reactive({
nickname: '',
phone: '',
password: '',
roleType: ''
roleType: '',
postId: ''
});
// 角色类型选择器数据
const roleColumns = reactive([
['管理员', '普通成员']
]);
// 角色选项(接口返回)
const roleOptions = ref([]);
const roleColumns = ref([[]]);
// 角色名称与值的映射
const roleMap = {
'管理员': 'manage',
'普通成员': 'common'
// 岗位选项按部门ID查询
const postOptions = ref([]);
const postColumns = ref([[]]);
const postPlaceholder = computed(() => {
if (!userInfo.value.deptId) return '请先登录并确认部门信息';
return postOptions.value.length ? '请选择岗位' : '暂无可用岗位';
});
// 打开添加成员弹窗:拉取角色和岗位列表
const openAddMemberPopup = async () => {
getUserInfo();
const deptId = userInfo.value.deptId;
if (!deptId) {
uni.showToast({ title: '缺少部门信息,无法添加成员', icon: 'none' });
return;
}
try {
uni.showLoading({ title: '加载中...' });
const [optionsRes, postRes] = await Promise.all([
getSystemUserFormOptions(),
listPostByDeptId(deptId)
]);
uni.hideLoading();
if (optionsRes.code !== 0 || !Array.isArray(optionsRes.roles) || !optionsRes.roles.length) {
uni.showToast({ title: optionsRes.msg || '获取角色列表失败', icon: 'none' });
return;
}
roleOptions.value = optionsRes.roles.filter((item) => item.status === '0');
roleColumns.value = [roleOptions.value.map((item) => item.roleName)];
const posts = postRes.data || postRes.rows || [];
postOptions.value = posts.filter((item) => item.status === '0');
postColumns.value = [postOptions.value.map((item) => item.postName)];
showPopup.value = true;
} catch (error) {
uni.hideLoading();
console.error('获取表单选项失败:', error);
uni.showToast({
title: error?.msg || '获取表单选项失败',
icon: 'none'
});
}
};
const openPostPicker = () => {
if (!postOptions.value.length) {
uni.showToast({ title: '当前部门暂无可用岗位', icon: 'none' });
return;
}
showPostPicker.value = true;
};
// 角色类型选择确认
const onRoleConfirm = (e) => {
if (e.value && e.value.length > 0) {
selectedRoleName.value = e.value[0];
formData.roleType = roleMap[e.value[0]];
const roleName = e.value[0];
const role = roleOptions.value.find((item) => item.roleName === roleName);
selectedRoleName.value = roleName;
formData.roleType = role?.roleKey || '';
}
showRolePicker.value = false;
};
// 岗位选择确认
const onPostConfirm = (e) => {
if (e.value && e.value.length > 0) {
const postName = e.value[0];
const post = postOptions.value.find((item) => item.postName === postName);
selectedPostName.value = postName;
formData.postId = post?.postId ?? '';
}
showPostPicker.value = false;
};
// 重置表单
const resetForm = () => {
formData.username = '';
@@ -208,7 +293,11 @@ const resetForm = () => {
formData.phone = '';
formData.password = '';
formData.roleType = '';
formData.postId = '';
selectedRoleName.value = '';
selectedPostName.value = '';
postOptions.value = [];
postColumns.value = [[]];
};
// 提交表单
@@ -226,13 +315,24 @@ const handleSubmit = async () => {
return;
}
getUserInfo();
const deptId = userInfo.value.deptId;
if (!deptId) {
uni.showToast({ title: '缺少部门信息,无法添加成员', icon: 'none' });
return;
}
const params = {
userName: formData.username,
nickName: formData.nickname || '',
phonenumber: formData.phone || '',
password: formData.password,
roleType: formData.roleType
roleType: formData.roleType,
deptId
};
if (formData.postId) {
params.postId = formData.postId;
}
try {
const res = await addMember(params);