소스 검색

fix:修复注册时无法选择部门的问题

LYK 2 주 전
부모
커밋
462677c291
2개의 변경된 파일374개의 추가작업 그리고 404개의 파일을 삭제
  1. 2 13
      components.d.ts
  2. 372 391
      src/view/register/index.vue

+ 2 - 13
components.d.ts

@@ -13,35 +13,26 @@ declare module 'vue' {
     RouterView: typeof import('vue-router')['RouterView']
     SelectInst: typeof import('./src/components/select-inst.vue')['default']
     SelectInstAppointRecord: typeof import('./src/components/select-inst-appoint-record.vue')['default']
-    VanActionBar: typeof import('vant/es')['ActionBar']
-    VanActionBarButton: typeof import('vant/es')['ActionBarButton']
-    VanActionBarIcon: typeof import('vant/es')['ActionBarIcon']
-    VanBackTop: typeof import('vant/es')['BackTop']
     VanButton: typeof import('vant/es')['Button']
-    VanCalendar: typeof import('vant/es')['Calendar']
     VanCell: typeof import('vant/es')['Cell']
     VanCellGroup: typeof import('vant/es')['CellGroup']
     VanCheckbox: typeof import('vant/es')['Checkbox']
     VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup']
-    VanCollapse: typeof import('vant/es')['Collapse']
-    VanCollapseItem: typeof import('vant/es')['CollapseItem']
     VanDatePicker: typeof import('vant/es')['DatePicker']
     VanDialog: typeof import('vant/es')['Dialog']
-    VanEmpty: typeof import('vant/es')['Empty']
     VanField: typeof import('vant/es')['Field']
-    VanFloatingBubble: typeof import('vant/es')['FloatingBubble']
     VanForm: typeof import('vant/es')['Form']
     VanIcon: typeof import('vant/es')['Icon']
     VanImage: typeof import('vant/es')['Image']
     VanList: typeof import('vant/es')['List']
     VanNotify: typeof import('vant/es')['Notify']
     VanPicker: typeof import('vant/es')['Picker']
+    VanPickerGroup: typeof import('vant/es')['PickerGroup']
     VanPopup: typeof import('vant/es')['Popup']
     VanRadio: typeof import('vant/es')['Radio']
     VanRadioGroup: typeof import('vant/es')['RadioGroup']
-    VanSearch: typeof import('vant/es')['Search']
+    VanRow: typeof import('vant/es')['Row']
     VanStep: typeof import('vant/es')['Step']
-    VanStepper: typeof import('vant/es')['Stepper']
     VanSteps: typeof import('vant/es')['Steps']
     VanSwipe: typeof import('vant/es')['Swipe']
     VanSwipeItem: typeof import('vant/es')['SwipeItem']
@@ -51,7 +42,5 @@ declare module 'vue' {
     VanTabs: typeof import('vant/es')['Tabs']
     VanTag: typeof import('vant/es')['Tag']
     VanTextEllipsis: typeof import('vant/es')['TextEllipsis']
-    VanTimePicker: typeof import('vant/es')['TimePicker']
-    VanUploader: typeof import('vant/es')['Uploader']
   }
 }

+ 372 - 391
src/view/register/index.vue

@@ -25,9 +25,9 @@
       <van-form ref="loginInfoRef" v-show="state.active == 0" required="auto">
         <van-cell-group inset>
           <van-field v-model="state.form.userName" label="登录账号" placeholder="登录账号" :rules="[{ required: true, message: '请填写登录账号' },
-            {validator: checkUserNameExists, message: '账号不可用'}]" />
+          { validator: checkUserNameExists, message: '账号不可用' }]" />
           <van-field v-model="state.form.password" type="password" label="密码" placeholder="密码"
