浏览代码

Merge branch 'iteration-20250221-tags' into jenkins

lex-xin 3 月之前
父节点
当前提交
3f92e49564
共有 1 个文件被更改,包括 20 次插入9 次删除
  1. 20 9
      src/views/prepare-lessons/model/subject-sync/index.tsx

+ 20 - 9
src/views/prepare-lessons/model/subject-sync/index.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, onMounted, ref } from 'vue';
+import { defineComponent, onMounted, ref, shallowRef } from 'vue';
 import styles from './index.module.less';
 import {
   NButton,
@@ -10,9 +10,6 @@ import {
 } from 'naive-ui';
 import { useCatchStore } from '/src/store/modules/catchData';
 import iconSelect from '../../images/icon-select.png';
-import { usePrepareStore } from '/src/store/modules/prepareLessons';
-import { PageEnum } from '/src/enums/pageEnum';
-
 export default defineComponent({
   name: 'subject-sync',
   props: {
@@ -24,10 +21,10 @@ export default defineComponent({
   emits: ['close', 'confirm'],
   setup(props, { emit }) {
     const catchStore = useCatchStore();
-    const prepareStore = usePrepareStore();
     const tabId = ref('' as any);
     const message = useMessage();
     const selectSubjectIds = ref([] as any);
+    const subjectAllList = shallowRef<any[]>([]); // 所有乐器列表
     const subjectList = ref([] as any);
 
     const subjectImgs = {
@@ -63,10 +60,9 @@ export default defineComponent({
 
       const subjectCode: any[] = [];
       selectSubjectIds.value.forEach((id: any) => {
-        const item = subjectList.value.find(
+        const item = subjectAllList.value.find(
           (subject: any) => subject.id === id
         );
-        console.log(item, 'item', item.code);
 
         if (item) {
           const tempCode = item.code ? item.code.split(',')[0] : '';
@@ -102,10 +98,21 @@ export default defineComponent({
 
       subjectList.value = temp;
     };
+
+    const formatSubjectAll = () => {
+      const subjects: any[] = catchStore.getEnableSubjects;
+      const temp: any = [];
+      subjects.forEach((subject: any) => {
+        if (tabId.value === '' && subject.instruments) {
+          temp.push(...subject.instruments);
+        }
+      });
+      subjectAllList.value = temp;
+    };
     onMounted(async () => {
       // 获取教材分类列表
       await catchStore.getSubjects();
-
+      formatSubjectAll();
       formatSubjectList();
       if (props.subjectId) {
         selectSubjectIds.value = [Number(props.subjectId)];
@@ -173,7 +180,11 @@ export default defineComponent({
           <NButton round onClick={() => emit('close')}>
             取消
           </NButton>
-          <NButton round type="primary" onClick={onSubmit} disabled={selectSubjectIds.value.length <= 0}>
+          <NButton
+            round
+            type="primary"
+            onClick={onSubmit}
+            disabled={selectSubjectIds.value.length <= 0}>
             确定
           </NButton>
         </NSpace>