123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721 |
- <script setup lang="ts">
- //引入MD5
- import { md5 } from 'js-md5'
- import { getPositionApi, userGroupApi, userRegisterApi } from '@/api/login';
- import CpmdHeader from '@/components/CpmdHeader.vue';
- import { ElMessage } from 'element-plus';
- import { onMounted, onUnmounted, reactive, ref } from 'vue'
- import { useRoute, useRouter } from 'vue-router'
- // 加一个锁表示不能重复点击
- const isLock = ref<boolean>(false)
- //定义账号
- const account = ref<string>('')
- //定义密码
- const password = ref<string>('')
- //定义确认密码
- const comPassword = ref<string>('')
- //定义所选组织架构ID
- const group = ref<string>('')
- //定义组织架构的名字
- const groupName = ref<string>('')
- //定义用户姓名
- const name = ref('')
- const position = ref('')
- //选择性别
- const sex = ref('')
- //定义所选组织架构的数据
- const groupData = ref([])
- //定义临时变量保存平铺的数据
- const ppData = ref<any>([])
- const listPosition = ref<any>([])
- //此处应该是唯一的报告ID
- const id = ref<string>('')
- //持久化设置 菜单状态
- //刚进入页面就将高度设置为页面需要的
- onMounted(() => {
- userGroupFun()
- getPosition()
- })
- //调用查询接口职务的接口
- const getPosition = async () => {
- let res: any = await getPositionApi()
- listPosition.value = res.data
- }
- //跳转到注册页面的方法
- const router = useRouter()
- const loginFun = () => {
- router.push({ name: 'login' })
- }
- //注册方法
- const registerFun = async () => {
- if (isLock.value) {
- return
- }
- isLock.value = true
- //点击注册的方法
- //判断各个字段是否都在---或是否都为空
- if (group.value == '') {
- ElMessage({
- message: '请选择组织架构',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (position.value == '') {
- ElMessage({
- message: '请选择职务',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (account.value == '') {
- ElMessage({
- message: '请填写账号',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (!/^[A-Za-z0-9]+$/.test(account.value)) {
- ElMessage({
- message: '账号只允许输入数字和英文',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (name.value == '') {
- ElMessage({
- message: '请填写姓名',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (name.value.length > 20) {
- ElMessage({
- message: '姓名不能超过20位',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (sex.value == '') {
- ElMessage({
- message: '请选择性别',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (password.value == '') {
- ElMessage({
- message: '请填写密码',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (password.value.length < 6) {
- ElMessage({
- message: '密码长度最小6位',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (comPassword.value == '') {
- ElMessage({
- message: '请填写确认密码',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- if (comPassword.value != password.value) {
- ElMessage({
- message: '两次密码输入不一致',
- type: 'warning'
- })
- isLock.value = false
- return
- }
- queryOrgName()
- //开始组织参数
- let params = {
- orgNo: group.value,
- orgName: groupName.value,
- userNo: account.value,
- userName: name.value,
- gender: sex.value,
- password: md5(password.value),
- position: parseInt(position.value),
- roleType: '1'
- }
- //如果都通过开始调用方法注册的方法
- const res: any = await userRegisterApi(params)
- isLock.value = false
- if (res.code == 200) {
- ElMessage({
- message: res.msg,
- type: 'success'
- })
- // 跳转到登录页面吧
- router.push({ name: 'login' })
- //如果注册成功过得话
- } else {
- ElMessage({
- message: res.msg,
- type: 'error'
- })
- }
- }
- //根据id查询组织架构名字的方法
- const queryOrgName = () => {
- for (let i = 0; i < ppData.value.length; i++) {
- if (group.value == ppData.value[i].orgNo) {
- groupName.value = ppData.value[i].orgName
- }
- }
- }
- //-----------------组织架构处理方法start---------------------
- //获取组织架构list
- const userGroupFun = async () => {
- let res: any = await userGroupApi()
- //数据的得到后新增数据格式的value字段 和id一样 新增数据格式的label 与name一致
- //增加字段的方法
- //先判断返回的是否有数据
- if (res.data.length > 0) {
- let resAdd = addPro(res.data)
- ppData.value = JSON.parse(JSON.stringify(resAdd))
- let forRes = arrToTree(resAdd)
- let resultRes = deleteChildren(forRes)
- groupData.value = resultRes
- } else {
- groupData.value = []
- }
- //修改数据的字段
- //只取当前的id字段
- //得到值后开始组装数据
- }
- //给数据增加两个字段的方法
- const addPro = (val: any) => {
- let data = JSON.parse(JSON.stringify(val))
- for (let i = 0; i < val.length; i++) {
- data[i].value = val[i].orgNo
- data[i].label = val[i].orgName
- }
- return data
- }
- //非递归方式:将平铺数据转换为树形结构数据
- const arrToTree = (arr: any) => {
- let data = arr.filter((item: any) => {
- item.children = arr.filter((e: any) => {
- return item.orgNo === e.parentOrgNo
- })
- return !item.parentOrgNo
- })
- return data;
- }
- //去除转换树形结构数据后存在的空children
- const deleteChildren = (arr: any) => {
- let childs = arr;
- for (let i = childs.length; i--; i > 0) {
- if (childs[i].children) {
- if (childs[i].children.length) {
- deleteChildren(childs[i].children);
- } else {
- delete childs[i].children;
- }
- }
- }
- return arr;
- }
- //-----------------组织架构处理方法结束---------------------
- //轮旋切换页面的方法
- //退出页面销毁 方法
- onUnmounted(() => {
- })
- </script>
- <template>
- <div class="home_header_out">
- <div class=" home_header_inner">
- <CpmdHeader />
- <div class="report_top">
- <div class="report_jt">
- <span>用户注册</span>
- </div>
- <!-- <img class="xlts_img" src="../assets/report/report_top.png" /> -->
- </div>
- </div>
- <div class="kply">
- <div class="kply_inner">
- <div style="padding: 10px 100px;">
- <div style="margin-top:20px">
- <div class="user_account">所属组织架构:</div>
- <div class="input_cus">
- <el-tree-select v-model="group" placeholder="请选择组织架构" :data="groupData" filterable
- style="width:100%" />
- </div>
- </div>
- <div style="margin-top:20px;display: flex;">
- <div style="flex: 1;">
- <div class="user_account">职务:</div>
- <div class="input_cus">
- <el-select v-model="position" placeholder="请选择职务" size="large" style="width: 90%;">
- <el-option v-for="item in listPosition" :key="item.paramValue"
- :label="item.paramName" :value="item.paramValue" />
- </el-select>
- </div>
- </div>
- <div style="flex: 1;display: flex;flex-direction: column;justify-content: end;">
- <div class="user_account" style="width: 90%;margin-left: 10%">账号(学号):</div>
- <div class="input_cus"> <el-input v-model="account" style="width: 90%;margin-left: 10%"
- placeholder="请输入账号" />
- </div>
- </div>
- </div>
- <div style="margin-top:20px;display: flex;">
- <div style="flex: 1;">
- <div class="user_account">姓名:</div>
- <div class="input_cus"> <el-input v-model="name" style="width: 90%;" placeholder="请输入姓名" />
- </div>
- </div>
- <div style="flex: 1;">
- <div class="user_account" style="width: 90%;margin-left:10%">性别:</div>
- <div class="input_cus" style="width: 90%;margin-left:10%"> <el-radio-group size="large"
- v-model="sex">
- <el-radio value="1" size="large">男</el-radio>
- <el-radio value="0" size="large">女</el-radio>
- </el-radio-group>
- </div>
- </div>
- </div>
- <div style="margin-top:20px">
- <div class="user_account">密码:</div>
- <div><el-input v-model="password" type="password" style="width: 100%" placeholder="请输入密码"
- show-password />
- </div>
- </div>
- <div style="margin-top:20px">
- <div class="user_account">确认密码:</div>
- <div><el-input v-model="comPassword" type="password" style="width: 100%" placeholder="请输入密码"
- show-password />
- </div>
- </div>
- <div class="go_register">
- <span @click="loginFun">
- 已有账号,去登录
- </span>
- </div>
- <div class="start_button_out">
- <div @click="registerFun" class="start_button_self">注册</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <style></style>
- <style lang="scss" scoped>
- :deep(.el-input__wrapper) {
- align-items: center;
- border-radius: 60px !important;
- border: 2px solid #B2F2D2 !important;
- padding-left: 20px;
- }
- :deep(.el-input__wrapper .is-fous) {
- box-shadow: none
- }
- :deep(.el-input__inner) {
- height: 36px;
- font-size: 16px;
- }
- :deep(.el-select__placeholder) {
- color: var(--el-input-text-color, var(--el-text-color-regular));
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- width: 100%;
- line-height: 30px;
- font-size: 16px;
- }
- :deep(.el-select__selection) {
- align-items: center;
- display: flex;
- flex: 1;
- flex-wrap: wrap;
- gap: 6px;
- min-width: 0;
- position: relative;
- height: 30px;
- }
- :deep(.el-select__wrapper) {
- border-radius: 60px;
- border: 2px solid #B2F2D2;
- padding-left: 20px;
- height: 40px;
- }
- :deep(.el-select__input) {
- -webkit-appearance: none;
- -moz-appearance: none;
- appearance: none;
- background-color: transparent;
- border: none;
- color: var(--el-select-multiple-input-color);
- font-family: inherit;
- font-size: 20px;
- height: 36px;
- max-width: 100%;
- width: 100% !important;
- outline: none;
- padding: 0;
- }
- :deep(.el-tree) {
- --el-tree-node-content-height: 53px;
- --el-tree-node-hover-bg-color: var(--el-fill-color-light);
- --el-tree-text-color: var(--el-text-color-regular);
- --el-tree-expand-icon-color: var(--el-text-color-placeholder);
- background: var(--el-fill-color-blank);
- color: var(--el-tree-text-color);
- cursor: default;
- font-size: 27px !important;
- position: relative;
- }
- :deep(.el-radio.el-radio--large .el-radio__inner) {
- height: 20px;
- width: 20px;
- }
- :deep(.el-radio.el-radio--large .el-radio__label) {
- font-size: 16px;
- }
- :deep(.el-radio.el-radio--large) {
- height: 36px;
- }
- :deep(.el-radio__input.is-checked .el-radio__inner) {
- background: #48D68E;
- border-color: #B2F2D2;
- }
- :deep(.el-radio__input.is-checked+.el-radio__label) {
- color: #48D68E;
- }
- .home_header_out {
- flex: 1;
- // position: relative;
- padding-bottom: 60px;
- width: 100%;
- min-width: 1200px;
- background-image: url('../assets/home/bg_ty.png');
- background-repeat: no-repeat;
- background-size: contain;
- background-color: #B3F1DA; //估计是需要动态
- //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
- .home_header_inner {
- min-height: 1;
- left: 0;
- right: 0;
- margin: auto;
- // height: 100px;
- width: 1200px;
- .report_top {
- width: 650px;
- // width: 860px; 210
- margin-left: 285px;
- margin-top: 20px;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- .xlts_img {
- width: 200px;
- }
- .report_jt {
- display: flex;
- flex-direction: column;
- font-size: 20px;
- font-weight: 700;
- letter-spacing: 3px;
- }
- }
- }
- .kply {
- width: 100%;
- margin-top: 20px;
- // background-color: #FAFAFA;
- .kply_inner {
- // padding: 20px 20px;
- left: 0;
- right: 0;
- margin: auto;
- width: 650px;
- min-height: 500px;
- background-color: #ffffff;
- border-radius: 40px;
- .user_account {
- font-size: 18px;
- // line-height: 70px;
- margin-bottom: 10px;
- letter-spacing: 5px;
- }
- .start_button_out {
- margin-top: 40px;
- margin-bottom: 20px;
- display: flex;
- flex-direction: row;
- justify-content: center;
- .start_button_self {
- cursor: pointer;
- // width: 100px;
- border-radius: 12px;
- border: 3px solid #48D68E;
- color: #ffffff;
- background-color: #000000;
- margin-right: 20px;
- padding: 10px 50px;
- cursor: pointer;
- display: flex;
- align-items: center;
- font-size: 16px;
- }
- }
- }
- .go_register {
- text-align: right;
- margin-top: 20px;
- span {
- color: #48D68E;
- cursor: pointer;
- font-size: 16px;
- }
- }
- }
- }
- .home_mid {
- // background-color: blanchedalmond;
- width: 1200px;
- left: 0;
- right: 0;
- margin: auto;
- margin-top: 40px;
- // position: relative;
- .kepu_title {
- text-align: center;
- font-size: 50px;
- color: #111111;
- line-height: 95px;
- // width: 100%;
- // left: 0;
- // right: 0;
- // margin: auto
- }
- .kepu_title_sub {
- margin-top: 30px;
- text-align: center;
- font-size: 28px;
- color: #48D68E;
- line-height: 26px;
- }
- .man1_group {
- margin-top: 60px;
- height: 100%;
- display: flex;
- .man1 {
- position: relative;
- width: 327px;
- // height: 100%;
- // height: 100%
- .man1_img {
- position: absolute;
- bottom: 0;
- /* bottom: 0px; */
- /* height: auto; */
- width: 100%;
- left: 100px
- }
- }
- .des {
- border: #48D68E solid 5px;
- border-radius: 40px;
- padding: 20px;
- letter-spacing: 6px;
- flex: 1;
- .des_inner {
- border: 1px dashed #48D68E;
- border-radius: 40px;
- padding-bottom: 40px;
- padding-top: 30px;
- padding-left: 100px;
- padding-right: 20px;
- letter-spacing: 6px;
- font-weight: normal;
- font-size: 24px;
- color: #333333;
- line-height: 40px;
- }
- }
- }
- .man2_group {
- margin-top: 60px;
- height: 100%;
- display: flex;
- .man2 {
- position: relative;
- width: 327px;
- // height: 100%;
- // height: 100%
- .man2_img {
- position: absolute;
- bottom: 0;
- /* bottom: 0px; */
- /* height: auto; */
- width: 100%;
- left: -100px
- }
- }
- .des2 {
- border: #48D68E solid 5px;
- border-radius: 40px;
- padding: 20px;
- letter-spacing: 6px;
- flex: 1;
- .des2_inner {
- border: 1px dashed #48D68E;
- border-radius: 40px;
- padding-bottom: 40px;
- padding-top: 30px;
- padding-left: 20px;
- padding-right: 100px;
- letter-spacing: 6px;
- font-weight: normal;
- font-size: 24px;
- color: #333333;
- line-height: 40px;
- }
- }
- }
- .get_more {
- text-align: center;
- img {
- width: 300px;
- margin-top: 60px;
- margin-bottom: 60px;
- }
- }
- }
- // .home_footer_out {
- // width: 100%;
- // background-color: #000000;
- // }</style>
|