//模糊查询
@Res...Mapper("list")
public Map<String,Object> list(Book book){
List<Book> list=bookService.list(book);
Map<String,Object> data=new HashMap<>();
data.put("OK",true);
data.put("rs",list);
return map;
}
//添加/修改/删除
@Res...Mapper("add")
public String list(Book book){
int count=bookService.add(book);
if(count > 0){
return "ture";
}else{
return "false";
}
}
select * from t_book where 1=1
<if test=bookname!=null>
and bookname like concat('%',#{bookname},'%')
</if>
//添加/修改按钮
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
if(this.form.id==null){
//添加
let url=this.axios.urls.BOOK_ADD;
axios.post(
url,this.form
).then(res=>{
if(res.data=="true"){
this.$message('添加成功')
this.getList();
}
});
//修改
}else{
let url=this.axios.urls.BOOK_UPDATE;
axios.post(
url,this.form
).then(res=>{
if(res.data=="true"){
this.$message('修改成功')
this.getList();
}
});
}
this.dialogFormVisible:ture;
} else {
console.log('error submit!!');
return false;
}
});
},
//删除按钮
dele(id){
this.$confirm('确定要删除吗?').then(()=>{
let url=this.axios.urls.BOOK_DELETE;
let data={
'id':id
}
axios.post(
url,this.form
).then(res=>{
if(res.data=="true"){
this.$message('删除成功')
this.getList();
}
});
});
}
//查询所有
getlist(){
let url=this.axios.urls.BOOK_LIST;
axios.get('url', {
params: {
bookname: this.form.bookname
}
}) .then(res=>{
let data=res.data;
this.tableData=data.rs;
})
}
//钩子函数
created(){
this.getlist();
}
//查询按钮
onSubmit(){
this.getlist();
},
type="flex"
add(){
this.title="添加书本"
this.form.bookname=null;
....
this.dialogFormVisible:ture;
}
update(row){
this.title="修改书本"
this.form.id=row.id;
this.form.bookname=row.bookname;
....
this.dialogFormVisible:ture;
}
'BOOK_LIST':'https://localhost:8080:ssm/book.list',
https://element.eleme.cn/#/zh-CN
https://github.com/axios/axios