index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. statisticsLim: true
  172. }
  173. },
  174. // 监听属性 类似于data概念
  175. computed: {},
  176. // 监控data中的数据变化
  177. watch: {},
  178. // 方法集合
  179. methods: {
  180. // 修改密码点击取消
  181. btnX () {
  182. this.$refs.ruleForm.resetFields()
  183. this.cut = false
  184. this.isShow = false
  185. this.form = {
  186. oldPassword: '',
  187. newPassword: '',
  188. checkPass: ''
  189. }
  190. },
  191. // 修改密码点击确定
  192. async btnOk () {
  193. await this.$refs.ruleForm.validate()
  194. try {
  195. await editPass(this.form)
  196. this.$message.success('修改成功')
  197. localStorage.removeItem('daliCK')
  198. localStorage.removeItem('daliCK_token')
  199. this.$router.push('/login')
  200. } catch (error) {
  201. this.$message.error('旧密码错误')
  202. }
  203. },
  204. // 退出登录
  205. loginOut () {
  206. this.$confirm('确定退出吗?', '提示', {
  207. confirmButtonText: '确定',
  208. cancelButtonText: '取消',
  209. type: 'warning'
  210. })
  211. .then(async () => {
  212. // 发请求,清空数据
  213. await loginOut()
  214. localStorage.removeItem('daliCK')
  215. localStorage.removeItem('daliCK_token')
  216. this.$router.push('/login')
  217. this.$message({
  218. type: 'success',
  219. message: '退出成功!'
  220. })
  221. })
  222. .catch(() => {
  223. this.$message({
  224. type: 'info',
  225. message: '已取消.'
  226. })
  227. })
  228. },
  229. // skip (item, ind, name) {
  230. // this.$router.push(item.push + ind).catch(() => {})
  231. // this.isShow = 0
  232. // // 如果从别的tab栏点击藏品总账,就自动刷新页面获取最新信息 location.reload(true)
  233. // this.$nextTick(() => {
  234. // setTimeout(() => {
  235. // if (name === '藏品总账' || name === '征集品总账') location.reload(true)
  236. // }, 500)
  237. // })
  238. // },
  239. toHome (index) {
  240. if (index === 0) this.$router.push('/layout/home').catch(() => {})
  241. if (index === 1) this.$router.push('/layout/holding0').catch(() => {})
  242. if (index === 2 && this.statisticsLim) this.$router.push('/layout/statistics0').catch(() => {})
  243. if (index === 2 && !this.statisticsLim) this.$router.push('/layout/statistics1').catch(() => {})
  244. if (index === 3) this.$router.push('/layout/system2').catch(() => {})
  245. }
  246. },
  247. // 生命周期 - 创建完成(可以访问当前this实例)
  248. created () {},
  249. // 生命周期 - 挂载完成(可以访问DOM元素)
  250. mounted () {
  251. // 进来显示用户信息
  252. const userData = localStorage.getItem('daliCK')
  253. this.userData = JSON.parse(userData).user
  254. // 只有系统管理员才能看到系统管理
  255. // 获取用户角色权限标识
  256. let temp = localStorage.getItem('daliCK')
  257. temp = JSON.parse(temp)
  258. if (temp) {
  259. const temp2 = temp.role[0]
  260. if (temp2 === 'sys_admin' || temp2 === 'sys_user') {
  261. this.tabList.push(
  262. {
  263. name: '系统管理',
  264. push: '/layout/system',
  265. son: [
  266. { name: '用户管理', id: 2 },
  267. { name: '角色管理', id: 3 },
  268. { name: '系统日志', id: 1 }
  269. ]
  270. }
  271. )
  272. } // 不是超级管理员和系统管理员
  273. }
  274. // 获取用户权限数据
  275. let temp3 = localStorage.getItem('daliCK_limits')
  276. temp3 = JSON.parse(temp3)
  277. this.statisticsLim = temp3[6].authority
  278. // console.log(temp3[6].authority)
  279. // // console.log(666, this.tabList[1].son, this.tabList[2].son)
  280. // const tempList1 = []
  281. // const tempList2 = []
  282. // temp2.forEach(v => {
  283. // if (v.authority) {
  284. // 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])
  285. // 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])
  286. // }
  287. // })
  288. // this.tabList[1].son = tempList1
  289. // tempList2.push({ name: '统计报表', id: 1, ip: 99999 })
  290. // this.tabList[2].son = tempList2
  291. // console.log(999, temp2)
  292. },
  293. beforeCreate () {}, // 生命周期 - 创建之前
  294. beforeMount () {}, // 生命周期 - 挂载之前
  295. beforeUpdate () {}, // 生命周期 - 更新之前
  296. updated () {}, // 生命周期 - 更新之后
  297. beforeDestroy () {}, // 生命周期 - 销毁之前
  298. destroyed () {}, // 生命周期 - 销毁完成
  299. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  300. }
  301. </script>
  302. <style lang='less' scoped>
  303. .layout {
  304. .top {
  305. min-width: 1142px;
  306. display: flex;
  307. justify-content: space-between;
  308. width: 100%;
  309. height: 68px;
  310. background-color: #001529;
  311. }
  312. .left {
  313. .active {
  314. color: #fff;
  315. }
  316. display: flex;
  317. align-items: center;
  318. & > img {
  319. margin-left: 15px;
  320. }
  321. h2 {
  322. color: #fff;
  323. margin-right: 30px;
  324. }
  325. .active {
  326. background-color: #3E5EB3;
  327. font-weight: 700;
  328. }
  329. .box {
  330. position: relative;
  331. cursor: pointer;
  332. margin: 0 10px;
  333. a{
  334. text-align: center;
  335. width: 94px;
  336. color: #fff;
  337. display: block;
  338. height: 68px;
  339. line-height: 68px;
  340. }
  341. ul {
  342. z-index: 9999;
  343. position: absolute;
  344. top: 66px;
  345. left: -18px;
  346. background-color: #001529;
  347. li {
  348. width: 130px;
  349. height: 50px;
  350. line-height: 50px;
  351. text-align: center;
  352. color: #a5acb3;
  353. font-size: 14px;
  354. }
  355. li:hover {
  356. background-color: #3E5EB3;
  357. color: #fff;
  358. }
  359. }
  360. }
  361. .box:hover a {
  362. background-color: #3E5EB3;
  363. }
  364. }
  365. .right {
  366. cursor: pointer;
  367. color: #fff;
  368. position: relative;
  369. .editPass {
  370. .button{
  371. width: 100%;
  372. display: flex;
  373. justify-content: center;
  374. }
  375. /deep/.el-form-item__label{
  376. color: #fff;
  377. }
  378. padding: 20px;
  379. z-index: 9999;
  380. position: absolute;
  381. top: 68px;
  382. right: 0px;
  383. width: 300px;
  384. // background: rgba(0,0,0,.8);
  385. background-color: #001529;
  386. }
  387. .loginOut {
  388. cursor: pointer;
  389. }
  390. display: flex;
  391. align-items: center;
  392. margin-right: 50px;
  393. .img {
  394. width: 40px;
  395. height: 40px;
  396. border-radius: 50%;
  397. overflow: hidden;
  398. img {
  399. width: 100%;
  400. height: 100%;
  401. }
  402. }
  403. & > span {
  404. margin-left: 15px;
  405. }
  406. i {
  407. margin-top: 5px;
  408. margin-left: 5px;
  409. }
  410. .pulldown{
  411. z-index: 999;
  412. background-color: #fff;
  413. position: absolute;
  414. bottom: -74px;
  415. right: 0px;
  416. li {
  417. padding:10px 20px;
  418. height: 40px;
  419. color: #3E5EB3;
  420. }
  421. li:hover{
  422. background-color:#3E5EB3;
  423. color: #fff;
  424. }
  425. }
  426. }
  427. }
  428. </style>