refactor(projects): 页面布局调整为rdms风格
This commit is contained in:
@@ -15,20 +15,21 @@
|
||||
* - 叶子节点:基层员工,没有下级
|
||||
*/
|
||||
|
||||
import {nextTick, onMounted, reactive, ref} from 'vue';
|
||||
import type {ElTree} from 'element-plus';
|
||||
import {ElButton, ElPopconfirm, ElTag} from 'element-plus';
|
||||
import {useBoolean} from '@sa/hooks';
|
||||
import { nextTick, onMounted, reactive, ref } from 'vue';
|
||||
import type { ElTree } from 'element-plus';
|
||||
import { ElButton, ElPopconfirm, ElTag } from 'element-plus';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import {
|
||||
fetchBatchDeleteUserManagementRelation,
|
||||
fetchDeleteUserManagementRelation, fetchGetUserListByDeptId,
|
||||
fetchDeleteUserManagementRelation,
|
||||
fetchGetUserListByDeptId,
|
||||
fetchGetUserManagementRelationQuery,
|
||||
fetchGetUserManagementRelationTree,
|
||||
fetchGetUserManagementRelationTree
|
||||
} from '@/service/api';
|
||||
import RelationOperateDialog from './modules/relation-operate-dialog.vue';
|
||||
import RelationSearch from './modules/relation-search.vue';
|
||||
|
||||
defineOptions({name: 'UserManagementRelation'});
|
||||
defineOptions({ name: 'UserManagementRelation' });
|
||||
|
||||
/**
|
||||
* 组件 userQuery 定义
|
||||
@@ -40,8 +41,8 @@ interface userQuery {
|
||||
deptId?: number | null;
|
||||
}
|
||||
|
||||
//从user的index组件访问带人关系,fromUserIndex为true,否则false; dept=100是灿能电力的id
|
||||
const {fromUserIndex = false, deptId = 100} = defineProps<userQuery>()
|
||||
// 从user的index组件访问带人关系,fromUserIndex为true,否则false; dept=100是灿能电力的id
|
||||
const { fromUserIndex = false, deptId = 100 } = defineProps<userQuery>();
|
||||
|
||||
/**
|
||||
* 初始化搜索参数
|
||||
@@ -86,7 +87,7 @@ const treeProps: any = {
|
||||
* 获取用户简单列表,供搜索组件和对话框组件共享使用
|
||||
*/
|
||||
async function loadUserList() {
|
||||
const {data, error} = await fetchGetUserListByDeptId(deptId);
|
||||
const { data, error } = await fetchGetUserListByDeptId(deptId);
|
||||
if (!error) {
|
||||
userList.value = data || [];
|
||||
}
|
||||
@@ -103,10 +104,10 @@ async function loadTreeData() {
|
||||
try {
|
||||
// 默认不是来自user的index组件访问且deptId=100,查询灿能电力及其以下所有部门的用户的带人关系
|
||||
const query: Api.SystemManage.UserManagementRelationQueryReqVO = {
|
||||
fromUserIndex: fromUserIndex,
|
||||
deptId: deptId
|
||||
fromUserIndex,
|
||||
deptId
|
||||
};
|
||||
const {data, error} = await fetchGetUserManagementRelationTree(query);
|
||||
const { data, error } = await fetchGetUserManagementRelationTree(query);
|
||||
|
||||
if (!error) {
|
||||
treeData.value = data || [];
|
||||
@@ -127,7 +128,7 @@ async function loadTreeDataByQuery(query: Api.SystemManage.UserManagementRelatio
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const {data, error} = await fetchGetUserManagementRelationQuery(query);
|
||||
const { data, error } = await fetchGetUserManagementRelationQuery(query);
|
||||
|
||||
if (!error) {
|
||||
treeData.value = data || [];
|
||||
@@ -164,8 +165,8 @@ async function handleSearch() {
|
||||
// 有搜索条件,调用查询接口
|
||||
const query: Api.SystemManage.UserManagementRelationQueryReqVO = {
|
||||
subordinateUserId: searchParams.subordinateUserId,
|
||||
fromUserIndex: fromUserIndex,
|
||||
deptId: deptId
|
||||
fromUserIndex,
|
||||
deptId
|
||||
};
|
||||
await loadTreeDataByQuery(query);
|
||||
} else {
|
||||
@@ -188,7 +189,7 @@ function resetSearchParams() {
|
||||
}
|
||||
|
||||
// 对话框相关状态
|
||||
const {bool: operateVisible, setTrue: openOperateModal, setFalse: closeOperateModal} = useBoolean();
|
||||
const { bool: operateVisible, setTrue: openOperateModal, setFalse: closeOperateModal } = useBoolean();
|
||||
const operateType = ref<UI.TableOperateType>('add');
|
||||
const editingData = ref<Api.SystemManage.UserManagementRelation | null>(null);
|
||||
|
||||
@@ -203,14 +204,14 @@ function openAdd(item?: Api.SystemManage.UserManagementRelationTreeRespVO) {
|
||||
// 否则默认管理者为当前登录用户(在对话框组件中处理)
|
||||
editingData.value = item
|
||||
? {
|
||||
id: null,
|
||||
managerUserId: item.userId,
|
||||
subordinateUserId: null,
|
||||
effectiveFrom: null,
|
||||
effectiveUntil: null,
|
||||
remark: null,
|
||||
createTime: Date.now()
|
||||
}
|
||||
id: null,
|
||||
managerUserId: item.userId,
|
||||
subordinateUserId: null,
|
||||
effectiveFrom: null,
|
||||
effectiveUntil: null,
|
||||
remark: null,
|
||||
createTime: Date.now()
|
||||
}
|
||||
: null;
|
||||
openOperateModal();
|
||||
}
|
||||
@@ -225,14 +226,14 @@ function openEdit(item: Api.SystemManage.UserManagementRelationTreeRespVO) {
|
||||
// 构建树节点数据为编辑所需格式
|
||||
editingData.value = item.id
|
||||
? {
|
||||
id: item.id,
|
||||
managerUserId: item.managerUserId,
|
||||
subordinateUserId: item.userId,
|
||||
effectiveFrom: null,
|
||||
effectiveUntil: null,
|
||||
remark: null,
|
||||
createTime: Date.now()
|
||||
}
|
||||
id: item.id,
|
||||
managerUserId: item.managerUserId,
|
||||
subordinateUserId: item.userId,
|
||||
effectiveFrom: null,
|
||||
effectiveUntil: null,
|
||||
remark: null,
|
||||
createTime: Date.now()
|
||||
}
|
||||
: null;
|
||||
openOperateModal();
|
||||
}
|
||||
@@ -243,7 +244,7 @@ function openEdit(item: Api.SystemManage.UserManagementRelationTreeRespVO) {
|
||||
* @param item 要删除的关系记录
|
||||
*/
|
||||
async function handleDelete(item: Api.SystemManage.UserManagementRelationTreeRespVO) {
|
||||
const {error} = await fetchDeleteUserManagementRelation(item.id);
|
||||
const { error } = await fetchDeleteUserManagementRelation(item.id);
|
||||
|
||||
if (error) {
|
||||
return;
|
||||
@@ -263,7 +264,7 @@ async function handleBatchDelete() {
|
||||
return;
|
||||
}
|
||||
|
||||
const {error} = await fetchBatchDeleteUserManagementRelation(checkedNodeKeys.value);
|
||||
const { error } = await fetchBatchDeleteUserManagementRelation(checkedNodeKeys.value);
|
||||
|
||||
if (error) {
|
||||
return;
|
||||
@@ -350,23 +351,23 @@ onMounted(async () => {
|
||||
<div class="flex items-center gap-10px">
|
||||
<ElButton plain type="primary" @click="openAdd()">
|
||||
<template #icon>
|
||||
<icon-ic-round-plus class="text-icon"/>
|
||||
<icon-ic-round-plus class="text-icon" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<!-- <ElPopconfirm title="确认删除选中的关系吗?" @confirm="handleBatchDelete">-->
|
||||
<!-- <template #reference>-->
|
||||
<!-- <ElButton type="danger" plain :disabled="checkedNodeKeys.length === 0">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <icon-ic-round-delete class="text-icon"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 批量删除-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- </template>-->
|
||||
<!-- </ElPopconfirm>-->
|
||||
<!-- <ElPopconfirm title="确认删除选中的关系吗?" @confirm="handleBatchDelete">-->
|
||||
<!-- <template #reference>-->
|
||||
<!-- <ElButton type="danger" plain :disabled="checkedNodeKeys.length === 0">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <icon-ic-round-delete class="text-icon"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 批量删除-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- </template>-->
|
||||
<!-- </ElPopconfirm>-->
|
||||
<ElButton @click="reloadTreeData">
|
||||
<template #icon>
|
||||
<icon-ic-round-refresh class="text-icon"/>
|
||||
<icon-ic-round-refresh class="text-icon" />
|
||||
</template>
|
||||
刷新
|
||||
</ElButton>
|
||||
@@ -390,18 +391,18 @@ onMounted(async () => {
|
||||
<div class="flex flex-1 items-center justify-between">
|
||||
<span class="flex items-center gap-8px">
|
||||
<span>{{ node.label }}</span>
|
||||
<!-- <ElTag v-if="data.managerNickname" size="small" type="info">上级:{{ data.managerNickname }}</ElTag>-->
|
||||
<!-- <ElTag v-if="data.managerNickname" size="small" type="info">上级:{{ data.managerNickname }}</ElTag>-->
|
||||
</span>
|
||||
<div class="flex items-center">
|
||||
<ElButton link type="primary" size="default" @click.stop="openAdd(data)">
|
||||
<template #icon>
|
||||
<icon-ic-round-plus class="text-icon"/>
|
||||
<icon-ic-round-plus class="text-icon" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton link type="primary" size="small" @click.stop="openEdit(data)">
|
||||
<template #icon>
|
||||
<icon-ic-round-edit class="text-icon"/>
|
||||
<icon-ic-round-edit class="text-icon" />
|
||||
</template>
|
||||
编辑
|
||||
</ElButton>
|
||||
@@ -413,7 +414,7 @@ onMounted(async () => {
|
||||
<template #reference>
|
||||
<ElButton link type="danger" size="small">
|
||||
<template #icon>
|
||||
<icon-ic-round-delete class="text-icon"/>
|
||||
<icon-ic-round-delete class="text-icon" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
|
||||
@@ -284,26 +284,26 @@ watch(visible, value => {
|
||||
</ElRow>
|
||||
<ElRow :gutter="16">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="生效开始时间" prop="effectiveFrom" style="width:100%">
|
||||
<ElFormItem label="生效开始时间" prop="effectiveFrom" style="width: 100%">
|
||||
<ElDatePicker
|
||||
v-model="model.effectiveFrom"
|
||||
class="w-full"
|
||||
type="datetime"
|
||||
placeholder="请选择生效开始时间"
|
||||
value-format="x"
|
||||
style="width:100%"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="生效结束时间" prop="effectiveUntil" style="width:100%">
|
||||
<ElFormItem label="生效结束时间" prop="effectiveUntil" style="width: 100%">
|
||||
<ElDatePicker
|
||||
v-model="model.effectiveUntil"
|
||||
class="w-full"
|
||||
type="datetime"
|
||||
placeholder="请选择生效结束时间"
|
||||
value-format="x"
|
||||
style="width:100%"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
@@ -319,6 +319,4 @@ watch(visible, value => {
|
||||
</BusinessFormDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* - 用户列表通过 props 传入,由父组件统一管理
|
||||
*/
|
||||
|
||||
import {defineEmits, defineModel, defineOptions} from 'vue';
|
||||
import { defineEmits, defineModel, defineOptions } from 'vue';
|
||||
|
||||
defineOptions({name: 'RelationSearch'});
|
||||
defineOptions({ name: 'RelationSearch' });
|
||||
|
||||
/**
|
||||
* 组件 Emits 定义
|
||||
@@ -43,7 +43,7 @@ defineProps<Props>();
|
||||
/**
|
||||
* 搜索参数模型,支持双向绑定
|
||||
*/
|
||||
const model = defineModel<Api.SystemManage.UserManagementRelationQueryReqVO>('model', {required: true});
|
||||
const model = defineModel<Api.SystemManage.UserManagementRelationQueryReqVO>('model', { required: true });
|
||||
|
||||
/**
|
||||
* 重置搜索
|
||||
@@ -83,7 +83,7 @@ function search() {
|
||||
<ElCol :lg="8" :md="12" :sm="12">
|
||||
<ElFormItem label="用户名" prop="subordinateUserId" style="margin-left: -50px">
|
||||
<ElSelect v-model="model.subordinateUserId" class="w-full" placeholder="请选择用户名" clearable filterable>
|
||||
<ElOption v-for="user in userList" :key="user.id" :label="user.nickname" :value="user.id"/>
|
||||
<ElOption v-for="user in userList" :key="user.id" :label="user.nickname" :value="user.id" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
|
||||
Reference in New Issue
Block a user