单选框,复选框,多选框回显,开关
1.单选框
label 是关键
<el-form-item label="性别:" :label-width="formLabelWidth">
<el-radio v-model="addStudent.sex" label="男">男</el-radio>
<el-radio v-model="addStudent.sex" label="女">女</el-radio>
</el-form-item>
2.复选框
对数组复选框进行拼接依次填入
/*
学生修改按钮
*/
handleUpd(row){
console.log(row)
this.addStudent=row
let k = this.addStudent.courseId= row.courseName;
let s1 = k.substring(0,2);
let s2 = k.substring(3,5);
let s3 = k.substring(6,8);
this.addStudent.courseId=[s1,s2,s3];
console.log(this.addStudent.courseId)
this.dialogFormVisible=true
},
注意: courseId 是[ ] 类型
<el-form-item label="选课:" :label-width="formLabelWidth">
<el-checkbox-group v-model="addStudent.courseId">
<el-checkbox v-for="c in courseList" :key="c.courseId" :value="c.courseId" :label="c.courseName"></el-checkbox>
</el-checkbox-group>
</el-form-item>
//修改
handleUpd(row){
let bankLname = row.bankLname;
let s1 = bankLname.substring(0,4);
let s2 = bankLname.substring(5,9);
let s3 = bankLname.substring(10,14);
this.addform=row // 语文 数学 英语 结构的
this.addform.bankName=[s1,s2,s3]
this.dialogFormVisible=true
},
/**
* 添加修改
* @return
*/
@PostMapping("addsenior")
public R addsenior(@RequestBody SysSenior sysSenior){
if (sysSenior.getSeniorId()==null){
sysSenior.setTime(new Date());
sysSeniorService.save(sysSenior);
String[] jobId = sysSenior.getJobId();
for (String s : jobId) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("job_name",s);
SysJob one = sysJobService.getOne(queryWrapper);
SysSeniorJob sysSeniorJob = new SysSeniorJob();
sysSeniorJob.setJobId(one.getJobId());
sysSeniorJob.setSeniorId(sysSenior.getSeniorId());
sysSeniorJobService.save(sysSeniorJob);
}
return R.successed("添加成功");
}else{
sysSeniorService.updateById(sysSenior);
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("senior_id",sysSenior.getSeniorId());
sysSeniorJobService.remove(queryWrapper);
String[] jobId = sysSenior.getJobId();
for (String s : jobId) {
QueryWrapper queryWrapper1 = new QueryWrapper();
queryWrapper1.eq("job_name",s);
SysJob one = sysJobService.getOne(queryWrapper1);
if (ObjectUtil.isEmpty(one)){
System.err.println(one);
}else {
SysSeniorJob sysSeniorJob = new SysSeniorJob();
sysSeniorJob.setSeniorId(sysSenior.getSeniorId());
sysSeniorJob.setJobId(one.getJobId());
sysSeniorJobService.save(sysSeniorJob);
}
}
return R.successed("修改成功");
}
}
3.开关
<el-table-column
prop="status"
label="角色状态">
<template v-slot="pp">
<el-switch
v-model="pp.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
@change="outStatus(pp.row)" // 改变方法
active-value="0" // 开启的值
inactive-value="1"> // 关闭的值
</el-switch>
</template>
</el-table-column>
状态改变方法
/*
状态失效
*/
outStatus(u){
this.axios.post("role/roleUpdStatus",u).then(r=>{
this.$message.success(r.data.data)
this.getroleList()
})
},
s(u){
this.axios.post(“role/roleUpdStatus”,u).then(r=>{
this.$message.success(r.data.data)
this.getroleList()
})
},