Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
d3df7ddb
Z
zendata
项目概览
易企天创
/
zendata
大约 1 年 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d3df7ddb
编写于
11月 12, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
validation and adjust the values for field section
上级
c27b00a3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
137 addition
and
80 deletion
+137
-80
src/server/def/tiles.go
src/server/def/tiles.go
+2
-1
ui/src/components/FieldConfig.vue
ui/src/components/FieldConfig.vue
+135
-79
未找到文件。
src/server/def/tiles.go
浏览文件 @
d3df7ddb
...
@@ -14,7 +14,8 @@ func CreateDefFieldSection(fieldId, sectionsId uint) (err error) {
...
@@ -14,7 +14,8 @@ func CreateDefFieldSection(fieldId, sectionsId uint) (err error) {
var
preSection
model
.
Section
var
preSection
model
.
Section
err
=
vari
.
GormDB
.
Where
(
"id=?"
,
sectionsId
)
.
Find
(
&
preSection
)
.
Error
err
=
vari
.
GormDB
.
Where
(
"id=?"
,
sectionsId
)
.
Find
(
&
preSection
)
.
Error
section
:=
&
model
.
Section
{
Value
:
"0-9"
,
FieldID
:
fieldId
,
Ord
:
preSection
.
Ord
+
1
}
section
:=
&
model
.
Section
{
Value
:
"0-9"
,
FieldID
:
fieldId
,
Ord
:
preSection
.
Ord
+
1
,
Start
:
"0"
,
End
:
"9"
}
err
=
vari
.
GormDB
.
Create
(
&
section
)
.
Error
err
=
vari
.
GormDB
.
Create
(
&
section
)
.
Error
return
return
}
}
...
...
ui/src/components/FieldConfig.vue
浏览文件 @
d3df7ddb
...
@@ -65,65 +65,68 @@
...
@@ -65,65 +65,68 @@
@
ok=
"saveSection"
@
ok=
"saveSection"
@
cancel=
"cancelSection"
>
@
cancel=
"cancelSection"
>
<div>
<div>
<div
v-if=
"section.type==='scope'"
>
<a-form-model
ref=
"editForm"
:model=
"section"
:rules=
"rules"
>
<a-row
:gutter=
"cols"
>
<div
v-if=
"section.type==='scope'"
>
<a-col
:span=
"cols"
>
<a-row
:gutter=
"cols"
>
<a-form-model-item
label=
"开始"
prop=
"prefix"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-col
:span=
"cols"
>
<a-input
v-model=
"section.start"
placeholder=
"数字或单个字母"
/>
<a-form-model-item
label=
"开始"
prop=
"start"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
</a-form-model-item>
<a-input
v-model=
"section.start"
placeholder=
"数字或单个字母"
/>
</a-col>
</a-form-model-item>
</a-row>
</a-col>
<a-row
:gutter=
"cols"
>
</a-row>
<a-col
:span=
"cols"
>
<a-row
:gutter=
"cols"
>
<a-form-model-item
label=
"结束"
prop=
"postfix"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-col
:span=
"cols"
>
<a-input
v-model=
"section.end"
placeholder=
"数字或单个字母"
/>
<a-form-model-item
label=
"结束"
prop=
"end"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
</a-form-model-item>
<a-input
v-model=
"section.end"
placeholder=
"数字或单个字母"
/>
</a-col>
</a-form-model-item>
</a-row>
</a-col>
<a-row
:gutter=
"cols"
>
</a-row>
<a-col
:span=
"cols"
>
<a-row
:gutter=
"cols"
>
<a-form-model-item
label=
"重复次数"
prop=
"prefix"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-col
:span=
"cols"
>
<a-input
v-model=
"section.repeat"
:min=
"1"
placeholder=
""
/>
<a-form-model-item
label=
"重复次数"
prop=
"repeat"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
</a-form-model-item>
<a-input
v-model=
"section.repeat"
:precision=
"0"
:min=
"1"
placeholder=
""
/>
</a-col>
</a-form-model-item>
</a-row>
</a-col>
<a-row
:gutter=
"cols"
>
</a-row>
<a-col
:span=
"cols"
>
<a-row
:gutter=
"cols"
>
<a-form-model-item
label=
"随机"
prop=
"prefix"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-col
:span=
"cols"
>
<a-switch
v-model=
"section.rand"
/>
<a-form-model-item
label=
"随机"
prop=
"rand"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
</a-form-model-item>
<a-switch
v-model=
"section.rand"
/>
</a-col>
</a-form-model-item>
</a-row>
</a-col>
<a-row
:gutter=
"cols"
v-if=
"!section.rand"
>
</a-row>
<a-col
:span=
"cols"
>
<a-row
:gutter=
"cols"
v-if=
"!section.rand"
>
<a-form-model-item
label=
"步长"
prop=
"postfix"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-col
:span=
"cols"
>
<a-input
v-model=
"section.step"
placeholder=
"数字"
/>
<a-form-model-item
label=
"步长"
prop=
"step"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
</a-form-model-item>
<a-input
v-model=
"section.step"
placeholder=
"数字"
/>
</a-col>
</a-form-model-item>
</a-row>
</a-col>
</div>
</a-row>
</div>
<div
v-if=
"section.type==='arr'"
>
<div
v-if=
"section.type==='arr'"
>
<a-row
:gutter=
"cols"
>
<a-row
:gutter=
"cols"
>
<a-col
:span=
"cols"
>
<a-col
:span=
"cols"
>
<a-form-model-item
label=
"数组"
prop=
"prefix
"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-form-model-item
label=
"数组"
prop=
"text
"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-input
v-model=
"section.text"
type=
"textarea"
rows=
"3"
/>
<a-input
v-model=
"section.text"
type=
"textarea"
rows=
"3"
/>
每行一个值
每行一个值
</a-form-model-item>
</a-form-model-item>
</a-col>
</a-col>
</a-row>
</a-row>
</div>
</div>
<div
v-if=
"section.type==='const'"
>
<div
v-if=
"section.type==='const'"
>
<a-row
:gutter=
"cols"
>
<a-row
:gutter=
"cols"
>
<a-col
:span=
"cols"
>
<a-col
:span=
"cols"
>
<a-form-model-item
label=
"字面常量"
prop=
"prefix"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-form-model-item
label=
"字面常量"
prop=
"text"
:labelCol=
"labelColFull"
:wrapperCol=
"wrapperColFull"
>
<a-input
v-model=
"section.text"
placeholder=
""
/>
<a-input
v-model=
"section.text"
placeholder=
""
/>
</a-form-model-item>
</a-form-model-item>
</a-col>
</a-col>
</a-row>
</a-row>
</div>
</div>
</a-form-model>
</div>
</div>
</a-modal>
</a-modal>
</div>
</div>
...
@@ -148,6 +151,23 @@ export default {
...
@@ -148,6 +151,23 @@ export default {
section
:
{},
section
:
{},
editTitle
:
''
,
editTitle
:
''
,
editSectionVisible
:
false
,
editSectionVisible
:
false
,
rules
:
{
start
:
[
{
required
:
true
,
message
:
'
必须是数字或单个字母
'
,
trigger
:
'
change
'
},
{
validator
:
this
.
checkRange
,
trigger
:
'
change
'
},
],
end
:
[
{
required
:
true
,
message
:
'
必须是数字或单个字母
'
,
trigger
:
'
change
'
},
{
validator
:
this
.
checkRange
,
trigger
:
'
change
'
},
],
repeat
:
[
{
validator
:
this
.
checkRepeat
,
message
:
'
必须是正整数
'
,
trigger
:
'
change
'
},
],
step
:
[
{
validator
:
this
.
checkStep
,
message
:
'
必须是数字
'
,
trigger
:
'
change
'
},
],
},
};
};
},
},
props
:
{
props
:
{
...
@@ -205,36 +225,47 @@ export default {
...
@@ -205,36 +225,47 @@ export default {
this
.
editSectionVisible
=
true
this
.
editSectionVisible
=
true
},
},
saveSection
()
{
saveSection
()
{
console
.
log
(
'
saveSection
'
,
this
.
section
)
this
.
$refs
.
editForm
.
validate
(
valid
=>
{
console
.
log
(
valid
,
this
.
section
)
if
(
!
valid
)
{
console
.
log
(
'
validation fail
'
)
return
}
if
(
this
.
section
.
type
===
'
scope
'
)
{
if
(
this
.
section
.
type
===
'
scope
'
)
{
this
.
section
.
value
=
this
.
section
.
start
+
'
-
'
+
this
.
section
.
end
this
.
section
.
value
=
this
.
section
.
start
+
'
-
'
+
this
.
section
.
end
if
(
this
.
section
.
rand
)
{
if
(
this
.
section
.
rand
)
{
this
.
section
.
value
+=
'
:R
'
this
.
section
.
value
+=
'
:R
'
this
.
section
.
step
=
0
this
.
section
.
step
=
0
}
else
if
(
this
.
section
.
step
&&
this
.
section
.
step
!=
''
&&
this
.
section
.
step
!=
1
)
{
}
else
if
(
this
.
section
.
step
&&
this
.
section
.
step
!=
''
&&
this
.
section
.
step
!=
1
)
{
this
.
section
.
value
+=
'
:
'
+
this
.
section
.
step
const
regx
=
/^
[
a-z,A-Z
]
$/
}
if
(
regx
.
test
(
this
.
section
.
start
)
||
regx
.
test
(
this
.
section
.
end
))
{
this
.
section
.
step
=
Math
.
floor
(
this
.
section
.
step
)
}
if
(
this
.
section
.
repeat
&&
this
.
section
.
repeat
!=
''
&&
this
.
section
.
repeat
!=
'
1
'
)
{
this
.
section
.
value
+=
'
:
'
+
this
.
section
.
step
this
.
section
.
value
+=
'
{
'
+
this
.
section
.
repeat
+
'
}
'
}
}
}
else
if
(
this
.
section
.
type
===
'
arr
'
)
{
if
(
this
.
section
.
repeat
&&
this
.
section
.
repeat
!=
''
&&
this
.
section
.
repeat
!=
'
1
'
)
{
const
arr
=
this
.
section
.
text
.
split
(
'
\n
'
)
this
.
section
.
value
+=
'
{
'
+
this
.
section
.
repeat
+
'
}
'
this
.
section
.
value
=
'
[
'
+
arr
.
join
(
'
,
'
)
+
'
]
'
}
}
else
if
(
this
.
section
.
type
===
'
const
'
)
{
}
else
if
(
this
.
section
.
type
===
'
arr
'
)
{
this
.
section
.
value
=
'
`
'
+
this
.
section
.
text
+
'
`
'
const
arr
=
this
.
section
.
text
.
split
(
'
\n
'
)
}
this
.
section
.
value
=
'
[
'
+
arr
.
join
(
'
,
'
)
+
'
]
'
updateDefFieldSection
(
this
.
section
).
then
(
res
=>
{
}
else
if
(
this
.
section
.
type
===
'
const
'
)
{
console
.
log
(
'
updateDefFieldSection
'
,
res
)
this
.
section
.
value
=
'
`
'
+
this
.
section
.
text
+
'
`
'
this
.
sections
=
res
.
data
}
})
this
.
editSectionVisible
=
false
updateDefFieldSection
(
this
.
section
).
then
(
res
=>
{
console
.
log
(
'
updateDefFieldSection
'
,
res
)
this
.
sections
=
res
.
data
})
this
.
editSectionVisible
=
false
})
},
},
cancelSection
()
{
cancelSection
()
{
console
.
log
(
'
cancelSection
'
)
console
.
log
(
'
cancelSection
'
)
...
@@ -249,6 +280,31 @@ export default {
...
@@ -249,6 +280,31 @@ export default {
this
.
sections
=
res
.
data
this
.
sections
=
res
.
data
})
})
},
},
checkRange
(
rule
,
value
,
callback
){
console
.
log
(
'
checkRange
'
,
value
)
const
test1
=
/^
[
0-9
]
+
\.?[
0-9
]
*$/
.
test
(
value
);
const
test2
=
/^
[
a-z,A-Z
]
$/
.
test
(
value
);
if
(
!
test1
&&
!
test2
)
{
callback
(
'
必须是数字或单个字母
'
)
}
callback
()
},
checkRepeat
(
rule
,
value
,
callback
)
{
const
test
=
/^
[
1-9
][
0-9
]
*$/
.
test
(
value
);
if
(
!
test
)
{
callback
(
'
必须是正整数
'
)
}
callback
()
},
checkStep
(
rule
,
value
,
callback
)
{
const
test
=
/^
[
0-9
]
+
\.?[
0-9
]
*$/
.
test
(
value
);
if
(
!
test
)
{
callback
(
'
必须是数字
'
)
}
callback
()
}
}
}
}
}
</
script
>
</
script
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录