HomePage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <el-container :class="getRole">
  3. <el-aside>
  4. <div class="logo">
  5. <p v-if="userLoginDTO&&userLoginDTO.type=='0'"><b>医院知识库后台管理系统</b></p>
  6. </div>
  7. <lt-menu v-if="menuWrappers&&menuWrappers.length" v-bind:role="getRole" v-bind:data="menuWrappers"></lt-menu>
  8. </el-aside>
  9. <el-container>
  10. <el-header class="clearfix">
  11. <div class="title fl">
  12. <h2>{{organization&&organization.name}}</h2>
  13. </div>
  14. <div class="userInfo fr">
  15. <span class="username" @click="goCenter">
  16. <i>{{userLoginDTO&&userLoginDTO.linkman}}</i>
  17. <img class="actionDo" src="../../images/arrow_down.png" />
  18. </span>
  19. <ul class="action">
  20. <li @click="changeWords">修改密码</li>
  21. <li @click="logout">退出系统</li>
  22. </ul>
  23. </div>
  24. </el-header>
  25. <el-main>
  26. <router-view v-if="ok" v-on:status-change="changeStatus"></router-view>
  27. </el-main>
  28. </el-container>
  29. <el-dialog
  30. title="修改密码"
  31. class="changewords"
  32. :visible.sync="changePassWord"
  33. width="600"
  34. top="20vh"
  35. center>
  36. <el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
  37. <el-form-item label="旧密码:" prop="oldpass">
  38. <el-input type="password" placeholder="请输入旧密码" @keyup.enter.native="submitForm('ruleForm2')" v-model.trim="ruleForm2.oldpass" auto-complete="off"></el-input>
  39. </el-form-item>
  40. <el-form-item label="新密码:" prop="pass">
  41. <el-input type="password" placeholder="6-20位,可输入字符、数字或符号" @keyup.enter.native="submitForm('ruleForm2')" v-model.trim="ruleForm2.pass" auto-complete="off"></el-input>
  42. </el-form-item>
  43. <el-form-item label="再次输入新密码:" prop="checkPass">
  44. <el-input type="password" placeholder="6-20位,可输入字符、数字或符号" @keyup.enter.native="submitForm('ruleForm2')" v-model.trim="ruleForm2.checkPass" auto-complete="off"></el-input>
  45. </el-form-item>
  46. </el-form>
  47. <span slot="footer" class="dialog-footer">
  48. <el-button type="primary" @click="submitForm('ruleForm2')">确 定</el-button>
  49. </span>
  50. </el-dialog>
  51. </el-container>
  52. </template>
  53. <script>
  54. import LtMenu from '../common/Menu.vue';
  55. import api from '@api/index.js';
  56. import newIcon from '../../images/new.png';
  57. import md5 from 'js-md5'
  58. export default {
  59. name: 'homepage',
  60. components: {
  61. 'lt-menu': LtMenu,
  62. },
  63. data() {
  64. var validatePass1 = (rule, value, callback) => {
  65. if (value === '') {
  66. callback(new Error('请输入旧密码'));
  67. } else {
  68. callback();
  69. }
  70. };
  71. var validatePass = (rule, value, callback) => {
  72. if (value === '') {
  73. callback(new Error('请输入新密码'));
  74. } else {
  75. if (this.ruleForm2.checkPass !== '') {
  76. this.$refs.ruleForm2.validateField('checkPass');
  77. }
  78. callback();
  79. }
  80. };
  81. var validatePass2 = (rule, value, callback) => {
  82. if (value === '') {
  83. callback(new Error('请再次输入密码'));
  84. } else if (value !== this.ruleForm2.pass) {
  85. callback(new Error('两次输入密码不一致!'));
  86. } else {
  87. callback();
  88. }
  89. };
  90. return {
  91. menuWrappers: null,
  92. organization: null,
  93. userLoginDTO: null,
  94. authStatus: null,
  95. authStatusName:'',
  96. ok:false, //是否已获取到菜单
  97. versionName:'',
  98. versionVisible:false,
  99. versionInfo:'',
  100. isNewV:false,
  101. version:null, //版本信息接口返回的数据
  102. changePassWord: false,
  103. ruleForm2: {
  104. pass: '',
  105. checkPass: '',
  106. oldpass: ''
  107. },
  108. rules2: {
  109. oldpass: [
  110. { validator: validatePass1, trigger: 'change',required:true }
  111. ],
  112. pass: [
  113. { min: 6, max: 20, message: '密码要求6-20位,可输入字母、数字或符号', trigger: 'blur' },
  114. { validator: validatePass, trigger: 'blur',required:true }
  115. ],
  116. checkPass: [
  117. { min: 6, max: 20, message: '密码要求6-20位,可输入字母、数字或符号', trigger: 'blur' },
  118. { validator: validatePass2, trigger: 'blur',required:true }
  119. ]
  120. }
  121. }
  122. },
  123. computed: {
  124. getRole: function () {
  125. return 'admin'
  126. }
  127. },
  128. created () {
  129. //获取菜单
  130. this.getMenuList();
  131. },
  132. watch:{
  133. '$route': function(to,from){
  134. if(from.name=='login'){
  135. this.getMenuList();
  136. }
  137. if(to.path=='/'){ // 退出时清空菜单
  138. this.menuWrappers=[];
  139. this.isNewV = false;
  140. }
  141. }
  142. },
  143. methods: {
  144. CalcuMD5(password){
  145. password = md5(password);
  146. return password;
  147. },
  148. submitForm(formName) {
  149. this.$refs[formName].validate((valid) => {
  150. if (valid) {
  151. api.midifyPassword({
  152. 'password':this.CalcuMD5(this.ruleForm2.oldpass),
  153. 'modifyPassword':this.CalcuMD5(this.ruleForm2.pass)
  154. }).then((res) => {
  155. if (res.data.code == '0') {
  156. const data = res.data.data;
  157. this.$refs['ruleForm2'].resetFields();
  158. this.changePassWord = false
  159. this.$message({
  160. message: '修改成功',
  161. type: 'success',
  162. duration: 1000,
  163. onClose:()=>{
  164. // this.logout()
  165. }
  166. })
  167. } else if(res.data.code === '00020005'){
  168. console.log('原密码错误');
  169. this.$refs['ruleForm2'].clearValidate()
  170. // 手动操作校验、展示登录错误信息
  171. this.rules2.oldpass.push({ // js新增一个自定义校验
  172. validator: (rule, value, callback) => {
  173. callback('旧密码输入错误')
  174. },
  175. trigger: 'change'
  176. })
  177. this.$refs['ruleForm2'].validateField('oldpass') // 手动校验
  178. this.rules2.oldpass = this.rules2.oldpass.slice(0, 1) // 删除校验
  179. }else{
  180. this.$message({
  181. message: res.data.msg,
  182. type: 'error',
  183. duration: 1000,
  184. })
  185. }
  186. }).catch((error) => {
  187. console.log(error);
  188. });
  189. } else {
  190. console.log('error submit!!');
  191. return false;
  192. }
  193. });
  194. },
  195. resetForm(formName) {
  196. this.$refs[formName].resetFields();
  197. },
  198. changeWords(){
  199. this.changePassWord = true
  200. this.$refs['ruleForm2'] && this.$refs['ruleForm2'].resetFields();
  201. },
  202. getMenuList(){
  203. api.getAccessdMenu().then((res) => {
  204. if (res.data.code == '0') {
  205. const data = res.data.data;
  206. this.ok = true;
  207. const hasConcole=data.menuWrappers.find((it)=>{
  208. return it.code.indexOf('-KZT')>-1;
  209. });
  210. this.menuWrappers = data.menuWrappers;
  211. this.organization = data.organization;
  212. this.userLoginDTO = data.userLoginDTO;
  213. localStorage.setItem('userLoginDTO', JSON.stringify(data.userLoginDTO));
  214. if(hasConcole){
  215. const url = '/admin/LT-KZT';
  216. this.$router.push({path:url});
  217. }
  218. }
  219. }).catch((error) => {
  220. console.log(error);
  221. });
  222. },
  223. isNewVersion(){ //判断是否为新版
  224. },
  225. changeStatus(text){ //账号信息中提交认证后修改状态
  226. this.authStatus = 2;
  227. this.authStatusName = text;
  228. },
  229. goCenter(){
  230. },
  231. logout(){//退出
  232. localStorage.removeItem('token');
  233. this.$router.push({path:'/'});
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="less">
  239. @import '../../less/common.less';
  240. .user .el-menu-item.is-active {
  241. color: @userBase;
  242. }
  243. .admin .el-menu-item.is-active {
  244. color: @adminBase;
  245. }
  246. .admin .username{
  247. cursor: pointer;
  248. }
  249. .version-info h3{
  250. font-size: 14px;
  251. margin-bottom: 20px;
  252. span{
  253. float: right;
  254. font-weight: normal;
  255. }
  256. }
  257. </style>
  258. <style lang="less" scoped>
  259. @import '../../less/common.less';
  260. .el-menu-vertical-demo.el-menu{
  261. height: calc(100% - 120px);
  262. overflow-y: auto;
  263. }
  264. .userInfo {
  265. position: relative;
  266. padding-left: 20px;
  267. cursor: pointer;
  268. .username {
  269. font-size: 14px;
  270. color: #545455;
  271. img {
  272. width: 10px;
  273. margin-left: 8px;
  274. position: relative;
  275. bottom: 2px;
  276. }
  277. }
  278. &:hover .action {
  279. display: block;
  280. }
  281. .action {
  282. width: 94px;
  283. height: 70px;
  284. box-shadow: 1px 2px 8px 1px #ccc;
  285. border-radius: 3px;
  286. position: absolute;
  287. top: 50px;
  288. right: -5px;
  289. z-index: 999;
  290. background-color: #fff;
  291. color: #333;
  292. font-size: 14px;
  293. display: none;
  294. li {
  295. height: 35px;
  296. line-height: 35px;
  297. text-align: center;
  298. cursor: pointer;
  299. &:hover {
  300. background-color: #F2F2F2;
  301. }
  302. }
  303. }
  304. }
  305. .version{
  306. position: fixed;
  307. bottom: 0;
  308. width: @aside-width;
  309. min-width: 270px;
  310. font-size: 12px;
  311. /*text-indent: 50px;*/
  312. text-align: center;
  313. height:54px;
  314. line-height: 54px;
  315. background: #fff;
  316. i{
  317. display: inline-block;
  318. width: 20px;
  319. height: 16px;
  320. img{
  321. vertical-align: text-top;
  322. }
  323. }
  324. }
  325. .user .version a{
  326. color: @userBase;
  327. }
  328. .admin .version a{
  329. color: @adminBase;
  330. }
  331. .user .logo {
  332. background: @userBase;
  333. p {
  334. font-size: 16px;
  335. line-height: normal
  336. }
  337. }
  338. .admin .logo {
  339. background: @adminBase;
  340. p {
  341. font-size: 18px;
  342. line-height: 40px;
  343. }
  344. }
  345. .title {
  346. h2 {
  347. display: inline-block;
  348. line-height: 60px;
  349. font-size: 18px;
  350. }
  351. }
  352. .block {
  353. height: 40px;
  354. width: 100%;
  355. background: #fff;
  356. box-shadow: 0px 1px 2px #c9c9c9;
  357. }
  358. .el-main{
  359. padding: 0;
  360. }
  361. .el-button{
  362. margin-left: 15px;
  363. }
  364. .changewords{
  365. // /deep/ .el-icon-circle-close{
  366. // display: none;
  367. // }
  368. .dialog-footer{
  369. .el-button{
  370. // float: right;
  371. position: relative;
  372. left: 200px;
  373. }
  374. }
  375. }
  376. </style>