zlwu 1 год назад
Родитель
Сommit
787db625c0

+ 86 - 5
web/src/views/xg/xgss/dormHygieneCheck/dormHygieneCheck/components/ViolationRecordDialog.vue

@@ -14,9 +14,18 @@
       <!-- 违纪类型选择 -->
       <el-form-item label="违纪类型" prop="disciplineTypeId" class="discipline-form-item">
         <el-select v-model="form.disciplineTypeId" placeholder="请选择违纪类型" style="width: 100%" @change="handleDisciplineTypeChange" filterable>
-          <el-option v-for="item in allViolationTypes" :key="item.id" :label="item.typeName" :value="item.id" :disabled="item.status !== '0'">
+          <el-option
+            v-for="item in allViolationTypes"
+            :key="item.id"
+            :label="getViolationTypeLabel(item)"
+            :value="item.id"
+            :disabled="item.status !== '0'"
+          >
             <div class="violation-type-option">
-              <span class="violation-type-name" :title="item.typeName">{{ getShortTypeName(item.typeName) }}</span>
+              <span class="violation-type-name" :title="getViolationTypeLabel(item)">
+                <span class="area-tag" :class="getAreaTypeClass(item.areaType)">{{ getAreaTypeText(item.areaType) }}</span>
+                {{ getShortTypeName(item.typeName) }}
+              </span>
               <span class="score-range">{{ item.minScore }}-{{ item.maxScore }}分</span>
             </div>
           </el-option>
@@ -271,8 +280,25 @@ const getAllViolationTypes = async () => {
     if (response.code === 200) {
       // 修复:使用 response.rows 而不是 response.data
       const violationTypes = response.rows || [];
-      allViolationTypes.value = violationTypes;
-      console.log('获取违纪类型成功,数量:', allViolationTypes.value.length);
+
+      // 按区域类型排序:1-宿舍区违纪优先,2-教学区违纪其次,然后按排序号排序
+      const sortedViolationTypes = violationTypes.sort((a: any, b: any) => {
+        // 首先按区域类型排序(宿舍区违纪优先)
+        const aAreaType = a.areaType || '2'; // 默认为教学区
+        const bAreaType = b.areaType || '2'; // 默认为教学区
+
+        if (aAreaType !== bAreaType) {
+          return aAreaType.localeCompare(bAreaType); // "1"在"2"前面
+        }
+
+        // 相同区域类型内部按排序号排序
+        const aSortOrder = a.sortOrder || 999;
+        const bSortOrder = b.sortOrder || 999;
+        return aSortOrder - bSortOrder;
+      });
+
+      allViolationTypes.value = sortedViolationTypes;
+      console.log('获取违纪类型成功,数量:', allViolationTypes.value.length, '(已按宿舍区优先排序)');
 
       if (violationTypes.length === 0) {
         ElMessage.warning('暂无可用的违纪类型数据');
@@ -505,6 +531,36 @@ const getShortTypeName = (typeName: string) => {
   return result;
 };
 
+// 获取区域类型文本
+const getAreaTypeText = (areaType: string) => {
+  switch (areaType) {
+    case '1':
+      return '宿舍';
+    case '2':
+      return '教学';
+    default:
+      return '其他';
+  }
+};
+
+// 获取区域类型样式类名
+const getAreaTypeClass = (areaType: string) => {
+  switch (areaType) {
+    case '1':
+      return 'area-tag-dorm';
+    case '2':
+      return 'area-tag-teaching';
+    default:
+      return 'area-tag-other';
+  }
+};
+
+// 获取违纪类型完整标签(用于搜索和显示)
+const getViolationTypeLabel = (item: any) => {
+  const areaText = getAreaTypeText(item.areaType);
+  return `[${areaText}] ${item.typeName}`;
+};
+
 // 文件预览
 const handleFilePreview = (file: any) => {
   if (isImageFile(file)) {
@@ -762,6 +818,31 @@ onMounted(() => {
   line-height: 1.4;
 }
 
+/* 区域标签样式 */
+.area-tag {
+  display: inline-block;
+  padding: 1px 6px;
+  font-size: 10px;
+  line-height: 14px;
+  border-radius: 2px;
+  margin-right: 6px;
+  color: #fff;
+  font-weight: bold;
+  vertical-align: middle;
+}
+
+.area-tag-dorm {
+  background-color: #67c23a; /* 绿色 - 宿舍区 */
+}
+
+.area-tag-teaching {
+  background-color: #409eff; /* 蓝色 - 教学区 */
+}
+
+.area-tag-other {
+  background-color: #909399; /* 灰色 - 其他 */
+}
+
 /* 违纪类型选择框样式优化 */
 :deep(.el-select-dropdown__item) {
   padding: 8px 12px !important;
@@ -774,7 +855,7 @@ onMounted(() => {
   justify-content: space-between !important;
   align-items: center !important;
   width: 100% !important;
-  min-width: 280px !important; /* 确保有足够宽度 */
+  min-width: 300px !important; /* 增加宽度以容纳区域标签 */
 }
 
 :deep(.el-select-dropdown__item .score-range) {