|
@@ -21,6 +21,12 @@
|
|
<slot name="options" v-bind="{ item, form, fieldChange }"></slot>
|
|
<slot name="options" v-bind="{ item, form, fieldChange }"></slot>
|
|
</el-select>
|
|
</el-select>
|
|
</template>
|
|
</template>
|
|
|
|
+ <template v-else-if="item.type === 'textarea'">
|
|
|
|
+ <el-input v-model="form[item.model]" type="textarea" :autosize="{ minRows: 3, maxRows: 5 }"></el-input>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else-if="item.type === 'editor'">
|
|
|
|
+ <wang-editor v-model="form[item.model]" v-if="!loading"></wang-editor>
|
|
|
|
+ </template>
|
|
<template v-else>
|
|
<template v-else>
|
|
<el-input v-model="form[item.model]" :type="getField('type', item)" :placeholder="getField('placeholder', item)" v-bind="item.options"></el-input>
|
|
<el-input v-model="form[item.model]" :type="getField('type', item)" :placeholder="getField('placeholder', item)" v-bind="item.options"></el-input>
|
|
</template>
|
|
</template>
|
|
@@ -34,9 +40,9 @@
|
|
<el-col :span="6">
|
|
<el-col :span="6">
|
|
<el-button type="primary" @click="save">保存</el-button>
|
|
<el-button type="primary" @click="save">保存</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
- <el-col :span="6">
|
|
|
|
|
|
+ <!-- <el-col :span="6">
|
|
<el-button @click="$emit('cancel')">返回</el-button>
|
|
<el-button @click="$emit('cancel')">返回</el-button>
|
|
- </el-col>
|
|
|
|
|
|
+ </el-col> -->
|
|
</el-row>
|
|
</el-row>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
@@ -45,6 +51,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
|
+import wangEditor from '@frame/components/wang-editor';
|
|
export default {
|
|
export default {
|
|
name: 'add',
|
|
name: 'add',
|
|
props: {
|
|
props: {
|
|
@@ -53,12 +60,15 @@ export default {
|
|
isNew: { type: Boolean, default: true },
|
|
isNew: { type: Boolean, default: true },
|
|
data: null,
|
|
data: null,
|
|
},
|
|
},
|
|
- components: {},
|
|
|
|
|
|
+ components: {
|
|
|
|
+ wangEditor,
|
|
|
|
+ },
|
|
data: () => ({
|
|
data: () => ({
|
|
form: {},
|
|
form: {},
|
|
display: undefined,
|
|
display: undefined,
|
|
show: false,
|
|
show: false,
|
|
dateShow: false,
|
|
dateShow: false,
|
|
|
|
+ loading: true,
|
|
}),
|
|
}),
|
|
created() {},
|
|
created() {},
|
|
computed: {},
|
|
computed: {},
|
|
@@ -73,6 +83,7 @@ export default {
|
|
data: {
|
|
data: {
|
|
handler(val) {
|
|
handler(val) {
|
|
if (val) this.$set(this, `form`, this.data);
|
|
if (val) this.$set(this, `form`, this.data);
|
|
|
|
+ this.loading = false;
|
|
},
|
|
},
|
|
immediate: true,
|
|
immediate: true,
|
|
},
|
|
},
|
|
@@ -99,7 +110,12 @@ export default {
|
|
this.$set(this.form, model, value);
|
|
this.$set(this.form, model, value);
|
|
},
|
|
},
|
|
checkType() {
|
|
checkType() {
|
|
- console.log(this.fields);
|
|
|
|
|
|
+ let arr = this.fields.filter(fil => fil.type === 'checkbox');
|
|
|
|
+ if (arr.length > 0 && this.isNew) {
|
|
|
|
+ for (const item of arr) {
|
|
|
|
+ this.$set(this.form, `${item.model}`, []);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|