forked from opentiny/tiny-engine
fix: 修复新建区块的表单确定时未校验的问题 (#302)
This commit is contained in:
parent
f26456bbb5
commit
4d247ef406
|
|
@ -5,6 +5,7 @@
|
||||||
show-message
|
show-message
|
||||||
:model="formData"
|
:model="formData"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
|
ref="formRef"
|
||||||
label-width="120px"
|
label-width="120px"
|
||||||
:label-align="true"
|
:label-align="true"
|
||||||
label-position="left"
|
label-position="left"
|
||||||
|
|
@ -33,7 +34,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { reactive, computed } from 'vue'
|
import { reactive, computed, ref } from 'vue'
|
||||||
import { Input, Form, FormItem, Button, DialogBox, Select } from '@opentiny/vue'
|
import { Input, Form, FormItem, Button, DialogBox, Select } from '@opentiny/vue'
|
||||||
import { useBlock, useLayout, useCanvas, useModal } from '@opentiny/tiny-engine-controller'
|
import { useBlock, useLayout, useCanvas, useModal } from '@opentiny/tiny-engine-controller'
|
||||||
import { REGEXP_BLOCK_NAME } from '../js/verification'
|
import { REGEXP_BLOCK_NAME } from '../js/verification'
|
||||||
|
|
@ -64,6 +65,7 @@ export default {
|
||||||
const { PLUGIN_NAME, activePlugin } = useLayout()
|
const { PLUGIN_NAME, activePlugin } = useLayout()
|
||||||
const { isSaved } = useCanvas()
|
const { isSaved } = useCanvas()
|
||||||
const { confirm } = useModal()
|
const { confirm } = useModal()
|
||||||
|
const formRef = ref(null)
|
||||||
|
|
||||||
const categoryList = computed(() =>
|
const categoryList = computed(() =>
|
||||||
getCategoryList().map((item) => ({ ...item, value: item.id, label: item.name }))
|
getCategoryList().map((item) => ({ ...item, value: item.id, label: item.name }))
|
||||||
|
|
@ -84,6 +86,11 @@ export default {
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
const addBlock = () => {
|
const addBlock = () => {
|
||||||
|
formRef.value.validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (isSaved()) {
|
if (isSaved()) {
|
||||||
handleAddBlock()
|
handleAddBlock()
|
||||||
return
|
return
|
||||||
|
|
@ -94,6 +101,7 @@ export default {
|
||||||
handleAddBlock()
|
handleAddBlock()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
|
|
@ -107,6 +115,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
formData,
|
formData,
|
||||||
categoryList,
|
categoryList,
|
||||||
|
formRef,
|
||||||
rules,
|
rules,
|
||||||
addBlock,
|
addBlock,
|
||||||
cancel,
|
cancel,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue