学员信息列表,性别改为显示标签

This commit is contained in:
2026-09-23 15:39:25 +08:00
parent 69a1a7d560
commit ad92f4afc9
@@ -14,8 +14,7 @@
</el-form-item>
<el-form-item label="性别">
<el-select v-model="searchForm.xb" placeholder="请选择性别" clearable class="full-width">
<el-option label="男" value="男" />
<el-option label="女" value="女" />
<el-option v-for="item in sexOptions" :key="item.dictCode || item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
</el-select>
</el-form-item>
<el-form-item label="证件号码">
@@ -112,7 +111,7 @@
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="xh" label="学号" width="130" align="center" show-overflow-tooltip />
<el-table-column prop="xm" label="姓名" width="90" align="center" show-overflow-tooltip />
<el-table-column prop="xb" label="性别" width="70" align="center" />
<el-table-column prop="xb" label="性别" width="70" align="center" :formatter="sexFormatter" />
<el-table-column prop="nj" label="年级" width="80" align="center" />
<el-table-column prop="zy" label="专业" width="160" align="center" show-overflow-tooltip />
<el-table-column prop="xylb" label="学员类别" width="110" align="center" show-overflow-tooltip />
@@ -163,7 +162,7 @@
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="姓名" prop="xm"><el-input v-model="formData.xm" placeholder="请输入姓名" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="性别" prop="xb"><el-select v-model="formData.xb" placeholder="请选择" class="full-width"><el-option label="男" value="1" /><el-option label="女" value="0" /></el-select></el-form-item></el-col>
<el-col :span="12"><el-form-item label="性别" prop="xb"><el-select v-model="formData.xb" placeholder="请选择" class="full-width"><el-option v-for="item in sexOptions" :key="item.dictCode || item.dictValue" :label="item.dictLabel" :value="item.dictValue" /></el-select></el-form-item></el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="出生日期" prop="csrq"><el-date-picker v-model="formData.csrq" type="date" placeholder="请选择" value-format="yyyy-MM-dd" class="full-width" /></el-form-item></el-col>
@@ -415,6 +414,7 @@ export default {
degreeOptions: [],
educationLevelOptions: [],
studentCategoryOptions: [],
sexOptions: [],
// ==================== 数据表格 ====================
loading: false,
@@ -500,15 +500,17 @@ export default {
/** 加载学员基础信息字典,业务字段按字典标签查询和提交。 */
async loadStudentDictionaries() {
const emptyResponse = { data: [] }
const [politicalStatusResponse, nationResponse, degreeResponse, educationLevelResponse, dictTypeResponse] =
const [politicalStatusResponse, nationResponse, degreeResponse, educationLevelResponse, sexResponse, dictTypeResponse] =
await Promise.all([
getDicts(POLITICAL_STATUS_DICT_CODE).catch(() => emptyResponse),
getDicts(NATION_DICT_CODE).catch(() => emptyResponse),
getDicts(DEGREE_DICT_CODE).catch(() => emptyResponse),
getDicts(EDUCATION_LEVEL_DICT_CODE).catch(() => emptyResponse),
getDicts('stu_sex').catch(() => emptyResponse),
optionselect().catch(() => emptyResponse)
])
this.sexOptions = sexResponse.data || []
this.politicalStatusOptions = politicalStatusResponse.data || []
this.nationOptions = nationResponse.data || []
this.degreeOptions = degreeResponse.data || []
@@ -541,6 +543,16 @@ export default {
this.studentCategoryOptions = this.mergeFieldOptions(this.studentCategoryOptions, 'xylb')
},
/** 性别列:字典值转中文名 */
sexFormatter(row) {
const value = row && row.xb
if (value === '' || value === null || value === undefined) {
return ''
}
const hit = this.sexOptions.find(item => String(item.dictValue) === String(value))
return hit ? hit.dictLabel : String(value)
},
mergeFieldOptions(dictionaryOptions, fieldName) {
const options = dictionaryOptions.slice()
const existingLabels = new Set(options.map(item => String(item.dictLabel)))