123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import { NButton, NSpace, useMessage, NForm, NFormItem } from 'naive-ui';
- import { defineComponent, onMounted, reactive, ref } from 'vue';
- import styles from '../index.module.less';
- import CSelect from '/src/components/CSelect';
- import { getConfiguredSubjects, resetClass } from '../api';
- import { useCatchStore } from '/src/store/modules/catchData';
- export default defineComponent({
- props: {
- activeRow: {
- type: Object,
- default: () => ({ id: '' })
- },
- subjectList: {
- type: Array,
- default: () => []
- }
- },
- name: 'resetStudent',
- emits: ['close', 'getList', 'confirm'],
- setup(props, { emit }) {
- const catchStore = useCatchStore();
- const data = reactive({
- uploading: false
- });
- const message = useMessage();
- const subjectList = ref([] as any);
- const foemsRef = ref();
- const createClassForm = reactive({
- currentGradeNum: null,
- currentClass: null,
- subjectId: null,
- id: null
- });
- const getConfigSubject = async () => {
- try {
- const { data } = await getConfiguredSubjects({
- currentGradeNum: createClassForm.currentGradeNum,
- currentClass: createClassForm.currentClass
- });
- const temp = data || [];
- subjectList.value = temp.map((item: any) => {
- return {
- label: item.name,
- value: item.id
- };
- });
- } catch {
- //
- }
- };
- onMounted(async () => {
- // 获取教材分类列表
- // await catchStore.getSubjects();
- // subjectList.value = [
- // { id: null, name: '选择声部' },
- // ...catchStore.getSubjectList
- // ];
- createClassForm.currentGradeNum = props.activeRow.currentGradeNum;
- createClassForm.currentClass = props.activeRow.currentClass;
- createClassForm.subjectId = props.activeRow.subjectId;
- createClassForm.id = props.activeRow.id;
- getConfigSubject();
- });
- const submitForms = () => {
- foemsRef.value.validate(async (error: any) => {
- if (error) {
- return;
- }
- data.uploading = true;
- try {
- await resetClass({ ...createClassForm });
- message.success('修改成功');
- emit('close');
- emit('confirm', {
- lastUseCoursewareId: props.activeRow.lessonCoursewareId,
- unit: props.activeRow.lessonCoursewareKnowledgeDetailId,
- subjectId: createClassForm.subjectId,
- name: props.activeRow.name, // 班级名称
- classGroupId: props.activeRow.id // 班级编号
- });
- emit('getList');
- } catch (e) {
- console.log(e);
- }
- data.uploading = false;
- });
- };
- return () => (
- <div class={[styles.addClass]}>
- <NForm label-placement="left" model={createClassForm} ref={foemsRef}>
- <NFormItem
- path="subjectId"
- rule={[
- {
- required: true,
- message: '请选择声部'
- }
- ]}>
- <CSelect
- {...({
- style: { width: '400px' },
- options: subjectList.value,
- placeholder: '选择声部',
- clearable: true
- } as any)}
- v-model:value={createClassForm.subjectId}></CSelect>
- </NFormItem>
- </NForm>
- <NSpace class={styles.btnGroup} justify="center">
- <NButton round onClick={() => emit('close')}>
- 取消
- </NButton>
- <NButton
- round
- loading={data.uploading}
- onClick={() => submitForms()}
- type="primary">
- 确定
- </NButton>
- </NSpace>
- </div>
- );
- }
- });
|