index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <el-container>
  3. <el-header>
  4. <el-row type="flex" style="height:100%;" justify="space-between" align="middle">
  5. <div>航空工业集团快递智能柜管理程序</div>
  6. <div>
  7. <el-dropdown @command="onUserEdit">
  8. <span class="el-dropdown-link">
  9. <i class="el-icon-user" style="margin-right: 10px"></i>管理员
  10. <i class="el-icon-arrow-down el-icon--right"></i>
  11. </span>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item command="logout" icon="el-icon-caret-left">退出登录</el-dropdown-item>
  14. <el-dropdown-item command="editPwd" icon="el-icon-edit">修改密码</el-dropdown-item>
  15. </el-dropdown-menu>
  16. </el-dropdown>
  17. </div>
  18. </el-row>
  19. </el-header>
  20. <el-container style="height: 100%; border: 1px solid #eee">
  21. <el-aside width="250px">
  22. <el-menu router class="el-menu" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" :default-active="curPath">
  23. <el-menu-item index="express" route="express">
  24. <i class="el-icon-menu"></i>
  25. <span slot="title">柜体控制</span>
  26. </el-menu-item>
  27. <el-menu-item index="order" route="order">
  28. <i class="el-icon-s-order"></i>
  29. <span slot="title">订单管理</span>
  30. </el-menu-item>
  31. <el-menu-item index="log" route="log">
  32. <i class="el-icon-document"></i>
  33. <span slot="title">日志管理</span>
  34. </el-menu-item>
  35. <el-menu-item index="message" route="message">
  36. <i class="el-icon-message"></i>
  37. <span slot="title">消息通知</span>
  38. </el-menu-item>
  39. <el-menu-item index="view" route="view">
  40. <i class="el-icon-s-platform"></i>
  41. <span slot="title">操作记录</span>
  42. </el-menu-item>
  43. <el-menu-item index="status" route="status">
  44. <i class="el-icon-user"></i>
  45. <span slot="title">运营人员管理</span>
  46. </el-menu-item>
  47. </el-menu>
  48. </el-aside>
  49. <el-main class="el-menu">
  50. <router-view />
  51. </el-main>
  52. <el-dialog title="修改密码" :visible.sync="editVisible" width="50%" @closed="onCloseEditDialog">
  53. <el-form :model="editForm" :rules="editRules" ref="editForm" label-width="120px" class="demo-ruleForm">
  54. <el-form-item label="密码" prop="pwd">
  55. <el-input v-model="editForm.pwd" type="password"></el-input>
  56. </el-form-item>
  57. <el-form-item label="确认密码" prop="rePwd">
  58. <el-input v-model="editForm.rePwd" type="password"></el-input>
  59. </el-form-item>
  60. </el-form>
  61. <span slot="footer" class="dialog-footer">
  62. <el-button @click="onCloseEditDialog">取 消</el-button>
  63. <el-button type="primary" @click="onEditSubmit('editForm')">确认修改</el-button>
  64. </span>
  65. </el-dialog>
  66. </el-container>
  67. </el-container>
  68. </template>
  69. <script>
  70. import {
  71. loginOut,
  72. editPwd
  73. } from "@/api";
  74. export default {
  75. created() {
  76. this.curPath = this.$route.name;
  77. },
  78. data() {
  79. return {
  80. curPath: "",
  81. editVisible: false,
  82. editForm: {
  83. pwd: "",
  84. rePwd: "",
  85. },
  86. editRules: {
  87. pwd: [{
  88. required: true,
  89. message: "请输入登录密码",
  90. trigger: "blur",
  91. }, ],
  92. rePwd: [{
  93. required: true,
  94. validator: this.validateRePwd2,
  95. trigger: "blur",
  96. }, ],
  97. },
  98. };
  99. },
  100. methods: {
  101. onCloseEditDialog() {
  102. this.editForm = {};
  103. this.editVisible = false;
  104. this.editPwdId = "";
  105. this.$refs.editForm.resetFields();
  106. },
  107. validateRePwd2(rule, value, callback) {
  108. if (value === "") {
  109. callback(new Error("请再次输入密码"));
  110. } else if (value !== this.editForm.pwd) {
  111. callback(new Error("两次输入密码不一致!"));
  112. } else {
  113. callback();
  114. }
  115. },
  116. onUserEdit(command) {
  117. if (command == "logout") {
  118. this.$confirm("确认退出该账号?", "退出", {
  119. confirmButtonText: "确定",
  120. cancelButtonText: "取消",
  121. type: "warning",
  122. })
  123. .then(() => {
  124. this.onLoginOut();
  125. })
  126. .catch(() => {
  127. return false;
  128. });
  129. } else if (command == "editPwd") {
  130. this.editVisible = true;
  131. }
  132. },
  133. onLoginOut() {
  134. loginOut().then((res) => {
  135. if (res && res.msg == "ok") {
  136. this.$router.replace({
  137. path: "/login",
  138. });
  139. }
  140. });
  141. },
  142. onEditSubmit(formName) {
  143. const _self = this;
  144. this.$refs[formName].validate((valid) => {
  145. if (valid) {
  146. editPwd({
  147. password: _self.editForm.pwd,
  148. repassword: _self.editForm.rePwd,
  149. }).then((res) => {
  150. console.log(res);
  151. if (res && res.msg == "ok") {
  152. this.$message({
  153. message: "修改成功",
  154. type: "success",
  155. center: true,
  156. duration: 1000,
  157. onClose: () => {
  158. _self.onCloseEditDialog();
  159. },
  160. });
  161. }
  162. });
  163. } else {
  164. console.log("error submit!!");
  165. return false;
  166. }
  167. });
  168. },
  169. },
  170. };
  171. </script>
  172. <style scoped>
  173. .el-menu {
  174. height: calc(100vh - 62px);
  175. }
  176. .el-dropdown-link {
  177. color: #409eff;
  178. }
  179. </style>