Bläddra i källkod

编辑违禁词

rkljw 1 vecka sedan
förälder
incheckning
41b9393510
2 ändrade filer med 39 tillägg och 2 borttagningar
  1. 7 0
      src/api/blackWord.js
  2. 32 2
      src/views/website/blackWordList.vue

+ 7 - 0
src/api/blackWord.js

@@ -26,3 +26,10 @@ export const delBlackWord = (data) => {
         data
     })
 }
+export const upBlackWord = (data) => {
+    return request({
+        url: '/public/upBlackWord',
+        method: 'post',
+        data
+    })
+}

+ 32 - 2
src/views/website/blackWordList.vue

@@ -32,13 +32,17 @@
                         <el-table-column prop="created_at" label="创建时间">
                         </el-table-column>
                     
-                        <el-table-column fixed="right" label="操作" width="110">
+                        <el-table-column fixed="right" header-align="center" label="操作" width="220">
                             <template slot-scope="scope">
                                 <div class="listBtnBox">
                                     <div class="listDeleteBtn" @click="deleteRow(scope.row.name, scope.row)">
                                         <i class="el-icon-delete"></i>删除
                                     </div>
+                                    <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
+                                        <i class="el-icon-edit-outline"></i>编辑
+                                    </div>
                                 </div>
+                                
                             </template>
                         </el-table-column>
                     </el-table>
@@ -85,7 +89,7 @@ import tableTitle from './components/blogroll/tableTitle.vue';
 //引入公用样式
 import '@/styles/global.less';
 // 引入api
-import { getBlackWordList, addBlackWord, delBlackWord } from '@/api/blackWord.js'
+import { getBlackWordList, addBlackWord, delBlackWord, upBlackWord } from '@/api/blackWord.js'
 
 export default {
     components: {
@@ -117,6 +121,7 @@ export default {
             // 图片相关
             formLabelWidth: '120px',//表单的长度
 
+            id:'',
             //表单相关
             ruleForm: {
                 name: '', //违禁词名称
@@ -225,12 +230,37 @@ export default {
                         }
                     })
                 }  
+                if (this.dialogName == "编辑") {
+                upBlackWord({
+                    id: this.id,
+                    name: this.ruleForm.name,
+                }).then(data => {
+                    console.log(data);
+                    if (data.code == 200) {
+                            this.$message({
+                                message: "添加成功",
+                                type: 'success'
+                            });
+                            this.dialogTableVisible = false
+                            this.getData()
+                        } else {
+                            this.$message.error(data.message)
+                        }
+                    })
+                }
         },
         //取消添加或编辑
         cancelForm() {
             this.dialogTableVisible = false
         },
+        goEdit(id, val) {
+            this.dialogTableVisible = true //弹框显示
+            this.dialogName = "编辑"    //弹框名字
+            this.id = id //活动id
+            this.ruleForm.name = val.name //违规词名称
+        },
     },
+
     mounted() {
         //获取网站列表数据
         this.getData()