navigation.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <template>
  2. <div class="header-box">
  3. <!--<div class="edit" @click="handleCommand">退出登录</div>-->
  4. <el-dropdown class="edit" trigger="click" @command="handleCommand">
  5. <span class="el-dropdown-link" style="display: flex">
  6. <span style="font-size: 15px;line-height: 25px;color: #fff;margin-right:10px;display: flex;">
  7. <svg-icon class="logo-tou" icon-class="logoTou"/>
  8. <span>{{userName}}</span>
  9. </span>
  10. <i class="el-icon-caret-bottom"></i>
  11. </span>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item
  14. v-for="(item,value) in status"
  15. :key="value"
  16. :command="item.key"
  17. >{{ item.lab }}</el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. <template>
  21. <div class="logo-box">
  22. <img :src="companyLogo" />
  23. {{ companyName }}
  24. </div>
  25. </template>
  26. <el-menu
  27. :default-active="defaultActive"
  28. router
  29. class="el-menu-demo"
  30. mode="horizontal"
  31. background-color="#000"
  32. text-color="#999"
  33. >
  34. <el-menu-item index="/home">主页</el-menu-item>
  35. <el-menu-item index="/bayed">已购服务</el-menu-item>
  36. <el-menu-item index="/companyInfoIndex">公司信息</el-menu-item>
  37. <!-- <el-menu-item index="/travelCompanyIndex">往来公司</el-menu-item> -->
  38. <el-menu-item index="/organizationIndex">组织架构</el-menu-item>
  39. <!--<el-menu-item :index="routerLink">组织架构</el-menu-item>-->
  40. <el-menu-item index="/check-flow">审核流设置</el-menu-item>
  41. <!-- <el-menu-item v-if="serviceType == 'ship' || serviceType == 'both'" index="/shipManagement">船端管理</el-menu-item> -->
  42. </el-menu>
  43. <el-dialog
  44. :title="uploadTitle"
  45. :visible.sync="uploadUserFlag"
  46. width="525px"
  47. :close-on-click-modal="false"
  48. append-to-body
  49. @close="cancel"
  50. class="upload-user"
  51. >
  52. <el-form
  53. ref="loginMsg"
  54. :model="loginMsg"
  55. :rules="loginMsgRules"
  56. >
  57. <el-form-item label="当前管理员:" prop="userRealName" v-if="lastStepFlag">
  58. <span>{{ loginMsg.userRealName }}</span>
  59. </el-form-item>
  60. <el-form-item label="新的企业管理员:" prop="userRealName" v-else>
  61. <el-select v-model="loginMsg.userRealName" placeholder="请选择" @change="newUser" style="width: 315px;">
  62. <el-option
  63. v-for="item in userList"
  64. :key="item.staffMobilePhone"
  65. :label="item.staffName"
  66. :value="item.staffMobilePhone"
  67. />
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="手机号:" prop="userCellPhone">
  71. <el-input v-model="loginMsg.userCellPhone" :disabled="true" style="width: 200px;vertical-align: top;" />
  72. <el-button
  73. :type="buttonState"
  74. class="send-button"
  75. :disabled="buttonDisable"
  76. :class="{stateGray:buttonDisable}"
  77. @click="sendNum(userCellPhone,loginMsg.userRealName)"
  78. >{{ buttonMsg }}</el-button>
  79. </el-form-item>
  80. <el-form-item label="验证码:" prop="veriCode">
  81. <el-input v-model="loginMsg.veriCode" style="width: 318px;" />
  82. </el-form-item>
  83. <div class="next-button" v-if="lastStepFlag"><el-button @click="nextStyle('loginMsg')">下一步</el-button></div>
  84. <div class="next-button" v-else><el-button type="primary" @click="saveStyle('loginMsg')">确定</el-button></div>
  85. </el-form>
  86. </el-dialog>
  87. <!--修改密码-->
  88. <el-dialog
  89. title="修改密码"
  90. :visible.sync="passwordFlag"
  91. width="525px"
  92. :close-on-click-modal="false"
  93. append-to-body
  94. @close="cancelPaw"
  95. class="upload-user password"
  96. >
  97. <el-form
  98. ref="passwordMsg"
  99. :model="passwordMsg"
  100. :rules="passwordMsgRules"
  101. >
  102. <el-form-item label="当前密码:" prop="originalPassword">
  103. <el-input type="password" placeholder="请输入当前密码" v-model="passwordMsg.originalPassword" style="width: 318px;" />
  104. </el-form-item>
  105. <el-form-item label="新密码:" prop="newPassword">
  106. <el-input type="password" v-model="passwordMsg.newPassword" placeholder="密码为6-20位字母及数字组合" style="width: 318px;" />
  107. </el-form-item>
  108. <el-form-item label="确认密码:" prop="password">
  109. <el-input type="password" v-model="passwordMsg.password" placeholder="密码为6-20位字母及数字组合" style="width: 318px;" />
  110. </el-form-item>
  111. </el-form>
  112. <span slot="footer" class="dialog-footer">
  113. <el-button @click="passwordFlag = false">取 消</el-button>
  114. <el-button type="primary" @click="savePassword('passwordMsg')">确 定</el-button>
  115. </span>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import { mapGetters } from 'vuex';
  121. import {
  122. validPassword
  123. } from "../../utils/validate";
  124. const validPasswordRule = function(rule, value, callback) {
  125. if (!validPassword(value)) {
  126. callback(new Error('密码为6到20位数字密码任意组合'));
  127. } else {
  128. callback();
  129. }
  130. };
  131. const validPasswordRule2 = function(rule, value, callback) {
  132. if (!value) {
  133. callback(new Error('请再次输入密码'));
  134. } else if (value !== this.passwordMsg.newPassword) {
  135. callback(new Error('两次输入密码不一致'));
  136. } else {
  137. callback();
  138. }
  139. };
  140. import {
  141. getLoginInfo,
  142. changePasswordByPwd,
  143. sendMsg,
  144. checkMsg,
  145. changeManager,
  146. } from '../../api/loginOut';
  147. import { getstaffsHasTelByDept } from '../../api/basicData';
  148. export default {
  149. name: 'Navigation',
  150. data() {
  151. return {
  152. userName: localStorage.getItem('enterprise-front-userRealName'),
  153. companyName: localStorage.getItem('enterprise-front-companyName'),
  154. uploadUserFlag: false,
  155. uploadTitle:'',
  156. loginMsgRules:{
  157. userCellPhone: [{required: true, trigger: 'blur'}],
  158. userRealName: [{required: true,trigger: 'blur'}],
  159. veriCode: [{required: true,trigger: 'blur'}],
  160. },
  161. loginMsg:{
  162. userCellPhone: '',
  163. userRealName: '',
  164. veriCode: ''
  165. },
  166. passwordMsgRules:{
  167. originalPassword: [{ required: true, message: ' ', trigger: 'blur' }],
  168. newPassword: [{ required: true, trigger: 'blur', validator: validPasswordRule.bind(this) }],
  169. password: [{ required: true, trigger: 'blur', validator: validPasswordRule2.bind(this) }],
  170. },
  171. passwordMsg:{
  172. originalPassword: '', // 原始密码
  173. newPassword: '', // 新密码
  174. password: '' // 二次输入密码
  175. },
  176. userCellPhone: '',
  177. oldVeriCode: '',
  178. buttonState: 'primary',
  179. buttonDisable: false,
  180. passwordFlag: false,
  181. lastStepFlag: true,
  182. buttonMsg: '发送验证码',
  183. timer: null,
  184. userList:[],
  185. };
  186. },
  187. computed: {
  188. userName(){
  189. },
  190. companyLogo(){
  191. return !this.$store.getters.companyLogo? require('../../static/images/page/login/login.png'): this.$store.getters.companyLogo
  192. },
  193. status() {
  194. return [
  195. {
  196. lab: '修改密码',
  197. key: '0',
  198. },
  199. {
  200. lab: '更换企业管理员',
  201. key: '1',
  202. },
  203. {
  204. lab: '退出',
  205. key: '2',
  206. }
  207. ]
  208. },
  209. defaultActive() {
  210. return this.$route.matched[this.$route.matched.length - 1].path;
  211. },
  212. // routerLink() {
  213. // let type = ''
  214. // if (this.serviceType === 'ship') {
  215. // type = '/organizationShip'
  216. // } else {
  217. // type = '/organization'
  218. // }
  219. // return type
  220. // },
  221. ...mapGetters({
  222. serviceType: 'serviceType'
  223. })
  224. },
  225. methods: {
  226. cancelPaw(){
  227. this.$refs.passwordMsg.resetFields();
  228. },
  229. cancel(){
  230. this.$refs.loginMsg.resetFields();
  231. },
  232. // 下拉选择
  233. handleCommand(command) {
  234. // 退出
  235. if(command === '2') {
  236. this.$store.dispatch('user/logout');
  237. this.$router.push(`/login?redirect=${this.$route.fullPath}`);
  238. // 更换企业管理员
  239. } else if(command === '1') {
  240. this.uploadTitle = '换绑企业管理员账号,需要验证当前企业管理员账号的身份';
  241. this.uploadUserFlag = true;
  242. this.getloading();
  243. // 修改密码
  244. } else {
  245. this.passwordFlag = true;
  246. }
  247. },
  248. // 修改管理员密码
  249. savePassword(formName) {
  250. this.$refs[formName].validate((valid) => {
  251. if (valid) {
  252. const data = {
  253. originalPassword: this.passwordMsg.originalPassword,
  254. password: this.passwordMsg.password
  255. };
  256. changePasswordByPwd(data).then(() => {
  257. this.$message({
  258. message: '修改成功',
  259. type: 'success',
  260. showClose: true,
  261. });
  262. this.passwordFlag = false;
  263. }).catch((code) => {
  264. if (code === 'AUTH_005') {
  265. this.$message({
  266. message: '原始密码不正确!',
  267. type: 'error',
  268. showClose: true,
  269. });
  270. return false;
  271. } if (code === 'AUTH_006') {
  272. this.$message({
  273. message: '新密码与原始密码相同!',
  274. type: 'error',
  275. showClose: true,
  276. });
  277. }
  278. });
  279. } else {
  280. this.$message({
  281. message: '带*号为必填项!',
  282. type: 'error',
  283. showClose: true,
  284. });
  285. return false;
  286. }
  287. });
  288. },
  289. // 确认修改管理员
  290. saveStyle(formName) {
  291. this.$refs[formName].validate((valid) => {
  292. if (valid) {
  293. let index = this.userList.findIndex(itm => itm.staffMobilePhone === this.loginMsg.userRealName)
  294. let newManagerId = this.userList.find(
  295. item => item.staffMobilePhone === this.loginMsg.userRealName
  296. ).staffId
  297. const data = {
  298. newManagerId: newManagerId,
  299. originalManagerVeriCode: this.oldVeriCode,
  300. newManagerVeriCode: this.loginMsg.veriCode
  301. };
  302. changeManager(data).then(() => {
  303. this.$message({
  304. message: '修改成功',
  305. type: 'success',
  306. showClose: true,
  307. });
  308. localStorage.setItem('enterprise-front-userRealName', this.userList[index].staffName)
  309. let dom = document.getElementsByClassName("hello-title")[0]
  310. dom.textContent = dom.textContent.split(',')[0] + ',' + this.userList[index].staffName
  311. this.userName = this.userList[index].staffName
  312. clearInterval(this.timer);
  313. this.buttonMsg = '发送验证码';
  314. this.buttonState = 'primary';
  315. this.buttonDisable = false;
  316. this.uploadUserFlag = false;
  317. this.cancel();
  318. }).catch(() => {
  319. this.$message({
  320. message: '修改失败',
  321. type: 'error',
  322. showClose: true,
  323. });
  324. });
  325. } else {
  326. this.$message({
  327. message: '带*号为必填项',
  328. type: 'error',
  329. showClose: true,
  330. });
  331. return false;
  332. }
  333. });
  334. },
  335. // 获取部门下成员岸端
  336. getUserList() {
  337. getstaffsHasTelByDept({
  338. enabled: '1',
  339. vesselBankFlag: 'B'
  340. }).then(response => {
  341. this.userList = response.records;
  342. }).catch(err=>{
  343. if(err){
  344. this.$message({
  345. message: '公司岸端成员加载失败,请重新获取!',
  346. type: 'error',
  347. showClose: true,
  348. });
  349. }
  350. })
  351. },
  352. // 当前登录人基本信息
  353. getloading() {
  354. getLoginInfo().then((response) => {
  355. let phonenum = response.managerMobilePhone;
  356. this.userCellPhone = phonenum;
  357. phonenum = phonenum.split('');
  358. phonenum.splice(3, 4, '****');
  359. phonenum = phonenum.join('');
  360. this.loginMsg.userCellPhone = phonenum;
  361. this.loginMsg.userRealName = response.managerName;
  362. });
  363. },
  364. // 下一步
  365. nextStyle(formName) {
  366. this.$refs[formName].validate((valid) => {
  367. if (valid) {
  368. const data = {
  369. mobilePhone: this.userCellPhone,
  370. veriCode: this.loginMsg.veriCode
  371. };
  372. this.oldVeriCode = JSON.parse(JSON.stringify(this.loginMsg.veriCode));
  373. checkMsg(data).then((response) => {
  374. if (response) {
  375. this.$message({
  376. message: '验证成功',
  377. type: 'success',
  378. showClose: true,
  379. });
  380. this.uploadTitle = '修改完成后,绑定的安全手机号也会修改';
  381. clearInterval(this.timer);
  382. this.buttonMsg = '发送验证码';
  383. this.buttonState = 'primary';
  384. this.buttonDisable = false;
  385. this.cancel();
  386. this.lastStepFlag = false;
  387. this.getUserList();
  388. } else {
  389. this.$message({
  390. message: '验证码填写错误,请检查后重试',
  391. type: 'error',
  392. showClose: true,
  393. });
  394. }
  395. }).catch(() => {
  396. this.$message({
  397. message: '验证失败',
  398. type: 'error',
  399. showClose: true,
  400. });
  401. });
  402. } else {
  403. this.$message({
  404. message: '验证码不能为空',
  405. type: 'error',
  406. showClose: true,
  407. });
  408. return false;
  409. }
  410. });
  411. },
  412. // 第二次发送验证
  413. newUser(phone){
  414. this.userCellPhone = phone;
  415. phone = phone.split('');
  416. phone.splice(3, 4, '****');
  417. phone = phone.join('');
  418. this.loginMsg.userCellPhone = phone;
  419. },
  420. // 发送验证码
  421. sendNum(mobilePhone, userKind) {
  422. if (mobilePhone === '' && userKind === '') {
  423. this.$message({
  424. message: '企业管理员及电话号不能为空',
  425. type: 'error',
  426. showClose: true,
  427. });
  428. } else {
  429. let data = {};
  430. if(this.lastStepFlag){
  431. data = {
  432. mobilePhone,
  433. domainName: localStorage.getItem('enterprise-front-domainName'),
  434. companyId: localStorage.getItem('enterprise-front-companyId')
  435. };
  436. }else{
  437. data = {
  438. mobilePhone,
  439. domainName: localStorage.getItem('enterprise-front-domainName'),
  440. userKind : "STAFF",
  441. companyId: localStorage.getItem('enterprise-front-companyId')
  442. };
  443. }
  444. sendMsg(data).then(() => {
  445. this.$message({
  446. message: '验证码已发出,请注意查收',
  447. type: 'success',
  448. showClose: true,
  449. });
  450. this.buttonMsg = '重试( 60 ) ';
  451. this.buttonState = 'info';
  452. this.buttonDisable = true;
  453. this.setS();
  454. }).catch(() => {
  455. this.$message({
  456. message: '验证码发送失败,请重试',
  457. type: 'error',
  458. showClose: true,
  459. });
  460. });
  461. }
  462. },
  463. // 计时器
  464. setS() {
  465. let s = 60;
  466. this.timer = setInterval(() => {
  467. if (s > 0) {
  468. s -= 1;
  469. this.buttonMsg = '重新( ' + s + ' ) ';
  470. } else {
  471. this.buttonMsg = '重试';
  472. this.buttonState = 'primary';
  473. this.buttonDisable = false;
  474. clearInterval(this.timer);
  475. }
  476. }, 1000);
  477. },
  478. }
  479. };
  480. </script>
  481. <style scoped lang="scss">
  482. .send-button {
  483. height: 32px;
  484. line-height: 16px;
  485. vertical-align: top;
  486. width: 112px;
  487. }
  488. .stateGray {
  489. color: #333333;
  490. }
  491. .header-box {
  492. display: flex;
  493. position: fixed;
  494. left: 0;
  495. top: 0;
  496. right: 0;
  497. background-color: black;
  498. .logo-box {
  499. position: absolute;
  500. left: 80px;
  501. display: flex;
  502. align-items: center;
  503. height: 60px;
  504. line-height: 60px;
  505. color: #999;
  506. font-size: 15px;
  507. img {
  508. padding-bottom: 2px;
  509. height: 19px;
  510. width: 19px;
  511. margin-right: 8px;
  512. }
  513. }
  514. }
  515. .edit {
  516. top: 20px;
  517. position: absolute;
  518. right: 23px;
  519. color: rgb(153, 153, 153);
  520. font-size: 18px;
  521. padding-bottom: 20px;
  522. cursor: pointer;
  523. }
  524. .edit-title {
  525. top: 20px;
  526. position: absolute;
  527. right: 48px;
  528. font-size: 15px;
  529. line-height: 25px;
  530. color: #fff;
  531. cursor: pointer;
  532. span{
  533. vertical-align: top;
  534. }
  535. }
  536. .logo-tou {
  537. width: 38px !important;
  538. height: 25px !important;
  539. margin-right: 5px;
  540. }
  541. .next-button {
  542. text-align: left;
  543. width: 208px;
  544. margin: 0 auto;
  545. }
  546. .upload-user {
  547. /deep/ .el-form-item__label {
  548. flex: 0 0 140px;
  549. }
  550. }
  551. .password {
  552. /deep/ .el-form-item__error {
  553. display: block;
  554. }
  555. }
  556. </style>