mysql分隔
key_pollution_source_type 数值:1,2,3 逗号分隔的
查询有1和99或者1,99同时有的数据总数
查询语句:
select count(t.key_pollution_source_type)
from t_yw_qy_baseinfo t
where t.key_pollution_source_type
regexp ‘(^|,)(1|99)(,|$)’;
xml中不能写
regexp ‘(^|,)(#{keyPollutionSourceType})(,|$)’
;
需要转换一下:
if(!StringUtils.isBlank(tYwQyBaseinfo.getKeyPollutionSourceType())){
tYwQyBaseinfo.setKeyPollutionSourceType("(^|,)("+tYwQyBaseinfo.getKeyPollutionSourceType()+")(,|$)");
}
xml中:
and key_pollution_source_type regexp #{keyPollutionSourceType}
下拉框多选:
只需要添加一个multiple就可以啦。
前端可以在添加、修改、查看时候转一下
添加multiple这个
string转数组
1、数组转字符串
data.join(‘,’)
//变成字符串后,以逗号分隔
2、字符串转数组
data.split(‘,’)
//字符串按逗号分隔成数组
所以修改要写这个转一下类型
if (this.form.zw != null && this.form.zw != "") {
this.form.zw = this.form.zw.split(",");
}
数组转string在提交转一下
if (this.form.zw && this.form.zw.length > 0) {
this.form.zw = this.form.zw
.map((a, ai) => {
return a;
})
.join(",");
} else {
this.form.zw = "";
}
查看列表也要转一下
/** 查询用户列表 */
getList() {
this.loading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
(response) => {
response.rows &&
response.rows.map((a) => {
// if ((a.zw && a.zw != "null") || a.zw != "") {
// a.zw = a.zw && a.zw.split(",");
// }
if (a.zw != null && a.zw != "") {
a.zw = a.zw.split(",");
}
});
this.userList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},