用户账号生成
This commit is contained in:
parent
22a68dae35
commit
d4589f5049
|
@ -6,10 +6,10 @@ VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
|
|
||||||
# 跨域代理,您可以配置多个 ,请注意,没有换行符
|
# 跨域代理,您可以配置多个 ,请注意,没有换行符
|
||||||
VITE_PROXY = [["/jeecgboot","http://localhost:8080/jeecg-boot"],["/upload","http://localhost:3300/upload"]]
|
VITE_PROXY = [["/jeecgboot","http://localhost:8091/jeecg-boot"],["/upload","http://localhost:3300/upload"]]
|
||||||
|
|
||||||
#后台接口全路径地址(必填)
|
#后台接口全路径地址(必填)
|
||||||
VITE_GLOB_DOMAIN_URL=http://localhost:8080/jeecg-boot
|
VITE_GLOB_DOMAIN_URL=http://localhost:8091/jeecg-boot
|
||||||
|
|
||||||
#后台接口父地址(必填)
|
#后台接口父地址(必填)
|
||||||
VITE_GLOB_API_URL=/jeecgboot
|
VITE_GLOB_API_URL=/jeecgboot
|
||||||
|
|
|
@ -4,14 +4,15 @@ import { useMessage } from "/@/hooks/web/useMessage";
|
||||||
const { createConfirm } = useMessage();
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
enum Api {
|
enum Api {
|
||||||
list = '/org.jeecg.modules/ceesUser/list',
|
list = '/cees/ceesUser/list',
|
||||||
save='/org.jeecg.modules/ceesUser/add',
|
save='/cees/ceesUser/add',
|
||||||
edit='/org.jeecg.modules/ceesUser/edit',
|
edit='/cees/ceesUser/edit',
|
||||||
deleteOne = '/org.jeecg.modules/ceesUser/delete',
|
deleteOne = '/cees/ceesUser/delete',
|
||||||
deleteBatch = '/org.jeecg.modules/ceesUser/deleteBatch',
|
deleteBatch = '/cees/ceesUser/deleteBatch',
|
||||||
importExcel = '/org.jeecg.modules/ceesUser/importExcel',
|
importExcel = '/cees/ceesUser/importExcel',
|
||||||
exportXls = '/org.jeecg.modules/ceesUser/exportXls',
|
exportXls = '/cees/ceesUser/exportXls',
|
||||||
updateGroupUser = '/cees/ceesGroup/updateGroupUser',
|
updateGroupUser = '/cees/ceesGroup/updateGroupUser',
|
||||||
|
createAccount = '/cees/ceesUser/createAccount'
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取分组
|
//获取分组
|
||||||
|
@ -80,3 +81,9 @@ export const saveOrUpdate = (params, isUpdate) => {
|
||||||
updateGroupUser(groupUserParams);
|
updateGroupUser(groupUserParams);
|
||||||
return defHttp.post({url: url, params});
|
return defHttp.post({url: url, params});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 生成账号
|
||||||
|
export const generateAccount = async (params) => {
|
||||||
|
const res = await defHttp.post({url: Api.createAccount, params});
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
|
@ -13,20 +13,20 @@ export const updateGroupOptions = reactive({
|
||||||
});
|
});
|
||||||
//列表数据
|
//列表数据
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{
|
|
||||||
title: '姓名',
|
|
||||||
align: 'center',
|
|
||||||
dataIndex: 'userName',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '用户身份码',
|
title: '用户身份码',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'userId',
|
dataIndex: 'userId',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '姓名',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'userName',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '用户专业ID',
|
title: '用户专业ID',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'userHeadingCode',
|
dataIndex: 'userMajorId',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '身份',
|
title: '身份',
|
||||||
|
@ -93,7 +93,7 @@ export const formSchema: FormSchema[] = [
|
||||||
options: [
|
options: [
|
||||||
{ label: '管理员', value: 1 },
|
{ label: '管理员', value: 1 },
|
||||||
{ label: '学生', value: 2 },
|
{ label: '学生', value: 2 },
|
||||||
{ label: '老师', value: 3 },
|
{ label: '本校老师', value: 3 },
|
||||||
{ label: '外校老师', value: 4 },
|
{ label: '外校老师', value: 4 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
<!-- 高级查询 -->
|
<!-- 高级查询 -->
|
||||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||||
|
<!-- 新增生成账号按钮 -->
|
||||||
|
<a-button type="primary" @click="showAutoGenerateForm = true" preIcon="ant-design:plus-outlined">
|
||||||
|
生成账号
|
||||||
|
</a-button>
|
||||||
</template>
|
</template>
|
||||||
<!--操作栏-->
|
<!--操作栏-->
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
|
@ -41,27 +45,139 @@
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
|
|
||||||
<!-- 表单区域 -->
|
<!-- 表单区域 -->
|
||||||
<CeesUserModal @register="registerModal" @success="handleSuccess" />
|
<CeesUserModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
|
||||||
|
<!-- 生成账号表单 -->
|
||||||
|
<a-modal v-model:visible="showAutoGenerateForm" title="生成账号" @ok="handleAutoGenerate"
|
||||||
|
@cancel="showAutoGenerateForm = false" :width="600" :bodyStyle="{ padding: '24px' }">
|
||||||
|
<a-form :model="autoGenerateForm" layout="vertical">
|
||||||
|
<a-form-item label="账号类型" class="form-item-custom">
|
||||||
|
<a-select v-model="autoGenerateForm.group" placeholder="请选择账号类型" @change="handleGroupChange"
|
||||||
|
class="select-custom">
|
||||||
|
<a-select-option v-for="item in autoGeneratType" :key="item.id" :value="item.value">
|
||||||
|
{{ item.name }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="专业" class="form-item-custom">
|
||||||
|
<a-select v-model="autoGenerateForm.majorId" placeholder="请选择专业" @change="handleMajorChange"
|
||||||
|
class="select-custom">
|
||||||
|
<a-select-option v-for="item in majors" :key="item.id" :value="item.value">
|
||||||
|
{{ item.name }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="账号数量" class="form-item-custom">
|
||||||
|
<a-input-number v-model="autoGenerateForm.num" :min="1" placeholder="请输入账号数量" @change="handleNumChange"
|
||||||
|
class="input-number-custom" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" name="org.jeecg.modules-ceesUser" setup>
|
<script lang="ts" name="org.jeecg.modules-ceesUser" setup>
|
||||||
import { ref, onMounted, reactive, computed, unref } from 'vue';
|
import { ref, onMounted, reactive } from 'vue';
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import { useListPage } from '/@/hooks/system/useListPage';
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
import CeesUserModal from './components/CeesUserModal.vue';
|
import CeesUserModal from './components/CeesUserModal.vue';
|
||||||
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesUser.data';
|
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesUser.data';
|
||||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate, getGroup } from './CeesUser.api';
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate, getGroup, generateAccount } from './CeesUser.api';
|
||||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
|
||||||
|
// 表单相关状态
|
||||||
|
const showAutoGenerateForm = ref(false); // 控制表单显示
|
||||||
|
|
||||||
|
const handleGroupChange = (value) => {
|
||||||
|
autoGenerateForm.group = value;
|
||||||
|
};
|
||||||
|
const handleMajorChange = (value) => {
|
||||||
|
autoGenerateForm.majorId = value;
|
||||||
|
};
|
||||||
|
const handleNumChange = (value) => {
|
||||||
|
autoGenerateForm.num = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const autoGenerateForm = reactive({
|
||||||
|
group: undefined, // 账号类型
|
||||||
|
majorId: undefined, // 专业
|
||||||
|
num: undefined, // 账号数量
|
||||||
|
});
|
||||||
|
|
||||||
|
// 账号类型选项
|
||||||
|
const autoGeneratType = ref([
|
||||||
|
{ id: 1, name: '研究生', value: 2 },
|
||||||
|
{ id: 2, name: '本校老师', value: 3 },
|
||||||
|
{ id: 3, name: "外校老师", value: 4 }
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 专业选项
|
||||||
|
const majors = ref([
|
||||||
|
{ id: 1, name: '语文', value: 1 },
|
||||||
|
{ id: 2, name: '地理', value: 4 },
|
||||||
|
{ id: 3, name: '历史', value: 7 },
|
||||||
|
{ id: 4, name: '政治', value: 8 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 生成账号逻辑
|
||||||
|
const handleAutoGenerate = () => {
|
||||||
|
console.log(autoGenerateForm)
|
||||||
|
if (autoGenerateForm.group == undefined) {
|
||||||
|
message.warning('请选择身份', 1.5);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (autoGenerateForm.majorId == undefined) {
|
||||||
|
message.warning('请选择专业', 1.5);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (autoGenerateForm.num == undefined) {
|
||||||
|
message.warning('请输入账号数量', 1.5);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 账号数量小于500并且大于0
|
||||||
|
if (autoGenerateForm.num <= 0) {
|
||||||
|
message.warning('账号数量必须大于0', 1.5);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (autoGenerateForm.num > 500) {
|
||||||
|
message.warning('账号数量不能大于500', 1.5);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 调用生成账号的 API 或逻辑
|
||||||
|
try {
|
||||||
|
generateAccount(autoGenerateForm).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
message.success('生成账号成功', 1.5);
|
||||||
|
//清空表单
|
||||||
|
autoGenerateForm.group = undefined;
|
||||||
|
autoGenerateForm.majorId = undefined;
|
||||||
|
autoGenerateForm.num = undefined;
|
||||||
|
} else {
|
||||||
|
message.error('生成账号失败', 1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
// 处理失败逻辑
|
||||||
|
message.error('账号生成失败,请重试');
|
||||||
|
} finally {
|
||||||
|
showAutoGenerateForm.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 其他代码保持不变
|
||||||
const queryParam = reactive<any>({});
|
const queryParam = reactive<any>({});
|
||||||
const checkedKeys = ref<Array<string | number>>([]);
|
const checkedKeys = ref<Array<string | number>>([]);
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
//注册model
|
|
||||||
const [registerModal, { openModal }] = useModal();
|
const [registerModal, { openModal }] = useModal();
|
||||||
//注册table数据
|
|
||||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
tableProps: {
|
tableProps: {
|
||||||
title: 'CEES用户表',
|
title: 'CEES用户表',
|
||||||
|
@ -69,7 +185,6 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
columns,
|
columns,
|
||||||
canResize: false,
|
canResize: false,
|
||||||
formConfig: {
|
formConfig: {
|
||||||
//labelWidth: 120,
|
|
||||||
schemas: searchFormSchema,
|
schemas: searchFormSchema,
|
||||||
autoSubmitOnEnter: true,
|
autoSubmitOnEnter: true,
|
||||||
showAdvancedButton: true,
|
showAdvancedButton: true,
|
||||||
|
@ -95,59 +210,37 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 在组件加载时获取分组数据
|
|
||||||
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getGroup();
|
const res = await getGroup();
|
||||||
groupOptions.value = res.map((group) => ({
|
groupOptions.value = res.map((group) => ({
|
||||||
label: group.name, // 假设分组名称字段为 name
|
label: group.name,
|
||||||
value: group.id, // 假设分组 ID 字段为 id
|
value: group.id,
|
||||||
}));
|
}));
|
||||||
updateGroupOptions.updateGroupOptions(groupOptions.value);
|
updateGroupOptions.updateGroupOptions(groupOptions.value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取分组数据失败:', error);
|
console.error('获取分组数据失败:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const workloadSeen = ref(true);
|
|
||||||
const handleWordLoadBlur = (record) => {
|
|
||||||
console.log(record);
|
|
||||||
saveOrUpdate(record, true);
|
|
||||||
record.seen = false;
|
|
||||||
//workloadSeen.value = true;
|
|
||||||
};
|
|
||||||
const handleWordloadClick = (record) => {
|
|
||||||
//workloadSeen.value = false;
|
|
||||||
record.seen = true;
|
|
||||||
console.log(111);
|
|
||||||
};
|
|
||||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
|
||||||
|
|
||||||
// 高级查询配置
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
const superQueryConfig = reactive(superQuerySchema);
|
const superQueryConfig = reactive(superQuerySchema);
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级查询事件
|
|
||||||
*/
|
|
||||||
function handleSuperQuery(params) {
|
function handleSuperQuery(params) {
|
||||||
Object.keys(params).map((k) => {
|
Object.keys(params).map((k) => {
|
||||||
queryParam[k] = params[k];
|
queryParam[k] = params[k];
|
||||||
});
|
});
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 新增事件
|
|
||||||
*/
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
openModal(true, {
|
openModal(true, {
|
||||||
isUpdate: false,
|
isUpdate: false,
|
||||||
showFooter: true,
|
showFooter: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 编辑事件
|
|
||||||
*/
|
|
||||||
function handleEdit(record: Recordable) {
|
function handleEdit(record: Recordable) {
|
||||||
openModal(true, {
|
openModal(true, {
|
||||||
record,
|
record,
|
||||||
|
@ -155,9 +248,7 @@ function handleEdit(record: Recordable) {
|
||||||
showFooter: true,
|
showFooter: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 详情
|
|
||||||
*/
|
|
||||||
function handleDetail(record: Recordable) {
|
function handleDetail(record: Recordable) {
|
||||||
openModal(true, {
|
openModal(true, {
|
||||||
record,
|
record,
|
||||||
|
@ -165,27 +256,19 @@ function handleDetail(record: Recordable) {
|
||||||
showFooter: false,
|
showFooter: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 删除事件
|
|
||||||
*/
|
|
||||||
async function handleDelete(record) {
|
async function handleDelete(record) {
|
||||||
await deleteOne({ id: record.id }, handleSuccess);
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 批量删除事件
|
|
||||||
*/
|
|
||||||
async function batchHandleDelete() {
|
async function batchHandleDelete() {
|
||||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 成功回调
|
|
||||||
*/
|
|
||||||
function handleSuccess() {
|
function handleSuccess() {
|
||||||
(selectedRowKeys.value = []) && reload();
|
(selectedRowKeys.value = []) && reload();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 操作栏
|
|
||||||
*/
|
|
||||||
function getTableAction(record) {
|
function getTableAction(record) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
@ -194,9 +277,7 @@ function getTableAction(record) {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 下拉操作栏
|
|
||||||
*/
|
|
||||||
function getDropDownAction(record) {
|
function getDropDownAction(record) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
@ -215,4 +296,16 @@ function getDropDownAction(record) {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
.form-item-custom {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-custom {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-number-custom {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
let formData = {};
|
let formData = {};
|
||||||
const queryByIdUrl = '/org.jeecg.modules/ceesUser/queryById';
|
const queryByIdUrl = '/cees/ceesUser/queryById';
|
||||||
async function initFormData() {
|
async function initFormData() {
|
||||||
let params = { id: props.formData.dataId };
|
let params = { id: props.formData.dataId };
|
||||||
const data = await defHttp.get({ url: queryByIdUrl, params });
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
|
Loading…
Reference in New Issue