Просмотр исходного кода

Merge branch 'henandk' of http://49.234.186.218:9000/root/ieplus into henandk

mingfu 1 день назад
Родитель
Сommit
da31034b6b

+ 7 - 2
back-ui/src/views/dz/cards/components/CardTable.vue

@@ -60,9 +60,14 @@
         </el-table-column>
         <el-table-column label="考生类型(注册)" prop="examType" align="center" min-width="140">
           <template #default="scope">
-            <template v-if="scope.row && scope.row.examType && exam_type">
+            <div v-if="scope.row && scope.row.examType && exam_type">
               <dict-tag :options="exam_type" :value="scope.row.examType" />
-            </template>
+              <div v-if="scope.row.examMajorName || scope.row.examMajor" class="text-[12px] text-gray-600 mt-1">
+                <span v-if="scope.row.examMajor">{{ scope.row.examMajor }}</span>
+                <span v-if="scope.row.examMajor && scope.row.examMajorName"> - </span>
+                <span v-if="scope.row.examMajorName">{{ scope.row.examMajorName }}</span>
+              </div>
+            </div>
             <span v-else>-</span>
           </template>
         </el-table-column>

+ 84 - 2
back-ui/src/views/dz/cards/components/EditDialog.vue

@@ -23,6 +23,11 @@
             <ie-select v-model="selectedExamType" :options="examTypeList" label-key="dictLabel" value-key="dictValue" />
           </el-form-item>
         </el-col>
+        <el-col :span="12" prop="examMajor"  v-if="selectedExamType === 'VHS'">
+          <el-form-item label="专业类别" prop="examMajor">
+            <ie-select v-model="selectedExamMajor" :options="examMajorList" label-key="dictLabel" value-key="dictValue" placeholder="请选择专业类别" />
+          </el-form-item>
+        </el-col>
 
         <el-col :span="12">
           <el-form-item label="注册学校" prop="schoolId">
@@ -119,9 +124,10 @@ import IeSelect from '@/components/IeSelect/index.vue';
 import IeUniversitySelect from '@/components/IeUniversitySelect/index.vue';
 import DirectionDialog from './DirectionDialog.vue';
 import { updateCardUser, getUserByCardId } from '@/api/dz/cards';
+import { listAllSubject } from '@/api/dz/subject';
 import { getCurrentInstance, nextTick, watch, watchEffect } from 'vue';
 import draggable from 'vuedraggable';
-import { Rank } from '@element-plus/icons-vue';
+import { Rank, Close } from '@element-plus/icons-vue';
 
 const { proxy } = getCurrentInstance();
 
@@ -132,6 +138,10 @@ const form = ref({
   directionStudy: []
 })
 
