index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="app-wrapper" @change="eveclk">
  3. <sidebar class="sidebar-container"/>
  4. <div class="main-container">
  5. <navbar />
  6. <app-main id="main-containers" />
  7. </div>
  8. <!--修改密码弹框-->
  9. <Dialog width="496px" customClass="dataStoreInfoDialog" :flag="pwdflag">
  10. <div class="dialog-public-background">
  11. <div class="title">修改密码</div>
  12. <div class="content">
  13. <el-form
  14. :model="dataForm"
  15. :rules="dataRules"
  16. ref="dataForm"
  17. class="demo-dataForm"
  18. >
  19. <el-form-item label="旧密码" prop="old">
  20. <el-input
  21. size="medium"
  22. placeholder="请输入旧密码"
  23. show-password
  24. v-model="dataForm.old"
  25. ></el-input>
  26. </el-form-item>
  27. <el-form-item label="新密码" prop="new">
  28. <el-input
  29. size="medium"
  30. placeholder="请输入新密码"
  31. show-password
  32. v-model="dataForm.new"
  33. ></el-input>
  34. </el-form-item>
  35. <el-form-item label="再次确认新密码" prop="again">
  36. <el-input
  37. size="medium"
  38. placeholder="请再次确认新密码"
  39. show-password
  40. v-model="dataForm.again"
  41. ></el-input>
  42. </el-form-item>
  43. </el-form>
  44. </div>
  45. <div class="foot center t30">
  46. <el-button
  47. size="medium"
  48. type="primary"
  49. @click="addSubmit('dataForm')"
  50. class="r24"
  51. >保存</el-button
  52. >
  53. <el-button size="medium" @click="resetForm('dataForm')"
  54. >取消</el-button
  55. >
  56. </div>
  57. </div>
  58. </Dialog>
  59. <!--退出弹框-->
  60. <Dialog :flag="outflag">
  61. <div class="airportInfoDialog">
  62. <div class="flx">退出系统</div>
  63. <div class="content">是否确认退出系统?</div>
  64. <div class="foot right t30" style="margin-top: 24px">
  65. <el-button size="medium" class="r25 r26" @click="outQd" type="primary"
  66. >确定</el-button
  67. >
  68. <el-button size="medium" @click="outQx" class="r26">取消</el-button>
  69. </div>
  70. </div>
  71. </Dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import { Navbar, Sidebar, AppMain } from "./components";
  76. import ResizeMixin from "./mixin/ResizeHandler";
  77. import { mapGetters } from "vuex";
  78. import { EditPwd } from "@/api/apiHome";
  79. import Dialog from "@/layout/components/Dialog";
  80. export default {
  81. name: "Layout",
  82. components: {
  83. Navbar,
  84. Sidebar,
  85. AppMain,
  86. Dialog,
  87. },
  88. mixins: [ResizeMixin],
  89. data() {
  90. return {
  91. dataForm: {
  92. //数据项表单
  93. old: "",
  94. new: "",
  95. again: "",
  96. },
  97. leup: true,
  98. dataRules: {
  99. //数据项表单验证
  100. old: [{ required: true, message: "请输入旧密码", trigger: "blur" }],
  101. new: [{ required: true, message: "请输入新密码", trigger: "blur" }],
  102. again: [
  103. { required: true, message: "请再次确认新密码", trigger: "blur" },
  104. ],
  105. },
  106. };
  107. },
  108. computed: {
  109. ...mapGetters(["pwdflag", "outflag", "name"]),
  110. },
  111. mounted() {
  112. // document.getElementById("sidebar-container").style.width = "150px";
  113. },
  114. methods: {
  115. eveclk() {
  116. document.getElementById("sidebar-container").style.width = "150px";
  117. this.leup = true;
  118. // document.getElementById("main-containers").style.paddingLeft = "50px";
  119. },
  120. upLeft() {
  121. document.getElementById("sidebar-container").style.width = "48px";
  122. this.leup = false;
  123. // document.getElementById("main-containers").style.paddingLeft = "30px";
  124. },
  125. //存储数据项-提交
  126. addSubmit(formName) {
  127. this.$refs[formName].validate((valid) => {
  128. if (valid) {
  129. if (this.dataForm.new !== this.dataForm.again) {
  130. this.$message.error("两次输入的密码不一致,请重新输入");
  131. return false;
  132. }
  133. this.editPwd();
  134. } else {
  135. console.log("error submit!!");
  136. return false;
  137. }
  138. });
  139. },
  140. //存储数据项-取消
  141. resetForm(formName) {
  142. this.$store.dispatch("app/togglePwdflag", false);
  143. this.$refs[formName].resetFields();
  144. },
  145. //退出系统-取消
  146. outQx() {
  147. this.$store.dispatch("app/toggleOutflag", false);
  148. },
  149. //退出系统-确定
  150. async outQd() {
  151. sessionStorage.removeItem("userName");
  152. this.$store.dispatch("app/toggleOutflag", false);
  153. await this.$store.dispatch("user/logout");
  154. this.$router.push(`/login?redirect=${this.$route.fullPath}`);
  155. },
  156. //修改密码
  157. async editPwd() {
  158. try {
  159. const res = await EditPwd({
  160. LoginName: this.name,
  161. LoginPwd: this.dataForm.old,
  162. LoginPwdNew: this.dataForm.again,
  163. });
  164. if (res.code === 0) {
  165. this.$message.success(res.message);
  166. this.$store.dispatch("app/togglePwdflag", false);
  167. setTimeout(() => {
  168. this.outQd();
  169. }, 2000);
  170. } else {
  171. this.$message.error(res.message);
  172. }
  173. } catch (error) {
  174. console.log("出错了", error);
  175. }
  176. },
  177. },
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. @import "~@/styles/mixin.scss";
  182. @import "~@/styles/variables.scss";
  183. .app-wrapper {
  184. @include clearfix;
  185. position: relative;
  186. height: 100%;
  187. width: 100%;
  188. &.mobile.openSidebar {
  189. position: fixed;
  190. top: 0;
  191. }
  192. }
  193. .drawer-bg {
  194. background: #000;
  195. opacity: 0.3;
  196. width: 100%;
  197. top: 0;
  198. height: 100%;
  199. position: absolute;
  200. z-index: 999;
  201. }
  202. .fixed-header {
  203. position: fixed;
  204. top: 0;
  205. right: 0;
  206. z-index: 9;
  207. width: calc(100% - #{$sideBarWidth});
  208. transition: width 0.28s;
  209. }
  210. .hideSidebar .fixed-header {
  211. width: calc(100% - 54px);
  212. }
  213. .mobile .fixed-header {
  214. width: 100%;
  215. }
  216. </style>