index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <!-- -->
  2. <template>
  3. <div class="layout">
  4. <div class="top">
  5. <div class="left">
  6. <img src="../../assets/img/logo.png" alt="" />
  7. <h2>馆藏管理系统</h2>
  8. <div
  9. class="box"
  10. v-for="(item, index) in tabList"
  11. :key="index"
  12. >
  13. <a
  14. @click="toHome(index)"
  15. :class="{ active: $route.meta.myInd === index }"
  16. >
  17. {{ item.name }}
  18. <!-- v-show="isShow === index" -->
  19. <!-- <ul v-show="isShow === index" @mouseenter="isShow = index">
  20. <li
  21. v-for="(val, ind) in item.son"
  22. :key="ind"
  23. @click="skip(item, val.id,val.name)"
  24. >
  25. {{ val.name }}
  26. </li>
  27. </ul> -->
  28. </a>
  29. </div>
  30. <!-- <router-link to="/layout/holding0" :class='{active:$route.meta.myInd===1}'>馆藏管理
  31. <ul>
  32. <li>藏品登记</li>
  33. </ul>
  34. </router-link>
  35. <router-link to="/layout/collect0" :class='{active:$route.meta.myInd===2}'>征集品管理</router-link>
  36. <router-link to="/layout/statistics0" :class='{active:$route.meta.myInd===3}'>库房管理</router-link>
  37. <router-link to="/layout/system0" :class='{active:$route.meta.myInd===4}'>系统管理</router-link> -->
  38. </div>
  39. <div class="right" @click="pulldownShow=!pulldownShow">
  40. <div class="img">
  41. <img src="@/assets/img/user1.jpg" alt="" />
  42. </div>
  43. <span>{{ userData.realName }}</span>
  44. <i class="el-icon-caret-top" v-if="pulldownShow"></i>
  45. <i class="el-icon-caret-bottom" v-else></i>
  46. <!-- 点击箭头的显示和隐藏 -->
  47. <ul class="pulldown" v-show="pulldownShow">
  48. <li @click="isShow = true">修改密码</li>
  49. <li @click="loginOut">退出登录</li>
  50. </ul>
  51. </div>
  52. </div>
  53. <Router-view />
  54. <!-- 点击修改密码出现弹窗 -->
  55. <el-dialog title="修改密码" :visible.sync="isShow" @close="btnX()">
  56. <el-form :model="form" label-width="100px" :rules="rules" ref="ruleForm">
  57. <el-form-item label="旧密码:" prop="oldPassword">
  58. <el-input
  59. v-model="form.oldPassword"
  60. placeholder="请输入"
  61. show-password
  62. ></el-input>
  63. </el-form-item>
  64. <el-form-item label="新密码:" prop="newPassword">
  65. <el-input
  66. v-model="form.newPassword"
  67. placeholder="请输入"
  68. show-password
  69. ></el-input>
  70. </el-form-item>
  71. <el-form-item label="确定新密码:" prop="checkPass">
  72. <el-input
  73. v-model="form.checkPass"
  74. placeholder="请输入"
  75. show-password
  76. ></el-input>
  77. </el-form-item>
  78. </el-form>
  79. <div slot="footer" class="dialog-footer">
  80. <el-button @click="btnX">取 消</el-button>
  81. <el-button type="primary" @click="btnOk">确 定</el-button>
  82. </div>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script>
  87. import { loginOut, editPass } from '@/apis/home'
  88. export default {
  89. name: 'Layout',
  90. // import引入的组件需要注入到对象中才能使用
  91. components: {},
  92. data () {
  93. // 这里存放数据
  94. const validatePass2 = (rule, value, callback) => {
  95. if (value !== this.form.newPassword) {
  96. callback(new Error('两次输入密码不一致!'))
  97. } else {
  98. callback()
  99. }
  100. }
  101. return {
  102. isShow: false,
  103. pulldownShow: false,
  104. // 修改密码
  105. form: {
  106. oldPassword: '',
  107. newPassword: '',
  108. checkPass: ''
  109. },
  110. // 用户信息
  111. userData: {},
  112. // 控制子菜单显示
  113. // isShow: 0,
  114. tabList: [
  115. {
  116. name: '首页',
  117. push: '/layout/home'
  118. },
  119. {
  120. name: '馆藏管理',
  121. push: '/layout/holding',
  122. son: [
  123. { name: '藏品登记', id: 0, ip: 100 },
  124. { name: '藏品总账', id: 3, ip: 200 },
  125. { name: '入库管理', id: 1, ip: 300 },
  126. { name: '出库管理', id: 2, ip: 400 },
  127. { name: '藏品修改', id: 4, ip: 500 },
  128. { name: '藏品注销', id: 5, ip: 600 }
  129. ]
  130. },
  131. // {
  132. // name: '征集管理',
  133. // push: '/layout/collect',
  134. // son: [
  135. // { name: '征集品总账', id: 0 },
  136. // { name: '征集品提用', id: 1 },
  137. // { name: '征集品修改', id: 3 },
  138. // { name: '征集品注销', id: 2 }
  139. // ]
  140. // },
  141. {
  142. name: '库房管理',
  143. push: '/layout/statistics',
  144. son: [
  145. { name: '库房设置', id: 0, ip: 700 },
  146. { name: '统计报表', id: 1, ip: 99999 },
  147. { name: '藏品移库', id: 2, ip: 800 }
  148. ]
  149. }
  150. // {
  151. // name: '系统管理',
  152. // push: '/layout/system',
  153. // son: [
  154. // { name: '用户管理', id: 2 },
  155. // { name: '角色管理', id: 3 },
  156. // { name: '系统日志', id: 1 }
  157. // ]
  158. // }
  159. ],
  160. rules: {
  161. checkPass: [
  162. { validator: validatePass2, trigger: 'blur' }
  163. ],
  164. oldPassword: [
  165. { required: true, message: '不能为空', trigger: 'blur' }
  166. ],
  167. newPassword: [
  168. { required: true, message: '不能为空', trigger: 'blur' }
  169. ]
  170. }
  171. }
  172. },
  173. // 监听属性 类似于data概念
  174. computed: {},
  175. // 监控data中的数据变化
  176. watch: {},
  177. // 方法集合
  178. methods: {
  179. // 修改密码点击取消
  180. btnX () {
  181. this.$refs.ruleForm.resetFields()
  182. this.cut = false
  183. this.isShow = false
  184. this.form = {
  185. oldPassword: '',
  186. newPassword: '',
  187. checkPass: ''
  188. }
  189. },
  190. // 修改密码点击确定
  191. async btnOk () {
  192. await this.$refs.ruleForm.validate()
  193. try {
  194. await editPass(this.form)
  195. this.$message.success('修改成功')
  196. localStorage.removeItem('daliCK')
  197. localStorage.removeItem('daliCK_token')
  198. this.$router.push('/login')
  199. } catch (error) {
  200. this.$message.error('旧密码错误')
  201. }
  202. },
  203. // 退出登录
  204. loginOut () {
  205. this.$confirm('确定退出吗?', '提示', {
  206. confirmButtonText: '确定',
  207. cancelButtonText: '取消',
  208. type: 'warning'
  209. })
  210. .then(async () => {
  211. // 发请求,清空数据
  212. await loginOut()
  213. localStorage.removeItem('daliCK')
  214. localStorage.removeItem('daliCK_token')
  215. this.$router.push('/login')
  216. this.$message({
  217. type: 'success',
  218. message: '退出成功!'
  219. })
  220. })
  221. .catch(() => {
  222. this.$message({
  223. type: 'info',
  224. message: '已取消.'
  225. })
  226. })
  227. },
  228. // skip (item, ind, name) {
  229. // this.$router.push(item.push + ind).catch(() => {})
  230. // this.isShow = 0
  231. // // 如果从别的tab栏点击藏品总账,就自动刷新页面获取最新信息 location.reload(true)
  232. // this.$nextTick(() => {
  233. // setTimeout(() => {
  234. // if (name === '藏品总账' || name === '征集品总账') location.reload(true)
  235. // }, 500)
  236. // })
  237. // },
  238. toHome (index) {
  239. if (index === 0) this.$router.push('/layout/home').catch(() => {})
  240. if (index === 1) this.$router.push('/layout/holding0').catch(() => {})
  241. if (index === 2) this.$router.push('/layout/statistics0').catch(() => {})
  242. if (index === 3) this.$router.push('/layout/system2').catch(() => {})
  243. }
  244. },
  245. // 生命周期 - 创建完成(可以访问当前this实例)
  246. created () {},
  247. // 生命周期 - 挂载完成(可以访问DOM元素)
  248. mounted () {
  249. // 进来显示用户信息
  250. const userData = localStorage.getItem('daliCK')
  251. this.userData = JSON.parse(userData).user
  252. // 只有系统管理员才能看到系统管理
  253. // 获取用户角色权限标识
  254. let temp = localStorage.getItem('daliCK')
  255. temp = JSON.parse(temp)
  256. if (temp) {
  257. const temp2 = temp.role[0]
  258. if (temp2 === 'sys_admin' || temp2 === 'sys_user') {
  259. this.tabList.push(
  260. {
  261. name: '系统管理',
  262. push: '/layout/system',
  263. son: [
  264. { name: '用户管理', id: 2 },
  265. { name: '角色管理', id: 3 },
  266. { name: '系统日志', id: 1 }
  267. ]
  268. }
  269. )
  270. } // 不是超级管理员和系统管理员
  271. }
  272. // 获取用户权限数据
  273. // let temp2 = localStorage.getItem('daliCK_limits')
  274. // temp2 = JSON.parse(temp2)
  275. // // console.log(666, this.tabList[1].son, this.tabList[2].son)
  276. // const tempList1 = []
  277. // const tempList2 = []
  278. // temp2.forEach(v => {
  279. // if (v.authority) {
  280. // if ((this.tabList[1].son.filter(p => p.ip === v.id))[0]) tempList1.push((this.tabList[1].son.filter(p => p.ip === v.id))[0])
  281. // if ((this.tabList[2].son.filter(p => p.ip === v.id))[0]) tempList2.push((this.tabList[2].son.filter(p => p.ip === v.id))[0])
  282. // }
  283. // })
  284. // this.tabList[1].son = tempList1
  285. // tempList2.push({ name: '统计报表', id: 1, ip: 99999 })
  286. // this.tabList[2].son = tempList2
  287. // console.log(999, temp2)
  288. },
  289. beforeCreate () {}, // 生命周期 - 创建之前
  290. beforeMount () {}, // 生命周期 - 挂载之前
  291. beforeUpdate () {}, // 生命周期 - 更新之前
  292. updated () {}, // 生命周期 - 更新之后
  293. beforeDestroy () {}, // 生命周期 - 销毁之前
  294. destroyed () {}, // 生命周期 - 销毁完成
  295. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  296. }
  297. </script>
  298. <style lang='less' scoped>
  299. .layout {
  300. .top {
  301. min-width: 1142px;
  302. display: flex;
  303. justify-content: space-between;
  304. width: 100%;
  305. height: 68px;
  306. background-color: #001529;
  307. }
  308. .left {
  309. .active {
  310. color: #fff;
  311. }
  312. display: flex;
  313. align-items: center;
  314. & > img {
  315. margin-left: 15px;
  316. }
  317. h2 {
  318. color: #fff;
  319. margin-right: 30px;
  320. }
  321. .active {
  322. background-color: #3E5EB3;
  323. font-weight: 700;
  324. }
  325. .box {
  326. position: relative;
  327. cursor: pointer;
  328. margin: 0 10px;
  329. a{
  330. text-align: center;
  331. width: 94px;
  332. color: #fff;
  333. display: block;
  334. height: 68px;
  335. line-height: 68px;
  336. }
  337. ul {
  338. z-index: 9999;
  339. position: absolute;
  340. top: 66px;
  341. left: -18px;
  342. background-color: #001529;
  343. li {
  344. width: 130px;
  345. height: 50px;
  346. line-height: 50px;
  347. text-align: center;
  348. color: #a5acb3;
  349. font-size: 14px;
  350. }
  351. li:hover {
  352. background-color: #3E5EB3;
  353. color: #fff;
  354. }
  355. }
  356. }
  357. .box:hover a {
  358. background-color: #3E5EB3;
  359. }
  360. }
  361. .right {
  362. cursor: pointer;
  363. color: #fff;
  364. position: relative;
  365. .editPass {
  366. .button{
  367. width: 100%;
  368. display: flex;
  369. justify-content: center;
  370. }
  371. /deep/.el-form-item__label{
  372. color: #fff;
  373. }
  374. padding: 20px;
  375. z-index: 9999;
  376. position: absolute;
  377. top: 68px;
  378. right: 0px;
  379. width: 300px;
  380. // background: rgba(0,0,0,.8);
  381. background-color: #001529;
  382. }
  383. .loginOut {
  384. cursor: pointer;
  385. }
  386. display: flex;
  387. align-items: center;
  388. margin-right: 50px;
  389. .img {
  390. width: 40px;
  391. height: 40px;
  392. border-radius: 50%;
  393. overflow: hidden;
  394. img {
  395. width: 100%;
  396. height: 100%;
  397. }
  398. }
  399. & > span {
  400. margin-left: 15px;
  401. }
  402. i {
  403. margin-top: 5px;
  404. margin-left: 5px;
  405. }
  406. .pulldown{
  407. z-index: 999;
  408. background-color: #fff;
  409. position: absolute;
  410. bottom: -74px;
  411. right: 0px;
  412. li {
  413. padding:10px 20px;
  414. height: 40px;
  415. color: #3E5EB3;
  416. }
  417. li:hover{
  418. background-color:#3E5EB3;
  419. color: #fff;
  420. }
  421. }
  422. }
  423. }
  424. </style>