Register.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <script setup lang="ts">
  2. //引入MD5
  3. import { md5 } from 'js-md5'
  4. import { getPositionApi, userGroupApi, userRegisterApi } from '@/api/login';
  5. import CpmdHeader from '@/components/CpmdHeader.vue';
  6. import { ElMessage } from 'element-plus';
  7. import { onMounted, onUnmounted, reactive, ref } from 'vue'
  8. import { useRoute, useRouter } from 'vue-router'
  9. // 加一个锁表示不能重复点击
  10. const isLock = ref<boolean>(false)
  11. //定义账号
  12. const account = ref<string>('')
  13. //定义密码
  14. const password = ref<string>('')
  15. //定义确认密码
  16. const comPassword = ref<string>('')
  17. //定义所选组织架构ID
  18. const group = ref<string>('')
  19. //定义组织架构的名字
  20. const groupName = ref<string>('')
  21. //定义用户姓名
  22. const name = ref('')
  23. const position = ref('')
  24. //选择性别
  25. const sex = ref('')
  26. //定义所选组织架构的数据
  27. const groupData = ref([])
  28. //定义临时变量保存平铺的数据
  29. const ppData = ref<any>([])
  30. const listPosition = ref<any>([])
  31. //此处应该是唯一的报告ID
  32. const id = ref<string>('')
  33. //持久化设置 菜单状态
  34. //刚进入页面就将高度设置为页面需要的
  35. onMounted(() => {
  36. userGroupFun()
  37. getPosition()
  38. })
  39. //调用查询接口职务的接口
  40. const getPosition = async () => {
  41. let res: any = await getPositionApi()
  42. listPosition.value = res.data
  43. }
  44. //跳转到注册页面的方法
  45. const router = useRouter()
  46. const loginFun = () => {
  47. router.push({ name: 'login' })
  48. }
  49. //注册方法
  50. const registerFun = async () => {
  51. if (isLock.value) {
  52. return
  53. }
  54. isLock.value = true
  55. //点击注册的方法
  56. //判断各个字段是否都在---或是否都为空
  57. if (group.value == '') {
  58. ElMessage({
  59. message: '请选择组织架构',
  60. type: 'warning'
  61. })
  62. isLock.value = false
  63. return
  64. }
  65. if (position.value == '') {
  66. ElMessage({
  67. message: '请选择职务',
  68. type: 'warning'
  69. })
  70. isLock.value = false
  71. return
  72. }
  73. if (account.value == '') {
  74. ElMessage({
  75. message: '请填写账号',
  76. type: 'warning'
  77. })
  78. isLock.value = false
  79. return
  80. }
  81. if (!/^[A-Za-z0-9]+$/.test(account.value)) {
  82. ElMessage({
  83. message: '账号只允许输入数字和英文',
  84. type: 'warning'
  85. })
  86. isLock.value = false
  87. return
  88. }
  89. if (name.value == '') {
  90. ElMessage({
  91. message: '请填写姓名',
  92. type: 'warning'
  93. })
  94. isLock.value = false
  95. return
  96. }
  97. if (name.value.length > 20) {
  98. ElMessage({
  99. message: '姓名不能超过20位',
  100. type: 'warning'
  101. })
  102. isLock.value = false
  103. return
  104. }
  105. if (sex.value == '') {
  106. ElMessage({
  107. message: '请选择性别',
  108. type: 'warning'
  109. })
  110. isLock.value = false
  111. return
  112. }
  113. if (password.value == '') {
  114. ElMessage({
  115. message: '请填写密码',
  116. type: 'warning'
  117. })
  118. isLock.value = false
  119. return
  120. }
  121. if (password.value.length < 6) {
  122. ElMessage({
  123. message: '密码长度最小6位',
  124. type: 'warning'
  125. })
  126. isLock.value = false
  127. return
  128. }
  129. if (comPassword.value == '') {
  130. ElMessage({
  131. message: '请填写确认密码',
  132. type: 'warning'
  133. })
  134. isLock.value = false
  135. return
  136. }
  137. if (comPassword.value != password.value) {
  138. ElMessage({
  139. message: '两次密码输入不一致',
  140. type: 'warning'
  141. })
  142. isLock.value = false
  143. return
  144. }
  145. queryOrgName()
  146. //开始组织参数
  147. let params = {
  148. orgNo: group.value,
  149. orgName: groupName.value,
  150. userNo: account.value,
  151. userName: name.value,
  152. gender: sex.value,
  153. password: md5(password.value),
  154. position: parseInt(position.value),
  155. roleType: '1'
  156. }
  157. //如果都通过开始调用方法注册的方法
  158. const res: any = await userRegisterApi(params)
  159. isLock.value = false
  160. if (res.code == 200) {
  161. ElMessage({
  162. message: res.msg,
  163. type: 'success'
  164. })
  165. // 跳转到登录页面吧
  166. router.push({ name: 'login' })
  167. //如果注册成功过得话
  168. } else {
  169. ElMessage({
  170. message: res.msg,
  171. type: 'error'
  172. })
  173. }
  174. }
  175. //根据id查询组织架构名字的方法
  176. const queryOrgName = () => {
  177. for (let i = 0; i < ppData.value.length; i++) {
  178. if (group.value == ppData.value[i].orgNo) {
  179. groupName.value = ppData.value[i].orgName
  180. }
  181. }
  182. }
  183. //-----------------组织架构处理方法start---------------------
  184. //获取组织架构list
  185. const userGroupFun = async () => {
  186. let res: any = await userGroupApi()
  187. //数据的得到后新增数据格式的value字段 和id一样 新增数据格式的label 与name一致
  188. //增加字段的方法
  189. //先判断返回的是否有数据
  190. if (res.data.length > 0) {
  191. let resAdd = addPro(res.data)
  192. ppData.value = JSON.parse(JSON.stringify(resAdd))
  193. let forRes = arrToTree(resAdd)
  194. let resultRes = deleteChildren(forRes)
  195. groupData.value = resultRes
  196. } else {
  197. groupData.value = []
  198. }
  199. //修改数据的字段
  200. //只取当前的id字段
  201. //得到值后开始组装数据
  202. }
  203. //给数据增加两个字段的方法
  204. const addPro = (val: any) => {
  205. let data = JSON.parse(JSON.stringify(val))
  206. for (let i = 0; i < val.length; i++) {
  207. data[i].value = val[i].orgNo
  208. data[i].label = val[i].orgName
  209. }
  210. return data
  211. }
  212. //非递归方式:将平铺数据转换为树形结构数据
  213. const arrToTree = (arr: any) => {
  214. let data = arr.filter((item: any) => {
  215. item.children = arr.filter((e: any) => {
  216. return item.orgNo === e.parentOrgNo
  217. })
  218. return !item.parentOrgNo
  219. })
  220. return data;
  221. }
  222. //去除转换树形结构数据后存在的空children
  223. const deleteChildren = (arr: any) => {
  224. let childs = arr;
  225. for (let i = childs.length; i--; i > 0) {
  226. if (childs[i].children) {
  227. if (childs[i].children.length) {
  228. deleteChildren(childs[i].children);
  229. } else {
  230. delete childs[i].children;
  231. }
  232. }
  233. }
  234. return arr;
  235. }
  236. //-----------------组织架构处理方法结束---------------------
  237. //轮旋切换页面的方法
  238. //退出页面销毁 方法
  239. onUnmounted(() => {
  240. })
  241. </script>
  242. <template>
  243. <div class="home_header_out">
  244. <div class=" home_header_inner">
  245. <CpmdHeader />
  246. <div class="report_top">
  247. <div class="report_jt">
  248. <span>用户注册</span>
  249. </div>
  250. <!-- <img class="xlts_img" src="../assets/report/report_top.png" /> -->
  251. </div>
  252. </div>
  253. <div class="kply">
  254. <div class="kply_inner">
  255. <div style="padding: 10px 100px;">
  256. <div style="margin-top:20px">
  257. <div class="user_account">所属组织架构:</div>
  258. <div class="input_cus">
  259. <el-tree-select v-model="group" placeholder="请选择组织架构" :data="groupData" filterable
  260. style="width:100%" />
  261. </div>
  262. </div>
  263. <div style="margin-top:20px;display: flex;">
  264. <div style="flex: 1;">
  265. <div class="user_account">职务:</div>
  266. <div class="input_cus">
  267. <el-select v-model="position" placeholder="请选择职务" size="large" style="width: 90%;">
  268. <el-option v-for="item in listPosition" :key="item.paramValue"
  269. :label="item.paramName" :value="item.paramValue" />
  270. </el-select>
  271. </div>
  272. </div>
  273. <div style="flex: 1;display: flex;flex-direction: column;justify-content: end;">
  274. <div class="user_account" style="width: 90%;margin-left: 10%">账号(学号):</div>
  275. <div class="input_cus"> <el-input v-model="account" style="width: 90%;margin-left: 10%"
  276. placeholder="请输入账号" />
  277. </div>
  278. </div>
  279. </div>
  280. <div style="margin-top:20px;display: flex;">
  281. <div style="flex: 1;">
  282. <div class="user_account">姓名:</div>
  283. <div class="input_cus"> <el-input v-model="name" style="width: 90%;" placeholder="请输入姓名" />
  284. </div>
  285. </div>
  286. <div style="flex: 1;">
  287. <div class="user_account" style="width: 90%;margin-left:10%">性别:</div>
  288. <div class="input_cus" style="width: 90%;margin-left:10%"> <el-radio-group size="large"
  289. v-model="sex">
  290. <el-radio value="1" size="large">男</el-radio>
  291. <el-radio value="0" size="large">女</el-radio>
  292. </el-radio-group>
  293. </div>
  294. </div>
  295. </div>
  296. <div style="margin-top:20px">
  297. <div class="user_account">密码:</div>
  298. <div><el-input v-model="password" type="password" style="width: 100%" placeholder="请输入密码"
  299. show-password />
  300. </div>
  301. </div>
  302. <div style="margin-top:20px">
  303. <div class="user_account">确认密码:</div>
  304. <div><el-input v-model="comPassword" type="password" style="width: 100%" placeholder="请输入密码"
  305. show-password />
  306. </div>
  307. </div>
  308. <div class="go_register">
  309. <span @click="loginFun">
  310. 已有账号,去登录
  311. </span>
  312. </div>
  313. <div class="start_button_out">
  314. <div @click="registerFun" class="start_button_self">注册</div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. </template>
  321. <style></style>
  322. <style lang="scss" scoped>
  323. :deep(.el-input__wrapper) {
  324. align-items: center;
  325. border-radius: 60px !important;
  326. border: 2px solid #B2F2D2 !important;
  327. padding-left: 20px;
  328. }
  329. :deep(.el-input__wrapper .is-fous) {
  330. box-shadow: none
  331. }
  332. :deep(.el-input__inner) {
  333. height: 36px;
  334. font-size: 16px;
  335. }
  336. :deep(.el-select__placeholder) {
  337. color: var(--el-input-text-color, var(--el-text-color-regular));
  338. position: absolute;
  339. top: 50%;
  340. transform: translateY(-50%);
  341. width: 100%;
  342. line-height: 30px;
  343. font-size: 16px;
  344. }
  345. :deep(.el-select__selection) {
  346. align-items: center;
  347. display: flex;
  348. flex: 1;
  349. flex-wrap: wrap;
  350. gap: 6px;
  351. min-width: 0;
  352. position: relative;
  353. height: 30px;
  354. }
  355. :deep(.el-select__wrapper) {
  356. border-radius: 60px;
  357. border: 2px solid #B2F2D2;
  358. padding-left: 20px;
  359. height: 40px;
  360. }
  361. :deep(.el-select__input) {
  362. -webkit-appearance: none;
  363. -moz-appearance: none;
  364. appearance: none;
  365. background-color: transparent;
  366. border: none;
  367. color: var(--el-select-multiple-input-color);
  368. font-family: inherit;
  369. font-size: 20px;
  370. height: 36px;
  371. max-width: 100%;
  372. width: 100% !important;
  373. outline: none;
  374. padding: 0;
  375. }
  376. :deep(.el-tree) {
  377. --el-tree-node-content-height: 53px;
  378. --el-tree-node-hover-bg-color: var(--el-fill-color-light);
  379. --el-tree-text-color: var(--el-text-color-regular);
  380. --el-tree-expand-icon-color: var(--el-text-color-placeholder);
  381. background: var(--el-fill-color-blank);
  382. color: var(--el-tree-text-color);
  383. cursor: default;
  384. font-size: 27px !important;
  385. position: relative;
  386. }
  387. :deep(.el-radio.el-radio--large .el-radio__inner) {
  388. height: 20px;
  389. width: 20px;
  390. }
  391. :deep(.el-radio.el-radio--large .el-radio__label) {
  392. font-size: 16px;
  393. }
  394. :deep(.el-radio.el-radio--large) {
  395. height: 36px;
  396. }
  397. :deep(.el-radio__input.is-checked .el-radio__inner) {
  398. background: #48D68E;
  399. border-color: #B2F2D2;
  400. }
  401. :deep(.el-radio__input.is-checked+.el-radio__label) {
  402. color: #48D68E;
  403. }
  404. .home_header_out {
  405. flex: 1;
  406. // position: relative;
  407. padding-bottom: 60px;
  408. width: 100%;
  409. min-width: 1200px;
  410. background-image: url('../assets/home/bg_ty.png');
  411. background-repeat: no-repeat;
  412. background-size: contain;
  413. background-color: #B3F1DA; //估计是需要动态
  414. //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
  415. .home_header_inner {
  416. min-height: 1;
  417. left: 0;
  418. right: 0;
  419. margin: auto;
  420. // height: 100px;
  421. width: 1200px;
  422. .report_top {
  423. width: 650px;
  424. // width: 860px; 210
  425. margin-left: 285px;
  426. margin-top: 20px;
  427. display: flex;
  428. flex-direction: row;
  429. justify-content: space-between;
  430. align-items: center;
  431. .xlts_img {
  432. width: 200px;
  433. }
  434. .report_jt {
  435. display: flex;
  436. flex-direction: column;
  437. font-size: 20px;
  438. font-weight: 700;
  439. letter-spacing: 3px;
  440. }
  441. }
  442. }
  443. .kply {
  444. width: 100%;
  445. margin-top: 20px;
  446. // background-color: #FAFAFA;
  447. .kply_inner {
  448. // padding: 20px 20px;
  449. left: 0;
  450. right: 0;
  451. margin: auto;
  452. width: 650px;
  453. min-height: 500px;
  454. background-color: #ffffff;
  455. border-radius: 40px;
  456. .user_account {
  457. font-size: 18px;
  458. // line-height: 70px;
  459. margin-bottom: 10px;
  460. letter-spacing: 5px;
  461. }
  462. .start_button_out {
  463. margin-top: 40px;
  464. margin-bottom: 20px;
  465. display: flex;
  466. flex-direction: row;
  467. justify-content: center;
  468. .start_button_self {
  469. cursor: pointer;
  470. // width: 100px;
  471. border-radius: 12px;
  472. border: 3px solid #48D68E;
  473. color: #ffffff;
  474. background-color: #000000;
  475. margin-right: 20px;
  476. padding: 10px 50px;
  477. cursor: pointer;
  478. display: flex;
  479. align-items: center;
  480. font-size: 16px;
  481. }
  482. }
  483. }
  484. .go_register {
  485. text-align: right;
  486. margin-top: 20px;
  487. span {
  488. color: #48D68E;
  489. cursor: pointer;
  490. font-size: 16px;
  491. }
  492. }
  493. }
  494. }
  495. .home_mid {
  496. // background-color: blanchedalmond;
  497. width: 1200px;
  498. left: 0;
  499. right: 0;
  500. margin: auto;
  501. margin-top: 40px;
  502. // position: relative;
  503. .kepu_title {
  504. text-align: center;
  505. font-size: 50px;
  506. color: #111111;
  507. line-height: 95px;
  508. // width: 100%;
  509. // left: 0;
  510. // right: 0;
  511. // margin: auto
  512. }
  513. .kepu_title_sub {
  514. margin-top: 30px;
  515. text-align: center;
  516. font-size: 28px;
  517. color: #48D68E;
  518. line-height: 26px;
  519. }
  520. .man1_group {
  521. margin-top: 60px;
  522. height: 100%;
  523. display: flex;
  524. .man1 {
  525. position: relative;
  526. width: 327px;
  527. // height: 100%;
  528. // height: 100%
  529. .man1_img {
  530. position: absolute;
  531. bottom: 0;
  532. /* bottom: 0px; */
  533. /* height: auto; */
  534. width: 100%;
  535. left: 100px
  536. }
  537. }
  538. .des {
  539. border: #48D68E solid 5px;
  540. border-radius: 40px;
  541. padding: 20px;
  542. letter-spacing: 6px;
  543. flex: 1;
  544. .des_inner {
  545. border: 1px dashed #48D68E;
  546. border-radius: 40px;
  547. padding-bottom: 40px;
  548. padding-top: 30px;
  549. padding-left: 100px;
  550. padding-right: 20px;
  551. letter-spacing: 6px;
  552. font-weight: normal;
  553. font-size: 24px;
  554. color: #333333;
  555. line-height: 40px;
  556. }
  557. }
  558. }
  559. .man2_group {
  560. margin-top: 60px;
  561. height: 100%;
  562. display: flex;
  563. .man2 {
  564. position: relative;
  565. width: 327px;
  566. // height: 100%;
  567. // height: 100%
  568. .man2_img {
  569. position: absolute;
  570. bottom: 0;
  571. /* bottom: 0px; */
  572. /* height: auto; */
  573. width: 100%;
  574. left: -100px
  575. }
  576. }
  577. .des2 {
  578. border: #48D68E solid 5px;
  579. border-radius: 40px;
  580. padding: 20px;
  581. letter-spacing: 6px;
  582. flex: 1;
  583. .des2_inner {
  584. border: 1px dashed #48D68E;
  585. border-radius: 40px;
  586. padding-bottom: 40px;
  587. padding-top: 30px;
  588. padding-left: 20px;
  589. padding-right: 100px;
  590. letter-spacing: 6px;
  591. font-weight: normal;
  592. font-size: 24px;
  593. color: #333333;
  594. line-height: 40px;
  595. }
  596. }
  597. }
  598. .get_more {
  599. text-align: center;
  600. img {
  601. width: 300px;
  602. margin-top: 60px;
  603. margin-bottom: 60px;
  604. }
  605. }
  606. }
  607. // .home_footer_out {
  608. // width: 100%;
  609. // background-color: #000000;
  610. // }</style>