feat(B批收尾): B1门禁可信/B7-1菜单环防护/B2空值守卫/B7-2分页/B7-3字段清洗/B3空态/B4索引key/B5-3 comment三集合选A新建schema(漂移清零)/B6清理+admin配置+changelog
This commit is contained in:
+103
-166
@@ -1,166 +1,103 @@
|
||||
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
|
||||
|
||||
|
||||
const validator = {
|
||||
"font_color": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"pattern": "^#[0-9a-fA-F]{3,6}$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"backgrond_color": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"pattern": "^#[0-9a-fA-F]{3,6}$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"select_src": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"temptele_src": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"temptele_name": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"minLength": 2,
|
||||
"maxLength": 50
|
||||
}
|
||||
]
|
||||
},
|
||||
"select_icon_color": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"pattern": "^#[0-9a-fA-F]{3,6}$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"icon_color": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"pattern": "^#[0-9a-fA-F]{3,6}$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"user_name_color": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"pattern": "^#[0-9a-fA-F]{3,6}$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"btn_color": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"pattern": "^#[0-9a-fA-F]{3,6}$"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const enumConverter = {}
|
||||
|
||||
function filterToWhere(filter, command) {
|
||||
let where = {}
|
||||
for (let field in filter) {
|
||||
let { type, value } = filter[field]
|
||||
switch (type) {
|
||||
case "search":
|
||||
if (typeof value === 'string' && value.length) {
|
||||
where[field] = new RegExp(value)
|
||||
}
|
||||
break;
|
||||
case "select":
|
||||
if (value.length) {
|
||||
let selectValue = []
|
||||
for (let s of value) {
|
||||
selectValue.push(command.eq(s))
|
||||
}
|
||||
where[field] = command.or(selectValue)
|
||||
}
|
||||
break;
|
||||
case "range":
|
||||
if (value.length) {
|
||||
let gt = value[0]
|
||||
let lt = value[1]
|
||||
where[field] = command.and([command.gte(gt), command.lte(lt)])
|
||||
}
|
||||
break;
|
||||
case "date":
|
||||
if (value.length) {
|
||||
let [s, e] = value
|
||||
let startDate = new Date(s)
|
||||
let endDate = new Date(e)
|
||||
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
|
||||
}
|
||||
break;
|
||||
case "timestamp":
|
||||
if (value.length) {
|
||||
let [startDate, endDate] = value
|
||||
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
export { validator, enumConverter, filterToWhere }
|
||||
// 表单校验规则由 schema2code 生成;字段同时保留旧拼写 backgrond_color 以兼容历史数据。
|
||||
|
||||
const colorRules = Object.freeze([
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请输入颜色代码'
|
||||
},
|
||||
{
|
||||
format: 'string'
|
||||
},
|
||||
{
|
||||
pattern: '^#[0-9a-fA-F]{3,8}$',
|
||||
errorMessage: '请输入有效的颜色代码,例如 #fff 或 #ffffff'
|
||||
}
|
||||
])
|
||||
|
||||
const stringRules = [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '此项不能为空'
|
||||
},
|
||||
{
|
||||
format: 'string'
|
||||
}
|
||||
]
|
||||
|
||||
const validator = {
|
||||
font_color: { rules: colorRules },
|
||||
// 新字段;backgrond_color 仍保留在下方作为旧数据兼容字段。
|
||||
background_color: { rules: colorRules },
|
||||
backgrond_color: { rules: colorRules },
|
||||
select_src: { rules: stringRules },
|
||||
temptele_src: { rules: stringRules },
|
||||
temptele_name: {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请输入模板名称'
|
||||
},
|
||||
{
|
||||
format: 'string'
|
||||
},
|
||||
{
|
||||
minLength: 2,
|
||||
maxLength: 50,
|
||||
errorMessage: '模板名称长度应为 2-50 个字符'
|
||||
}
|
||||
]
|
||||
},
|
||||
select_icon_color: { rules: colorRules },
|
||||
icon_color: { rules: colorRules },
|
||||
user_name_color: { rules: colorRules },
|
||||
btn_color: { rules: colorRules }
|
||||
}
|
||||
|
||||
const enumConverter = {}
|
||||
|
||||
function filterToWhere(filter, command) {
|
||||
let where = {}
|
||||
for (let field in filter) {
|
||||
let { type, value } = filter[field]
|
||||
switch (type) {
|
||||
case "search":
|
||||
if (typeof value === 'string' && value.length) {
|
||||
where[field] = new RegExp(value)
|
||||
}
|
||||
break;
|
||||
case "select":
|
||||
if (value.length) {
|
||||
let selectValue = []
|
||||
for (let s of value) {
|
||||
selectValue.push(command.eq(s))
|
||||
}
|
||||
where[field] = command.or(selectValue)
|
||||
}
|
||||
break;
|
||||
case "range":
|
||||
if (value.length) {
|
||||
let gt = value[0]
|
||||
let lt = value[1]
|
||||
where[field] = command.and([command.gte(gt), command.lte(lt)])
|
||||
}
|
||||
break;
|
||||
case "date":
|
||||
if (value.length) {
|
||||
let [s, e] = value
|
||||
let startDate = new Date(s)
|
||||
let endDate = new Date(e)
|
||||
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
|
||||
}
|
||||
break;
|
||||
case "timestamp":
|
||||
if (value.length) {
|
||||
let [startDate, endDate] = value
|
||||
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
export { validator, enumConverter, filterToWhere }
|
||||
|
||||
Reference in New Issue
Block a user