Переглянути джерело

Merge remote-tracking branch 'origin/dev' into dev

zcuishan 4 місяців тому
батько
коміт
17bcdcc3a2

+ 105 - 54
src/views/bonusManager/scholarshipAdmin/components/data.config.ts

@@ -1,85 +1,154 @@
 import { BasicColumn, FormSchema } from '/@/components/Table';
 import { getDataOption } from '/@/api/system/dic';
 import { requestMagicApi } from '/@/api/magicApi';
+import { BasicOptionModel } from '/@/api/model/baseModel';
 
-export const columns: BasicColumn[] = [
+export const levelOptions: BasicOptionModel[] = [
+  { label: '无等级', value: 0 },
+  { label: '2级', value: 2 },
+  { label: '3级', value: 3 },
+  { label: '4级', value: 4 },
+  { label: '5级', value: 5 },
+];
+
+export const tableColumns: BasicColumn[] = [
+  {
+    title: '类型',
+    dataIndex: 'type',
+    align: 'left',
+    width: 120,
+  },
   {
-    title: '奖学金名称',
+    title: '名称',
     dataIndex: 'name',
+    align: 'left',
   },
   {
-    title: '奖学金总金额',
+    title: '总金额',
     dataIndex: 'totalAmount',
+    align: 'left',
+    width: 100,
   },
   {
-    title: '奖学金来源',
+    title: '来源',
     dataIndex: 'scholarshipSourceCn',
+    align: 'left',
+    width: 120,
+  },
+  {
+    title: '资助单位/个人',
+    dataIndex: 'scholarship',
+    align: 'left',
+    width: 120,
   },
   {
-    title: '奖学金等级',
+    title: '等级',
     dataIndex: 'scholarshipLevel',
+    align: 'left',
+    width: 100,
+    customRender: ({ text }) => {
+      return levelOptions.find((item) => item.value === text)?.label;
+    },
   },
 ];
 
 export const searchFormSchema: FormSchema[] = [
   {
     field: 'scholarshipName',
-    label: '奖学金名称',
+    label: '名称',
     component: 'Input',
     colProps: { span: 8 },
   },
   {
     field: 'scholarshipSource',
-    label: '奖学金来源',
-    component: 'Input',
+    label: '来源',
+    component: 'ApiSelect',
     colProps: { span: 8 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      api: getDataOption,
+      params: { code: 'scholarship_source' },
+      showSearch: true,
+      filterOption: (input: string, option: any) => {
+        return (
+          option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
+          option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
+      },
+    },
   },
   {
     field: 'scholarshipLevel',
-    label: '奖学金等级',
-    component: 'Input',
+    label: '等级',
+    component: 'Select',
     colProps: { span: 8 },
+    componentProps: {
+      getPopupContainer: () => document.body,
+      options: levelOptions,
+    },
   },
 ];
-// export导出
-// import 导出
-export const FromSchema: FormSchema[] = [
+
+
+export const formSchema: FormSchema[] = [
   {
-    field: 'id',
-    label: 'id',
+    field: 'baseSemesterId',
+    label: '所属学期',
+    required: true,
+    component: 'ApiSelect',
+    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: 'type',
+    label: '类型',
     component: 'Input',
-    show: false,
+    colProps: { span: 24 },
+    required: true,
   },
   {
     field: 'name',
-    label: '奖学金名称',
+    label: '名称',
     component: 'Input',
     colProps: { span: 24 },
     required: true,
   },
   {
     field: 'scholarshipSource',
-    label: '奖学金来源',
-    // APi请求下拉框
+    label: '来源',
     component: 'ApiSelect',
     required: true,
     componentProps: {
+      getPopupContainer: () => document.body,
       api: getDataOption,
       params: { code: 'scholarship_source' },
+      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: 'baseSemesterId',
-    label: '所属学期',
-    required: true,
-    component: 'ApiSelect',
-    componentProps: {
-      api: requestMagicApi,
-      params: { url: 'baseData/semester/option' },
-    },
-
+    field: 'name',
+    label: '资助单位/个人',
+    component: 'Input',
     colProps: { span: 24 },
+    required: true,
   },
   {
     field: 'totalAmount',
@@ -90,33 +159,13 @@ export const FromSchema: FormSchema[] = [
   },
   {
     field: 'scholarshipLevel',
-    label: '奖学金等级',
+    label: '等级',
     component: 'Select',
     required: true,
     componentProps: ({ formModel }) => {
       return {
-        options: [
-          {
-            label: '无等级',
-            value: 0,
-          },
-          {
-            label: '2级',
-            value: 2,
-          },
-          {
-            label: '3级',
-            value: 3,
-          },
-          {
-            label: '4级',
-            value: 4,
-          },
-          {
-            label: '5级',
-            value: 5,
-          },
-        ],
+        options: levelOptions,
+        getPopupContainer: () => document.body,
         onChange: (e) => {
           formModel.baseStudentScholarshipLevelList = [];
           if (e === 0) {
@@ -128,7 +177,6 @@ export const FromSchema: FormSchema[] = [
             ];
             return;
           }
-          //   for of
 
           for (let i = 0; i < e; i++) {
             formModel.baseStudentScholarshipLevelList.push({
@@ -155,21 +203,24 @@ export const moneyColumns: BasicColumn[] = [
   {
     title: '等级',
     dataIndex: 'level',
+    align: 'left',
+    width: 100,
   },
   {
     title: '金额',
     dataIndex: 'money',
-    align: 'center',
     slots: {
       customRender: 'money',
     },
+    align: 'left',
   },
   {
     title: '单位',
     dataIndex: 'unit',
-    align: 'center',
     customRender: ({}) => {
       return '元/每人';
     },
+    align: 'left',
+    width: 80,
   },
 ];

+ 55 - 50
src/views/bonusManager/scholarshipAdmin/components/editForm.vue

@@ -1,85 +1,90 @@
 <script setup lang="ts">
-  import { FromSchema, moneyColumns } from './data.config';
+  import { formSchema, moneyColumns } from './data.config';
   import BasicDrawer from '/@/components/Drawer/src/BasicDrawer.vue';
   import { useDrawerInner } from '/@/components/Drawer';
   import BasicForm from '/@/components/TableForm/src/BasicForm.vue';
   import { useForm } from '/@/components/Form';
   import { Table } from 'ant-design-vue';
-  import { ref } from 'vue';
+  import { computed, ref, unref } from 'vue';
   import { useMessage } from '/@/hooks/web/useMessage';
   import {
     getBaseStudentScholarshipCategoryInfo,
     postStudentBaseStudentScholarshipCategory,
     putStudentBaseStudentScholarshipCategory,
   } from '/@/services/apis/BaseStudentScholarshipCategoryController';
-  //  可以接受参数
-  const title = ref('');
+
   const isUpdate = ref(false);
-  const emit = defineEmits('success');
-  const [formReg, { closeDrawer }] = useDrawerInner(async (data) => {
-    title.value = data.isUpdate ? '编辑奖学金类别' : '新增奖学金类别';
-    isUpdate.value = data.isUpdate;
+  const modelRef = ref({});
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增奖学金类别' : '编辑奖学金类别'));
+
+  const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
+    labelWidth: 100,
+    schemas: formSchema,
+    showActionButtonGroup: false,
+  });
+
+  const [registerModal, { closeDrawer, setDrawerProps }] = useDrawerInner(async (data) => {
+    resetFields();
+    setDrawerProps({ confirmLoading: false });
+
+    modelRef.value = { ...data.baseData };
+
     if (isUpdate.value) {
-      const dataInfo = await getBaseStudentScholarshipCategoryInfo({ id: data.id });
-      await setFieldsValue(dataInfo);
+      const resData = await getBaseStudentScholarshipCategoryInfo({ id: data.baseData.id });
+      modelRef.value = { ...resData };
+      setFieldsValue({
+        ...resData,
+      });
     }
   });
-  const [editFormReg, { validate, resetFields, setFieldsValue }] = useForm({
-    schemas: FromSchema,
-    layout: 'vertical',
-    showActionButtonGroup: false,
-  });
+
   const { createMessage } = useMessage();
   const handleSubmit = async () => {
-    const data = await validate();
-    //   判断data.score是否有空的项目
-    if (data.baseStudentScholarshipLevelList.some((item) => !item.amount)) {
-      createMessage.error('请填写金额');
-      return;
-    }
-    //   判断data.score所有的金额相加是否大于100
-    if (
-      data.baseStudentScholarshipLevelList.reduce((total, item) => total + item.amount, 0) >
-      data.totalAmount
-    ) {
-      createMessage.error('奖学金金额总和不能大于总金额');
-      return;
-    }
     try {
-      if (isUpdate.value) {
-        await putStudentBaseStudentScholarshipCategory(data);
-        createMessage.success('编辑成功');
-        //  编辑
+      const values = await validate();
+      if (values.baseStudentScholarshipLevelList.some((item) => !item.amount)) {
+        createMessage.error('请填写金额');
+        return;
+      }
+      if (
+        values.baseStudentScholarshipLevelList.reduce((total, item) => total + item.amount, 0) >
+        values.totalAmount
+      ) {
+        createMessage.error('奖学金金额总和不能大于总金额');
+        return;
+      }
+      setDrawerProps({ confirmLoading: true });
+      const postParams = unref(modelRef);
+      Object.assign(postParams, values);
+      if (unref(isUpdate)) {
+        await putStudentBaseStudentScholarshipCategory(postParams);
       } else {
-        await postStudentBaseStudentScholarshipCategory(data);
-        createMessage.success('新增成功');
-        //  新增
+        await postStudentBaseStudentScholarshipCategory(postParams);
       }
+
+      createMessage.success('操作成功');
       emit('success');
-      await resetFields();
       closeDrawer();
-    } catch (catchError) {
-      createMessage.error(catchError.message);
     } finally {
+      setDrawerProps({ confirmLoading: false });
     }
   };
-  const handleClose = () => {
-    resetFields();
-    closeDrawer();
-  };
 </script>
 
 <template>
-  <!--  title 定义抽屉的标题   show-footer是否显示下方按钮-->
   <BasicDrawer
-    @register="formReg"
-    :title="title"
-    width="50%"
-    show-footer
     @ok="handleSubmit"
-    @close="handleClose"
+    :destroyOnClose="true"
+    :maskClosable="false"
+    v-bind="$attrs"
+    @register="registerModal"
+    :title="getTitle"
+    :width="1002"
+    showFooter
   >
-    <BasicForm @register="editFormReg">
+    <BasicForm @register="registerForm">
       <template #score="{ model }">
         <Table
           :columns="moneyColumns"

+ 56 - 42
src/views/bonusManager/scholarshipAdmin/index.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
   import { PageWrapper } from '/@/components/Page';
   import { useTable, BasicTable } from '/@/components/Table';
-  import { columns, searchFormSchema } from './components/data.config';
-  import { ref } from 'vue';
+  import { tableColumns, searchFormSchema } from './components/data.config';
+  import { reactive, ref } from 'vue';
   import editForm from './components/editForm.vue';
   import { useDrawer } from '/@/components/Drawer';
   import {
@@ -11,40 +11,50 @@
   } from '/@/services/apis/BaseStudentScholarshipCategoryController';
   import TableAction from '/@/components/Table/src/components/TableAction.vue';
   import { useMessage } from '/@/hooks/web/useMessage';
-  const selectedRowKeysList = ref([]);
-  // 注册抽屉
+  import SemesterTree from '/@/views/finance/config/components/SemesterTree.vue';
+
+  const checkedKeys = ref<Array<string | number>>([]);
+
   const [editFormReg, { openDrawer }] = useDrawer();
-  // reload 刷新表格
+  const searchInfo = reactive<Recordable>({});
+
   const [tableReg, { reload }] = useTable({
-    title: '奖学金类别列表',
     api: getBaseStudentScholarshipCategoryPage,
-    showTableSetting: true,
-    bordered: true,
-    columns: columns,
+    title: '赛事活动列表',
     rowKey: 'id',
-    useSearchForm: true,
+    columns: tableColumns,
     formConfig: {
-      schemas: searchFormSchema,
       labelWidth: 120,
-      size: 'small',
+      schemas: searchFormSchema,
     },
+    useSearchForm: true,
+    showTableSetting: true,
+    bordered: true,
+    immediate: true,
+    canResize: true,
     actionColumn: {
-      width: 200,
+      width: 120,
       title: '操作',
       dataIndex: 'action',
-      slots: {
-        customRender: 'action',
-      },
+      slots: { customRender: 'action' },
+      fixed: 'right',
     },
     rowSelection: {
       type: 'checkbox',
-      onChange: (selectedRowKeys) => {
-        selectedRowKeysList.value = selectedRowKeys;
-      },
+      onChange: onSelectChange,
     },
   });
+
+  function onSelectChange(selectedRowKeys: (string | number)[]) {
+    checkedKeys.value = selectedRowKeys;
+  }
   const handleEdit = (record) => {
-    openDrawer(true, { isUpdate: true, ...record });
+    openDrawer(true, {
+      isUpdate: true,
+      baseData: {
+        ...record,
+      },
+    });
   };
   //  打开抽屉
   const handleAdd = () => {
@@ -59,7 +69,7 @@
       onOk: async () => {
         try {
           if (isAll) {
-            await deleteStudentBaseStudentScholarshipCategory(selectedRowKeysList.value);
+            await deleteStudentBaseStudentScholarshipCategory(checkedKeys.value);
           } else {
             await deleteStudentBaseStudentScholarshipCategory([record.id]);
           }
@@ -73,35 +83,39 @@
       cancelText: '取消',
     });
   };
+
+  const handleSelect = (item) => {
+    if (item.parentId) {
+      searchInfo.baseSemesterId = item.id;
+      reload();
+    }
+  };
 </script>
 
 <template>
   <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
-    <BasicTable @register="tableReg">
+    <SemesterTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
+    <BasicTable class="w-3/4 xl:w-4/5" @register="tableReg" :searchInfo="searchInfo">
       <template #toolbar>
         <a-button type="primary" @click="handleAdd">新增</a-button>
-        <a-button :disabled="!selectedRowKeysList.length" @click="handleDelete('null', true)"
-          >删除</a-button
-        >
+        <a-button :disabled="!checkedKeys.length" @click="handleDelete('null', true)">
+          删除
+        </a-button>
       </template>
       <template #action="{ record }">
-        <div style="display: flex; justify-content: center">
-          <TableAction
-            :actions="[
-              {
-                label: '编辑',
-                icon: 'carbon:edit',
-                onClick: handleEdit.bind(null, record),
-              },
-              {
-                label: '删除',
-                icon: 'carbon:delete',
-                color: 'error',
-                onClick: handleDelete.bind(null, record, false),
-              },
-            ]"
-          />
-        </div>
+        <TableAction
+          :actions="[
+            {
+              label: '编辑',
+              onClick: handleEdit.bind(null, record),
+            },
+            {
+              label: '删除',
+              color: 'error',
+              onClick: handleDelete.bind(null, record, false),
+            },
+          ]"
+        />
       </template>
     </BasicTable>
     <editForm @register="editFormReg" @success="reload" />

+ 1 - 1
src/views/finance/config/components/SemesterTree.vue

@@ -35,7 +35,7 @@
       const selectedKeys = ref<string[]>([]);
 
       async function fetch() {
-        treeData.value = ((await getPbSemesterConfigTree({})) as unknown) as TreeItem[];
+        treeData.value = (await getPbSemesterConfigTree({} as any)) as unknown as TreeItem[];
       }
 
       const handleSelect = (_, event) => {

+ 11 - 0
src/views/teachingManager/textbookManagement/components/data.config.ts

@@ -353,6 +353,17 @@ export const formSchema: FormSchema[] = [
     },
     colProps: { span: 12 },
   },
+  {
+    label: '教材类型',
+    field: 'textbookCategory',
+    component: 'ApiSelect',
+    componentProps: {
+      api: getDataOption,
+      params: { code: 'textbook_category' },
+      getPopupContainer: () => document.body,
+    },
+    colProps: { span: 12 },
+  },
   {
     label: '校企合作教材',
     field: 'isSecd',