Browse Source

no message

DESKTOP-SVI9JE1\muzen 1 năm trước cách đây
mục cha
commit
b58f6f7c74
1 tập tin đã thay đổi với 13 bổ sung7 xóa
  1. 13 7
      src/views/operation/recommend/index.vue

+ 13 - 7
src/views/operation/recommend/index.vue

@@ -5,7 +5,8 @@
       :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
       <el-table-column width="80px">
         <template slot-scope="scope">
-          <el-link v-if="scope.row.hidden" :underline="false" class="el-icon-arrow-right" @click="getList(scope.row)" />
+          <el-link v-if="scope.row.hidden" :underline="false" class="el-icon-arrow-right"
+            @click="getList(scope.row, scope.row.index)" />
         </template>
       </el-table-column>
       <el-table-column label="导航名称" align="center" prop="name" show-overflow-tooltip>
@@ -165,7 +166,9 @@ export default {
       }, {
         value: 3,
         label: '已失效'
-      }]
+      }],
+      // 当前数据缓存
+      index: null
     }
   },
   mounted() {
@@ -177,7 +180,8 @@ export default {
     getTabList() {
       tabList().then(res => {
         if (res.code === 0) {
-          res.data.map(i => {
+          res.data.map((i, index) => {
+            i.index = index
             i.hidden = true
             i.children = []
           })
@@ -197,8 +201,8 @@ export default {
     },
 
     // 首次获取二级列表
-    getList(row) {
-      let e = this.tableData[row.tabIndex - 1]
+    getList(row, index) {
+      let e = this.tableData[index]
       list(row.id).then(res => {
         if (res.code === 0) {
           if (res.data.length > 0) {
@@ -222,7 +226,7 @@ export default {
             if (res.code === 0) {
               this.$message.success('提交成功')
               this.cancel()
-              this.getTabList()
+              this.getList(this.tableData[this.index], this.index)
             }
           })
         } else {
@@ -240,6 +244,7 @@ export default {
 
     // 弹窗
     getDialog(title, row) {
+      this.index = this.tableData.findIndex(i => i.id == row.id)
       this.title = title
       this.dialogVisible = true
       this.dialogForm.categoryId = row.id
@@ -272,10 +277,11 @@ export default {
       this.$confirm(`是否删除?`, '提醒', {
         type: 'warning'
       }).then(() => {
+        let index = this.tableData.findIndex(i => i.id == row.categoryId)
         remove(row.lv, row.id).then(res => {
           if (res.code === 0) {
             this.$message.success('删除成功!')
-            this.getTabList()
+            this.getList(this.tableData[index], index)
           }
         })
       }).catch(() => { })