-            :rules="[{ required: true, message: '密码不能为空'}, {validator: checkPassword, message: '密码不合法'}]" />
+            :rules="[{ required: true, message: '密码不能为空' }, { validator: checkPassword, message: '密码不合法' }]" />
           <van-field v-model="state.form.confirmPassword" type="password" label="确认密码" placeholder="确认密码"
             :rules="[{ required: true, validator: confirmPasswordSame, message: '两次输入的密码不一致' }]" />
         </van-cell-group>
@@ -107,40 +107,21 @@
             <div v-for="(item, index) in state.form.projectList" :key="index" class="project-card">
               <div class="project-card-header">
                 <span class="project-card-title">项目 {{ index + 1 }}</span>
-                <van-button 
-                  v-if="state.form.projectList.length > 1"
-                  size="mini" 
-                  type="danger" 
-                  plain
-                  @click="delProjectItem(index)"
-                  class="delete-btn">
+                <van-button v-if="state.form.projectList.length > 1" size="mini" type="danger" plain
+                  @click="delProjectItem(index)" class="delete-btn">
                   删除
                 </van-button>
               </div>
               <div class="project-card-body">
-                <van-field 
-                  v-model="item.projectName" 
-                  label="项目名称" 
-                  placeholder="请输入项目名称"
-                  :rules="[{ required: true, message: '请输入项目名称' }]"
-                  class="project-field">
+                <van-field v-model="item.projectName" label="项目名称" placeholder="请输入项目名称"
+                  :rules="[{ required: true, message: '请输入项目名称' }]" class="project-field">
                 </van-field>
-                <van-field 
-                  v-model="item.projectTypeName" 
-                  is-link 
-                  readonly 
-                  label="项目类型" 
-                  placeholder="请选择项目类型"
-                  @click="openPjtType(item, index)"
-                  :rules="[{ required: true, message: '请选择项目类型' }]"
+                <van-field v-model="item.projectTypeName" is-link readonly label="项目类型" placeholder="请选择项目类型"
+                  @click="openPjtType(item, index)" :rules="[{ required: true, message: '请选择项目类型' }]"
                   class="project-field">
                 </van-field>
-                <van-field 
-                  v-model="item.projectSource" 
-                  label="项目来源" 
-                  placeholder="请输入项目来源"
-                  :rules="[{ required: true, message: '请输入项目来源' }]"
-                  class="project-field">
+                <van-field v-model="item.projectSource" label="项目来源" placeholder="请输入项目来源"
+                  :rules="[{ required: true, message: '请输入项目来源' }]" class="project-field">
                 </van-field>
               </div>
             </div>
@@ -230,426 +211,426 @@
 </template>
 
 <script name="register" lang="ts" setup>
