修改合并错误
This commit is contained in:
parent
ba52357482
commit
c6f6a2431b
|
@ -16,15 +16,15 @@
|
|||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button>批量操作
|
||||
<a-button
|
||||
>批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<!-- 高级查询 -->
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
<!-- 新增生成账号按钮 -->
|
||||
<a-button type="primary" @click="showAutoGenerateForm = true" preIcon="ant-design:plus-outlined"> 生成账号
|
||||
</a-button>
|
||||
<a-button type="primary" @click="showAutoGenerateForm = true" preIcon="ant-design:plus-outlined"> 生成账号 </a-button>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
|
@ -49,8 +49,14 @@
|
|||
<CeesUserModal @register="registerModal" @success="handleSuccess" />
|
||||
|
||||
<!-- 生成账号表单 -->
|
||||
<a-modal v-model:visible="showAutoGenerateForm" title="生成账号" @ok="handleAutoGenerate"
|
||||
@cancel="showAutoGenerateForm = false" :width="600" :bodyStyle="{ padding: '24px' }">
|
||||
<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 class="form-item-custom" style="text-align: right">
|
||||
|
@ -58,8 +64,7 @@
|
|||
</a-form-item>
|
||||
|
||||
<a-form-item label="账号类型" class="form-item-custom">
|
||||
<a-select v-model="autoGenerateForm.group" placeholder="请选择账号类型" @change="handleGroupChange"
|
||||
class="select-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>
|
||||
|
@ -67,8 +72,7 @@
|
|||
</a-form-item>
|
||||
|
||||
<a-form-item v-if="isDisplay" label="专业" class="form-item-custom">
|
||||
<a-select v-model="autoGenerateForm.majorId" placeholder="请选择专业" @change="handleMajorChange"
|
||||
class="select-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>
|
||||
|
@ -76,8 +80,13 @@
|
|||
</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-input-number
|
||||
v-model="autoGenerateForm.num"
|
||||
:min="1"
|
||||
placeholder="请输入账号数量"
|
||||
@change="handleNumChange"
|
||||
class="input-number-custom"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
|
@ -127,16 +136,6 @@
|
|||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { ref, onMounted, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import CeesUserModal from './components/CeesUserModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesUser.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate, getGroup, generateAccount } from './CeesUser.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
// 表单相关状态
|
||||
const showAutoGenerateForm = ref(false); // 控制表单显示
|
||||
|
@ -210,225 +209,224 @@ import { message } from 'ant-design-vue';
|
|||
console.error('请求失败:', error); // 打印错误信息方便调试
|
||||
}
|
||||
};
|
||||
const handleGroupChange = (value) => {
|
||||
autoGenerateForm.group = value;
|
||||
if (value != 1) {
|
||||
isDisplay.value = true;
|
||||
} else {
|
||||
isDisplay.value = false;
|
||||
autoGenerateForm.majorId = undefined;
|
||||
}
|
||||
};
|
||||
const handleMajorChange = (value) => {
|
||||
autoGenerateForm.majorId = value;
|
||||
};
|
||||
const handleNumChange = (value) => {
|
||||
autoGenerateForm.num = value;
|
||||
}
|
||||
const handleGroupChange = (value) => {
|
||||
autoGenerateForm.group = value;
|
||||
if (value != 1) {
|
||||
isDisplay.value = true;
|
||||
} else {
|
||||
isDisplay.value = false;
|
||||
autoGenerateForm.majorId = undefined;
|
||||
}
|
||||
};
|
||||
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: 1 },
|
||||
{ id: 2, 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 && isDisplay.value == true) {
|
||||
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) => {
|
||||
console.log(res)
|
||||
if (res.code == 200) {
|
||||
message.success(res.message, 1.5);
|
||||
//清空表单
|
||||
autoGenerateForm.group = undefined;
|
||||
autoGenerateForm.majorId = undefined;
|
||||
autoGenerateForm.num = undefined;
|
||||
} else {
|
||||
message.error(res.message, 1.5);
|
||||
}
|
||||
|
||||
})
|
||||
} catch (error) {
|
||||
// 处理失败逻辑
|
||||
message.error('账号生成失败,请重试');
|
||||
} finally {
|
||||
showAutoGenerateForm.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 其他代码保持不变
|
||||
const queryParam = reactive<any>({});
|
||||
const checkedKeys = ref<Array<string | number>>([]);
|
||||
const userStore = useUserStore();
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: 'CEES用户表',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: false,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
fieldMapToNumber: [],
|
||||
fieldMapToTime: [],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: 'CEES用户表',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
||||
onMounted(async () => {
|
||||
fetchDefaultValues();
|
||||
try {
|
||||
const res = await getGroup();
|
||||
groupOptions.value = res.map((group) => ({
|
||||
label: group.name,
|
||||
value: group.id,
|
||||
}));
|
||||
updateGroupOptions.updateGroupOptions(groupOptions.value);
|
||||
} catch (error) {
|
||||
console.error('获取分组数据失败:', error);
|
||||
}
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).map((k) => {
|
||||
queryParam[k] = params[k];
|
||||
const autoGenerateForm = reactive({
|
||||
group: undefined, // 账号类型
|
||||
majorId: undefined, // 专业
|
||||
num: undefined, // 账号数量
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
// 账号类型选项
|
||||
const autoGeneratType = ref([
|
||||
{ id: 1, name: '行政人员', value: 1 },
|
||||
{ id: 2, name: '研究生', value: 2 },
|
||||
{ id: 2, name: '本校老师', value: 3 },
|
||||
{ id: 3, name: '外校老师', value: 4 },
|
||||
]);
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
// 专业选项
|
||||
const majors = ref([
|
||||
{ id: 1, name: '语文', value: 1 },
|
||||
{ id: 2, name: '地理', value: 4 },
|
||||
{ id: 3, name: '历史', value: 7 },
|
||||
{ id: 4, name: '政治', value: 8 },
|
||||
]);
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: false,
|
||||
});
|
||||
}
|
||||
// 生成账号逻辑
|
||||
const handleAutoGenerate = () => {
|
||||
console.log(autoGenerateForm);
|
||||
if (autoGenerateForm.group == undefined) {
|
||||
message.warning('请选择身份', 1.5);
|
||||
return;
|
||||
}
|
||||
if (autoGenerateForm.majorId == undefined && isDisplay.value == true) {
|
||||
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) => {
|
||||
console.log(res);
|
||||
if (res.code == 200) {
|
||||
message.success(res.message, 1.5);
|
||||
//清空表单
|
||||
autoGenerateForm.group = undefined;
|
||||
autoGenerateForm.majorId = undefined;
|
||||
autoGenerateForm.num = undefined;
|
||||
} else {
|
||||
message.error(res.message, 1.5);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
// 处理失败逻辑
|
||||
message.error('账号生成失败,请重试');
|
||||
} finally {
|
||||
showAutoGenerateForm.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
placement: 'topLeft',
|
||||
// 其他代码保持不变
|
||||
const queryParam = reactive<any>({});
|
||||
const checkedKeys = ref<Array<string | number>>([]);
|
||||
const userStore = useUserStore();
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: 'CEES用户表',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: false,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
fieldMapToNumber: [],
|
||||
fieldMapToTime: [],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
exportConfig: {
|
||||
name: 'CEES用户表',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
||||
onMounted(async () => {
|
||||
fetchDefaultValues();
|
||||
try {
|
||||
const res = await getGroup();
|
||||
groupOptions.value = res.map((group) => ({
|
||||
label: group.name,
|
||||
value: group.id,
|
||||
}));
|
||||
updateGroupOptions.updateGroupOptions(groupOptions.value);
|
||||
} catch (error) {
|
||||
console.error('获取分组数据失败:', error);
|
||||
}
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).map((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: false,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
placement: 'topLeft',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-item-custom {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.form-item-custom {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.select-custom {
|
||||
width: 100%;
|
||||
}
|
||||
.select-custom {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-number-custom {
|
||||
width: 100%;
|
||||
}
|
||||
.input-number-custom {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue