Browse Source

1. 绑定keyup时间
2. 调整样式

daxiong.yang 7 years ago
parent
commit
e541634e36

+ 3 - 3
src/api/modules/role.js

@ -13,7 +13,7 @@ export function list (params) {
13 13
}
14 14
15 15
// 获取角色列表, 根据当前用户
16
export function listByUser () {
16
export function select () {
17 17
  return request({
18 18
    url: requestUrl('/sys/role/select'),
19 19
    method: 'get',
@ -22,9 +22,9 @@ export function listByUser () {
22 22
}
23 23
24 24
// 获取角色信息
25
export function info (roleId) {
25
export function info (id) {
26 26
  return request({
27
    url: requestUrl('/sys/role/info' + (isInteger(roleId) ? `/${roleId}` : '')),
27
    url: requestUrl('/sys/role/info' + (isInteger(id) ? `/${id}` : '')),
28 28
    method: 'get',
29 29
    params: requestParam({}, 'get')
30 30
  })

+ 2 - 2
src/api/modules/user.js

@ -13,9 +13,9 @@ export function list (params) {
13 13
}
14 14
15 15
// 获取用户信息
16
export function info (userId) {
16
export function info (id) {
17 17
  return request({
18
    url: requestUrl('/sys/user/info' + (isInteger(userId) ? `/${userId}` : '')),
18
    url: requestUrl('/sys/user/info' + (isInteger(id) ? `/${id}` : '')),
19 19
    method: 'get',
20 20
    params: requestParam({}, 'get')
21 21
  })

+ 13 - 4
src/assets/scss/_base.scss

@ -79,11 +79,12 @@ img {
79 79
  .el-submenu__title {
80 80
    text-align: center;
81 81
  }
82
  .site-sidebar__menu-icon {
83
    margin-right: 0;
84
    font-size: 20px;
82
  .site-sidebar__menu.el-menu {
83
    .site-sidebar__menu-icon {
84
      margin-right: 0;
85
      font-size: 20px;
86
    }
85 87
  }
86
  .el-menu-item span,
87 88
  .el-submenu > .el-submenu__title span {
88 89
    display: none;
89 90
  }
@ -106,6 +107,7 @@ img {
106 107
  float: left;
107 108
  width: 230px;
108 109
  height: 50px;
110
  transition: width .2s;
109 111
}
110 112
.site-logo {
111 113
  display: table-cell;
@ -116,6 +118,7 @@ img {
116 118
  font-size: 20px;
117 119
  text-align: center;
118 120
  text-transform: uppercase;
121
  transition: width .2s;
119 122
  &__lg,
120 123
  &__mini {
121 124
    color: #fff;
@ -149,6 +152,7 @@ img {
149 152
  margin-left: 230px;
150 153
  padding-right: 15px;
151 154
  background-color: #fff;
155
  transition: margin-left .2s;
152 156
}
153 157
.site-topbar__menu {
154 158
  float: left;
@ -176,6 +180,7 @@ img {
176 180
  width: 230px;
177 181
  background-color: #545c64;
178 182
  overflow: hidden;
183
  transition: width .2s;
179 184
}
180 185
.site-sidebar__inner {
181 186
  position: relative;
@ -184,10 +189,12 @@ img {
184 189
  height: 100%;
185 190
  padding-bottom: 15px;
186 191
  overflow-y: scroll;
192
  transition: width .2s;
187 193
}
188 194
.site-sidebar__menu.el-menu {
189 195
  width: 230px;
190 196
  border-right: 0;
197
  transition: width .2s;
191 198
  .site-sidebar__menu-icon {
192 199
    margin-right: 5px;
193 200
    font-size: 16px;
@ -200,6 +207,7 @@ img {
200 207
  padding-top: 50px;
201 208
  margin-left: 230px;
202 209
  min-height: 100%;
210
  transition: margin-left .2s;
203 211
}
204 212
.site-content {
205 213
  position: relative;
@ -217,6 +225,7 @@ img {
217 225
      padding: 0 15px;
218 226
      box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .12), 0 0 6px 0 rgba(0, 0, 0, .04);
219 227
      background-color: #fff;
228
      transition: left .2s;
220 229
    }
221 230
    .el-tabs__nav-wrap {
222 231
      margin-bottom: 0;

+ 1 - 0
src/store/mutation-types.js

@ -4,6 +4,7 @@ export const UPDATE_DOCUMENT_CLIENT_HEIGHT = 'UPDATE_DOCUMENT_CLIENT_HEIGHT'
4 4
export const UPDATE_MENU_NAV_LIST = 'UPDATE_MENU_NAV_LIST'
5 5
export const ADD_CONTENT_TAB = 'ADD_CONTENT_TAB'
6 6
export const UPDATE_CONTENT_TABS = 'UPDATE_CONTENT_TABS'
7
export const DELETE_CONTENT_TABS = 'DELETE_CONTENT_TABS'
7 8
export const UPDATE_CONTENT_TABS_ACTIVE_NAME = 'UPDATE_CONTENT_TABS_ACTIVE_NAME'
8 9
// 用户
9 10
export const UPDATE_USER_ID = 'UPDATE_USER_ID'

+ 4 - 0
src/store/mutations.js

@ -21,6 +21,10 @@ export default {
21 21
    state.contentTabs = tabs
22 22
  },
23 23
24
  [types.DELETE_CONTENT_TABS] (state) {
25
    state.contentTabs = []
26
  },
27
24 28
  [types.UPDATE_CONTENT_TABS_ACTIVE_NAME] (state, { name }) {
25 29
    state.contentTabsActiveName = name
26 30
  }

+ 1 - 1
src/views/config/index.vue

@ -1,6 +1,6 @@
1 1
<template>
2 2
  <div class="mod-config">
3
    <el-form :inline="true" :model="dataForm">
3
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
4 4
      <el-form-item>
5 5
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
6 6
      </el-form-item>

+ 6 - 4
src/views/home/index.vue

@ -1,6 +1,6 @@
1 1
<template>
2 2
  <div class="site-content site-content--home">
3
    <el-card :style="contentViewHeight()">
3
    <el-card :style="contentViewStyles">
4 4
      <h3>项目介绍</h3>
5 5
      <ul>
6 6
        <li><a href="http://demo.renren.io/renren-fast/" target="_blank">http://demo.renren.io/renren-fast/</a></li>
@ -34,14 +34,16 @@
34 34
      return {
35 35
      }
36 36
    },
37
    methods: {
38
      contentViewHeight () {
37
    computed: {
38
      contentViewStyles () {
39 39
        var height = this.$store.state.documentClientHeight
40 40
        height -= 50 // site-topbar
41 41
        height -= 15 // site-content padding-top
42 42
        height -= 15 // site-content padding-bottom
43 43
        height += 'px'
44
        return { minHeight: height }
44
        return [
45
          { minHeight: height }
46
        ]
45 47
      }
46 48
    }
47 49
  }

+ 1 - 1
src/views/layout/sidebar.vue

@ -9,7 +9,7 @@
9 9
        text-color="#fff"
10 10
        active-text-color="#ffd04b">
11 11
        <el-menu-item index="1-1" @click="$router.push({ name: 'home' })">
12
          <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg>
12
          <i class="site-sidebar__menu-icon fa fa-home"></i>
13 13
          <span slot="title">首页</span>
14 14
        </el-menu-item>
15 15
        <sub-menu-nav

+ 16 - 9
src/views/layout/topbar.vue

@ -1,9 +1,9 @@
1 1
<template>
2 2
  <header class="site-topbar">
3 3
    <div class="site-topbar__header">
4
      <h1 class="site-logo">
5
        <a class="site-logo__lg" href="/">Vue-cli-basic</a>
6
        <a class="site-logo__mini" href="/">Vue</a>
4
      <h1 class="site-logo" @click="$router.push({ name: 'home' })">
5
        <a class="site-logo__lg" href="javascript:;">Vue-cli-basic</a>
6
        <a class="site-logo__mini" href="javascript:;">Vue</a>
7 7
      </h1>
8 8
    </div>
9 9
    <div class="site-topbar__body clearfix">
@ -63,14 +63,21 @@
63 63
      },
64 64
      // 退出
65 65
      logoutHandle () {
66
        API.common.logout().then(({data}) => {
67
          if (data && data.code === 0) {
68
            this.$cookie.delete('token')
69
            this.$router.replace({ name: 'login' })
70
          }
66
        this.$confirm(`确定进行[退出]操作?`, '提示', {
67
          confirmButtonText: '确定',
68
          cancelButtonText: '取消',
69
          type: 'warning'
70
        }).then(() => {
71
          API.common.logout().then(({data}) => {
72
            if (data && data.code === 0) {
73
              this.DELETE_CONTENT_TABS([])
74
              this.$cookie.delete('token')
75
              this.$router.replace({ name: 'login' })
76
            }
77
          })
71 78
        })
72 79
      },
73
      ...mapMutations(['SWITCH_SIDEBAR_COLLAPSE'])
80
      ...mapMutations(['SWITCH_SIDEBAR_COLLAPSE', 'DELETE_CONTENT_TABS'])
74 81
    }
75 82
  }
76 83
</script>

+ 5 - 2
src/views/layout/update-password.vue

@ -3,7 +3,7 @@
3 3
    title="修改密码"
4 4
    :visible.sync="visible"
5 5
    :append-to-body="true">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
7 7
      <el-form-item label="账号">
8 8
        <span>{{ $store.state.user.name }}</span>
9 9
      </el-form-item>
@ -26,6 +26,7 @@
26 26
27 27
<script>
28 28
  import API from '@/api'
29
  import { mapMutations } from 'vuex'
29 30
  export default {
30 31
    data () {
31 32
      var validateConfirmPassword = (rule, value, callback) => {
@ -81,6 +82,7 @@
81 82
                  onClose: () => {
82 83
                    this.visible = false
83 84
                    this.$nextTick(() => {
85
                      this.DELETE_CONTENT_TABS([])
84 86
                      this.$cookie.delete('token')
85 87
                      this.$router.replace({ name: 'login' })
86 88
                    })
@ -92,7 +94,8 @@
92 94
            })
93 95
          }
94 96
        })
95
      }
97
      },
98
      ...mapMutations(['DELETE_CONTENT_TABS'])
96 99
    }
97 100
  }
98 101
</script>

+ 1 - 1
src/views/log/index.vue

@ -1,6 +1,6 @@
1 1
<template>
2 2
  <div class="mod-log">
3
    <el-form :inline="true" :model="dataForm">
3
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
4 4
      <el-form-item>
5 5
        <el-input v-model="dataForm.key" placeholder="用户名/用户操作" clearable></el-input>
6 6
      </el-form-item>

+ 1 - 4
src/views/login/index.vue

@ -8,7 +8,7 @@
8 8
        </div>
9 9
        <div class="login-main">
10 10
          <h3 class="login-title">管理员登录</h3>
11
          <el-form :model="dataForm" :rules="dataRule" @keyup.enter.native="dataFormSubmit()" ref="dataForm" status-icon>
11
          <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" status-icon>
12 12
            <el-form-item prop="userName">
13 13
              <el-input v-model="dataForm.userName" placeholder="帐号"></el-input>
14 14
            </el-form-item>
@ -101,7 +101,6 @@
101 101
    left: 0;
102 102
    background-color: rgba(38, 50, 56, .6);
103 103
    overflow: hidden;
104
105 104
    &:before {
106 105
      position: fixed;
107 106
      top: 0;
@ -113,7 +112,6 @@
113 112
      background-image: url(~@/assets/img/login_bg.jpg);
114 113
      background-size: cover;
115 114
    }
116
117 115
    .site-content__wrapper {
118 116
      position: absolute;
119 117
      top: 0;
@ -159,7 +157,6 @@
159 157
    }
160 158
    .login-captcha {
161 159
      overflow: hidden;
162
163 160
      > img {
164 161
        width: 100%;
165 162
        cursor: pointer;

+ 1 - 1
src/views/menu/add-or-update.vue

@ -3,7 +3,7 @@
3 3
    :title="!dataForm.id ? '新增' : '修改'"
4 4
    :close-on-click-modal="false"
5 5
    :visible.sync="visible">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
7 7
      <el-form-item label="类型" prop="type">
8 8
        <el-radio-group v-model="dataForm.type">
9 9
          <el-radio :label="0">目录</el-radio>

+ 1 - 1
src/views/role/index.vue

@ -1,6 +1,6 @@
1 1
<template>
2 2
  <div class="mod-role">
3
    <el-form :inline="true" :model="dataForm">
3
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
4 4
      <el-form-item>
5 5
        <el-input v-model="dataForm.roleName" placeholder="角色名称" clearable></el-input>
6 6
      </el-form-item>

+ 1 - 1
src/views/schedule/index.vue

@ -1,6 +1,6 @@
1 1
<template>
2 2
  <div class="mod-schedule">
3
    <el-form :inline="true" :model="dataForm">
3
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
4 4
      <el-form-item>
5 5
        <el-input v-model="dataForm.beanName" placeholder="bean名称" clearable></el-input>
6 6
      </el-form-item>

+ 169 - 0
src/views/user/add-or-update.vue

@ -0,0 +1,169 @@
1
<template>
2
  <el-dialog
3
    :title="!dataForm.id ? '新增' : '修改'"
4
    :close-on-click-modal="false"
5
    :visible.sync="visible">
6
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
7
      <el-form-item label="用户名" prop="userName">
8
        <el-input v-model="dataForm.userName" placeholder="登录帐号"></el-input>
9
      </el-form-item>
10
      <el-form-item label="密码" prop="password" :class="{ 'is-required': !dataForm.id }">
11
        <el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
12
      </el-form-item>
13
      <el-form-item label="确认密码" prop="comfirmPassword" :class="{ 'is-required': !dataForm.id }">
14
        <el-input v-model="dataForm.comfirmPassword" type="password" placeholder="确认密码"></el-input>
15
      </el-form-item>
16
      <el-form-item label="邮箱" prop="email">
17
        <el-input v-model="dataForm.email" placeholder="邮箱"></el-input>
18
      </el-form-item>
19
      <el-form-item label="手机号" prop="mobile">
20
        <el-input v-model="dataForm.mobile" placeholder="手机号"></el-input>
21
      </el-form-item>
22
      <el-form-item label="角色" size="mini" prop="roleIdList">
23
        <el-checkbox-group v-model="dataForm.roleIdList">
24
          <el-checkbox v-for="role in roleList" :key="role.roleId" :label="role.roleId">{{ role.roleName }}</el-checkbox>
25
        </el-checkbox-group>
26
      </el-form-item>
27
      <el-form-item label="状态" size="mini" prop="status">
28
        <el-radio-group v-model="dataForm.status">
29
          <el-radio :label="0">禁用</el-radio>
30
          <el-radio :label="1">正常</el-radio>
31
        </el-radio-group>
32
      </el-form-item>
33
    </el-form>
34
    <span slot="footer" class="dialog-footer">
35
      <el-button @click="visible = false">取消</el-button>
36
      <el-button type="primary" @click="addOrUpdateFormSubmit()">确定</el-button>
37
    </span>
38
  </el-dialog>
39
</template>
40
41
<script>
42
  import API from '@/api'
43
  import { isEmail, isMobile } from '@/utils/validate'
44
  export default {
45
    data () {
46
      var validatePassword = (rule, value, callback) => {
47
        if (!this.dataForm.id && !/\S/.test(value)) {
48
          callback(new Error('密码不能为空'))
49
        } else {
50
          callback()
51
        }
52
      }
53
      var validateComfirmPassword = (rule, value, callback) => {
54
        if (!this.dataForm.id && !/\S/.test(value)) {
55
          callback(new Error('确认密码不能为空'))
56
        } else if (this.dataForm.password !== value) {
57
          callback(new Error('确认密码与密码输入不一致'))
58
        } else {
59
          callback()
60
        }
61
      }
62
      var validateEmail = (rule, value, callback) => {
63
        if (!isEmail(value)) {
64
          callback(new Error('邮箱格式错误'))
65
        } else {
66
          callback()
67
        }
68
      }
69
      var validateMobile = (rule, value, callback) => {
70
        if (!isMobile(value)) {
71
          callback(new Error('手机号格式错误'))
72
        } else {
73
          callback()
74
        }
75
      }
76
      return {
77
        visible: false,
78
        roleList: [],
79
        dataForm: {
80
          id: 0,
81
          userName: '',
82
          password: '',
83
          comfirmPassword: '',
84
          email: '',
85
          mobile: '',
86
          roleIdList: [],
87
          status: 1
88
        },
89
        dataRule: {
90
          userName: [
91
            { required: true, message: '用户名不能为空', trigger: 'blur' }
92
          ],
93
          password: [
94
            { validator: validatePassword, trigger: 'blur' }
95
          ],
96
          comfirmPassword: [
97
            { validator: validateComfirmPassword, trigger: 'blur' }
98
          ],
99
          email: [
100
            { required: true, message: '邮箱不能为空', trigger: 'blur' },
101
            { validator: validateEmail, trigger: 'blur' }
102
          ],
103
          mobile: [
104
            { required: true, message: '手机号不能为空', trigger: 'blur' },
105
            { validator: validateMobile, trigger: 'blur' }
106
          ]
107
        }
108
      }
109
    },
110
    methods: {
111
      init (id) {
112
        this.dataForm.id = id || 0
113
        API.role.select().then(({data}) => {
114
          this.roleList = data && data.code === 0 ? data.list : []
115
        }).then(() => {
116
          this.visible = true
117
          this.$nextTick(() => {
118
            this.$refs['dataForm'].resetFields()
119
          })
120
        }).then(() => {
121
          if (this.dataForm.id) {
122
            API.user.info(this.dataForm.id).then(({data}) => {
123
              if (data && data.code === 0) {
124
                this.dataForm.userName = data.user.username
125
                this.dataForm.email = data.user.email
126
                this.dataForm.mobile = data.user.mobile
127
                this.dataForm.roleIdList = data.user.roleIdList
128
                this.dataForm.status = data.user.status
129
              }
130
            })
131
          }
132
        })
133
      },
134
      // 新增 / 修改, 提交
135
      addOrUpdateFormSubmit () {
136
        this.$refs['dataForm'].validate((valid) => {
137
          if (valid) {
138
            var params = {
139
              'userId': this.dataForm.id || undefined,
140
              'username': this.dataForm.userName,
141
              'password': this.dataForm.password,
142
              'email': this.dataForm.email,
143
              'mobile': this.dataForm.mobile,
144
              'status': this.dataForm.status,
145
              'roleIdList': this.dataForm.roleIdList
146
            }
147
            var tick = this.dataForm.id ? API.user.update(params) : API.user.add(params)
148
            tick.then(({data}) => {
149
              if (data && data.code === 0) {
150
                this.$message({
151
                  message: '操作成功',
152
                  type: 'success',
153
                  duration: 1500,
154
                  onClose: () => {
155
                    this.visible = false
156
                    this.getDataList()
157
                  }
158
                })
159
              } else {
160
                this.$message.error(data.msg)
161
              }
162
            })
163
          }
164
        })
165
      }
166
    }
167
  }
168
</script>
169

+ 10 - 152
src/views/user/index.vue

@ -1,6 +1,6 @@
1 1
<template>
2 2
  <div class="mod-user">
3
    <el-form :inline="true" :model="dataForm">
3
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
4 4
      <el-form-item>
5 5
        <el-input v-model="dataForm.userName" placeholder="用户名" clearable></el-input>
6 6
      </el-form-item>
@ -86,81 +86,15 @@
86 86
      layout="total, sizes, prev, pager, next, jumper">
87 87
    </el-pagination>
88 88
    <!-- 弹窗, 新增 / 修改 -->
89
    <el-dialog
90
      :title="!addOrUpdateForm.userId ? '新增' : '修改'"
91
      :close-on-click-modal="false"
92
      :visible.sync="addOrUpdateDialogVisible">
93
      <el-form :model="addOrUpdateForm" :rules="addOrUpdateRule" ref="addOrUpdateForm" label-width="80px">
94
        <el-form-item label="用户名" prop="userName">
95
          <el-input v-model="addOrUpdateForm.userName" placeholder="登录帐号"></el-input>
96
        </el-form-item>
97
        <el-form-item label="密码" prop="password" :class="{ 'is-required': !addOrUpdateForm.userId }">
98
          <el-input v-model="addOrUpdateForm.password" type="password" placeholder="密码"></el-input>
99
        </el-form-item>
100
        <el-form-item label="确认密码" prop="comfirmPassword" :class="{ 'is-required': !addOrUpdateForm.userId }">
101
          <el-input v-model="addOrUpdateForm.comfirmPassword" type="password" placeholder="确认密码"></el-input>
102
        </el-form-item>
103
        <el-form-item label="邮箱" prop="email">
104
          <el-input v-model="addOrUpdateForm.email" placeholder="邮箱"></el-input>
105
        </el-form-item>
106
        <el-form-item label="手机号" prop="mobile">
107
          <el-input v-model="addOrUpdateForm.mobile" placeholder="手机号"></el-input>
108
        </el-form-item>
109
        <el-form-item label="角色" size="mini" prop="roleIdList">
110
          <el-checkbox-group v-model="addOrUpdateForm.roleIdList">
111
            <el-checkbox v-for="role in roleList" :key="role.roleId" :label="role.roleId">{{ role.roleName }}</el-checkbox>
112
          </el-checkbox-group>
113
        </el-form-item>
114
        <el-form-item label="状态" size="mini" prop="status">
115
          <el-radio-group v-model="addOrUpdateForm.status">
116
            <el-radio :label="0">禁用</el-radio>
117
            <el-radio :label="1">正常</el-radio>
118
          </el-radio-group>
119
        </el-form-item>
120
      </el-form>
121
      <span slot="footer" class="dialog-footer">
122
        <el-button @click="addOrUpdateDialogVisible = false">取消</el-button>
123
        <el-button type="primary" @click="addOrUpdateFormSubmit()">确定</el-button>
124
      </span>
125
    </el-dialog>
89
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
126 90
  </div>
127 91
</template>
128 92
129 93
<script>
130 94
  import API from '@/api'
131
  import { isEmail, isMobile } from '@/utils/validate'
95
  import AddOrUpdate from './add-or-update'
132 96
  export default {
133 97
    data () {
134
      var validatePassword = (rule, value, callback) => {
135
        if (!this.addOrUpdateForm.userId && !/\S/.test(value)) {
136
          callback(new Error('密码不能为空'))
137
        } else {
138
          callback()
139
        }
140
      }
141
      var validateComfirmPassword = (rule, value, callback) => {
142
        if (!this.addOrUpdateForm.userId && !/\S/.test(value)) {
143
          callback(new Error('确认密码不能为空'))
144
        } else if (this.addOrUpdateForm.password !== value) {
145
          callback(new Error('确认密码与密码输入不一致'))
146
        } else {
147
          callback()
148
        }
149
      }
150
      var validateEmail = (rule, value, callback) => {
151
        if (!isEmail(value)) {
152
          callback(new Error('邮箱格式错误'))
153
        } else {
154
          callback()
155
        }
156
      }
157
      var validateMobile = (rule, value, callback) => {
158
        if (!isMobile(value)) {
159
          callback(new Error('手机号格式错误'))
160
        } else {
161
          callback()
162
        }
163
      }
164 98
      return {
165 99
        dataForm: {
166 100
          userName: ''
@ -171,39 +105,12 @@
171 105
        totalPage: 0,
172 106
        dataListLoading: false,
173 107
        dataListSelections: [],
174
        roleList: [],
175
        addOrUpdateDialogVisible: false,
176
        addOrUpdateForm: {
177
          userId: 0,
178
          userName: '',
179
          password: '',
180
          comfirmPassword: '',
181
          email: '',
182
          mobile: '',
183
          roleIdList: [],
184
          status: 1
185
        },
186
        addOrUpdateRule: {
187
          userName: [
188
            { required: true, message: '用户名不能为空', trigger: 'blur' }
189
          ],
190
          password: [
191
            { validator: validatePassword, trigger: 'blur' }
192
          ],
193
          comfirmPassword: [
194
            { validator: validateComfirmPassword, trigger: 'blur' }
195
          ],
196
          email: [
197
            { required: true, message: '邮箱不能为空', trigger: 'blur' },
198
            { validator: validateEmail, trigger: 'blur' }
199
          ],
200
          mobile: [
201
            { required: true, message: '手机号不能为空', trigger: 'blur' },
202
            { validator: validateMobile, trigger: 'blur' }
203
          ]
204
        }
108
        addOrUpdateVisible: false
205 109
      }
206 110
    },
111
    components: {
112
      AddOrUpdate
113
    },
207 114
    activated () {
208 115
      this.getDataList()
209 116
    },
@ -244,58 +151,9 @@
244 151
      },
245 152
      // 新增 / 修改
246 153
      addOrUpdateHandle (id) {
247
        this.addOrUpdateForm.userId = id || 0
248
        API.role.listByUser().then(({data}) => {
249
          this.roleList = data && data.code === 0 ? data.list : []
250
        }).then(() => {
251
          this.addOrUpdateDialogVisible = true
252
          this.$nextTick(() => {
253
            this.$refs['addOrUpdateForm'].resetFields()
254
          })
255
        }).then(() => {
256
          if (this.addOrUpdateForm.userId) {
257
            API.user.info(this.addOrUpdateForm.userId).then(({data}) => {
258
              if (data && data.code === 0) {
259
                this.addOrUpdateForm.userName = data.user.username
260
                this.addOrUpdateForm.email = data.user.email
261
                this.addOrUpdateForm.mobile = data.user.mobile
262
                this.addOrUpdateForm.roleIdList = data.user.roleIdList
263
                this.addOrUpdateForm.status = data.user.status
264
              }
265
            })
266
          }
267
        })
268
      },
269
      // 新增 / 修改, 提交
270
      addOrUpdateFormSubmit () {
271
        this.$refs['addOrUpdateForm'].validate((valid) => {
272
          if (valid) {
273
            var params = {
274
              'userId': this.addOrUpdateForm.userId || undefined,
275
              'username': this.addOrUpdateForm.userName,
276
              'password': this.addOrUpdateForm.password,
277
              'email': this.addOrUpdateForm.email,
278
              'mobile': this.addOrUpdateForm.mobile,
279
              'status': this.addOrUpdateForm.status,
280
              'roleIdList': this.addOrUpdateForm.roleIdList
281
            }
282
            var tick = this.addOrUpdateForm.userId ? API.user.update(params) : API.user.add(params)
283
            tick.then(({data}) => {
284
              if (data && data.code === 0) {
285
                this.$message({
286
                  message: '操作成功',
287
                  type: 'success',
288
                  duration: 1500,
289
                  onClose: () => {
290
                    this.addOrUpdateDialogVisible = false
291
                    this.getDataList()
292
                  }
293
                })
294
              } else {
295
                this.$message.error(data.msg)
296
              }
297
            })
298
          }
154
        this.addOrUpdateVisible = true
155
        this.$nextTick(() => {
156
          this.$refs.addOrUpdate.init(id)
299 157
        })
300 158
      },
301 159
      // 删除