Rap 原分销系统代码Web
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

222 строки
8.0KB

  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :xs="24" :sm="24" :md="8" :lg="6" :xl="5" style="margin-bottom: 10px">
  5. <el-card class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>个人信息</span>
  8. </div>
  9. <div>
  10. <div style="text-align: center">
  11. <div class="el-upload">
  12. <img :src="user.avatarName ? baseApi + '/avatar/' + user.avatarName : Avatar" title="点击上传头像" class="avatar" @click="toggleShow">
  13. <myUpload
  14. v-model="show"
  15. :headers="headers"
  16. :url="updateAvatarApi"
  17. @crop-upload-success="cropUploadSuccess"
  18. />
  19. </div>
  20. </div>
  21. <ul class="user-info">
  22. <li><div style="height: 100%"><svg-icon icon-class="login" /> 登录账号<div class="user-right">{{ user.username }}</div></div></li>
  23. <li><svg-icon icon-class="user1" /> 用户昵称 <div class="user-right">{{ user.nickName }}</div></li>
  24. <li><svg-icon icon-class="dept" /> 所属部门 <div class="user-right"> {{ user.dept.name }}</div></li>
  25. <li><svg-icon icon-class="phone" /> 手机号码 <div class="user-right">{{ user.phone }}</div></li>
  26. <li><svg-icon icon-class="email" /> 用户邮箱 <div class="user-right">{{ user.email }}</div></li>
  27. <li>
  28. <svg-icon icon-class="anq" /> 安全设置
  29. <div class="user-right">
  30. <a @click="$refs.pass.dialog = true">修改密码</a>
  31. <a @click="$refs.email.dialog = true">修改邮箱</a>
  32. </div>
  33. </li>
  34. </ul>
  35. </div>
  36. </el-card>
  37. </el-col>
  38. <el-col :xs="24" :sm="24" :md="16" :lg="18" :xl="19">
  39. <!-- 用户资料 -->
  40. <el-card class="box-card">
  41. <el-tabs v-model="activeName" @tab-click="handleClick">
  42. <el-tab-pane label="用户资料" name="first">
  43. <el-form ref="form" :model="form" :rules="rules" style="margin-top: 10px;" size="small" label-width="65px">
  44. <el-form-item label="昵称" prop="nickName">
  45. <el-input v-model="form.nickName" style="width: 35%" />
  46. <span style="color: #C0C0C0;margin-left: 10px;">用户昵称不作为登录使用</span>
  47. </el-form-item>
  48. <el-form-item label="手机号" prop="phone">
  49. <el-input v-model="form.phone" style="width: 35%;" />
  50. <span style="color: #C0C0C0;margin-left: 10px;">手机号码不能重复</span>
  51. </el-form-item>
  52. <el-form-item label="性别">
  53. <el-radio-group v-model="form.gender" style="width: 178px">
  54. <el-radio label="男">男</el-radio>
  55. <el-radio label="女">女</el-radio>
  56. </el-radio-group>
  57. </el-form-item>
  58. <el-form-item label="">
  59. <el-button :loading="saveLoading" size="mini" type="primary" @click="doSubmit">保存配置</el-button>
  60. </el-form-item>
  61. </el-form>
  62. </el-tab-pane>
  63. <!-- 操作日志 -->
  64. <el-tab-pane label="操作日志" name="second">
  65. <el-table v-loading="loading" :data="data" style="width: 100%;">
  66. <el-table-column prop="description" label="行为" />
  67. <el-table-column prop="requestIp" label="IP" />
  68. <el-table-column :show-overflow-tooltip="true" prop="address" label="IP来源" />
  69. <el-table-column prop="browser" label="浏览器" />
  70. <el-table-column prop="time" label="请求耗时" align="center">
  71. <template slot-scope="scope">
  72. <el-tag v-if="scope.row.time <= 300">{{ scope.row.time }}ms</el-tag>
  73. <el-tag v-else-if="scope.row.time <= 1000" type="warning">{{ scope.row.time }}ms</el-tag>
  74. <el-tag v-else type="danger">{{ scope.row.time }}ms</el-tag>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. align="right"
  79. >
  80. <template slot="header">
  81. <div style="display:inline-block;float: right;cursor: pointer" @click="init">创建日期<i class="el-icon-refresh" style="margin-left: 40px" /></div>
  82. </template>
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.createTime }}</span>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. <!--分页组件-->
  89. <el-pagination
  90. :total="total"
  91. :current-page="page + 1"
  92. style="margin-top: 8px;"
  93. layout="total, prev, pager, next, sizes"
  94. @size-change="sizeChange"
  95. @current-change="pageChange"
  96. />
  97. </el-tab-pane>
  98. </el-tabs>
  99. </el-card>
  100. </el-col>
  101. </el-row>
  102. <updateEmail ref="email" :email="user.email" />
  103. <updatePass ref="pass" />
  104. </div>
  105. </template>
  106. <script>
  107. import myUpload from 'vue-image-crop-upload'
  108. import { mapGetters } from 'vuex'
  109. import updatePass from './center/updatePass'
  110. import updateEmail from './center/updateEmail'
  111. import { getToken } from '@/utils/auth'
  112. import store from '@/store'
  113. import { isvalidPhone } from '@/utils/validate'
  114. import crud from '@/mixins/crud'
  115. import { editUser } from '@/api/system/user'
  116. import Avatar from '@/assets/images/avatar.png'
  117. export default {
  118. name: 'Center',
  119. components: { updatePass, updateEmail, myUpload },
  120. mixins: [crud],
  121. data() {
  122. // 自定义验证
  123. const validPhone = (rule, value, callback) => {
  124. if (!value) {
  125. callback(new Error('请输入电话号码'))
  126. } else if (!isvalidPhone(value)) {
  127. callback(new Error('请输入正确的11位手机号码'))
  128. } else {
  129. callback()
  130. }
  131. }
  132. return {
  133. show: false,
  134. Avatar: Avatar,
  135. activeName: 'first',
  136. saveLoading: false,
  137. headers: {
  138. 'Authorization': getToken()
  139. },
  140. form: {},
  141. rules: {
  142. nickName: [
  143. { required: true, message: '请输入用户昵称', trigger: 'blur' },
  144. { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
  145. ],
  146. phone: [
  147. { required: true, trigger: 'blur', validator: validPhone }
  148. ]
  149. }
  150. }
  151. },
  152. computed: {
  153. ...mapGetters([
  154. 'user',
  155. 'updateAvatarApi',
  156. 'baseApi'
  157. ])
  158. },
  159. created() {
  160. this.form = { id: this.user.id, nickName: this.user.nickName, gender: this.user.gender, phone: this.user.phone }
  161. store.dispatch('GetInfo').then(() => {})
  162. },
  163. methods: {
  164. toggleShow() {
  165. this.show = !this.show
  166. },
  167. handleClick(tab, event) {
  168. if (tab.name === 'second') {
  169. this.init()
  170. }
  171. },
  172. beforeInit() {
  173. this.url = 'api/logs/user'
  174. return true
  175. },
  176. cropUploadSuccess(jsonData, field) {
  177. store.dispatch('GetInfo').then(() => {})
  178. },
  179. doSubmit() {
  180. if (this.$refs['form']) {
  181. this.$refs['form'].validate((valid) => {
  182. if (valid) {
  183. this.saveLoading = true
  184. editUser(this.form).then(() => {
  185. this.editSuccessNotify()
  186. store.dispatch('GetInfo').then(() => {})
  187. this.saveLoading = false
  188. }).catch(() => {
  189. this.saveLoading = false
  190. })
  191. }
  192. })
  193. }
  194. }
  195. }
  196. }
  197. </script>
  198. <style rel="stylesheet/scss" lang="scss">
  199. .avatar {
  200. width: 120px;
  201. height: 120px;
  202. border-radius: 50%;
  203. }
  204. .user-info {
  205. padding-left: 0;
  206. list-style: none;
  207. li{
  208. border-bottom: 1px solid #F0F3F4;
  209. padding: 11px 0;
  210. font-size: 13px;
  211. }
  212. .user-right {
  213. float: right;
  214. a{
  215. color: #317EF3;
  216. }
  217. }
  218. }
  219. </style>