@@ -4,6 +4,18 @@
< el -form -item label = "学年名称" prop = "stuYearName" >
< el -form -item label = "学年名称" prop = "stuYearName" >
< el-input v-model = "queryParams.stuYearName" placeholder="请输入学年名称" clearable @keyup.enter.native="handleQuery" / >
< el-input v-model = "queryParams.stuYearName" placeholder="请输入学年名称" clearable @keyup.enter.native="handleQuery" / >
< / el-form-item >
< / el-form-item >
<!-- 在搜索表单中添加标签筛选 -- >
<!-- < el-form-item label = "模块标签" prop = "moduleTags" >
< el-select v-model = "queryParams.moduleTags" placeholder="请选择模块标签" clearable >
< el-option
v-for = "dict in dict.type.module_tag"
:key = "dict.value"
:label = "dict.label"
:value = "dict.value"
/ >
< / el-select >
< / el-form-item > -- >
< el-form-item label = "开始时间" prop = "startTime" >
< el-form-item label = "开始时间" prop = "startTime" >
< el-date-picker v-model = "queryParams.startTime" clearable type="date" value-format="yyyy-MM-dd"
< el-date-picker v-model = "queryParams.startTime" clearable type="date" value-format="yyyy-MM-dd"
placeholder = "请选择开始时间"
placeholder = "请选择开始时间"
@@ -64,6 +76,16 @@
< dict-tag :options = "dict.type.srs_stu_year_status" :value = "scope.row.status" / >
< dict-tag :options = "dict.type.srs_stu_year_status" :value = "scope.row.status" / >
< / template >
< / template >
< / el-table-column >
< / el-table-column >
<!-- 在表格中添加标签展示列 ( 在状态列后添加 ) -- >
< el-table-column label = "模块标签" align = "center" prop = "moduleTags" >
< template slot -scope = " scope " >
< dict-tag
:options = "dict.type.module_tag"
: value = "scope.row.moduleTags ? scope.row.moduleTags.split(',') : []"
:showType = "'tag'"
/ >
< / template >
< / el-table-column >
< el-table-column label = "操作" align = "center" class -name = " small -padding fixed -width " >
< el-table-column label = "操作" align = "center" class -name = " small -padding fixed -width " >
< template slot -scope = " scope " >
< template slot -scope = " scope " >
< el-button v-hasPermi = "['system:year:edit']" size="mini" type="text" icon="el-icon-edit"
< el-button v-hasPermi = "['system:year:edit']" size="mini" type="text" icon="el-icon-edit"
@@ -73,6 +95,9 @@
@click ="handleDelete(scope.row)"
@click ="handleDelete(scope.row)"
> 删除 < / el-button >
> 删除 < / el-button >
<!-- 新增分配标签按钮 -- >
< el-button size = "mini" type = "text" icon = "el-icon-setting" @click ="handleAssignTag(scope.row)" > 分配标签 < / el -button >
< el-button size = "mini" type = "text" icon = "el-icon-edit" @click ="updateStatusVClick(scope.row)" > 修改状态 < / el -button >
< el-button size = "mini" type = "text" icon = "el-icon-edit" @click ="updateStatusVClick(scope.row)" > 修改状态 < / el -button >
< / template >
< / template >
< / el-table-column >
< / el-table-column >
@@ -133,17 +158,54 @@
< el-button @click ="cancel" > 取 消 < / el -button >
< el-button @click ="cancel" > 取 消 < / el -button >
< / div >
< / div >
< / el-dialog >
< / el-dialog >
<!-- 添加分配标签对话框 -- >
< el-dialog
title = "分配标签"
:visible.sync = "assignTagVisible"
width = "500px"
append -to -body
>
< el-form ref = "assignTagForm" :model = "assignTagForm" label -width = " 80px " >
< el-form-item label = "学年" >
< el-input v-model = "assignTagForm.stuYearName" readonly / >
< / el-form-item >
< el-form-item label = "模块标签" >
< el-checkbox-group v-model = "assignTagForm.selectedTags" >
< el -checkbox
v-for = "dict in dict.type.module_tag"
:key = "dict.value"
:label = "dict.value"
:disabled = "isTagAssigned(dict.value)"
>
{ { dict . label } }
< / el-checkbox >
< / el-checkbox-group >
< / el-form-item >
< / el-form >
< div slot = "footer" class = "dialog-footer" >
< el-button @click ="assignTagVisible = false" > 取 消 < / el -button >
< el-button type = "primary" @click ="submitAssignTag" > 确 定 < / el -button >
< / div >
< / el-dialog >
< / div >
< / div >
< / template >
< / template >
< script >
< script >
import { listYear , getYear , delYear , addYear , updateYear } from '@/api/stuCQS/basedata/year'
import { listYear , getYear , delYear , addYear , updateYear , assignTag } from '@/api/stuCQS/basedata/year'
export default {
export default {
name : 'Year' ,
name : 'Year' ,
dicts : [ 'srs_stu_year_status' ] ,
dicts : [ 'srs_stu_year_status' , 'module_tag' ],
data ( ) {
data ( ) {
return {
return {
// 分配标签对话框可见性
assignTagVisible : false ,
// 分配标签表单
assignTagForm : {
id : null ,
stuYearName : '' ,
selectedTags : [ ]
} ,
updateStatusV : false ,
updateStatusV : false ,
updateForm : {
updateForm : {
id : null ,
id : null ,
@@ -315,7 +377,47 @@ export default {
this . download ( 'system/year/export' , {
this . download ( 'system/year/export' , {
... this . queryParams
... this . queryParams
} , ` year_ ${ new Date ( ) . getTime ( ) } .xlsx ` )
} , ` year_ ${ new Date ( ) . getTime ( ) } .xlsx ` )
} ,
/** 分配标签按钮操作 */
handleAssignTag ( row ) {
this . assignTagForm . id = row . id
this . assignTagForm . stuYearName = row . stuYearName
// 将已有的标签转换为数组
this . assignTagForm . selectedTags = row . moduleTags ? row . moduleTags . split ( ',' ) : [ ]
this . assignTagVisible = true
} ,
/** 提交分配标签 */
submitAssignTag ( ) {
// 获取当前学年已有的标签
const currentYear = this . yearList . find ( item => item . id === this . assignTagForm . id ) ;
let existingTags = [ ] ;
if ( currentYear && currentYear . moduleTags ) {
existingTags = currentYear . moduleTags . split ( ',' ) ;
}
// 过滤掉已存在的标签,只发送新增的标签
const newTags = this . assignTagForm . selectedTags . filter ( tag => ! existingTags . includes ( tag ) ) ;
const tags = newTags . join ( ',' ) ;
assignTag ( this . assignTagForm . id , tags ) . then ( response => {
if ( response . code === 200 ) {
this . $message . success ( response . msg ) ;
this . assignTagVisible = false ;
this . getList ( ) ;
}
}
} )
} ,
/** 判断标签是否已分配给当前学年(基于数据库数据) */
isTagAssigned ( tagValue ) {
// 从 yearList 中找到当前正在编辑的学年记录
const currentYear = this . yearList . find ( item => item . id === this . assignTagForm . id ) ;
if ( currentYear && currentYear . moduleTags ) {
// 基于数据库中的实际标签数据判断
const existingTags = currentYear . moduleTags . split ( ',' ) ;
return existingTags . includes ( tagValue ) ;
}
return false ;
}
}
}
}
}
< / script >
< / script >