yuantianjiao 6 年前
父节点
当前提交
332041c2f1

+ 8
- 3
src/pages/system/systemSet/userManger/add.vue 查看文件

153
           </div>
153
           </div>
154
         </li>
154
         </li>
155
         <li style="text-align:center">
155
         <li style="text-align:center">
156
-          <el-button type="primary" size="mini">保存</el-button>
157
-          <el-button type="danger" size="mini">取消</el-button>
156
+          <el-button type="primary" size="mini" @click="submit">保存</el-button>
157
+          <el-button type="danger" size="mini" @click="cancel">取消</el-button>
158
         </li>
158
         </li>
159
       </ul>
159
       </ul>
160
     </form>
160
     </form>
189
     })
189
     })
190
   },
190
   },
191
   methods: {
191
   methods: {
192
-
192
+    submit () {
193
+      console.log(this.postData)
194
+    },
195
+    cancel () {
196
+      this.$router.go(-1)
197
+    }
193
   },
198
   },
194
   mounted () {}
199
   mounted () {}
195
 }
200
 }

+ 8
- 3
src/pages/system/systemSet/userManger/edit.vue 查看文件

153
           </div>
153
           </div>
154
         </li>
154
         </li>
155
         <li style="text-align:center">
155
         <li style="text-align:center">
156
-          <el-button type="primary" size="mini">保存</el-button>
157
-          <el-button type="danger" size="mini">取消</el-button>
156
+          <el-button type="primary" size="mini" @click="submit">保存</el-button>
157
+          <el-button type="danger" size="mini" @click="cancel">取消</el-button>
158
         </li>
158
         </li>
159
       </ul>
159
       </ul>
160
     </form>
160
     </form>
189
     })
189
     })
190
   },
190
   },
191
   methods: {
191
   methods: {
192
-
192
+    submit () {
193
+      console.log(this.postData)
194
+    },
195
+    cancel () {
196
+      this.$router.go(-1)
197
+    }
193
   },
198
   },
194
   mounted () {}
199
   mounted () {}
195
 }
200
 }

+ 7
- 1
src/pages/system/systemSet/userManger/index.vue 查看文件

89
             <div class="flex-item">
89
             <div class="flex-item">
90
               <div>
90
               <div>
91
                 <el-input
91
                 <el-input
92
-                  placeholder="请输入角色"
92
+                  placeholder="请输入角色名称并按回车搜索"
93
                   v-model="postData.searchData"
93
                   v-model="postData.searchData"
94
+                  @change='getRole'
94
                   clearable>
95
                   clearable>
95
                 </el-input>
96
                 </el-input>
96
               </div>
97
               </div>
218
     },
219
     },
219
     ...mapUserActions(['upDateRoleList']),
220
     ...mapUserActions(['upDateRoleList']),
220
     addTag (tag) {
221
     addTag (tag) {
222
+      // 调用添加绑定角色接口
223
+      this.tags.push(tag)
221
       this.upDateRoleList(tag)
224
       this.upDateRoleList(tag)
225
+    },
226
+    getRole () { // 绑定角色搜索事件,发送请求搜索角色列表
227
+      console.log(this.postData.searchData)
222
     }
228
     }
223
   }
229
   }
224
 }
230
 }

+ 4
- 2
src/store/index.js 查看文件

1
 import Vue from 'vue'
1
 import Vue from 'vue'
2
 import Vuex from 'vuex'
2
 import Vuex from 'vuex'
3
-
3
+import Ajax from '../util/ajax'
4
+import api from '../util/api'
4
 Vue.use(Vuex)
5
 Vue.use(Vuex)
5
 
6
 
6
 const store = new Vuex.Store({
7
 const store = new Vuex.Store({
8
     loadding: false,
9
     loadding: false,
9
   }
10
   }
10
 })
11
 })
11
-
12
+Vuex.Store.prototype.$api = api
13
+Vuex.Store.prototype.$ajax = Ajax
12
 export const modules = {
14
 export const modules = {
13
   case: () => require('./case').default,
15
   case: () => require('./case').default,
14
   user: () => require('./user').default,
16
   user: () => require('./user').default,

+ 12
- 0
src/store/user/index.js 查看文件

24
   },
24
   },
25
   mutations: {
25
   mutations: {
26
     deleteRoleListItem (state, index) { // 这里的state对应着上面这个state
26
     deleteRoleListItem (state, index) { // 这里的state对应着上面这个state
27
+      this.$ajax(this.$api.test.area.url, {
28
+        method: this.$api.test.area.method,
29
+        data: {
30
+          caseid: 1,
31
+          id: 2
32
+        }
33
+      })
34
+        .then((res) => {
35
+          console.log(res)
36
+        }).catch(msg => {
37
+          return false
38
+        })
27
       state.roleList.splice(state.roleList.indexOf(index), 1) // 你还可以在这里执行其他的操作改变state
39
       state.roleList.splice(state.roleList.indexOf(index), 1) // 你还可以在这里执行其他的操作改变state
28
     }
40
     }
29
   },
41
   },

+ 7
- 14
src/util/ajax.js 查看文件

33
 })
33
 })
34
 
34
 
35
 Axios.interceptors.response.use((res) => {
35
 Axios.interceptors.response.use((res) => {
36
-  if (res.data.code === 1) {
37
-    return res
38
-  } else if (res.data.code === 2) {
36
+  console.log(res)
37
+  if (res.status === 200) {
38
+    return res.data
39
+  } else {
39
     Message({
40
     Message({
40
-      message: res.data.message,
41
-      position: 'bottom',
42
-      duration: 2000
41
+      message: res.data.msg,
42
+      type: 'error'
43
     })
43
     })
44
-    return res.data.code
45
-  } else if (res.data.code === 0) {
46
-    Message({
47
-      message: res.data.message,
48
-      position: 'bottom',
49
-      duration: 2000
50
-    })
51
-    return res.data.code
44
+    return res.data
52
   }
45
   }
53
 }, (error) => {
46
 }, (error) => {
54
   console.log(error)
47
   console.log(error)