HelloWorld.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div class="common-layout">
  3. <el-container style="height: 100vh">
  4. <el-header>
  5. <el-row :gutter="24">
  6. <!-- <el-col :span="6" style="text-align: left">
  7. 抑郁认知行为治疗系统管理端
  8. </el-col> -->
  9. <el-col :span="6" style="text-align: left"> 管理端 </el-col>
  10. <el-col :span="6"> </el-col>
  11. <el-col :span="6"> </el-col>
  12. <el-col :span="6" class="user_operate">
  13. <el-dropdown @command="handleCommand">
  14. <span class="el-dropdown-link">
  15. {{ userInfo.organName }}
  16. <el-icon class="el-icon--right">
  17. <arrow-down />
  18. </el-icon>
  19. </span>
  20. <template #dropdown>
  21. <el-dropdown-menu>
  22. <el-dropdown-item command="logout">退出登录</el-dropdown-item>
  23. <el-dropdown-item command="editPassword"
  24. >修改密码</el-dropdown-item
  25. >
  26. </el-dropdown-menu>
  27. </template>
  28. </el-dropdown>
  29. </el-col>
  30. </el-row>
  31. </el-header>
  32. <el-container>
  33. <el-container>
  34. <el-aside width="auto" height="100%">
  35. <el-menu
  36. default-active="/TreeHoleManage"
  37. class="el-menu-vertical-demo"
  38. :collapse="isCollapse"
  39. router
  40. @open="handleOpen"
  41. @close="handleClose"
  42. >
  43. <!-- <el-menu-item index="/main/TreeHoleManage">
  44. <el-icon><icon-menu /></el-icon>
  45. <template #title>树洞管理</template>
  46. </el-menu-item> -->
  47. <!-- <el-menu-item index="/main/PsychologicalConsultation">
  48. <el-icon>
  49. <el-icon>
  50. <ChatLineSquare />
  51. </el-icon>
  52. </el-icon>
  53. <template #title>心理咨询</template>
  54. </el-menu-item> -->
  55. <!-- <el-menu-item
  56. v-if="userInfo.type === '0'"
  57. index="/main/WangEditor"
  58. >
  59. <el-icon>
  60. <document />
  61. </el-icon>
  62. <template #title>文章编辑</template>
  63. </el-menu-item>
  64. <el-menu-item index="/main/RecordList">
  65. <el-icon>
  66. <Notebook />
  67. </el-icon>
  68. <template #title>发作记录</template>
  69. </el-menu-item> -->
  70. <!-- <el-menu-item index="/main/WuRen">
  71. <el-icon><document /></el-icon>
  72. <template #title>无人机</template>
  73. </el-menu-item> -->
  74. <!-- <el-menu-item v-if="userInfo.type === '1'" index="/main/Audit">
  75. <el-icon>
  76. <document />
  77. </el-icon>
  78. <template #title>审核页面</template>
  79. </el-menu-item> -->
  80. <!-- <el-menu-item index="/main/institutionManage" v-if="type == '1'">
  81. <el-icon>
  82. <document />
  83. </el-icon>
  84. <template #title>用户管理</template>
  85. </el-menu-item>
  86. <el-menu-item index="/main/fileUpload">
  87. <el-icon>
  88. <document />
  89. </el-icon>
  90. <template #title>文件上传</template>
  91. </el-menu-item> -->
  92. <el-menu-item index="/main/Direction" v-if="type == '1'">
  93. <el-icon>
  94. <document />
  95. </el-icon>
  96. <template #title>车辆方向检测</template>
  97. </el-menu-item>
  98. <el-menu-item index="/main/Category">
  99. <el-icon>
  100. <document />
  101. </el-icon>
  102. <template #title>车辆分类检测</template>
  103. </el-menu-item>
  104. <el-menu-item index="/main/DirectionAndCategory" v-if="type == '1'">
  105. <el-icon>
  106. <document />
  107. </el-icon>
  108. <template #title>车辆分类与方向检测</template>
  109. </el-menu-item>
  110. <!--
  111. <el-menu-item index="/main/fileUpload">
  112. <el-icon>
  113. <document />
  114. </el-icon>
  115. <template #title>文件上传</template>
  116. </el-menu-item> -->
  117. <el-menu-item index="/main/recordList">
  118. <el-icon>
  119. <document />
  120. </el-icon>
  121. <template #title>历史记录</template>
  122. </el-menu-item>
  123. <!-- <el-menu-item
  124. v-if="userInfo.type === '0'"
  125. index="/main/institutionManage"
  126. >
  127. <el-icon>
  128. <User />
  129. </el-icon>
  130. <template #title>机构管理</template>
  131. </el-menu-item> -->
  132. </el-menu></el-aside
  133. >
  134. <el-main>
  135. <p class="main_p">
  136. <Expand
  137. @click="isCollapse = !isCollapse"
  138. style="width: 1em; height: 1em; margin-right: 8px"
  139. />
  140. </p>
  141. <div class="main">
  142. <router-view></router-view>
  143. </div>
  144. </el-main>
  145. </el-container>
  146. </el-container>
  147. <el-footer>
  148. <div class="footer">
  149. <div class="wrap" style="overflow: hidden">
  150. <ul class="record">
  151. <!-- <li>
  152. <a
  153. target="_blank"
  154. href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11011402011379"
  155. ><img src="../assets/beian.png" /><span class="ml10"
  156. >京公网安备 11011402011379号</span
  157. ></a
  158. >
  159. </li>
  160. <li>
  161. <a href="javascript:;">京ICP备20000146号-2</a>
  162. </li> -->
  163. <!-- <li>
  164. <a href="javascript:;">Copyright© 北京决明科技有限公司</a>
  165. </li> -->
  166. <li>
  167. <a href="javascript:;">Copyright©2024</a>
  168. </li>
  169. </ul>
  170. </div>
  171. </div>
  172. </el-footer>
  173. </el-container>
  174. <el-dialog
  175. v-model="dialogFormVisible"
  176. title="修改密码"
  177. width="480"
  178. @close="cancelHandle"
  179. >
  180. <el-form ref="ruleFormRef" :model="orginizeInfo" :rules="rules">
  181. <el-form-item label="原密码" :label-width="120" prop="oldPassword">
  182. <el-input
  183. v-model="orginizeInfo.oldPassword"
  184. type="password"
  185. placeholder="请输入原密码"
  186. autocomplete="off"
  187. />
  188. </el-form-item>
  189. <el-form-item label="新密码" :label-width="120" prop="newPassword">
  190. <el-input
  191. v-model="orginizeInfo.newPassword"
  192. type="password"
  193. placeholder="请输入新密码"
  194. autocomplete="off"
  195. />
  196. </el-form-item>
  197. </el-form>
  198. <template #footer>
  199. <span class="dialog-footer">
  200. <el-button @click="cancelHandle">取消</el-button>
  201. <el-button type="primary" @click="updataPassword(ruleFormRef)">
  202. 保存
  203. </el-button>
  204. </span>
  205. </template>
  206. </el-dialog>
  207. </div>
  208. </template>
  209. <script lang="ts" setup>
  210. import { ref, reactive, onBeforeMount } from "vue";
  211. import { ArrowDown } from "@element-plus/icons-vue";
  212. import { ElMessage, ElMessageBox } from "element-plus";
  213. import CryptoJS from "crypto-js";
  214. import axios from "../utils/http";
  215. import { useRouter } from "vue-router";
  216. const router = useRouter();
  217. const userInfo = ref({
  218. organName: "",
  219. type: "",
  220. });
  221. const type=ref()
  222. defineProps({
  223. // msg: {
  224. // type: String,
  225. // required: true,
  226. // },
  227. });
  228. let dialogFormVisible = ref(false);
  229. let orginizeInfo = reactive({
  230. organNumber: "",
  231. oldPassword: "",
  232. newPassword: "",
  233. });
  234. const ruleFormRef = ref();
  235. const validatePass = (rule, value, callback) => {
  236. if (value === "") {
  237. callback(new Error("请输入密码"));
  238. } else {
  239. const reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{6,12}$/;
  240. if (!reg.test(value)) {
  241. callback(new Error("密码需为6~12位的字母数字组合"));
  242. return;
  243. }
  244. callback();
  245. }
  246. };
  247. const rules = reactive({
  248. oldPassword: [
  249. {
  250. required: true,
  251. validator: validatePass,
  252. trigger: "blur",
  253. },
  254. ],
  255. newPassword: [
  256. {
  257. required: true,
  258. validator: validatePass,
  259. trigger: "blur",
  260. },
  261. ],
  262. });
  263. const isCollapse = ref(false);
  264. onBeforeMount(() => {
  265. let tempStr = sessionStorage.getItem("userInfo") ?? "{}";
  266. if (tempStr) userInfo.value = JSON.parse(tempStr);
  267. type.value=JSON.parse(tempStr).type
  268. console.log('type'+type.value)
  269. });
  270. const handleOpen = (key: string, keyPath: string[]) => {
  271. console.log(key, keyPath);
  272. };
  273. const handleClose = (key: string, keyPath: string[]) => {
  274. console.log(key, keyPath);
  275. };
  276. const handleCommand = (command: string | number | object) => {
  277. if (command === "logout") {
  278. sessionStorage.clear();
  279. router.push("/login");
  280. } else if (command === "editPassword") {
  281. dialogFormVisible.value = true;
  282. }
  283. };
  284. const cancelHandle = () => {
  285. ruleFormRef.value.resetFields();
  286. dialogFormVisible.value = false;
  287. ruleFormRef.value.clearValidate();
  288. };
  289. const updataPassword = async (formEl) => {
  290. if (!formEl) return;
  291. await formEl.validate((valid, fields) => {
  292. if (valid) {
  293. let username = JSON.parse(
  294. sessionStorage.getItem("userInfo") ?? "{}"
  295. )?.organName;
  296. let password1 = CryptoJS.MD5(
  297. orginizeInfo.oldPassword
  298. ).toString();
  299. let password2= CryptoJS.MD5(
  300. orginizeInfo.newPassword
  301. ).toString();
  302. axios
  303. .post(`/v1/user/change/password`, {
  304. username: username,
  305. password: password1,
  306. newPassword: password2,
  307. })
  308. .then((res) => {
  309. if (res.code == 200) {
  310. ElMessage({
  311. message: "密码修改成功",
  312. type: "success",
  313. });
  314. dialogFormVisible.value = false;
  315. }else{
  316. ElMessage({
  317. message: res.message,
  318. type: "error",
  319. });
  320. }
  321. })
  322. .catch((err) => {
  323. ElMessage({
  324. message: err.msg,
  325. type: "error",
  326. });
  327. });
  328. } else {
  329. ElMessage({
  330. message: "请将信息填写完整",
  331. type: "error",
  332. });
  333. }
  334. });
  335. };
  336. </script>
  337. <style >
  338. .el-aside {
  339. background-color: #ffffff !important;
  340. }
  341. </style>
  342. <style scoped>
  343. .el-header,
  344. .el-footer {
  345. background-color: #57acbb;
  346. color: #ffffff;
  347. text-align: center;
  348. line-height: 60px;
  349. }
  350. .el-aside {
  351. background-color: #d3dce6;
  352. color: var(--el-text-color-primary);
  353. text-align: center;
  354. line-height: 200px;
  355. }
  356. .el-main {
  357. background-color: #e9eef3;
  358. color: var(--el-text-color-primary);
  359. /* text-align: center;
  360. line-height: 160px; */
  361. }
  362. body > .el-container {
  363. margin-bottom: 40px;
  364. }
  365. .el-container:nth-child(5) .el-aside,
  366. .el-container:nth-child(6) .el-aside {
  367. line-height: 260px;
  368. }
  369. .el-container:nth-child(7) .el-aside {
  370. line-height: 320px;
  371. }
  372. .el-menu-vertical-demo:not(.el-menu--collapse) {
  373. width: 200px;
  374. min-height: 400px;
  375. }
  376. .el-main {
  377. --el-main-padding: 0px;
  378. }
  379. .main_p {
  380. line-height: 15px;
  381. text-align: left;
  382. margin-top: 2px;
  383. }
  384. .el-dropdown-link {
  385. cursor: pointer;
  386. color: #ffffff;
  387. display: flex;
  388. align-items: center;
  389. }
  390. .user_operate {
  391. display: flex !important;
  392. justify-content: end;
  393. align-items: center;
  394. }
  395. .main {
  396. padding: 20px;
  397. margin: 8px;
  398. background: #ffffff;
  399. border-radius: 5px;
  400. box-shadow: 0px 3px 10px 0px rgba(49, 131, 207, 0.38);
  401. }
  402. .el-footer {
  403. height: auto;
  404. }
  405. .footer {
  406. width: 100%;
  407. background: #57acbb;
  408. overflow: hidden;
  409. }
  410. .footer .record {
  411. display: flex;
  412. justify-content: center;
  413. margin: 0;
  414. }
  415. .footer .record li {
  416. line-height: 60px;
  417. margin: 0 35px;
  418. }
  419. .footer .record li a {
  420. color: #ffffff;
  421. }
  422. .footer .record img,
  423. .footer .record span {
  424. vertical-align: middle;
  425. }
  426. </style>