【前端】智能库房综合管理系统前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

367 lines
11 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="app-container">
  3. <el-row class="container-main" :gutter="20">
  4. <el-col class="container-left" :xs="24" :sm="24" :md="8" :lg="6" :xl="5">
  5. <span class="right-top-line" />
  6. <span class="left-bottom-line" />
  7. <div class="user-content">
  8. <h4 class="info-title">个人信息</h4>
  9. <div class="el-upload">
  10. <img :src="user.avatarName ? baseApi + '/avatar/' + user.avatarName : Avatar" title="点击上传头像" class="avatar" @click="toggleShow">
  11. <myUpload
  12. v-model="show"
  13. :headers="headers"
  14. :url="updateAvatarApi"
  15. @crop-upload-success="cropUploadSuccess"
  16. />
  17. </div>
  18. <ul class="user-info">
  19. <li><div style="height: 100%"><i class="iconfont icon-dengluzhanghao-fanbai" /> 登录账号<div class="user-right">{{ user.username }}</div></div></li>
  20. <li><i class="iconfont icon-yonghunicheng-fanbai" /> 用户昵称 <div class="user-right">{{ user.nickName }}</div></li>
  21. <li><i class="iconfont icon-suoshubumen-fanbai" /> 所属部门 <div class="user-right"> {{ user.dept.name }}</div></li>
  22. <li><i class="iconfont icon-shoujihaoma-fanbai" /> 手机号码 <div class="user-right">{{ user.phone }}</div></li>
  23. <li><i class="iconfont icon-yonghuyouxiang-fanbai" /> 用户邮箱 <div class="user-right">{{ user.email }}</div></li>
  24. <li>
  25. <i class="iconfont icon-anquanshezhi-fanbai" /> 安全设置
  26. <div class="user-right">
  27. <a @click="$refs.pass.dialog = true">修改密码</a>
  28. <a @click="$refs.email.dialog = true">修改邮箱</a>
  29. </div>
  30. </li>
  31. </ul>
  32. </div>
  33. </el-col>
  34. <el-col class="container-right tab-content" :xs="24" :sm="24" :md="16" :lg="18" :xl="19">
  35. <span class="right-top-line" />
  36. <span class="left-bottom-line" />
  37. <div class="user-right-content">
  38. <ul class="tab-nav">
  39. <li :class="{'active-tab-nav': activeIndex == 0}" @click="handleClick(0)">用户资料<i /></li>
  40. <li :class="{'active-tab-nav': activeIndex == 1}" @click="handleClick(1)">操作日志<i /></li>
  41. <!-- 最右侧装饰img -->
  42. <span class="tab-right-img" />
  43. </ul>
  44. <div v-if="activeIndex == 0" class="tab-item">
  45. <el-form ref="form" :model="form" :rules="rules" size="small" label-width="65px">
  46. <el-form-item label="昵称" prop="nickName">
  47. <el-input v-model="form.nickName" style="width: 35%" />
  48. <span style="color:#999;margin-left: 22px;">用户昵称不作为登录使用</span>
  49. </el-form-item>
  50. <el-form-item label="手机号" prop="phone">
  51. <el-input v-model="form.phone" style="width: 35%;" />
  52. <span style="color: #999;margin-left: 22px;">手机号码不能重复</span>
  53. </el-form-item>
  54. <el-form-item label="性别">
  55. <el-radio-group v-model="form.gender" style="width: 178px">
  56. <el-radio label="男"></el-radio>
  57. <el-radio label="女"></el-radio>
  58. </el-radio-group>
  59. </el-form-item>
  60. <el-form-item label="">
  61. <el-button :loading="saveLoading" size="mini" type="primary" @click="doSubmit">保存配置</el-button>
  62. </el-form-item>
  63. </el-form>
  64. </div>
  65. <!-- 操作日志 -->
  66. <div v-if="activeIndex == 1" class="tab-item">
  67. <el-table v-loading="loading" :data="data" style="width: 100%;">
  68. <el-table-column prop="description" label="行为" />
  69. <el-table-column prop="requestIp" label="IP" />
  70. <el-table-column :show-overflow-tooltip="true" prop="address" label="IP来源" />
  71. <el-table-column prop="browser" label="浏览器" />
  72. <el-table-column prop="time" label="请求耗时" align="center">
  73. <template slot-scope="scope">
  74. <el-tag v-if="scope.row.time <= 300">{{ scope.row.time }}ms</el-tag>
  75. <el-tag v-else-if="scope.row.time <= 1000" type="warning">{{ scope.row.time }}ms</el-tag>
  76. <el-tag v-else type="danger">{{ scope.row.time }}ms</el-tag>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="right">
  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. </div>
  98. </div>
  99. </el-col>
  100. </el-row>
  101. <updateEmail ref="email" :email="user.email" />
  102. <updatePass ref="pass" />
  103. </div>
  104. </template>
  105. <script>
  106. import myUpload from 'vue-image-crop-upload'
  107. import { mapGetters } from 'vuex'
  108. import updatePass from './center/updatePass'
  109. import updateEmail from './center/updateEmail'
  110. import { getToken } from '@/utils/auth'
  111. import store from '@/store'
  112. import { isvalidPhone } from '@/utils/validate'
  113. import crud from '@/mixins/crud'
  114. import { editUser } from '@/api/system/user'
  115. import Avatar from '@/assets/images/avatar.png'
  116. export default {
  117. name: 'Center',
  118. components: { updatePass, updateEmail, myUpload },
  119. mixins: [crud],
  120. data() {
  121. // 自定义验证
  122. const validPhone = (rule, value, callback) => {
  123. if (!value) {
  124. callback(new Error('请输入电话号码'))
  125. } else if (!isvalidPhone(value)) {
  126. callback(new Error('请输入正确的11位手机号码'))
  127. } else {
  128. callback()
  129. }
  130. }
  131. return {
  132. show: false,
  133. Avatar: Avatar,
  134. activeIndex: 0,
  135. saveLoading: false,
  136. headers: {
  137. 'Authorization': getToken()
  138. },
  139. form: {},
  140. rules: {
  141. nickName: [
  142. { required: true, message: '请输入用户昵称', trigger: 'blur' },
  143. { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
  144. ],
  145. phone: [
  146. { required: true, trigger: 'blur', validator: validPhone }
  147. ]
  148. }
  149. }
  150. },
  151. computed: {
  152. ...mapGetters([
  153. 'user',
  154. 'updateAvatarApi',
  155. 'baseApi'
  156. ])
  157. },
  158. created() {
  159. this.form = { id: this.user.id, nickName: this.user.nickName, gender: this.user.gender, phone: this.user.phone }
  160. store.dispatch('GetInfo').then(() => {})
  161. },
  162. methods: {
  163. toggleShow() {
  164. this.show = !this.show
  165. },
  166. handleClick(index) {
  167. this.activeIndex = index
  168. if (this.activeIndex === 1) {
  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. .user-content{
  200. color: #fff;
  201. .iconfont{
  202. margin-right: 12px;
  203. }
  204. }
  205. .info-title{
  206. margin: 0;
  207. height: 40px;
  208. line-height: 40px;
  209. font-size: 16px;
  210. font-weight: bold;
  211. color: #359AFC;
  212. text-align: center;
  213. letter-spacing: 2px;
  214. background-color: #02255F;
  215. }
  216. .el-upload{
  217. display: block;
  218. width: 120px;
  219. height: 120px;
  220. border-radius: 50%;
  221. margin: 40px auto 60px auto;
  222. overflow: hidden;
  223. .avatar {
  224. width: 100%;
  225. height: 100%;
  226. }
  227. }
  228. .user-info {
  229. padding: 0 22px;
  230. list-style: none;
  231. li{
  232. border-bottom: 1px dashed #113D72;
  233. font-size: 14px;
  234. height: 41px;
  235. line-height: 40px;
  236. }
  237. .user-right {
  238. float: right;
  239. a{
  240. margin-left: 20px;
  241. color: #3A99FD;
  242. }
  243. }
  244. }
  245. .container-left,
  246. .container-right{
  247. min-height: calc(100vh - 230px);
  248. }
  249. .tab-content{
  250. margin-top: 40px;
  251. border-top: none;
  252. &::before{
  253. display: none;
  254. }
  255. .tab-nav{
  256. display: flex;
  257. justify-content: flex-start;
  258. height: 41px;
  259. line-height: 41px;
  260. margin: -41px 0 30px -1px;
  261. font-size: 16px;
  262. font-weight: bold;
  263. color: #359AFC;
  264. border-bottom: 1px solid #113D72;
  265. li{
  266. position: relative;
  267. padding: 0 24px;
  268. margin: -1px 30px 0 0;
  269. letter-spacing: 2px;
  270. border-top: 1px solid #113D72;
  271. cursor: pointer;
  272. &::before,
  273. &::after{
  274. content: "";
  275. position: absolute;
  276. top: 0;
  277. width: 33px;
  278. height: 41px;
  279. }
  280. &::before{
  281. left: -15px;
  282. background: url(~@/assets/images/tab_left.png) no-repeat;
  283. background-size: contain;
  284. }
  285. &::after{
  286. right: -32px;
  287. background: url(~@/assets/images/tab_right.png) no-repeat;
  288. background-size: contain;
  289. }
  290. &:first-child{
  291. border-left: 1px solid #113d72;;
  292. &::before{
  293. width: 17px;
  294. height: 17px;
  295. left: -1px;
  296. top: -1px;
  297. border-left: 1px solid #339cff;
  298. border-top: 1px solid #339cff;
  299. }
  300. }
  301. &.active-tab-nav{
  302. color: #fff;
  303. &::before{
  304. background: url(~@/assets/images/tab_left_active.png) no-repeat;
  305. background-size: contain;
  306. }
  307. &::after{
  308. background: url(~@/assets/images/tab_right_active.png) no-repeat;
  309. background-size: contain;
  310. }
  311. i{
  312. display: block;
  313. position: absolute;
  314. bottom: -1px;
  315. left: 0;
  316. width: 100%;
  317. height: 1px;
  318. border-bottom: 1px solid #021941;
  319. }
  320. }
  321. }
  322. .tab-right-img{
  323. display: block;
  324. width: 93px;
  325. margin: 4px 0 0 -14px;
  326. background: url(~@/assets/images/tab_img.png) no-repeat;
  327. background-size: contain;
  328. }
  329. }
  330. .el-form{
  331. padding: 0 20px;
  332. .el-form-item__label{
  333. color: #339CFF;
  334. }
  335. .el-input__inner{
  336. height: 36px;
  337. line-height: 36px;
  338. color: #fff;
  339. border: 1px solid #339CFF;
  340. background: transparent;
  341. }
  342. .el-radio{
  343. color: #fff;
  344. }
  345. .el-button{
  346. font-size: 16px;
  347. padding: 7px 20px;
  348. color: #fff;
  349. background: #3A99FD;
  350. }
  351. }
  352. }
  353. input:-webkit-autofill,
  354. textarea:-webkit-autofill,
  355. select:-webkit-autofill {
  356. -webkit-text-fill-color: #fff !important;
  357. background-color: transparent;
  358. transition: background-color 50000s ease-in-out 0s;
  359. }
  360. input {
  361. background-color: transparent;
  362. }
  363. </style>