index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <el-container class="app-wrapper">
  3. <el-header class="app-header" style="height: 48px;line-height: 48px;border-bottom: 1px solid #E1E4EA;">
  4. <div class="logo-title" style="display: inline-flex; align-items: center;">
  5. <!-- <img style="width: 132px; height: 35px;transform: translateY(2px);" src="../assets/logo3.png" />-->
  6. <el-image
  7. v-if="titleLogo"
  8. style="margin-right: 16px; width: 132px; height: 35px"
  9. :src="filePath + titleLogo"
  10. ></el-image>
  11. <span class="title">{{ title }}</span>
  12. </div>
  13. <div class="tags" style="position: relative;">
  14. <!-- <TagsView style="position:absolute;bottom:0"></TagsView> -->
  15. </div>
  16. <div class="header-action">
  17. <div style="display: flex; align-items: center">
  18. <!-- <img class="headImg" :src="headImg" style="border-radius: 50%" />
  19. <div class="user-name">
  20. {{ $store.state.user.name}}
  21. </div>
  22. <div @click="logout"><svg-icon icon-class="exit" class="c-icon u-pointer"></svg-icon><span class="u-pointer">退出登录</span></div> -->
  23. <el-dropdown size="medium" @command='logout'>
  24. <span class="el-dropdown-link">
  25. {{ $store.state.user.username }}({{ $store.state.user.name }})<i
  26. class="el-icon-arrow-down el-icon--right"></i>
  27. </span>
  28. <el-dropdown-menu slot="dropdown" class="logindropdown">
  29. <el-dropdown-item command='0'>修改密码</el-dropdown-item>
  30. <el-dropdown-item command='1'>退出登录</el-dropdown-item>
  31. </el-dropdown-menu>
  32. </el-dropdown>
  33. </div>
  34. </div>
  35. </el-header>
  36. <el-container style="height: calc(100% - 60px)">
  37. <el-aside class="left-aside" style="width: auto">
  38. <sidebar />
  39. </el-aside>
  40. <el-container style="background-color: #f2f2f2">
  41. <el-header class="container-header">
  42. <breadcrumb></breadcrumb>
  43. </el-header>
  44. <el-main class="main-container">
  45. <app-main />
  46. </el-main>
  47. </el-container>
  48. </el-container>
  49. <!-- 修改密码 -->
  50. <table-row-detail-dialog ref="passwordDialog" @confirm="handleConfirm" dialogWidth="686px" dialogTitle="修改密码"
  51. :customFooter="true" class="passwordDialog">
  52. <div class="dialog-body">
  53. <el-form ref="form" :inline="true" label-position="left" label-width="112px" :rules="rules" :model="formData"
  54. class="dialogFrom">
  55. <el-form-item label="旧密码" prop="oldPwd">
  56. <el-input v-model="formData.oldPwd" :type="showPassword0 ? 'text' : 'password'">
  57. <i slot="suffix" @click="handleIconClick(0)">
  58. <img v-if="showPassword0" class="input_icon" src="@/assets/password_show.png" />
  59. <img v-else class="input_icon" src="@/assets/password_hide.png" />
  60. </i>
  61. </el-input>
  62. </el-form-item>
  63. <el-form-item label="新密码" prop="newPwd">
  64. <el-input v-model="formData.newPwd" @input='changePwd' :type="showPassword1 ? 'text' : 'password'">
  65. <i slot="suffix" @click="handleIconClick(1)">
  66. <img v-if="showPassword1" class="input_icon" src="@/assets/password_show.png" />
  67. <img v-else class="input_icon" src="@/assets/password_hide.png" />
  68. </i>
  69. </el-input>
  70. </el-form-item>
  71. <div class="fromtip">
  72. <div class="levelLine" v-show="levelLabel">
  73. <div class="level">
  74. <div class="levelitem levelitem1" :style="{
  75. background: levelLabel == '弱' ?
  76. '#F56C6C' : levelLabel == '中' ?
  77. '#FDCC00' : levelLabel == '强' ?
  78. '#0CD9B5' : '#E7E7E7'
  79. }"></div>
  80. <div class="levelitem levelitem2" :style="{
  81. background: levelLabel == '中' ?
  82. '#FDCC00' : levelLabel == '强' ?
  83. '#0CD9B5' : '#E7E7E7'
  84. }"></div>
  85. <div class="levelitem levelitem3" :style="{ background: levelLabel == '强' ? '#0CD9B5' : '#E7E7E7' }">
  86. </div>
  87. </div>
  88. <span class="levelLabel">{{ levelLabel }}</span>
  89. </div>
  90. <div>密码请包含大小写字母、特殊字符和数字4种类型,长度8-20个字符,不允许出现顺序/逆序字符、账户名、及连续重复的数字或字母</div>
  91. </div>
  92. <el-form-item label="确认密码" prop="surePwd">
  93. <el-input v-model="formData.surePwd" :type="showPassword2 ? 'text' : 'password'">
  94. <i slot="suffix" @click="handleIconClick(2)">
  95. <img v-if="showPassword2" class="input_icon" src="@/assets/password_show.png" />
  96. <img v-else class="input_icon" src="@/assets/password_hide.png" />
  97. </i>
  98. </el-input>
  99. </el-form-item>
  100. </el-form>
  101. </div>
  102. <div slot="footerCon">
  103. <base-btn :btnData="btnClose" @click.native="cancel('form')"></base-btn>
  104. <base-btn :btnData="btnOk" @click.native="confirm('form')"></base-btn>
  105. </div>
  106. </table-row-detail-dialog>
  107. </el-container>
  108. </template>
  109. <script>
  110. import TableRowDetailDialog from '@/components/TableRowDetailDialogNew/index';
  111. import BaseBtn from '@/components/BaseBtn/index';
  112. import { AppMain, Sidebar, Breadcrumb } from './components';
  113. import AuthBtn from '@/components/AuthBtn';
  114. import { changePass } from '@/api/system/user.js';
  115. import { passEncrypt } from '@/utils/rsa';
  116. import { strictPwdValidator } from "@/utils/validate";
  117. // import TagsView from '@/layout/components/TagsView'
  118. export default {
  119. name: 'Layout',
  120. components: {
  121. AppMain,
  122. Sidebar,
  123. Breadcrumb,
  124. AuthBtn,
  125. TableRowDetailDialog,
  126. BaseBtn
  127. // TagsView
  128. },
  129. data() {
  130. var validatePass = (rule, value, callback) => {
  131. if (value === '') {
  132. callback(new Error('请输入新密码'));
  133. } else if (!strictPwdValidator(value, this.$store.state.user.username)) {
  134. callback(new Error('新密码不符合要求'));
  135. } else if (!this.checkPasswordStrength(value)) {
  136. callback(new Error('新密码不符合要求'));
  137. } else {
  138. callback();
  139. }
  140. };
  141. var validatePass2 = (rule, value, callback) => {
  142. if (value === '') {
  143. callback(new Error('请输入确认密码'));
  144. } else if (value !== this.formData.newPwd) {
  145. callback(new Error('输入内容请与新密码保持一致'));
  146. } else {
  147. callback();
  148. }
  149. };
  150. return {
  151. filePath: filePath,
  152. title: this.$store.state.user.companyInfo.companyName,
  153. titleLogo: this.$store.state.user.companyInfo.companyLogo,
  154. sysIcon: require('@/assets/search/sys-icon.svg'),
  155. headImg: require('@/assets/total_bg.jpg'),
  156. bgStyle: {},
  157. btnOk: {
  158. name: '确定'
  159. },
  160. btnClose: {
  161. name: '取消',
  162. bgColor: '#2B2B2C'
  163. },
  164. formData: {
  165. oldPwd: '',
  166. newPwd: '',
  167. surePwd: ''
  168. },
  169. rules: {
  170. oldPwd: [
  171. { required: true, message: '请输入旧密码', trigger: 'blur' },
  172. ],
  173. newPwd: [
  174. { required: true, validator: validatePass, trigger: 'blur' },
  175. // { required: true, message: '请输入新密码', trigger: 'blur' },
  176. ],
  177. surePwd: [
  178. { required: true, validator: validatePass2, trigger: 'blur' },
  179. // { required: true, message: '请输入确认密码', trigger: 'blur' },
  180. ],
  181. },
  182. showPassword0: false,
  183. showPassword1: false,
  184. showPassword2: false,
  185. levelLabel: ''
  186. };
  187. },
  188. watch: {
  189. watch: {
  190. '$store.state.user.companyInfo.companyName': {
  191. handler: function (nv, ov) {
  192. this.title = nv;
  193. },
  194. immediate: true
  195. },
  196. '$store.state.user.companyInfo.companyLogo': {
  197. handler: function (nv, ov) {
  198. this.titleLogo = nv;
  199. },
  200. immediate: true
  201. }
  202. },
  203. },
  204. mounted(){
  205. console.log("mounted:",this.$store.state.user.companyInfo);
  206. },
  207. computed: {},
  208. methods: {
  209. checkPasswordStrength(password) {
  210. const hasNumber = /[0-9]/.test(password);
  211. const hasletter = /[a-zA-Z]/.test(password);
  212. const hasSpecial = /[^0-9a-zA-Z]/.test(password);
  213. if (password.length <= 6 || password.length >= 20) {
  214. return false;
  215. } else if (hasNumber && hasletter && hasSpecial) {
  216. return '强';
  217. } else if (((hasNumber && hasletter) || (hasNumber && hasSpecial) || (hasletter && hasSpecial)) && password.length > 10) {
  218. return '中';
  219. } else if ((hasNumber && hasletter) || (hasNumber && hasSpecial) || (hasletter && hasSpecial)) {
  220. return '弱';
  221. } else {
  222. return false;
  223. }
  224. },
  225. changePwd(val) {
  226. var result = this.checkPasswordStrength(val)
  227. if (result) {
  228. this.levelLabel = result
  229. }
  230. },
  231. handleIconClick(index) {
  232. this['showPassword' + index] = !this['showPassword' + index]
  233. },
  234. confirm(formName) {
  235. this.$refs[formName].validate(async (valid) => {
  236. if (valid) {
  237. let passwordNew = await passEncrypt(this.formData.newPwd);
  238. let passwordOld = await passEncrypt(this.formData.oldPwd);
  239. changePass(this.$store.state.user.userId, {
  240. passwordNew: passwordNew,
  241. passwordOld: passwordOld,
  242. }).then((res) => {
  243. console.log(res);
  244. this.$message.success('密码修改成功!');
  245. this.cancel('form');
  246. });
  247. } else {
  248. return false;
  249. }
  250. });
  251. },
  252. cancel(formName) {
  253. this.$refs[formName].resetFields();
  254. this.$refs.passwordDialog.hide();
  255. this.levelLabel = ''
  256. },
  257. handleConfirm() {
  258. console.log(123)
  259. },
  260. calcAuth() {
  261. return this.$store.state.permission.routes.some(
  262. (ele) => ele.path === '/infor-search',
  263. );
  264. },
  265. // 跳转媒资检索
  266. toSearch() {
  267. this.$router.push({
  268. path: '/infor-search',
  269. });
  270. },
  271. logout(index) {
  272. if (index == 0) {
  273. this.$refs.passwordDialog.show();
  274. } else {
  275. this.$confirm('您确定要退出登录吗?', '您确定要退出登录吗?', {
  276. confirmButtonText: '确定',
  277. cancelButtonText: '取消',
  278. cancelButtonClass: 'cancel-msgbtn', confirmButtonClass: 'confirm-msgbtn', type: 'warning',
  279. })
  280. .then(async () => {
  281. await this.$store.dispatch('user/logout');
  282. this.$router.push(`/login`);
  283. })
  284. .catch(() => { });
  285. }
  286. // await this.$store.dispatch('user/logout');
  287. // this.$router.push(`/login`);
  288. },
  289. changeSkin(name) {
  290. this.$store.dispatch('settings/changeTheme', name);
  291. },
  292. },
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. @import '~@/styles/variables.scss';
  297. .app-wrapper {
  298. height: 100%;
  299. .app-header {
  300. color: $headerTxtColor;
  301. display: flex;
  302. align-items: center;
  303. justify-content: space-between;
  304. background: url(../assets/header_bg.png) no-repeat;
  305. background-position: 83%;
  306. .header-action {
  307. color: #303133;
  308. font-size: 16px;
  309. flex: 0 0 auto;
  310. margin-left: 10px;
  311. display: flex;
  312. justify-content: flex-end;
  313. align-items: center;
  314. }
  315. }
  316. }
  317. .title {
  318. display: flex;
  319. /* height: 27px; */
  320. font-size: 14px;
  321. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  322. font-weight: bold;
  323. color: #333333;
  324. /* line-height: 27px; */
  325. letter-spacing: 1px;
  326. align-items: center;
  327. //padding-bottom: 8px;
  328. }
  329. .headImg {
  330. width: 18px;
  331. height: 18px;
  332. }
  333. .container-header {
  334. height: 50px !important;
  335. }
  336. .el-aside {
  337. transition: width 0.15s;
  338. -webkit-transition: width 0.15s;
  339. -moz-transition: width 0.15s;
  340. -webkit-transition: width 0.15s;
  341. -o-transition: width 0.15s;
  342. }
  343. .logo-title {
  344. //flex: 0 0 260px;
  345. }
  346. .tags {
  347. flex: 1;
  348. min-width: 0;
  349. height: 100%;
  350. }
  351. .user-name {
  352. margin: 0 8px;
  353. }
  354. .c-icon {
  355. width: 18px;
  356. height: 18px;
  357. margin-right: 2px;
  358. }
  359. .header-action .el-dropdown {
  360. font-size: 16px;
  361. cursor: pointer;
  362. }
  363. .passwordDialog {
  364. // padding: 80px 90px;
  365. }
  366. .dialogFrom {
  367. padding: 20px 50px;
  368. }
  369. .fromtip {
  370. padding: 10px 0 20px 112px;
  371. }
  372. .el-form--inline .el-form-item {
  373. width: 100%;
  374. }
  375. .el-form--inline .el-form-item__content {
  376. width: 100%;
  377. }
  378. .input_icon {
  379. cursor: pointer;
  380. }
  381. .levelLine {
  382. display: flex;
  383. }
  384. .level {
  385. display: flex;
  386. margin-bottom: 20px;
  387. }
  388. .levelLabel {
  389. margin-left: 12px;
  390. }
  391. .levelitem {
  392. width: 56px;
  393. height: 12px;
  394. margin-right: 4px;
  395. // background: #F56C6C;
  396. background: #E7E7E7;
  397. }
  398. .levelitem1 {
  399. border-radius: 6px 0px 0px 6px;
  400. }
  401. .levelitem3 {
  402. border-radius: 0px 6px 6px 0px;
  403. }
  404. </style>
  405. <style>
  406. .passwordDialog .el-form--inline .el-form-item__content {
  407. width: 400px;
  408. }
  409. .el-theme1 .logindropdown .el-dropdown-menu__item:focus,
  410. .el-theme1 .logindropdown .el-dropdown-menu__item:not(.is-disabled):hover {
  411. background-color: #F5F7FA;
  412. color: #606266;
  413. }
  414. .el-theme1 .logindropdown {
  415. font-size: 14px;
  416. margin-top: 0px !important;
  417. }
  418. .el-theme1 .logindropdown .el-dropdown-menu__item {
  419. padding: 0 40px;
  420. line-height: 32px;
  421. }
  422. .el-theme1 .logindropdown .popper__arrow {
  423. display: none;
  424. }
  425. </style>