Commit f9288370 authored by 郭志伟's avatar 郭志伟

fix(saveModal): 调整保存表单校验逻辑

parent 216b9593
...@@ -10,7 +10,8 @@ import { getStyle } from '@service/utils.service'; ...@@ -10,7 +10,8 @@ import { getStyle } from '@service/utils.service';
@Component({ components: { Upload }, name: 'BasicPageForm' }) @Component({ components: { Upload }, name: 'BasicPageForm' })
export default class DynamicForm extends Vue { export default class DynamicForm extends Vue {
@Getter('pageInfo') pageData; @Getter('pageInfo') pageInfo;
@Getter('pageData') pageData;
@Prop(Boolean) value; @Prop(Boolean) value;
showPopup: boolean = false; showPopup: boolean = false;
...@@ -20,12 +21,19 @@ export default class DynamicForm extends Vue { ...@@ -20,12 +21,19 @@ export default class DynamicForm extends Vue {
ruleCustom: object = { ruleCustom: object = {
pageName: [ pageName: [
{ required: true, message: '请输入页面名称', trigger: 'blur' } { required: true, message: '请输入页面名称', trigger: 'blur' }
] ],
shareOpenMethod: [
{ validator: this.validateOpenMethod, trigger: 'blur' }
],
}; };
get enableShare() {
return this.pageData.props?.showShare;
}
@Watch('pageData', { immediate: true }) @Watch('pageData', { immediate: true })
onPageDataChange(newVal) { onPageDataChange(newVal) {
const { pageName, pageDescribe, pageKeywords, coverImage, isPublish, isTemplate, shareCoverImage, shareOpenMethod } = this.pageData; const { pageName, pageDescribe, pageKeywords, coverImage, isPublish, isTemplate, shareCoverImage, shareOpenMethod } = this.pageInfo;
this.formCustom = { pageName, pageDescribe, pageKeywords, coverImage, isPublish: !!isPublish, isTemplate: !!isTemplate, shareCoverImage, shareOpenMethod }; this.formCustom = { pageName, pageDescribe, pageKeywords, coverImage, isPublish: !!isPublish, isTemplate: !!isTemplate, shareCoverImage, shareOpenMethod };
} }
...@@ -38,7 +46,7 @@ export default class DynamicForm extends Vue { ...@@ -38,7 +46,7 @@ export default class DynamicForm extends Vue {
} }
handleSubmit(type) { handleSubmit(type) {
this.$refs.formCustom.validate(async (valid) => { this.$refs.formCustom?.validate(async (valid) => {
if (valid) { if (valid) {
if (type === 'save') { if (type === 'save') {
this.loadingSave = true; this.loadingSave = true;
...@@ -64,6 +72,13 @@ export default class DynamicForm extends Vue { ...@@ -64,6 +72,13 @@ export default class DynamicForm extends Vue {
this.formCustom.pageName = this.formCustom.pageName || '未命名'; this.formCustom.pageName = this.formCustom.pageName || '未命名';
this.handleSubmit('autoSave'); this.handleSubmit('autoSave');
} }
validateOpenMethod(rule, value, callback) {
if (!value && this.enableShare) {
callback(new Error('请选择H5打开方式'));
} else {
callback();
}
}
changeStyle(type) { changeStyle(type) {
const gridEle = document.querySelector('.vue-grid-layout'); const gridEle = document.querySelector('.vue-grid-layout');
......
...@@ -16,9 +16,10 @@ ...@@ -16,9 +16,10 @@
</FormItem> </FormItem>
<FormItem label="H5打开方式" prop="shareOpenMethod"> <FormItem label="H5打开方式" prop="shareOpenMethod">
<RadioGroup v-model="formCustom.shareOpenMethod"> <RadioGroup v-model="formCustom.shareOpenMethod">
<Radio :label="1">小程序</Radio> <Radio :label="1" :disabled="!enableShare">小程序</Radio>
<Radio :label="2">APP</Radio> <Radio :label="2" :disabled="!enableShare">APP</Radio>
</RadioGroup> </RadioGroup>
<p class="basic-form__tip">当分享功能未启用时,此处不可选</p>
</FormItem> </FormItem>
<FormItem label="是否发布" prop="isPublish"> <FormItem label="是否发布" prop="isPublish">
<i-switch v-model="formCustom.isPublish"></i-switch> <i-switch v-model="formCustom.isPublish"></i-switch>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment