基本实现LocalTeacher界面的批量分组操作
This commit is contained in:
parent
3170f6d4b3
commit
1f9a5ce88c
|
@ -1,5 +1,5 @@
|
||||||
import { defHttp } from '/@/utils/http/axios';
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
import { useMessage } from "/@/hooks/web/useMessage";
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
const { createConfirm } = useMessage();
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ enum Api {
|
||||||
importExcel = '/CEES/ceesLocalTeacher/importExcel',
|
importExcel = '/CEES/ceesLocalTeacher/importExcel',
|
||||||
exportXls = '/CEES/ceesLocalTeacher/exportXls',
|
exportXls = '/CEES/ceesLocalTeacher/exportXls',
|
||||||
updateGroupUser = '/cees/ceesGroup/updateGroupUser',
|
updateGroupUser = '/cees/ceesGroup/updateGroupUser',
|
||||||
|
batchGroup = '/CEES/ceesLocalTeacher/batchGroup',
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取分组
|
//获取分组
|
||||||
|
@ -32,8 +33,7 @@ export const getImportUrl = Api.importExcel;
|
||||||
* 列表接口
|
* 列表接口
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const list = (params) =>
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
defHttp.get({url: Api.list, params});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单个
|
* 删除单个
|
||||||
|
@ -42,7 +42,7 @@ export const deleteOne = (params,handleSuccess) => {
|
||||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
handleSuccess();
|
handleSuccess();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
* @param params
|
* @param params
|
||||||
|
@ -58,26 +58,45 @@ export const batchDelete = (params, handleSuccess) => {
|
||||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
handleSuccess();
|
handleSuccess();
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
/**
|
||||||
|
* 批量分组
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const batchGroup = (params, handleSuccess) => {
|
||||||
|
console.log('params', params);
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认分组',
|
||||||
|
content: '是否分组选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.post({ url: Api.batchGroup, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
//更新分组中间表
|
//更新分组中间表
|
||||||
export const updateGroupUser = (params) => {
|
export const updateGroupUser = (params) => {
|
||||||
return defHttp.post({ url: Api.updateGroupUser, params });
|
return defHttp.post({ url: Api.updateGroupUser, params });
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存或者更新
|
* 保存或者更新
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const saveOrUpdate = (params, isUpdate) => {
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
let url = isUpdate ? Api.edit : Api.save;
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
// 更新分组中间表
|
// 更新分组中间表
|
||||||
const groupUserParams = {
|
const groupUserParams = {
|
||||||
userId: params.userId,
|
userId: params.userId,
|
||||||
groupId: params.groupId
|
groupId: params.groupId,
|
||||||
}
|
};
|
||||||
updateGroupUser(groupUserParams);
|
updateGroupUser(groupUserParams);
|
||||||
return defHttp.post({ url: url, params });
|
return defHttp.post({ url: url, params });
|
||||||
}
|
};
|
||||||
|
|
|
@ -14,9 +14,14 @@
|
||||||
<Icon icon="ant-design:delete-outlined" />
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
删除
|
删除
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
|
<a-menu-item key="1" @click="batchHandleGroup">
|
||||||
|
<Icon icon="ant-design:usergroup-add-outlined" />
|
||||||
|
分组
|
||||||
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</template>
|
</template>
|
||||||
<a-button>批量操作
|
<a-button
|
||||||
|
>批量操作
|
||||||
<Icon icon="mdi:chevron-down" />
|
<Icon icon="mdi:chevron-down" />
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
|
@ -40,6 +45,7 @@
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<!-- 表单区域 -->
|
<!-- 表单区域 -->
|
||||||
<CeesLocalTeacherModal @register="registerModal" @success="handleSuccess" />
|
<CeesLocalTeacherModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
<GroupSelectModal ref="groupModalRef" @register="registerGroupModal" @success="handleGroupSuccess" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -49,8 +55,9 @@ 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 CeesLocalTeacherModal from './components/CeesLocalTeacherModal.vue';
|
import CeesLocalTeacherModal from './components/CeesLocalTeacherModal.vue';
|
||||||
|
import GroupSelectModal from './components/GroupSelectModal.vue';
|
||||||
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesLocalTeacher.data';
|
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesLocalTeacher.data';
|
||||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup } from './CeesLocalTeacher.api';
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup, batchGroup } from './CeesLocalTeacher.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';
|
||||||
const queryParam = reactive<any>({});
|
const queryParam = reactive<any>({});
|
||||||
|
@ -58,6 +65,8 @@ const checkedKeys = ref<Array<string | number>>([]);
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
//注册model
|
//注册model
|
||||||
const [registerModal, { openModal }] = useModal();
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
const [registerGroupModal, { openModal: openGroupModal }] = useModal();
|
||||||
|
const groupModalRef = ref<any>(null);
|
||||||
//注册table数据
|
//注册table数据
|
||||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
tableProps: {
|
tableProps: {
|
||||||
|
@ -107,7 +116,7 @@ onMounted(async () => {
|
||||||
value: group.id, // 假设分组 ID 字段为 id
|
value: group.id, // 假设分组 ID 字段为 id
|
||||||
}));
|
}));
|
||||||
console.log('分组数据:', groupOptions.value);
|
console.log('分组数据:', groupOptions.value);
|
||||||
updateGroupOptions.updateGroupOptions(groupOptions.value)
|
updateGroupOptions.updateGroupOptions(groupOptions.value);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取分组数据失败:', error);
|
console.error('获取分组数据失败:', error);
|
||||||
}
|
}
|
||||||
|
@ -166,6 +175,28 @@ async function handleDelete(record) {
|
||||||
async function batchHandleDelete() {
|
async function batchHandleDelete() {
|
||||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 批量分组事件
|
||||||
|
*/
|
||||||
|
async function batchHandleGroup() {
|
||||||
|
//if (selectedRowKeys.value.length === 0) {
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
groupModalRef.value?.setGroupOptions(groupOptions.value);
|
||||||
|
openGroupModal(true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 分组选好后的确认事件
|
||||||
|
*/
|
||||||
|
async function handleGroupSuccess(groupId) {
|
||||||
|
console.log('asdfasd');
|
||||||
|
try {
|
||||||
|
console.log('111');
|
||||||
|
await batchGroup({ ids: selectedRowKeys.value, groupId }, handleSuccess);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('批量分组失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 成功回调
|
* 成功回调
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" title="所属分组" @ok="handleOk" :canFullscreen="false">
|
||||||
|
<div class="group-select-modal">
|
||||||
|
<div class="form-wrapper">
|
||||||
|
<div class="form-item">
|
||||||
|
<span class="required-label">所属分组:</span>
|
||||||
|
<a-select v-model:value="formState.groupId" placeholder="请选择所属分组" class="select-width">
|
||||||
|
<a-select-option v-for="item in groupOptions" :key="item.value" :value="item.value">
|
||||||
|
{{ item.label }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const formState = ref({
|
||||||
|
groupId: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
|
||||||
|
const [registerModal, { closeModal }] = useModalInner(async (data) => {
|
||||||
|
formState.value.groupId = null;
|
||||||
|
if (data?.options) {
|
||||||
|
groupOptions.value = data.options;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function setGroupOptions(options) {
|
||||||
|
groupOptions.value = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleOk() {
|
||||||
|
if (!formState.value.groupId) {
|
||||||
|
message.warning('请选择分组!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit('success', formState.value.groupId);
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
setGroupOptions,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.group-select-modal {
|
||||||
|
padding: 20px 24px;
|
||||||
|
|
||||||
|
.form-wrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.required-label {
|
||||||
|
white-space: nowrap;
|
||||||
|
&::before {
|
||||||
|
content: '*';
|
||||||
|
color: #ff4d4f;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-width {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in New Issue