Browse Source

老师端增加声部筛选

liushengqiang 1 year ago
parent
commit
a2841f6be2
2 changed files with 74 additions and 12 deletions
  1. 19 4
      src/views/accompany/index.module.less
  2. 55 8
      src/views/accompany/music-list.tsx

+ 19 - 4
src/views/accompany/index.module.less

@@ -81,19 +81,34 @@
     justify-content: center;
     height: 60px;
     background-color: #f8f8f8;
+    .filterBox{
+      display: flex;
+      width: 100%;
+    }
     :global {
       .van-search {
+        display: flex;
+        align-items: center;
         flex: 1;
-        padding: 0 12px;
+        margin: 0 12px;
+        padding: 0;
+        height: 40px;
+        background: #fff;
+        border-radius: 20px !important;
         .van-search__content {
-          background: #fff !important;
+          background: transparent !important;
         }
       }
+      .van-dropdown-menu,
+      .van-dropdown-menu__bar{
+        height: 100%;
+        background: transparent;
+      }
 
       .van-search__field {
-        background-color: #fff;
+        background: transparent;
         border-radius: 20px 0 0 20px;
-        padding-left: 12px;
+        padding-left: 20px;
         height: 36px;
       }
       .van-search__action {

+ 55 - 8
src/views/accompany/music-list.tsx

@@ -25,6 +25,7 @@ import OSearch from '@/components/o-search'
 import OHeader from '@/components/o-header'
 import { getInstrumentName } from '@/constant/instruments'
 
+const subjectKey = "accompany-music-list-subject"
 export default defineComponent({
   name: 'accompany-music-list',
   props: {
@@ -37,6 +38,7 @@ export default defineComponent({
     const route = useRoute()
     const imgDefault = getImage('icon-music.svg')
     const userInfo = ref<any>({})
+    const subjectId = localStorage.getItem(subjectKey) || state.user?.data?.subjectId?.split(',')?.[0] || ''
     const data = reactive({
       loading: false,
       finished: false,
@@ -50,7 +52,9 @@ export default defineComponent({
       value2: null,
       PopoverOpen: false,
       list: [] as any,
-      keyword: ''
+      keyword: '',
+      musicSubject: subjectId,
+      subjectList: [] as any
     })
     const getTree = async () => {
       try {
@@ -67,6 +71,27 @@ export default defineComponent({
         console.log(error)
       }
     }
+    // 获取声部信息
+    const getSubjects = async () => {
+      try {
+        const subjects = await request.post(state.platformApi + '/open/subjectBasicConfig/page', {
+          data: {
+            enableFlag: true,
+            page: 1,
+            rows: 100
+          }
+        })
+        const rows = subjects.data.rows || []
+        rows.forEach((item: any) => {
+          data.subjectList.push({
+            text: item.subjectName,
+            value: item.subjectId + ''
+          })
+        })
+      } catch {
+        //
+      }
+    }
     /**获取会员购买记录 */
     const getUserInfo = async () => {
       try {
@@ -121,7 +146,8 @@ export default defineComponent({
             ...data.pagenation,
             keyword: data.keyword,
             musicSheetCategoriesId: data.value2 || data.value1,
-            status: 1
+            status: 1,
+            musicSubject: data.musicSubject
           },
           hideLoading: true
         })
@@ -165,6 +191,9 @@ export default defineComponent({
       if (state.platformType == 'STUDENT') {
         getUserInfo()
       }
+      if (state.platformType == 'TEACHER') {
+        getSubjects()
+      }
       getTree()
     })
 
@@ -185,13 +214,13 @@ export default defineComponent({
         parts = parts.filter((n) => !n.textContent?.toLocaleUpperCase()?.includes('COMMON'))
         for (let i = 0; i < parts.length; i++) {
           const name = getInstrumentName(parts[i].textContent || '')
-          partNames.push({ text: name ? (parts[i].textContent + `(${name})`) : '', value: i })
+          partNames.push({ text: name ? parts[i].textContent + `(${name})` : '', value: i })
         }
         closeToast()
       } catch (error) {
         console.log(error)
       }
-      console.log("🚀 ~ partNames:", partNames)
+      console.log('🚀 ~ partNames:', partNames)
       return partNames
     }
 
@@ -233,13 +262,31 @@ export default defineComponent({
             </DropdownMenu>
             <div class={styles.filter}>
               <OSearch
-                style={{ width: '100%' }}
-                background="transparent"
+                class={styles.filterBox}
                 onSearch={(keyword: string) => {
                   data.keyword = keyword
                   onSearch()
                 }}
-              />
+              >
+                {{
+                  left: () => (
+                    <>
+                      {state.platformType == 'TEACHER' ? (
+                        <DropdownMenu activeColor="var(--van-primary)">
+                          <DropdownItem
+                            v-model:modelValue={data.musicSubject}
+                            options={data.subjectList}
+                            onChange={() => {
+                              localStorage.setItem(subjectKey, data.musicSubject)
+                              onSearch()
+                            }}
+                          ></DropdownItem>
+                        </DropdownMenu>
+                      ) : null}
+                    </>
+                  )
+                }}
+              </OSearch>
             </div>
           </div>
         </OSticky>
@@ -292,7 +339,7 @@ export default defineComponent({
             onConfirm={(value) => {
               staffData.open = false
               staffData.partIndex = value.selectedValues[0]
-              openView({id: staffData.instrumentName})
+              openView({ id: staffData.instrumentName })
             }}
             onCancel={() => (staffData.open = false)}
           />