Browse Source

富文本内容获取

master
aBin 4 years ago
parent
commit
e35afafdca
  1. 9
      src/components/Detail/addOrEdit.vue
  2. 3
      src/components/Detail/editor.vue
  3. 9
      src/components/Detail/index.vue

9
src/components/Detail/addOrEdit.vue

@ -11,7 +11,7 @@
</el-cascader> </el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="正文:" prop="content"> <el-form-item label="正文:" prop="content">
<editor /> <editor ref="editor" />
<!-- <el-input <!-- <el-input
type="textarea" type="textarea"
:rows="2" :rows="2"
@ -90,8 +90,11 @@
submit(formName) { submit(formName) {
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate((valid) => {
if (valid) { if (valid) {
const child = this.$refs['editor']
formName.content = child.getValue();
if(this.showAdd){ if(this.showAdd){
this.addCarousel(formName) this.addCarousel(formName)
}else{ }else{
this.updateCarousel(formName) this.updateCarousel(formName)
} }
@ -114,7 +117,7 @@
await ADD_DETAIL(params).then((res) => { await ADD_DETAIL(params).then((res) => {
if(res.code === 200){ if(res.code === 200){
Alert.success('添加成功'); Alert.success('添加成功');
this.$emit('close', true) this.$emit('close')
}else{ }else{
Alert.fail(res.msg || '添加失败'); Alert.fail(res.msg || '添加失败');
} }
@ -134,7 +137,7 @@
await UPDATE_DETAIL(params).then((res) => { await UPDATE_DETAIL(params).then((res) => {
if(res.code === 200){ if(res.code === 200){
Alert.success('修改成功'); Alert.success('修改成功');
this.$emit('close', true) this.$emit('close')
}else{ }else{
Alert.fail(res.msg || '修改失败'); Alert.fail(res.msg || '修改失败');
} }

3
src/components/Detail/editor.vue

@ -34,6 +34,9 @@ export default {
handleChange(value){ handleChange(value){
console.log('value: ', value); console.log('value: ', value);
},
getValue() {
return this.tuieditor.getHtml()
} }
} }
}; };

9
src/components/Detail/index.vue

@ -110,6 +110,7 @@
:show-close="false" :show-close="false"
:visible.sync="showModal"> :visible.sync="showModal">
<add-or-edit ref="distribution" :show-add="showAdd" :currList="currList" v-if="showModal" @close="close"></add-or-edit> <add-or-edit ref="distribution" :show-add="showAdd" :currList="currList" v-if="showModal" @close="close"></add-or-edit>
<!-- <el-button type="primary" @click="dialogVisible = false"> </el-button> -->
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -240,18 +241,16 @@
}, },
editModal(currList) { editModal(currList) {
this.currList = currList;
this.showModal = true; this.showModal = true;
this.showAdd = false; this.showAdd = false;
// this.id = id; // this.id = id;
this.currList = currList
}, },
// //
close(type){ close(){
this.showModal = false this.showModal = false
if(type){ this.getList()
this.getList()
}
}, },
/** /**

Loading…
Cancel
Save