Pārlūkot izejas kodu

伴奏列表修改

wolyshaw 4 gadi atpakaļ
vecāks
revīzija
1442a227d4

+ 6 - 0
src/views/accompaniment/index.vue

@@ -84,6 +84,12 @@
         /> -->
         <el-table-column
           align="center"
+          prop="categoriesName"
+          label="等级"
+          width="180px"
+        />
+        <el-table-column
+          align="center"
           prop="createUserName"
           label="上传人"
           width="180px"

+ 15 - 4
src/views/accompaniment/modals/form.vue

@@ -112,7 +112,7 @@ export default {
         sysMusicScore: {
           name: '',
           url: '',
-          musicScoreCategoriesId: '',
+          musicScoreCategoriesId: [],
         },
         sysMusicScoreAccompaniments: [
           {
@@ -128,22 +128,33 @@ export default {
         value: 'id',
         label: 'name',
         children: 'sysMusicScoreCategoriesList',
-        checkStrictly: true
       }
     }
   },
-  mounted() {
+  async mounted() {
     this.$store.dispatch('setSubjects')
+    await this.FetchTree()
     if (this.detail) {
       this.$set(this.form, 'sysMusicScore', {
         name: this.detail.name,
         url: this.detail.url,
+        musicScoreCategoriesId: this.detail.categoriesId ? this.formatParentId(this.detail.categoriesId, this.tree) : [],
       })
       this.FeatchDetailList()
     }
-    this.FetchTree()
   },
   methods: {
+    formatParentId(id, list, ids = []) {
+      for (const item of list) {
+        if (item.sysMusicScoreCategoriesList) {
+          return this.formatParentId(id, item.sysMusicScoreCategoriesList, [...ids, item.id])
+        }
+        if (item.id === id) {
+          return [...ids, id]
+        }
+      }
+      return ids
+    },
     async FetchTree() {
       try {
         const res = await queryTree()