Commit 6e54520f authored by rockyl's avatar rockyl

meta编辑器一些字段必填

parent c0681ad5
...@@ -13,8 +13,12 @@ ...@@ -13,8 +13,12 @@
"Export": "Export", "Export": "Export",
"Upload": "Upload", "Upload": "Upload",
"Edit": "Edit", "Edit": "Edit",
"ID": "ID",
"Name": "Name", "Name": "Name",
"Output": "Output",
"Code": "Code",
"Desc": "Desc", "Desc": "Desc",
"Empty": "Empty",
"Event": "Event", "Event": "Event",
"No desc": "No desc", "No desc": "No desc",
"Description": "Description", "Description": "Description",
......
...@@ -3,37 +3,34 @@ ...@@ -3,37 +3,34 @@
:close-on-click-modal="false" :close-on-click-modal="false"
:append-to-body="true"> :append-to-body="true">
<div class="meta-editor-wrapper"> <div class="meta-editor-wrapper">
<el-form class="info-editor" size="mini" label-position="right" label-width="70px"> <el-form ref="form" v-if="meta" :model="meta" :rules="rules" :show-message="false" class="info-editor" size="mini" label-position="right" label-width="70px">
<template v-if="meta"> <template>
<el-form-item label="ID"> <el-form-item prop="id" label="ID">
<el-input v-model="meta.id" placeholder="ID" :readonly="!editable"/> <el-input v-model="meta.id" :placeholder="$t('ID')" :readonly="!editable"/>
</el-form-item> </el-form-item>
<el-form-item label="Name"> <el-form-item prop="name" label="Name">
<el-input v-model="meta.name" placeholder="Name" :readonly="!editable"/> <el-input v-model="meta.name" :placeholder="$t('Name')" :readonly="!editable"/>
</el-form-item> </el-form-item>
</template> <el-form-item prop="desc" label="Desc">
<el-input v-model="meta.desc" :placeholder="$t('Description')" :readonly="!editable"/>
<template v-if="meta">
<el-form-item label="Desc">
<el-input v-model="meta.desc" placeholder="Description" :readonly="!editable"/>
</el-form-item> </el-form-item>
<el-form-item label="Props"> <el-form-item label="Props">
<el-link :underline="false" @click="onClickEditProps" :disabled="!editable"> <el-link :underline="false" @click="onClickEditProps" :disabled="!editable">
<template v-if="Object.keys(meta.props).length"> <template v-if="Object.keys(meta.props).length">
<el-tag type="success" size="mini" v-for="(option, key) in meta.props" :key="key">{{key}}</el-tag> <el-tag type="success" size="mini" v-for="(option, key) in meta.props" :key="key">{{key}}</el-tag>
</template> </template>
<template v-else>Nothing</template> <template v-else>{{$t('Empty')}}</template>
</el-link> </el-link>
</el-form-item> </el-form-item>
<el-form-item label="Output"> <el-form-item label="Output">
<div style="display: flex;flex: 1;"> <div style="display: flex;flex: 1;">
<el-select style="flex: 1;" v-model="meta.output" :disabled="!editable" allow-create filterable multiple <el-select style="flex: 1;" v-model="meta.output" :disabled="!editable" allow-create filterable multiple
placeholder="Output"/> :placeholder="$t('Output')"/>
</div> </div>
</el-form-item> </el-form-item>
</template> </template>
</el-form> </el-form>
<el-input v-if="meta" class="script-editor" :readonly=" !editable" type="textarea" <el-input v-if="meta" class="script-editor" :readonly=" !editable" type="textarea" :placeholder="$t('Code')"
v-model="meta.script"></el-input> v-model="meta.script"></el-input>
</div> </div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
...@@ -58,6 +55,15 @@ ...@@ -58,6 +55,15 @@
visible: false, visible: false,
meta: null, meta: null,
propsEditorVisible: false, propsEditorVisible: false,
rules: {
id: [
{ required: true, message: '', trigger: 'blur' },
],
name: [
{ required: true, message: '', trigger: 'blur' }
],
},
} }
}, },
computed: { computed: {
...@@ -78,6 +84,8 @@ ...@@ -78,6 +84,8 @@
this.$refs.propsEditorDialog.edit(this.meta.props); this.$refs.propsEditorDialog.edit(this.meta.props);
}, },
save() { save() {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.oldMetaID !== this.meta.id && this.$store.getters.metaIDExists(this.meta.id)) { if (this.oldMetaID !== this.meta.id && this.$store.getters.metaIDExists(this.meta.id)) {
this.$alert(this.$t('This Meta ID is in use, can not save'), this.$t('Alert')) this.$alert(this.$t('This Meta ID is in use, can not save'), this.$t('Alert'))
.catch((e) => { .catch((e) => {
...@@ -86,6 +94,10 @@ ...@@ -86,6 +94,10 @@
this.$emit('input', this.meta); this.$emit('input', this.meta);
this.visible = false; this.visible = false;
} }
} else {
return false;
}
});
}, },
cancel() { cancel() {
this.visible = false; this.visible = false;
......
<template> <template>
<editor-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName"> <editor-wrapper :editable="editable" :value="value" :container="container" :property="property" :propertyName="propertyName">
<el-select :disabled="!editable" :value="editValue" @input="onInput" :placeholder="property.default" class="el-select"> <el-select :disabled="!editable" :value="editValue" filterable @input="onInput" :placeholder="property.default" class="el-select">
<el-option <el-option
v-for="(item, key) in assets" v-for="(item, key) in assets"
:key="key" :key="key"
......
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