|
@@ -1,77 +1,80 @@
|
|
|
+<template>
|
|
|
+ <BasicModal
|
|
|
+ @ok="handleSubmit"
|
|
|
+ :destroyOnClose="true"
|
|
|
+ :maskClosable="false"
|
|
|
+ v-bind="$attrs"
|
|
|
+ @register="registerModal"
|
|
|
+ :title="getTitle"
|
|
|
+ :width="1002"
|
|
|
+ showFooter
|
|
|
+ >
|
|
|
+ <BasicForm @register="registerForm">
|
|
|
+ <template #studentIds>
|
|
|
+ <div class="flex" style="flex-wrap: wrap">
|
|
|
+ <div v-for="(item, index) in modelRef" :key="index">
|
|
|
+ <div style="margin: 4px" v-if="index < 6"> {{ item.name }}</div>
|
|
|
+ </div>
|
|
|
+ <div style="margin: 4px" v-if="modelRef.length > 6"> ... 等{{ modelRef.length }}个 </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
+ </BasicModal>
|
|
|
+</template>
|
|
|
<script setup lang="ts">
|
|
|
- import { ref } from 'vue';
|
|
|
+ import { ref, computed, unref } from 'vue';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import BasicForm from '/@/components/Form/src/BasicForm.vue';
|
|
|
- import { useForm } from '/@/components/Form';
|
|
|
- import { formSchema } from './data.config';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
+ import { formDivisionSchema } from './data.config';
|
|
|
import {
|
|
|
- postAppBaseappfunction,
|
|
|
- putAppBaseappfunction,
|
|
|
- } from '/@/services/apis/BaseAppFunctionController';
|
|
|
- import BasicModal from '/@/components/Modal/src/BasicModal.vue';
|
|
|
- import { useModalInner } from '/@/components/Modal';
|
|
|
- const taskId = ref('');
|
|
|
- const isUpdate = ref();
|
|
|
- const [register, { closeModal }] = useModalInner(async (data) => {
|
|
|
- taskId.value = data.id;
|
|
|
- isUpdate.value = data.isUpdate;
|
|
|
- if (isUpdate.value) {
|
|
|
- title.value = '修改配置';
|
|
|
- } else if (taskId.value) {
|
|
|
- title.value = '查看配置';
|
|
|
- } else {
|
|
|
- title.value = '新增配置';
|
|
|
- }
|
|
|
- await setFieldsValue({ ...data });
|
|
|
- });
|
|
|
- const handleClose = () => {
|
|
|
- closeModal();
|
|
|
- };
|
|
|
+ postStudentBaseNewStudent,
|
|
|
+ putStudentBaseNewStudent,
|
|
|
+ } from '/@/services/apis/BaseNewStudentController';
|
|
|
+ import { postBandingTaskClassChangeClass } from '/@/services/apis/BandingTaskClassController';
|
|
|
+
|
|
|
+ const isUpdate = ref(true);
|
|
|
+ const modelRef = ref<Recordable[]>([]);
|
|
|
+ const emit = defineEmits(['success', 'register']);
|
|
|
const { createMessage } = useMessage();
|
|
|
- const emit = defineEmits(['success']);
|
|
|
- const [formReg, { validateFields, setFieldsValue, resetFields }] = useForm({
|
|
|
- schemas: formSchema,
|
|
|
- layout: 'vertical',
|
|
|
+ const [registerForm, { validate, resetFields }] = useForm({
|
|
|
+ labelWidth: 100,
|
|
|
+ schemas: formDivisionSchema,
|
|
|
showActionButtonGroup: false,
|
|
|
});
|
|
|
- const title = ref('手动分班');
|
|
|
+
|
|
|
+ const [registerModal, { closeModal, setModalProps }] = useModalInner(async (data) => {
|
|
|
+ resetFields();
|
|
|
+ setModalProps({ confirmLoading: false });
|
|
|
+ isUpdate.value = !!data?.isUpdate;
|
|
|
+ modelRef.value = [...data.baseData];
|
|
|
+ });
|
|
|
+
|
|
|
+ const getTitle = computed(() => (!unref(isUpdate) ? '手动分班' : '手动分班'));
|
|
|
const handleSubmit = async () => {
|
|
|
- const data = await validateFields();
|
|
|
try {
|
|
|
- if (isUpdate.value) {
|
|
|
- data.id = taskId.value;
|
|
|
- await putAppBaseappfunction({ ...(data as API.UpdateBaseAppFunctionDto) });
|
|
|
- createMessage.success('修改成功');
|
|
|
- } else {
|
|
|
- if (taskId.value) {
|
|
|
- closeModal();
|
|
|
- return false;
|
|
|
- }
|
|
|
- await postAppBaseappfunction({ ...(data as API.AddBaseAppFunctionDto) });
|
|
|
- createMessage.success('新增成功');
|
|
|
- }
|
|
|
- emit('success');
|
|
|
- await resetFields();
|
|
|
+ const values = await validate();
|
|
|
+ setModalProps({ confirmLoading: true });
|
|
|
+
|
|
|
+ const newStudentIds: string[] = [];
|
|
|
+
|
|
|
+ modelRef.value.forEach((item) => {
|
|
|
+ newStudentIds.push(item.id);
|
|
|
+ });
|
|
|
+
|
|
|
+ const postParams = {
|
|
|
+ newStudentIds: newStudentIds,
|
|
|
+ bandingTaskClassId: values.classId,
|
|
|
+ };
|
|
|
+ await postBandingTaskClassChangeClass(postParams as API.ChangeClassDto);
|
|
|
+
|
|
|
+ createMessage.success('操作成功');
|
|
|
closeModal();
|
|
|
- } catch (error) {
|
|
|
- createMessage.error(error.message);
|
|
|
+ emit('success');
|
|
|
+ } finally {
|
|
|
+ setModalProps({ confirmLoading: false });
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<template>
|
|
|
- <BasicModal
|
|
|
- show-footer
|
|
|
- @close="handleClose"
|
|
|
- @ok="handleSubmit"
|
|
|
- destroyOnClose
|
|
|
- v-bind="$attrs"
|
|
|
- @register="register"
|
|
|
- :title="title"
|
|
|
- width="50%"
|
|
|
- >
|
|
|
- <BasicForm @register="formReg" />
|
|
|
- </BasicModal>
|
|
|
-</template>
|
|
|
-
|
|
|
<style scoped lang="less"></style>
|