lex-xin 3 年之前
父節點
當前提交
b7bdd831bf

+ 9 - 5
src/components/Editor/index.vue

@@ -4,7 +4,7 @@
     <quill-editor
       class="ql-editor"
       v-model="forms[keyWord]"
-      ref="myQuillEditor"
+      :ref="alias"
       :options="editorOption"
       @change="onEditorChange($event)"
     ></quill-editor>
@@ -177,6 +177,10 @@ export default {
     form: {
       type: Object,
     },
+    alias: {
+      type: String,
+      default: 'myQuillEditor'
+    }
   },
   name: "editor",
   components: { quillEditor },
@@ -217,9 +221,9 @@ export default {
               video: function (value) {
                 if (value) {
                   that.dialogFormVisible = true;
-                  let editor = that.$refs.myQuillEditor.quill;
+                  let editor = that.$refs[this.alias].quill;
                   // 光标所在位置
-                   console.log(editor.getContents())
+                   console.log(editor, editor.getSelection())
                   that.editorIndex = editor.getSelection()?.index||0;
 
                 } else {
@@ -257,7 +261,7 @@ export default {
           };
           quill.insertEmbed(this.editorIndex, "video", params);
           // 调整光标到最后
-          console.log(this.editorIndex,)
+          console.log(this.editorIndex)
           quill.setSelection(this.editorIndex + 1, { preload: false });
 
           this.dialogFormVisible = false;
@@ -380,7 +384,7 @@ export default {
   },
   computed: {
     editor() {
-      return this.$refs.myQuillEditor.quill;
+      return this.$refs[this.alias].quill;
     },
     forms() {
       return this.form;

+ 2 - 2
src/views/operationManual/modals/manualSet.vue

@@ -43,7 +43,7 @@
           },
         ]"
       >
-        <Editor :form="form" :keyWord="'opFlow'" />
+        <Editor :form="form" alias="Editor1" :keyWord="'opFlow'" />
       </el-form-item>
       <el-form-item
         label="功能规则"
@@ -55,7 +55,7 @@
           },
         ]"
       >
-        <Editor :form="form" :keyWord="'funRule'" />
+        <Editor :form="form" alias="Editor2" :keyWord="'funRule'" />
       </el-form-item>
     </el-form>
     <!--      funRule: "",

+ 23 - 1
src/views/teachManager/index.vue

@@ -63,6 +63,7 @@
           :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
           :data="tableList"
           row-key="id"
+          :expand-row-keys="expands"
           :tree-props="{children: 'sysMusicScoreCategoriesList', hasChildren: 'hasChildren'}"
         >
           <!-- <el-table-column
@@ -124,7 +125,7 @@
                   <el-button
                     type="text"
                     @click="operationTeachClass('create', scope.row)"
-                    v-if="!scope.row.enable"
+                    v-if="!scope.row.enable && formatParentId(scope.row.id, tableList).length < 4"
                     >添加</el-button
                   >
                 </auth>
@@ -215,6 +216,7 @@ export default {
       activeRow: null,
       type: 'create',
       teachClassVisible: false,
+      expands: []
     };
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
@@ -253,10 +255,30 @@ export default {
       this.search();
     },
     operationTeachClass(type, row) {
+      console.log(row, this.expands)
+      console.log(this.formatParentId(row.id, this.tableList))
       this.type = type
       this.activeRow = row || null;
       this.teachClassVisible = true;
     },
+    formatParentId(id, list, ids = []) {
+      for (const item of list) {
+        if (item.sysMusicScoreCategoriesList) {
+          const cIds = this.formatParentId(
+            id,
+            item.sysMusicScoreCategoriesList,
+            [...ids, item.id]
+          );
+          if (cIds.includes(id)) {
+            return cIds;
+          }
+        }
+        if (item.id === id) {
+          return [...ids, id];
+        }
+      }
+      return ids;
+    },
     async stopTeach(row) {
       let str = "";
       if (row.enable) {

+ 16 - 37
src/views/teachManager/modals/addRoot.vue

@@ -23,6 +23,7 @@
       <el-form-item
         label="适用分部"
         prop="organId"
+        v-if="!activeRow.id"
         :rules="[
           {
             required: true,
@@ -135,56 +136,34 @@ export default {
         this.imageWidthM = 210
         this.imageHeightM = 268
       // }
-      console.log(this.type)
-      if(this.type == 'create') { // 添加一级分类或子级
-
-      } else if(this.type == 'update') { // 修改分类
-        try {
-          const res = await getSysMusicScoreDetail({ id: this.activeRow.id });
+      try {
+        const res = await getSysMusicScoreDetail({ id: this.activeRow.id });
+        if(this.type == 'create') { // 添加一级分类或子级
+          this.form.organId = res.data.organId.split(",").map((item) => {
+            return Number(item);
+          });
+        } else if(this.type == 'update') { // 修改分类
           this.form.name = res.data.name;
           this.form.organId = res.data.organId.split(",").map((item) => {
             return Number(item);
           });
           this.form.coverImg = res.data.coverImg;
           this.form.soundResource = res.data.soundResource;
-          this.form.sysMusicScoreCategoriesList =
-          this.recursionDate(res.data.sysMusicScoreCategoriesList) || [];
-        } catch (e) {}
-      }
+        }
+      } catch (e) {}
     }
   },
   methods: {
-    // 递归遍历数组
-    recursionDate(arr) {
-      // 这里来了
-      if (arr.length > 0) {
-        let newArr = [];
-        for (let i = 0; i < arr.length; i++) {
-          let obj = {
-            ...arr[i],
-            index: arr[i].id,
-          };
-
-          if (
-            arr[i].sysMusicScoreCategoriesList &&
-            arr[i].sysMusicScoreCategoriesList.length > 0
-          ) {
-            obj.sysMusicScoreCategoriesList = this.recursionDate(
-              arr[i].sysMusicScoreCategoriesList
-            );
-          }
-
-          newArr.push(obj);
-        }
-
-        return newArr;
-      }
-    },
     addSubmit() {
       this.$refs.form.validate(async (flag) => {
         if (flag) {
           let { organId, ...rest } = this.form;
-          let parentId = this.activeRow?.id || 0
+          let parentId = 0
+          if(this.type == 'create') {
+            parentId = this.activeRow?.id || 0
+          } else if(this.type == 'update') {
+            parentId = this.activeRow?.parentId || 0
+          }
           let obj = {
             ...rest,
             parentId,