Browse Source

增加教师角色

plg 3 months ago
parent
commit
9be97e76d3
1 changed files with 72 additions and 17 deletions
  1. 72 17
      src/views/Register.vue

+ 72 - 17
src/views/Register.vue

@@ -13,7 +13,8 @@ import { useRoute, useRouter } from 'vue-router'
 
 // 加一个锁表示不能重复点击
 const isLock = ref<boolean>(false)
-
+//账号角色
+const roleType = ref<string>('1')
 //定义账号
 const account = ref<string>('')
 //定义密码
@@ -81,14 +82,19 @@ const registerFun = async () => {
         isLock.value = false
         return
     }
-    if (position.value == '') {
-        ElMessage({
-            message: '请选择职务',
-            type: 'warning'
-        })
-        isLock.value = false
-        return
+
+    if (roleType.value == '1') {
+        if (position.value == '') {
+            ElMessage({
+                message: '请选择职务',
+                type: 'warning'
+            })
+            isLock.value = false
+            return
+        }
     }
+
+
     if (account.value == '') {
         ElMessage({
             message: '请填写账号',
@@ -171,8 +177,8 @@ const registerFun = async () => {
         userName: name.value,
         gender: sex.value,
         password: md5(password.value),
-        position: parseInt(position.value),
-        roleType: '1'
+        position: roleType.value == '2' ? -1 : parseInt(position.value),
+        roleType: roleType.value
     }
     //如果都通过开始调用方法注册的方法
     const res: any = await userRegisterApi(params)
@@ -215,7 +221,13 @@ const userGroupFun = async () => {
     //增加字段的方法
     //先判断返回的是否有数据
     if (res.data.length > 0) {
-        let resAdd = addPro(res.data)
+        //判断当前是  教师还是学生
+        console.log('组织架构信息')
+        console.log(res.data)
+
+        let list = roleTypeFilter(res.data)
+
+        let resAdd = addPro(list)
         ppData.value = JSON.parse(JSON.stringify(resAdd))
         let forRes = arrToTree(resAdd)
         let resultRes = deleteChildren(forRes)
@@ -229,6 +241,25 @@ const userGroupFun = async () => {
     //得到值后开始组装数据
 
 }
+
+//过滤数据进行测试
+const roleTypeFilter = (val: any) => {
+    let data = JSON.parse(JSON.stringify(val))
+    let list = []
+    if (roleType.value == '1') {
+        list = data.filter((item: any) => {
+            return item.orgNo.length != 12 || (item.orgNo.length == 12 && item.extend != '-1')
+        })
+    } else
+        if (roleType.value == '2') {
+            list = data.filter((item: any) => {
+                return (item.orgNo.length != 12) || item.orgNo.length == 12 && item.extend == '-1'
+            })
+        }
+
+    return list
+}
+
 //给数据增加两个字段的方法
 const addPro = (val: any) => {
     let data = JSON.parse(JSON.stringify(val))
@@ -273,7 +304,14 @@ const deleteChildren = (arr: any) => {
 onUnmounted(() => {
 
 })
-
+const roleTypeChange = (val: string) => {
+    //切换角色时
+    //当角色是2时要筛选角色是教师的组织架构
+    //当角色是1时要筛选角色是学生的组织架构
+    //清空选项
+    group.value = ''
+    userGroupFun()
+}
 
 
 
@@ -293,6 +331,20 @@ onUnmounted(() => {
         <div class="kply">
             <div class="kply_inner">
                 <div style="padding: 10px 100px;">
+                    <div style="margin-top:20px;display: flex;">
+
+
+                        <div style="flex: 1;">
+                            <div class="user_account" style="width: 100%;">用户类型:</div>
+                            <div class="input_cus" style="width: 100%;"> <el-radio-group size="large"
+                                    @change="roleTypeChange" v-model="roleType">
+                                    <el-radio value="2" size="large">我是教师</el-radio>
+                                    <el-radio value="1" size="large">我是学生</el-radio>
+                                </el-radio-group>
+                            </div>
+                        </div>
+
+                    </div>
                     <div style="margin-top:20px">
                         <div class="user_account">所属组织架构:</div>
                         <div class="input_cus">
@@ -301,20 +353,23 @@ onUnmounted(() => {
                         </div>
                     </div>
                     <div style="margin-top:20px;display: flex;">
-                        <div style="flex: 1;">
+                        <div style="flex: 1;" v-show="roleType == '1'">
                             <div class="user_account">职务:</div>
                             <div class="input_cus">
 
-                                <el-select v-model="position" placeholder="请选择职务" size="large" style="width: 90%;">
+                                <el-select v-model="position" placeholder="请选择职务" size="large">
                                     <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 class="user_account"
+                                :style="{ width: roleType == '1' ? '90%' : '100%', marginLeft: roleType == '1' ? '10%' : '0%' }">
+                                学号/编号:</div>
+                            <div class="input_cus"> <el-input v-model="account"
+                                    :style="{ width: roleType == '1' ? '90%' : '100%', marginLeft: roleType == '1' ? '10%' : '0%' }"
+                                    placeholder="请输入学号/编号" />
                             </div>
                         </div>