-import { onMounted, reactive, ref, watch } from 'vue'
-import to from 'await-to-js'
-import { useLoginApi } from '/@/api/login/index'
-import crypto from 'sm-crypto'
-import { useDictApi } from '/@/api/system/dict'
-import { useProApi } from '/@/api/project'
-import { useDeptApi } from '/@/api/system/dept'
-import { useRouter, useRoute } from 'vue-router'
-import { showNotify } from 'vant'
-
-import { UserTypeTooltip } from '/@/constants/pageConstants'
-import { isPasswordValid } from '/@/utils/stringUtils'
-
-const sm3 = crypto.sm3
-const loginApi = useLoginApi()
-const router = useRouter()
-const dictApi = useDictApi()
-const proApi = useProApi()
-const deptApi = useDeptApi()
-const loginInfoRef = ref()
-const personInfoRef = ref()
-const projectInfoRef = ref()
-const showDeptPicker = ref(false)
-const showPjtPicker = ref(false)
-const showPjtDatePicker = ref(false)
-const showPjtTypePicker = ref(false)
-const show = ref(false)
-const pjtTypeIndex = ref(-1)
-const needInputDeptInfo = ref(false)
-// 级联选择器相关数据
-const cascadeData = ref({
-  level1: <any[]>[],
-  level2: <any[]>[],
-  level3: <any[]>[],
-})
-const selectedLevel1 = ref<any>(null)
-const selectedLevel2 = ref<any>(null)
-const selectedLevel3 = ref<any>(null)
-
-const userTypeList = ref(<RowDicDataType[]>[])
-const userSexList = ref(<RowDicDataType[]>[])
-const userCertList = ref(<RowDicDataType[]>[])
-const deptData = ref(<any[]>[])
-const pjtList = ref(<any[]>[])
-const pjtTypeList = ref(<any[]>[])
-const state = reactive({
-  active: 0,
-  loading: {
-    signIn: false,
-  },
-  form: {
-    id: 0,
-    userName: '', // 账户名称
-    nickName: '', // 用户姓名
-    userType: '10', // 关联角色
-    deptId: null,
-    deptName: '', // 单位名称
-    phone: '', // 手机号
-    email: '', // 邮箱
-    sex: '30', // 性别
-    password: '', // 账户密码
-    confirmPassword: '',
-    status: '10', // 用户状态
-    describe: '', // 用户描述
-    avatar: '',
-    idType: '', //证件类型
-    idCode: '', // 证件号
-    personnelType: '', // 人员类型
-    projectId: null,
-    projectName: '',
-    projectDate: '',
-    startDate: [],
-    endDate: [],
-    registerType: '10',
-    applyPg: {},
-    projectGroupName: '',
-    projectGroupId: null,
-    projectList: <any[]>[{
+  import { onMounted, reactive, ref, watch } from 'vue'
+  import to from 'await-to-js'
+  import { useLoginApi } from '/@/api/login/index'
+  import crypto from 'sm-crypto'
+  import { useDictApi } from '/@/api/system/dict'
+  import { useProApi } from '/@/api/project'
+  import { useDeptApi } from '/@/api/system/dept'
+  import { useRouter, useRoute } from 'vue-router'
+  import { showNotify } from 'vant'
+
+  import { UserTypeTooltip } from '/@/constants/pageConstants'
+  import { isPasswordValid } from '/@/utils/stringUtils'
+
+  const sm3 = crypto.sm3
+  const loginApi = useLoginApi()
+  const router = useRouter()
+  const dictApi = useDictApi()
+  const proApi = useProApi()
+  const deptApi = useDeptApi()
+  const loginInfoRef = ref()
+  const personInfoRef = ref()
+  const projectInfoRef = ref()
+  const showDeptPicker = ref(false)
+  const showPjtPicker = ref(false)
+  const showPjtDatePicker = ref(false)
+  const showPjtTypePicker = ref(false)
+  const show = ref(false)
+  const pjtTypeIndex = ref(-1)
+  const needInputDeptInfo = ref(false)
+  // 级联选择器相关数据
+  const cascadeData = ref({
+    level1: <any[]>[],
+    level2: <any[]>[],
+    level3: <any[]>[],
+  })
+  const selectedLevel1 = ref<any>(null)
+  const selectedLevel2 = ref<any>(null)
+  const selectedLevel3 = ref<any>(null)
+
+  const userTypeList = ref(<RowDicDataType[]>[])
+  const userSexList = ref(<RowDicDataType[]>[])
+  const userCertList = ref(<RowDicDataType[]>[])
+  const deptData = ref(<any[]>[])
+  const pjtList = ref(<any[]>[])
+  const pjtTypeList = ref(<any[]>[])
+  const state = reactive({
+    active: 0,
+    loading: {
+      signIn: false,
+    },
+    form: {
+      id: 0,
+      userName: '', // 账户名称
+      nickName: '', // 用户姓名
+      userType: '10', // 关联角色
+      deptId: null,
+      deptName: '', // 单位名称
+      phone: '', // 手机号
+      email: '', // 邮箱
+      sex: '30', // 性别
+      password: '', // 账户密码
+      confirmPassword: '',
+      status: '10', // 用户状态
+      describe: '', // 用户描述
+      avatar: '',
+      idType: '', //证件类型
+      idCode: '', // 证件号
+      personnelType: '', // 人员类型
+      projectId: null,
       projectName: '',
-      projectType: '',
-      projectTypeName: '',
-      projectSource: '',
-    }],
-    unitName: '',
-    deptDescribe: '',
-  },
-})
-const deptDataBackup = ref(<any[]>[])
-
-const getDicts = () => {
-  Promise.all([
-    dictApi.getDictDataByType('sys_user_type'),
-    dictApi.getDictDataByType('sys_com_sex'),
-    dictApi.getDictDataByType('sys_user_certificate'),
-    deptApi.getDeptTree(),
-    proApi.getProjectGroupListForApp({ noPage: true }),
-    dictApi.getDictDataByType('sci_pjt_level'),
-  ]).then(([type, sex, cert, dept, pjt, pjtType]) => {
-    userTypeList.value = type.data.values || []
-    userSexList.value = sex.data.values || []
-    userCertList.value = cert.data.values || []
-    deptDataBackup.value = dept.data || []
-    deptData.value = dept.data || []
-    pjtList.value = pjt.data.list || []
-    pjtTypeList.value = pjtType.data.values || []
-
-    // 初始化级联数据
-    initCascadeData()
+      projectDate: '',
+      startDate: [],
+      endDate: [],
+      registerType: '10',
+      applyPg: {},
+      projectGroupName: '',
+      projectGroupId: null,
+      projectList: <any[]>[{
+        projectName: '',
+        projectType: '',
+        projectTypeName: '',
+        projectSource: '',
+      }],
+      unitName: '',
+      deptDescribe: '',
+    },
   })
-}
-
-const checkUserNamePhoneExists = async (type: 'userName' | 'phone') => {
-  let resquest = loginApi.checkUserNamePhoneExists({ userName: state.form.userName, phone: '' })
-
-  if (type === 'phone') {
-    resquest = loginApi.checkUserNamePhoneExists({ userName: '', phone: state.form.phone })
+  const deptDataBackup = ref(<any[]>[])
+
+  const getDicts = () => {
+    Promise.all([
+      dictApi.getDictDataByType('sys_user_type'),
+      dictApi.getDictDataByType('sys_com_sex'),
+      dictApi.getDictDataByType('sys_user_certificate'),
+      deptApi.getDeptTree(),
+      proApi.getProjectGroupListForApp({ noPage: true }),
+      dictApi.getDictDataByType('sci_pjt_level'),
+    ]).then(([type, sex, cert, dept, pjt, pjtType]) => {
+      userTypeList.value = type.data.values || []
+      userSexList.value = sex.data.values || []
+      userCertList.value = cert.data.values || []
+      deptDataBackup.value = dept.data || []
+      deptData.value = dept.data || []
+      pjtList.value = pjt.data.list || []
+      pjtTypeList.value = pjtType.data.values || []
+
+      // 初始化级联数据
+      initCascadeData()
+    })
   }
 
-  await to(resquest)
-}
+  const checkUserNamePhoneExists = async (type: 'userName' | 'phone') => {
+    let resquest = loginApi.checkUserNamePhoneExists({ userName: state.form.userName, phone: '' })
 
-const checkUserNameExists = (value: string) => {
-  if (!value) {
-    return "请输入账号"
-  }
-  return loginApi.checkUserNamePhoneExists({ userName: value, phone: '' })
-    .then(res => {
-      return true
-    })
-    .catch(() => {
-      return "账号不合法"
-    })
-}
-
-const renderDeptData = () => {
-  let daptTree = deptDataBackup.value
+    if (type === 'phone') {
+      resquest = loginApi.checkUserNamePhoneExists({ userName: '', phone: state.form.phone })
+    }
 
-  if (state.form.userType === '10') {
-    daptTree = daptTree.filter((item) => item.id === 100001)
+    await to(resquest)
   }
 
-  if (state.form.userType === '15') {
-    daptTree = daptTree.filter((item) => item.id !== 1000220)
+  const checkUserNameExists = (value: string) => {
+    if (!value) {
+      return "请输入账号"
+    }
+    return loginApi.checkUserNamePhoneExists({ userName: value, phone: '' })
+      .then(res => {
+        return true
+      })
+      .catch(() => {
+        return "账号不合法"
+      })
   }
 
-  if (state.form.userType === '20') {
-    daptTree = daptTree.filter((item) => item.id === 1000220)
-  }
+  const renderDeptData = () => {
+    let daptTree = deptDataBackup.value
 
-  return daptTree
-}
+    if (state.form.userType === '10') {
+      daptTree = daptTree.filter((item) => item.type === '10')
+    }
 
-const deptIncludesProjectGroup = async (deptId: number) => {
-  const [err, res]: ToResponse = await to(
-    proApi.getProjectGroupList({
-      pgOrg: deptId,
-      pgName: '',
-      pageNum: 1,
-      pageSize: 1000,
-    }),
-  )
-  if (err) return
+    if (state.form.userType === '15') {
+      daptTree = daptTree.filter((item) => item.id !== 1000220)
+    }
 
-  pjtList.value = res?.data.list || []
-}
+    if (state.form.userType === '20') {
+      daptTree = daptTree.filter((item) => item.id === 1000220)
+    }
 
-const preStep = () => {
-  state.active--
-}
-const validateProjectList = () => {
-  // 校验至少有一个项目
-  if (!state.form.projectList || state.form.projectList.length === 0) {
-    showNotify({
-      type: 'danger',
-      message: '请至少添加一个项目',
-    })
-    return false
+    return daptTree
   }
 
-  // 校验每个项目的必填字段
-  for (let i = 0; i < state.form.projectList.length; i++) {
-    const item = state.form.projectList[i]
-    if (!item.projectName || !item.projectName.trim()) {
-      showNotify({
-        type: 'danger',
-        message: `项目 ${i + 1} 的项目名称不能为空`,
-      })
-      return false
-    }
-    if (!item.projectType || !item.projectTypeName) {
+  const deptIncludesProjectGroup = async (deptId: number) => {
+    const [err, res]: ToResponse = await to(
+      proApi.getProjectGroupList({
+        pgOrg: deptId,
+        pgName: '',
+        pageNum: 1,
+        pageSize: 1000,
+      }),
+    )
+    if (err) return
+
+    pjtList.value = res?.data.list || []
+  }
+
+  const preStep = () => {
+    state.active--
+  }
+  const validateProjectList = () => {
+    // 校验至少有一个项目
+    if (!state.form.projectList || state.form.projectList.length === 0) {
       showNotify({
         type: 'danger',
-        message: `项目 ${i + 1} 的项目类型不能为空`,
+        message: '请至少添加一个项目',
       })
       return false
     }
-    if (!item.projectSource || !item.projectSource.trim()) {
-      showNotify({
-        type: 'danger',
-        message: `项目 ${i + 1} 的项目来源不能为空`,
-      })
-      return false
+
+    // 校验每个项目的必填字段
+    for (let i = 0; i < state.form.projectList.length; i++) {
+      const item = state.form.projectList[i]
+      if (!item.projectName || !item.projectName.trim()) {
+        showNotify({
+          type: 'danger',
+          message: `项目 ${i + 1} 的项目名称不能为空`,
+        })
+        return false
+      }
+      if (!item.projectType || !item.projectTypeName) {
+        showNotify({
+          type: 'danger',
+          message: `项目 ${i + 1} 的项目类型不能为空`,
+        })
+        return false
+      }
+      if (!item.projectSource || !item.projectSource.trim()) {
+        showNotify({
+          type: 'danger',
+          message: `项目 ${i + 1} 的项目来源不能为空`,
+        })
+        return false
+      }
     }
-  }
 
-  return true
-}
+    return true
+  }
 
-const nextStep = async () => {
-  if (state.active < 3) {
-    let form = loginInfoRef.value
-    if (state.active == 1) {
-      form = personInfoRef.value
-    } else if (state.active == 2) {
-      form = projectInfoRef.value
-      // 校验项目列表
-      if (!validateProjectList()) {
+  const nextStep = async () => {
+    if (state.active < 3) {
+      let form = loginInfoRef.value
+      if (state.active == 1) {
+        form = personInfoRef.value
+      } else if (state.active == 2) {
+        form = projectInfoRef.value
+        // 校验项目列表
+        if (!validateProjectList()) {
+          return
+        }
+        // 校验表单字段
+        const [err] = await to(form.validate())
+        if (err) return
+        state.active++
         return
       }
-      // 校验表单字段
-      const [err] = await to(form.validate())
+      const [err, res] = await to(form.validate())
       if (err) return
       state.active++
-      return
     }
-    const [err, res] = await to(form.validate())
-    if (err) return
-    state.active++
   }
-}
-
-// const checkPassword = (value: any) => {
-//   let checkResult = isPasswordValid(value)
-//   if (!checkResult.isPassed) {
-//     return checkResult.errorMsg
-//   }
-// }
 
-const checkPassword = (value: string) => {
-  if (!value) {
-    return "请输入密码"
-  }
-  return loginApi.validatePassword({ password: value })
-    .then(res => {
-      return true
-    })
-    .catch(() => {
-      return "密码不合法"
-    })
-}
+  // const checkPassword = (value: any) => {
+  //   let checkResult = isPasswordValid(value)
+  //   if (!checkResult.isPassed) {
+  //     return checkResult.errorMsg
+  //   }
+  // }
 
-const confirmPasswordSame = (value: any) => {
-  if (!value) {
-    return false
-  } else if (value !== state.form.password) {
-    return false
-  } else {
-    return true
+  const checkPassword = (value: string) => {
+    if (!value) {
+      return "请输入密码"
+    }
+    return loginApi.validatePassword({ password: value })
+      .then(res => {
+        return true
+      })
+      .catch(() => {
+        return "密码不合法"
+      })
   }
-}
 
-watch(
-  () => state.form.userType,
-  (newVal) => {
-    if (newVal === '20') {
-      state.form.idType = '30'
-      needInputDeptInfo.value = true
+  const confirmPasswordSame = (value: any) => {
+    if (!value) {
+      return false
+    } else if (value !== state.form.password) {
+      return false
     } else {
-      state.form.idType = '20'
-      state.form.deptId = null
-      state.form.deptName = ''
-      needInputDeptInfo.value = false
+      return true
     }
-  },
-  { immediate: true },
-)
+  }
 
-const changeType = (val: string) => {
-  state.form.registerType = val
-  if (val === '10' && state.active == 2) {
-    state.active = 1
+  watch(
+    () => state.form.userType,
+    (newVal) => {
+      if (newVal === '20') {
+        state.form.idType = '30'
+        needInputDeptInfo.value = true
+      } else {
+        state.form.idType = '20'
+        state.form.deptId = null
+        state.form.deptName = ''
+        needInputDeptInfo.value = false
+      }
+    },
+    { immediate: true },
+  )
+
+  const changeType = (val: string) => {
+    state.form.registerType = val
+    if (val === '10' && state.active == 2) {
+      state.active = 1
+    }
   }
-}
 
-const showDeptPickerHandler = () => {
-  initCascadeData()
-  showDeptPicker.value = true
-}
-const onPjtPicker = ({ selectedOptions }: { selectedOptions: any[] }) => {
-  showPjtPicker.value = false
-  state.form.projectGroupName = selectedOptions[0].pgName
-  state.form.projectGroupId = selectedOptions[0].id
-}
-const onPjtDatePicker = () => {
-  showPjtDatePicker.value = false
-  state.form.projectDate = `${state.form.startDate.join('-')}至${state.form.endDate.join('-')}`
-}
-const addProject = () => {
-  state.form.projectList.push({
-    projectName: '',
-    projectType: '',
-    projectTypeName: '',
-    projectSource: '',
-  })
-}
-const delProjectItem = (idx: number) => {
-  if (state.form.projectList.length > 1) {
-    state.form.projectList.splice(idx, 1)
-  } else {
-    showNotify({
-      type: 'danger',
-      message: '至少需要保留一个项目',
+  const showDeptPickerHandler = () => {
+    initCascadeData()
+    showDeptPicker.value = true
+  }
+  const onPjtPicker = ({ selectedOptions }: { selectedOptions: any[] }) => {
+    showPjtPicker.value = false
+    state.form.projectGroupName = selectedOptions[0].pgName
+    state.form.projectGroupId = selectedOptions[0].id
+  }
+  const onPjtDatePicker = () => {
+    showPjtDatePicker.value = false
+    state.form.projectDate = `${state.form.startDate.join('-')}至${state.form.endDate.join('-')}`
+  }
+  const addProject = () => {
+    state.form.projectList.push({
+      projectName: '',
+      projectType: '',
+      projectTypeName: '',
+      projectSource: '',
     })
   }
-}
-const openPjtType = (row: any, idx: number) => {
-  pjtTypeIndex.value = idx
-  showPjtTypePicker.value = true
-}
-const onPjtTypePicker = ({ selectedOptions }: { selectedOptions: any[] }) => {
-  showPjtTypePicker.value = false
-  state.form.projectList[pjtTypeIndex.value].projectType = selectedOptions[0].dictValue
-  state.form.projectList[pjtTypeIndex.value].projectTypeName = selectedOptions[0].dictLabel
-}
-
-watch(
-  () => state.form.deptId,
-  (newVal) => {
-    if (newVal) {
-      deptIncludesProjectGroup(newVal)
+  const delProjectItem = (idx: number) => {
+    if (state.form.projectList.length > 1) {
+      state.form.projectList.splice(idx, 1)
+    } else {
+      showNotify({
+        type: 'danger',
+        message: '至少需要保留一个项目',
+      })
     }
-  },
-)
-
-// 级联选择器方法
-const initCascadeData = () => {
-  cascadeData.value.level1 = renderDeptData()
-  cascadeData.value.level2 = []
-  cascadeData.value.level3 = []
-  selectedLevel1.value = null
-  selectedLevel2.value = null
-  selectedLevel3.value = null
-}
+  }
+  const openPjtType = (row: any, idx: number) => {
+    pjtTypeIndex.value = idx
+    showPjtTypePicker.value = true
+  }
+  const onPjtTypePicker = ({ selectedOptions }: { selectedOptions: any[] }) => {
+    showPjtTypePicker.value = false
+    state.form.projectList[pjtTypeIndex.value].projectType = selectedOptions[0].dictValue
+    state.form.projectList[pjtTypeIndex.value].projectTypeName = selectedOptions[0].dictLabel
+  }
 
-const selectLevel1 = (item: any) => {
-  selectedLevel1.value = item
-  selectedLevel2.value = null
-  selectedLevel3.value = null
+  watch(
+    () => state.form.deptId,
+    (newVal) => {
+      if (newVal) {
+        deptIncludesProjectGroup(newVal)
+      }
+    },
+  )
 
-  if (item.children && item.children.length > 0) {
-    cascadeData.value.level2 = item.children
-    cascadeData.value.level3 = []
-  } else {
+  // 级联选择器方法
+  const initCascadeData = () => {
+    cascadeData.value.level1 = renderDeptData()
     cascadeData.value.level2 = []
     cascadeData.value.level3 = []
+    selectedLevel1.value = null
+    selectedLevel2.value = null
+    selectedLevel3.value = null
   }
-}
 
-const selectLevel2 = (item: any) => {
-  selectedLevel2.value = item
-  selectedLevel3.value = null
+  const selectLevel1 = (item: any) => {
+    selectedLevel1.value = item
+    selectedLevel2.value = null
+    selectedLevel3.value = null
 
-  if (item.children && item.children.length > 0) {
-    cascadeData.value.level3 = item.children
-  } else {
-    cascadeData.value.level3 = []
+    if (item.children && item.children.length > 0) {
+      cascadeData.value.level2 = item.children
+      cascadeData.value.level3 = []
+    } else {
+      cascadeData.value.level2 = []
+      cascadeData.value.level3 = []
+    }
   }
-}
 
-const selectLevel3 = (item: any) => {
-  selectedLevel3.value = item
-}
+  const selectLevel2 = (item: any) => {
+    selectedLevel2.value = item
+    selectedLevel3.value = null
+
+    if (item.children && item.children.length > 0) {
+      cascadeData.value.level3 = item.children
+    } else {
+      cascadeData.value.level3 = []
+    }
+  }
 
-const confirmCascadeSelection = () => {
-  const selectedItem = selectedLevel3.value || selectedLevel2.value || selectedLevel1.value
-  if (selectedItem) {
-    state.form.deptName = selectedItem.deptName
-    state.form.deptId = selectedItem.id
-    showDeptPicker.value = false
+  const selectLevel3 = (item: any) => {
+    selectedLevel3.value = item
   }
-}
 
-const onRegister = async () => {
-  const form = state.form.registerType == '10' ? personInfoRef.value : personInfoRef.value
-  const [error] = await to(form.validate())
-  if (error) return
-  
-  // 如果是课题组负责人,需要校验项目信息
-  if (state.form.registerType === '20') {
-    if (!validateProjectList()) {
+  const confirmCascadeSelection = () => {
+    const selectedItem = selectedLevel3.value || selectedLevel2.value || selectedLevel1.value
+    if (selectedItem) {
+      state.form.deptName = selectedItem.deptName
+      state.form.deptId = selectedItem.id
+      showDeptPicker.value = false
+    }
+  }
+
+  const onRegister = async () => {
+    const form = state.form.registerType == '10' ? personInfoRef.value : personInfoRef.value
+    const [error] = await to(form.validate())
+    if (error) return
+
+    // 如果是课题组负责人,需要校验项目信息
+    if (state.form.registerType === '20') {
+      if (!validateProjectList()) {
+        return
+      }
+    }
+
+    const params = JSON.parse(JSON.stringify(state.form))
+    params.password = sm3(params.password)
+    delete params.confirmPassword
+    params.startDate = params.startDate.join('-')
+    params.endDate = params.endDate.join('-')
+    delete params.projectDate
+    const [err] = await to(loginApi.register(params))
+    if (err) {
+      // show.value = true
+      // setTimeout(() => {
+      //   show.value = false
+      // }, 2000)
       return
     }
+    showNotify({
+      type: 'success',
+      message:
+        state.form.registerType === '20'
+          ? '你已经注册为课题组负责人,等待系统管理员审核通过'
+          : '你已经注册为课题组成员,等待课题组负责人审核通过',
+    })
+    router.push('/login')
   }
-  
-  const params = JSON.parse(JSON.stringify(state.form))
-  params.password = sm3(params.password)
-  delete params.confirmPassword
-  params.startDate = params.startDate.join('-')
-  params.endDate = params.endDate.join('-')
-  delete params.projectDate
-  const [err] = await to(loginApi.register(params))
-  if (err) {
-    // show.value = true
-    // setTimeout(() => {
-    //   show.value = false
-    // }, 2000)
-    return
-  }
-  showNotify({
-    type: 'success',
-    message:
-      state.form.registerType === '20'
-        ? '你已经注册为课题组负责人,等待系统管理员审核通过'
-        : '你已经注册为课题组成员,等待课题组负责人审核通过',
+  onMounted(async () => {
+    getDicts()
   })
-  router.push('/login')
-}
-onMounted(async () => {
-  getDicts()
-})
 </script>
 
 <style lang="scss" scoped>