Kaynağa Gözat

fix: add enter

DESKTOP-USV654P\pc 2 ay önce
ebeveyn
işleme
f195aa7f02

+ 1 - 1
Makefile

@@ -12,7 +12,7 @@ build:
 
 commit:
 	git add . && \
-	git commit --no-verify -m "fix: change textbook "
+	git commit --no-verify -m "fix: add enter "
 
 checkPre:
 	git checkout pre

+ 176 - 0
src/views/educational/studentScore/enter/data.config.ts

@@ -0,0 +1,176 @@
+import { BasicColumn, FormSchema } from '/@/components/Table';
+
+import { requestMagicApi } from '/@/api/magicApi';
+import { getClassOption } from '/@/api/userMagic';
+import { getExamPlanPlanList } from '/@/services/apis/ExamPlanController';
+
+export const tableColumns: BasicColumn[] = [
+  {
+    title: '考试学期',
+    dataIndex: 'semesterName',
+    align: 'left',
+    width: 120,
+  },
+  {
+    title: '考试计划',
+    dataIndex: 'examPlanName',
+    align: 'left',
+    width: 150,
+  },
+  {
+    title: '科目',
+    dataIndex: 'milexamnames',
+    align: 'left',
+    width: 120,
+  },
+  {
+    title: '班级',
+    dataIndex: 'milexamnames',
+    align: 'left',
+  },
+  {
+    title: '录入时间',
+    dataIndex: 'milexamnames',
+    align: 'left',
+    width: 150,
+  },
+  {
+    title: '录入人',
+    dataIndex: 'milexamnames',
+    align: 'left',
+    width: 120,
+  },
+];
+
+export const searchFormSchema: FormSchema[] = [
+  {
+    field: 'semesterId',
+    label: '学期',
+    component: 'ApiSelect',
+    colProps: { span: 8 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: requestMagicApi,
+      params: {
+        url: '/baseData/semester/option',
+      },
+      showSearch: true,
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
+  },
+  {
+    field: 'examPlanId',
+    label: '计划',
+    component: 'ApiSelect',
+    colProps: { span: 8 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: getExamPlanPlanList,
+      valueField: 'id',
+      labelField: 'name',
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
+  },
+  {
+    field: 'courseName',
+    label: '科目',
+    component: 'Input',
+    colProps: { span: 8 },
+  },
+  {
+    field: 'classId',
+    label: '班级',
+    component: 'ApiSelect',
+    colProps: { span: 8 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: getClassOption,
+      showSearch: true,
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
+  },
+];
+
+export const formSchema: FormSchema[] = [
+  {
+    label: '学期',
+    field: 'semesterId',
+    component: 'ApiSelect',
+    required: true,
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: requestMagicApi,
+      params: {
+        url: '/baseData/semester/option',
+      },
+      showSearch: true,
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
+    colProps: { span: 24 },
+  },
+  {
+    field: 'examPlanId',
+    label: '考试计划',
+    component: 'ApiSelect',
+    required: true,
+    colProps: { span: 24 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: getExamPlanPlanList,
+      valueField: 'id',
+      labelField: 'name',
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
+  },
+  {
+    field: 'courseName',
+    label: '科目',
+    component: 'Input',
+    required: true,
+    colProps: { span: 24 },
+  },
+  {
+    field: 'classIds',
+    label: '班级',
+    component: 'ApiSelect',
+    required: true,
+    colProps: { span: 24 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: getClassOption,
+      mode: 'multiple',
+      showSearch: true,
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
+  },
+];

+ 78 - 0
src/views/educational/studentScore/enter/edit.vue

@@ -0,0 +1,78 @@
+<template>
+  <BasicModal
+    @ok="handleSubmit"
+    :destroyOnClose="true"
+    :maskClosable="false"
+    v-bind="$attrs"
+    @register="registerModal"
+    :title="getTitle"
+    :width="1002"
+    showFooter
+  >
+    <BasicForm @register="registerForm" />
+  </BasicModal>
+</template>
+<script setup lang="ts">
+  import { ref, computed, unref } from 'vue';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { BasicForm, useForm } from '/@/components/Form/index';
+  import { formSchema } from './data.config';
+  import {
+    getExamPlanInfo,
+    postXycxeduExamPlan,
+    putXycxeduExamPlan,
+  } from '/@/services/apis/ExamPlanController';
+
+  const isUpdate = ref(true);
+  const modelRef = ref({});
+  const emit = defineEmits(['success', 'register']);
+  const { createMessage } = useMessage();
+  const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
+    labelWidth: 100,
+    schemas: formSchema,
+    showActionButtonGroup: false,
+  });
+
+  const [registerModal, { closeModal, setModalProps }] = useModalInner(async (data) => {
+    resetFields();
+    setModalProps({ confirmLoading: false });
+    isUpdate.value = !!data?.isUpdate;
+    modelRef.value = { ...data.baseData };
+
+    if (unref(isUpdate)) {
+      const resData = await getExamPlanInfo({ id: data.baseData.id });
+      resData['classIds'] = resData['classIds'].split(',');
+
+      modelRef.value = { ...resData };
+      setFieldsValue({
+        ...resData,
+      });
+    }
+  });
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增录入' : '编辑录入'));
+  const handleSubmit = async () => {
+    try {
+      const values = await validate();
+      setModalProps({ confirmLoading: true });
+      const postParams = unref(modelRef);
+      Object.assign(postParams, values);
+      postParams['classIds'] = postParams['classIds'].join(',');
+
+      if (unref(isUpdate)) {
+        await putXycxeduExamPlan(postParams as API.UpdateExamPlanDto);
+      } else {
+        await postXycxeduExamPlan(postParams as API.AddExamPlanDto);
+      }
+
+      createMessage.success('操作成功');
+      closeModal();
+      emit('success');
+    } finally {
+      setModalProps({ confirmLoading: false });
+    }
+  };
+</script>
+
+<style scoped lang="less"></style>

+ 98 - 0
src/views/educational/studentScore/enter/index.vue

@@ -0,0 +1,98 @@
+<template>
+  <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
+    <BasicTable @register="registerTable">
+      <template #toolbar>
+        <a-button type="primary" @click="handleEdit({}, false)">新增</a-button>
+      </template>
+      <template #action="{ record }">
+        <TableAction
+          :actions="[
+            {
+              label: '录入成绩',
+              onClick: handleEdit.bind(null, record, true),
+            },
+            {
+              label: '删除',
+              color: 'error',
+              onClick: handleDelete.bind(null, record),
+            },
+          ]"
+        />
+      </template>
+    </BasicTable>
+    <FormEdit @register="registerModal" @success="handleSuccess" />
+  </PageWrapper>
+</template>
+
+<script setup lang="ts">
+  import { onMounted } from 'vue';
+  import { PageWrapper } from '/@/components/Page';
+  import { BasicTable, useTable, TableAction } from '/@/components/Table';
+  import { tableColumns, searchFormSchema } from './data.config';
+  import { useModal } from '/@/components/Modal';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import FormEdit from './edit.vue';
+  import { deleteXycxeduExamPlan, getExamPlanPage } from '/@/services/apis/ExamPlanController';
+
+  const [registerModal, { openModal }] = useModal();
+
+  const [registerTable, { reload }] = useTable({
+    api: getExamPlanPage,
+    title: '考试记录表',
+    rowKey: 'id',
+    columns: tableColumns,
+    formConfig: {
+      labelWidth: 120,
+      schemas: searchFormSchema,
+    },
+    useSearchForm: true,
+    showTableSetting: true,
+    bordered: true,
+    immediate: true,
+    canResize: true,
+    actionColumn: {
+      width: 120,
+      title: '操作',
+      dataIndex: 'action',
+      slots: { customRender: 'action' },
+      fixed: 'right',
+    },
+  });
+  const { createConfirm, createMessage } = useMessage();
+
+  const handleDelete = (record: any) => {
+    createConfirm({
+      iconType: 'warning',
+      title: '温馨提醒',
+      content: '是否删除该记录?',
+      onOk: async () => {
+        try {
+          await deleteXycxeduExamPlan([record.id]);
+          createMessage.success('删除成功');
+          await reload();
+        } catch (e) {
+          createMessage.error('删除失败');
+        }
+      },
+      okText: '确认',
+      cancelText: '取消',
+    });
+  };
+
+  const handleEdit = (record: any, isUpdate: boolean) => {
+    openModal(true, {
+      isUpdate: isUpdate,
+      baseData: {
+        ...record,
+      },
+    });
+  };
+
+  const handleSuccess = async () => {
+    await reload();
+  };
+
+  onMounted(async () => {});
+</script>
+
+<style scoped lang="less"></style>

+ 1 - 1
src/views/educational/studentScore/plan/data.config.ts

@@ -6,7 +6,7 @@ import { getExamPlanExamList } from '/@/services/apis/ExamPlanController';
 export const tableColumns: BasicColumn[] = [
   {
     title: '考试学期',
-    dataIndex: 'semesterCn',
+    dataIndex: 'semesterName',
     align: 'left',
     width: 120,
   },