page: 📄 用户CURD,删除部分表格操作新增功能
This commit is contained in:
parent
12b2902433
commit
2c9785d915
|
@ -0,0 +1,30 @@
|
|||
import { http } from '@/api/service/request';
|
||||
import type { BaseResult, ResultTable } from '@/api/service/types';
|
||||
|
||||
/**
|
||||
* 用户信息---获取用户信息列表
|
||||
*/
|
||||
export const fetchGetAdminUserList = (data: any) => {
|
||||
return http.request<BaseResult<ResultTable>>('get', `user/getAdminUserList/${data.currentPage}/${data.pageSize}`, { params: data });
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户信息---添加用户信息
|
||||
*/
|
||||
export const fetchAddAdminUser = (data: any) => {
|
||||
return http.request<BaseResult<object>>('post', 'user/addAdminUser', { data });
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户信息---更新用户信息
|
||||
*/
|
||||
export const fetchUpdateAdminUser = (data: any) => {
|
||||
return http.request<BaseResult<object>>('put', 'user/updateAdminUser', { data });
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户信息---删除用户信息
|
||||
*/
|
||||
export const fetchDeleteAdminUser = (data: any) => {
|
||||
return http.request<BaseResult<object>>('delete', 'user/deleteAdminUser', { data });
|
||||
};
|
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.3 KiB |
|
@ -0,0 +1,87 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { fetchAddAdminUser, fetchDeleteAdminUser, fetchGetAdminUserList, fetchUpdateAdminUser } from '@/api/v1/adminUser';
|
||||
import { pageSizes } from '@/enums/baseConstant';
|
||||
import { storeMessage } from '@/utils/message';
|
||||
import { storePagination } from '@/store/useStorePagination';
|
||||
|
||||
/**
|
||||
* 用户信息 Store
|
||||
*/
|
||||
export const useAdminUserStore = defineStore('adminUserStore', {
|
||||
state() {
|
||||
return {
|
||||
// 用户信息列表
|
||||
datalist: [],
|
||||
// 查询表单
|
||||
form: {
|
||||
// 用户名
|
||||
username: undefined,
|
||||
// 昵称
|
||||
nickName: undefined,
|
||||
// 邮箱
|
||||
email: undefined,
|
||||
// 手机号
|
||||
phone: undefined,
|
||||
// 性别
|
||||
sex: undefined,
|
||||
// 个人描述
|
||||
summary: undefined,
|
||||
// 状态
|
||||
status: undefined,
|
||||
},
|
||||
// 分页查询结果
|
||||
pagination: {
|
||||
currentPage: 1,
|
||||
pageSize: 150,
|
||||
total: 100,
|
||||
pageSizes,
|
||||
},
|
||||
// 加载
|
||||
loading: false,
|
||||
};
|
||||
},
|
||||
getters: {},
|
||||
actions: {
|
||||
/**
|
||||
* * 获取用户信息
|
||||
*/
|
||||
async getAdminUserList() {
|
||||
// 整理请求参数
|
||||
const data = { ...this.pagination, ...this.form };
|
||||
delete data.pageSizes;
|
||||
delete data.total;
|
||||
delete data.background;
|
||||
|
||||
// 获取用户信息列表
|
||||
const result = await fetchGetAdminUserList(data);
|
||||
|
||||
// 公共页面函数hook
|
||||
const pagination = storePagination.bind(this);
|
||||
return pagination(result);
|
||||
},
|
||||
|
||||
/**
|
||||
* * 添加用户信息
|
||||
*/
|
||||
async addAdminUser(data: any) {
|
||||
const result = await fetchAddAdminUser(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
|
||||
/**
|
||||
* * 修改用户信息
|
||||
*/
|
||||
async updateAdminUser(data: any) {
|
||||
const result = await fetchUpdateAdminUser(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
|
||||
/**
|
||||
* * 删除用户信息
|
||||
*/
|
||||
async deleteAdminUser(data: any) {
|
||||
const result = await fetchDeleteAdminUser(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
},
|
||||
});
|
|
@ -14,8 +14,6 @@ export const usePowerStore = defineStore('powerStore', {
|
|||
datalist: [],
|
||||
// 查询表单
|
||||
form: {
|
||||
// 父级id
|
||||
parentId: undefined,
|
||||
// 权限编码
|
||||
powerCode: undefined,
|
||||
// 权限名称
|
||||
|
|
|
@ -117,7 +117,6 @@ onMounted(() => {
|
|||
|
||||
<template #operation="{ row }">
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify') }} </el-button>
|
||||
<el-button v-show="row.menuType !== 3" :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary"> {{ $t('add_new') }} </el-button>
|
||||
<el-popconfirm :title="`${$t('confirm_delete')} ${row.translation}`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
|
|
|
@ -80,7 +80,6 @@ onMounted(() => {
|
|||
|
||||
<template #operation="{ row }">
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify') }} </el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
|
||||
<el-popconfirm :title="`是否确认删除 ${row.typeName}数据`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { rules } from '@/views/system/adminUser/utils/columns';
|
||||
import { FormProps } from '@/views/system/adminUser/utils/types';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
|
||||
const props = withDefaults(defineProps<FormProps>(), {
|
||||
formInline: () => ({
|
||||
// 用户名
|
||||
username: undefined,
|
||||
// 昵称
|
||||
nickName: undefined,
|
||||
// 邮箱
|
||||
email: undefined,
|
||||
// 手机号
|
||||
phone: undefined,
|
||||
// 密码
|
||||
password: undefined,
|
||||
// 头像
|
||||
avatar: undefined,
|
||||
// 性别
|
||||
sex: undefined,
|
||||
// 个人描述
|
||||
summary: undefined,
|
||||
// 状态
|
||||
status: undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = ref(props.formInline);
|
||||
|
||||
defineExpose({ formRef });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||
<el-form-item :label="$t('adminUser_username')" prop="username">
|
||||
<el-input v-model="form.username" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_nickName')" prop="nickName">
|
||||
<el-input v-model="form.nickName" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_email')" prop="email">
|
||||
<el-input v-model="form.email" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_phone')" prop="phone">
|
||||
<el-input v-model="form.phone" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_password')" prop="password">
|
||||
<el-input v-model="form.password" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_avatar')" prop="avatar">
|
||||
<el-input v-model="form.avatar" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_sex')" prop="sex">
|
||||
<el-input v-model="form.sex" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_summary')" prop="summary">
|
||||
<el-input v-model="form.summary" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_status')" prop="status">
|
||||
<el-input v-model="form.status" autocomplete="off" type="text" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
|
@ -0,0 +1,175 @@
|
|||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { columns } from '@/views/system/adminUser/utils/columns';
|
||||
import PureTableBar from '@/components/TableBar/src/bar';
|
||||
import AddFill from '@iconify-icons/ri/add-circle-line';
|
||||
import PureTable from '@pureadmin/table';
|
||||
import { onAdd, onDelete, onSearch, onUpdate } from '@/views/system/adminUser/utils/hooks';
|
||||
import Delete from '@iconify-icons/ep/delete';
|
||||
import EditPen from '@iconify-icons/ep/edit-pen';
|
||||
import Refresh from '@iconify-icons/ep/refresh';
|
||||
import { selectUserinfo } from '@/components/Table/Userinfo/columns';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import { useAdminUserStore } from '@/store/system/adminUser.ts';
|
||||
import { useRenderIcon } from '@/components/CommonIcon/src/hooks';
|
||||
import userAvatar from '@/assets/user.jpg';
|
||||
import Upload from '@iconify-icons/ri/upload-line';
|
||||
import Role from '@iconify-icons/ri/admin-line';
|
||||
import Password from '@iconify-icons/ri/lock-password-line';
|
||||
import More from '@iconify-icons/ep/more-filled';
|
||||
|
||||
const tableRef = ref();
|
||||
const formRef = ref();
|
||||
const adminUserStore = useAdminUserStore();
|
||||
|
||||
const handleUpdate = row => {
|
||||
console.log(row);
|
||||
};
|
||||
|
||||
/**
|
||||
* * 上传头像
|
||||
*/
|
||||
const onUploadAvatar = (row: any) => {};
|
||||
|
||||
/**
|
||||
* * 重置密码
|
||||
* @param row
|
||||
*/
|
||||
const onResetPassword = (row: any) => {};
|
||||
|
||||
/**
|
||||
* 为用户分配角色
|
||||
* @param row
|
||||
*/
|
||||
const onAssignRolesToUser = (row: any) => {};
|
||||
|
||||
/**
|
||||
* 重置表单
|
||||
* @param formEl
|
||||
*/
|
||||
const resetForm = async formEl => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
await onSearch();
|
||||
};
|
||||
|
||||
/**
|
||||
* * 按钮类
|
||||
*/
|
||||
const buttonClass = computed(() => ['!h-[20px]', 'reset-margin', '!text-gray-500', 'dark:!text-white', 'dark:hover:!text-primary']);
|
||||
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="adminUserStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
||||
<el-form-item :label="$t('adminUser_username')" prop="username">
|
||||
<el-input v-model="adminUserStore.form.username" :placeholder="`${$t('input')}${$t('adminUser_username')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_nickName')" prop="nickName">
|
||||
<el-input v-model="adminUserStore.form.nickName" :placeholder="`${$t('input')}${$t('adminUser_nickName')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_email')" prop="email">
|
||||
<el-input v-model="adminUserStore.form.email" :placeholder="`${$t('input')}${$t('adminUser_email')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_phone')" prop="phone">
|
||||
<el-input v-model="adminUserStore.form.phone" :placeholder="`${$t('input')}${$t('adminUser_phone')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_sex')" prop="sex">
|
||||
<el-input v-model="adminUserStore.form.sex" :placeholder="`${$t('input')}${$t('adminUser_sex')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_summary')" prop="summary">
|
||||
<el-input v-model="adminUserStore.form.summary" :placeholder="`${$t('input')}${$t('adminUser_summary')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('adminUser_status')" prop="status">
|
||||
<el-input v-model="adminUserStore.form.status" :placeholder="`${$t('input')}${$t('adminUser_status')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :icon="useRenderIcon('ri:search-line')" :loading="adminUserStore.loading" type="primary" @click="onSearch"> {{ $t('search') }} </el-button>
|
||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<PureTableBar :columns="columns" title="用户信息" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> 添加用户信息</el-button>
|
||||
</template>
|
||||
|
||||
<template v-slot="{ size, dynamicColumns }">
|
||||
<pure-table
|
||||
ref="tableRef"
|
||||
:adaptiveConfig="{ offsetBottom: 45 }"
|
||||
:columns="dynamicColumns"
|
||||
:data="adminUserStore.datalist"
|
||||
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
||||
:loading="adminUserStore.loading"
|
||||
:size="size"
|
||||
adaptive
|
||||
align-whole="center"
|
||||
border
|
||||
highlight-current-row
|
||||
row-key="id"
|
||||
showOverflowTooltip
|
||||
table-layout="auto"
|
||||
>
|
||||
<template #avatar="{ row }">
|
||||
<el-image :preview-src-list="Array.of(row.avatar || userAvatar)" :src="row.avatar || userAvatar" class="w-[24px] h-[24px] rounded-full align-middle" fit="cover" preview-teleported />
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
<el-switch v-model="row.status" active-text="禁用" class="ml-2" inactive-text="启用" inline-prompt style="
|
||||
|
||||
--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66" />
|
||||
</template>
|
||||
|
||||
<template #sex="{ row }">
|
||||
<el-tag :type="row.sex === 0 ? 'danger' : null" effect="plain"> {{ row.sex === 1 ? '男' : '女' }}</el-tag>
|
||||
</template>
|
||||
|
||||
<template #createUser="{ row }">
|
||||
<el-button link type="primary" @click="selectUserinfo(row.createUser)">{{ $t('table.createUser') }} </el-button>
|
||||
</template>
|
||||
|
||||
<template #updateUser="{ row }">
|
||||
<el-button link type="primary" @click="selectUserinfo(row.updateUser)">{{ $t('table.updateUser') }} </el-button>
|
||||
</template>
|
||||
|
||||
<template #operation="{ row }">
|
||||
<!-- 修改 -->
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify') }} </el-button>
|
||||
|
||||
<!-- 删除 -->
|
||||
<el-popconfirm :title="`是否确认删除 ${row.username}数据`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
{{ $t('delete') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
|
||||
<!-- 更多操作 -->
|
||||
<el-dropdown>
|
||||
<el-button :icon="useRenderIcon(More)" :size="size" class="ml-3 mt-[2px]" link type="primary" @click="handleUpdate(row)" />
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-button :class="buttonClass" :icon="useRenderIcon(Upload)" :size="size" link type="primary" @click="onUploadAvatar(row)"> 上传头像 </el-button>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-button :class="buttonClass" :icon="useRenderIcon(Password)" :size="size" link type="primary" @click="onResetPassword(row)"> 重置密码 </el-button>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-button :class="buttonClass" :icon="useRenderIcon(Role)" :size="size" link type="primary" @click="onAssignRolesToUser(row)"> 分配角色 </el-button>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</pure-table>
|
||||
</template>
|
||||
</PureTableBar>
|
||||
</div>
|
||||
</template>
|
|
@ -0,0 +1,52 @@
|
|||
import { reactive } from 'vue';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
|
||||
// 表格列
|
||||
export const columns: TableColumnList = [
|
||||
{ type: 'index', index: (index: number) => index + 1 },
|
||||
// 主键
|
||||
{ label: $t('id'), prop: 'id' },
|
||||
// 用户名
|
||||
{ label: $t('adminUser_username'), prop: 'username', width: 260 },
|
||||
// 状态
|
||||
{ label: $t('adminUser_status'), prop: 'status', slot: 'status' },
|
||||
// 昵称
|
||||
{ label: $t('adminUser_nickName'), prop: 'nickName', width: 260 },
|
||||
// 邮箱
|
||||
{ label: $t('adminUser_email'), prop: 'email', width: 260 },
|
||||
// 手机号
|
||||
{ label: $t('adminUser_phone'), prop: 'phone', width: 160 },
|
||||
// 头像
|
||||
{ label: $t('adminUser_avatar'), prop: 'avatar', slot: 'avatar' },
|
||||
// 性别
|
||||
{ label: $t('adminUser_sex'), prop: 'sex', slot: 'sex' },
|
||||
// 个人描述
|
||||
{ label: $t('adminUser_summary'), prop: 'summary', width: 460 },
|
||||
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160, fixed: 'right' },
|
||||
{ label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160, fixed: 'right' },
|
||||
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 90, fixed: 'right' },
|
||||
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 90, fixed: 'right' },
|
||||
{ label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' },
|
||||
];
|
||||
|
||||
// 添加规则
|
||||
export const rules = reactive({
|
||||
// 用户名
|
||||
username: [{ required: true, message: `${$t('input')}${$t('adminUser_username')}`, trigger: 'blur' }],
|
||||
// 昵称
|
||||
nickName: [{ required: true, message: `${$t('input')}${$t('adminUser_nickName')}`, trigger: 'blur' }],
|
||||
// 邮箱
|
||||
email: [{ required: true, message: `${$t('input')}${$t('adminUser_email')}`, trigger: 'blur' }],
|
||||
// 手机号
|
||||
phone: [{ required: true, message: `${$t('input')}${$t('adminUser_phone')}`, trigger: 'blur' }],
|
||||
// 密码
|
||||
password: [{ required: true, message: `${$t('input')}${$t('adminUser_password')}`, trigger: 'blur' }],
|
||||
// 头像
|
||||
avatar: [{ required: true, message: `${$t('input')}${$t('adminUser_avatar')}`, trigger: 'blur' }],
|
||||
// 性别
|
||||
sex: [{ required: true, message: `${$t('input')}${$t('adminUser_sex')}`, trigger: 'blur' }],
|
||||
// 个人描述
|
||||
summary: [{ required: true, message: `${$t('input')}${$t('adminUser_summary')}`, trigger: 'blur' }],
|
||||
// 状态
|
||||
status: [{ required: true, message: `${$t('input')}${$t('adminUser_status')}`, trigger: 'blur' }],
|
||||
});
|
|
@ -0,0 +1,116 @@
|
|||
import { addDialog } from '@/components/BaseDialog/index';
|
||||
import AdminUserDialog from '@/views/system/adminUser/admin-user-dialog.vue';
|
||||
import { useAdminUserStore } from '@/store/system/adminUser.ts';
|
||||
import { h, ref } from 'vue';
|
||||
import { messageBox } from '@/utils/message';
|
||||
import type { FormItemProps } from '@/views/system/adminUser/utils/types';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
|
||||
export const formRef = ref();
|
||||
const adminUserStore = useAdminUserStore();
|
||||
|
||||
/**
|
||||
* * 搜索初始化用户信息
|
||||
*/
|
||||
export async function onSearch() {
|
||||
adminUserStore.loading = true;
|
||||
await adminUserStore.getAdminUserList();
|
||||
adminUserStore.loading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 添加用户信息
|
||||
*/
|
||||
export function onAdd() {
|
||||
addDialog({
|
||||
title: `${$t('add_new')}${$t('adminUser')}`,
|
||||
width: '30%',
|
||||
props: {
|
||||
formInline: {
|
||||
username: undefined,
|
||||
nickName: undefined,
|
||||
email: undefined,
|
||||
phone: undefined,
|
||||
password: undefined,
|
||||
avatar: undefined,
|
||||
sex: undefined,
|
||||
summary: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(AdminUserDialog, { ref: formRef }),
|
||||
beforeSure: (done, { options }) => {
|
||||
const form = options.props.formInline as FormItemProps;
|
||||
formRef.value.formRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
|
||||
const result = await adminUserStore.addAdminUser(form);
|
||||
if (!result) return;
|
||||
done();
|
||||
await onSearch();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* * 更新用户信息
|
||||
* @param row
|
||||
*/
|
||||
export function onUpdate(row: any) {
|
||||
addDialog({
|
||||
title: `${$t('modify')}${$t('adminUser')}`,
|
||||
width: '30%',
|
||||
props: {
|
||||
formInline: {
|
||||
username: row.username,
|
||||
nickName: row.nickName,
|
||||
email: row.email,
|
||||
phone: row.phone,
|
||||
password: row.password,
|
||||
avatar: row.avatar,
|
||||
sex: row.sex,
|
||||
summary: row.summary,
|
||||
status: row.status,
|
||||
},
|
||||
},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(AdminUserDialog, { ref: formRef }),
|
||||
beforeSure: (done, { options }) => {
|
||||
const form = options.props.formInline as FormItemProps;
|
||||
formRef.value.formRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
|
||||
const result = await adminUserStore.updateAdminUser({ ...form, id: row.id });
|
||||
if (!result) return;
|
||||
done();
|
||||
await onSearch();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* * 删除用户信息
|
||||
*/
|
||||
export const onDelete = async (row: any) => {
|
||||
const id = row.id;
|
||||
|
||||
// 是否确认删除
|
||||
const result = await messageBox({
|
||||
title: $t('confirm_delete'),
|
||||
showMessage: false,
|
||||
confirmMessage: undefined,
|
||||
cancelMessage: $t('cancel_delete'),
|
||||
});
|
||||
if (!result) return;
|
||||
|
||||
// 删除数据
|
||||
await adminUserStore.deleteAdminUser([id]);
|
||||
await onSearch();
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
// 添加或者修改表单元素
|
||||
export interface FormItemProps {
|
||||
// 用户名
|
||||
username: string;
|
||||
// 昵称
|
||||
nickName: string;
|
||||
// 邮箱
|
||||
email: string;
|
||||
// 手机号
|
||||
phone: string;
|
||||
// 密码
|
||||
password: string;
|
||||
// 头像
|
||||
avatar: string;
|
||||
// 性别
|
||||
sex: number;
|
||||
// 个人描述
|
||||
summary: string;
|
||||
// 状态
|
||||
status: boolean;
|
||||
}
|
||||
|
||||
// 添加或修改表单Props
|
||||
export interface FormProps {
|
||||
formInline: FormItemProps;
|
||||
}
|
|
@ -98,7 +98,6 @@ onMounted(() => {
|
|||
|
||||
<template #operation="{ row }">
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify') }} </el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
|
||||
<el-popconfirm :title="`是否确认删除 ${row.iconName}数据`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { columns } from '@/views/system/power/utils/columns';
|
||||
import PureTableBar from '@/components/TableBar/src/bar';
|
||||
import AddFill from '@iconify-icons/ri/add-circle-line';
|
||||
|
@ -35,6 +35,11 @@ const resetForm = async formEl => {
|
|||
await onSearch();
|
||||
};
|
||||
|
||||
/**
|
||||
* * 按钮类
|
||||
*/
|
||||
const buttonClass = computed(() => ['!h-[20px]', 'reset-margin', '!text-gray-500', 'dark:!text-white', 'dark:hover:!text-primary']);
|
||||
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
|
@ -43,9 +48,6 @@ onMounted(() => {
|
|||
<template>
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="powerStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
||||
<el-form-item :label="$t('power_parentId')" prop="parentId">
|
||||
<el-input v-model="powerStore.form.parentId" :placeholder="`${$t('input')}${$t('power_parentId')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('power_powerCode')" prop="powerCode">
|
||||
<el-input v-model="powerStore.form.powerCode" :placeholder="`${$t('input')}${$t('power_powerCode')}`" class="!w-[180px]" clearable />
|
||||
</el-form-item>
|
||||
|
@ -99,8 +101,10 @@ onMounted(() => {
|
|||
</template>
|
||||
|
||||
<template #operation="{ row }">
|
||||
<!-- 修改 -->
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify') }} </el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
|
||||
|
||||
<!-- 删除 -->
|
||||
<el-popconfirm :title="`是否确认删除 ${row.powerName}数据`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
|
|
|
@ -93,7 +93,6 @@ onMounted(() => {
|
|||
|
||||
<template #operation="{ row }">
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify') }} </el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
|
||||
<el-popconfirm :title="`是否确认删除 ${row.roleCode}数据`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
|
|
Loading…
Reference in New Issue