+// 专业类别相关
+const examMajorList = ref([]);
+const selectedExamMajor = ref(null);
+
 const {
   reset,
   area,
@@ -155,8 +165,56 @@ watchEffect(() => {
   form.value.classId = selectedClass.value;
   form.value.campusSchoolId = selectedCampus.value;
   form.value.campusClassId = selectedCampusClass.value;
+  form.value.examMajor = selectedExamMajor.value;
+  // 同步 examMajorName:从 examMajorList 中找到对应的 dictLabel
+  if (selectedExamMajor.value != null) {
+    const selectedMajor = examMajorList.value.find(item => item.dictValue === selectedExamMajor.value);
+    form.value.examMajorName = selectedMajor ? selectedMajor.dictLabel : null;
+  } else {
+    form.value.examMajorName = null;
+  }
 });
 
+// 监听考生类型和省份变化,加载专业类别列表
+watch([selectedExamType, () => form.value.location], ([examType, location], [oldExamType, oldLocation]) => {
+  // 避免初始化时执行(第一次加载时 oldExamType 和 oldLocation 都是 undefined)
+  if (oldExamType === undefined && oldLocation === undefined) {
+    return;
+  }
+  // 如果考生类型变为 VHS 且有省份,加载专业类别列表
+  if (examType === 'VHS' && location) {
+    loadExamMajorList(location, examType).then(() => {
+      // 如果列表加载完成但 selectedExamMajor 还没有值,保持原值不变
+      // 这里不需要重新设置 selectedExamMajor,因为它在 getUserInfo 中已经设置过了
+    });
+  } else if (examType !== 'VHS') {
+    // 如果考生类型不是 VHS,清空专业类别相关数据
+    examMajorList.value = [];
+    selectedExamMajor.value = null;
+    form.value.examMajor = null;
+    form.value.examMajorName = null;
+  }
+});
+
+// 加载专业类别列表
+const loadExamMajorList = async (location, examType) => {
+  try {
+    const res = await listAllSubject({
+      location: location,
+      examType: examType
+    });
+    // 转换数据格式,dictValue 对应 subject_id,dictLabel 对应 subject_name
+    // 确保 dictValue 是 Number 类型,与 examMajor 的 Integer 类型匹配
+    examMajorList.value = (res.data || []).map(item => ({
+      dictValue: Number(item.subjectId),
+      dictLabel: item.subjectName
+    }));
+  } catch (error) {
+    console.error('加载专业类别列表失败:', error);
+    examMajorList.value = [];
+  }
+};
+
 
 
 const rules = ref({
@@ -179,6 +237,10 @@ const handleBeforeClose = () => {
     scores: {},
     directionStudy: []
   };
+  examMajorList.value = [];
+  selectedExamMajor.value = null;
+  form.value.examMajor = null;
+  form.value.examMajorName = null;
 }
 
 const open = (cardInfo) => {
@@ -207,6 +269,19 @@ const getUserInfo = (cardInfo) => {
       area.selected = targetArea.areaId;
       area.selectedItem = targetArea;
     }
+    // 先初始化专业类别(在设置 selectedExamType 之前,避免触发 watch)
+    if (res.data.examType === 'VHS' && form.value.location) {
+      await loadExamMajorList(form.value.location, res.data.examType);
+      // 确保类型一致,将 examMajor 转换为 Number 类型
+      if (res.data.examMajor != null) {
+        selectedExamMajor.value = Number(res.data.examMajor);
+      } else {
+        selectedExamMajor.value = null;
+      }
+    } else {
+      selectedExamMajor.value = null;
+    }
+    // 然后设置考生类型(这会触发 watch,但此时数据已经加载完成)
     selectedExamType.value = res.data.examType;
     selectedCampus.value = res.data.campusSchoolId;
     selectedCampusClass.value = res.data.campusClassId;
@@ -233,7 +308,14 @@ const handleConfirm = () => {
   formRef.value.validate((valid) => {
     if (valid) {
       modalRef.value.showLoading()
-      updateCardUser(form.value).then(res => {
+      // 准备提交的数据
+      const submitData = { ...form.value };
+      // 如果考生类型不是 VHS,则不传递 examMajor 和 examMajorName
+      if (selectedExamType.value !== 'VHS') {
+        delete submitData.examMajor;
+        delete submitData.examMajorName;
+      }
+      updateCardUser(submitData).then(res => {
         proxy.$modal.msgSuccess('修改成功')
         close();
         emit('refresh')

+ 2 - 2
back-ui/src/views/login.vue

@@ -163,8 +163,8 @@ getCode()
 getCookie()
 
 if (import.meta.env.DEV) {
-  loginForm.value.username = "admin"
-  loginForm.value.password = "admin123"
+  loginForm.value.username = ""
+  loginForm.value.password = ""
 }
 </script>
 

+ 13 - 9
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzCardsController.java

@@ -77,33 +77,37 @@ public class DzCardsController extends BaseController
         prepare(dzCards);
         startPage();
         List<DzCards> list = dzCardsService.selectDzCardsList2(dzCards);
-        
+
         // 根据cardIds查询用户,并将用户的directedStudy设置给DzCard
         if (!CollectionUtils.isEmpty(list)) {
             List<Long> cardIds = list.stream()
                     .map(DzCards::getCardId)
                     .filter(cardId -> cardId != null)
                     .collect(Collectors.toList());
-            
+
             if (!CollectionUtils.isEmpty(cardIds)) {
                 List<SysUser> users = sysUserService.selectUserByCardIds(cardIds);
                 // 创建cardId到user的映射
                 Map<Long, SysUser> userMap = users.stream()
                         .filter(user -> user.getCardId() != null)
                         .collect(Collectors.toMap(SysUser::getCardId, user -> user, (existing, replacement) -> existing));
-                
+
                 // 遍历list,设置directedStudy
                 for (DzCards card : list) {
                     if (card.getCardId() != null) {
                         SysUser user = userMap.get(card.getCardId());
-                        if (user != null && user.getDirectedStudy() != null) {
-                            card.setDirectedStudy(user.getDirectedStudy());
+                        if (user != null ) {
+                            if (user.getDirectedStudy() != null){
+                                card.setDirectedStudy(user.getDirectedStudy());
+                            }
+                            card.setExamMajor(user.getExamMajor());
+                            card.setExamMajorName(user.getExamMajorName());
                         }
                     }
                 }
             }
         }
-        
+
         return getDataTable(list);
     }
 
@@ -254,9 +258,9 @@ public class DzCardsController extends BaseController
     @PostMapping("/changeCampus")
     @ApiOperation("分配校区")
     @PreAuthorize("@ss.hasPermi('dz:cards:associateCampus')")
-    public AjaxResult changeCampus(@ApiParam("校区") Long campusId, 
+    public AjaxResult changeCampus(@ApiParam("校区") Long campusId,
                                    @ApiParam("校区班级") @RequestParam(required = false) Long campusClassId,
-                                   @ApiParam("开始号") @RequestParam(required = false) String begin, 
+                                   @ApiParam("开始号") @RequestParam(required = false) String begin,
                                    @ApiParam("结束号") @RequestParam(required = false) String end,
                                    @ApiParam("卡片ID列表") @RequestParam(required = false) String cardIds) {
         // 如果cardIds不为空,使用cardIds方式;否则使用begin和end方式
@@ -383,7 +387,7 @@ public class DzCardsController extends BaseController
         if (null != sysUser.getDirectedStudy()) {
             cardUserBody.setDirectionStudy(JSONArray.parse(sysUser.getDirectedStudy()));
         }
-        BeanUtils.copyProperties(dzCards, cardUserBody, "password", "nickName", "location", "examType", "endYear");
+        BeanUtils.copyProperties(dzCards, cardUserBody, "password", "nickName", "location", "examType", "endYear", "examMajor", "examMajorName");
         cardUserBody.setCampusSchoolId(dzCards.getCampusId());
         return success(cardUserBody);
     }

+ 4 - 0
ie-admin/src/main/java/com/ruoyi/web/domain/CardUserBody.java

@@ -19,4 +19,8 @@ public class CardUserBody extends RegisterBody {
     @ApiModelProperty(value = "到期日期", example = "2028-08-08")
     @JsonFormat(pattern = "yyyy-MM-dd")
     Date outDate;
+    /** 考生专业类别 **/
+    private Integer examMajor;
+    /** 考生专业类别名称 */
+    private String examMajorName;
 }

+ 2 - 0
ie-admin/src/main/java/com/ruoyi/web/service/SysRegisterService.java

@@ -178,6 +178,8 @@ public class SysRegisterService
         upUser.setSchoolId(cardUserBody.getSchoolId());
         upUser.setClassId(cardUserBody.getClassId());
         upUser.setPhonenumber(cardUserBody.getMobile());
+        upUser.setExamMajor(cardUserBody.getExamMajor());
+        upUser.setExamMajorName(cardUserBody.getExamMajorName());
         if (!userService.checkPhoneUnique(upUser)) {
             throw new ValidationException("保存用户'" + upUser.getNickName() + "'失败,注册手机已存在" + cardUserBody.getMobile());
         }

+ 22 - 0
ie-system/src/main/java/com/ruoyi/dz/domain/DzCards.java

@@ -182,6 +182,28 @@ public class DzCards extends BaseEntity
     /** 定向学习 */
     private String directedStudy;
 
+    /** 考生专业类别 **/
+    private Integer examMajor;
+
+    /** 考生专业类别 **/
+    private String examMajorName;
+
+    public Integer getExamMajor() {
+        return examMajor;
+    }
+
+    public void setExamMajor(Integer examMajor) {
+        this.examMajor = examMajor;
+    }
+
+    public String getExamMajorName() {
+        return examMajorName;
+    }
+
+    public void setExamMajorName(String examMajorName) {
+        this.examMajorName = examMajorName;
+    }
+
     public Long getTeacherId() {
         return teacherId;
     }