Browse Source

列表页

master
song 3 years ago
parent
commit
a6539d1caf
  1. 18
      src/components/Detail/addOrEdit.vue
  2. 24
      src/components/Detail/editor.vue
  3. 7
      src/components/Detail/index.vue
  4. 7
      src/components/News/index.vue
  5. 1
      src/views/lists/index.vue

18
src/components/Detail/addOrEdit.vue

@ -1,7 +1,7 @@
<template> <template>
<div class="container"> <div class="container">
<div class="title">{{ showAdd ? '添加' : '修改' }}详情</div> <div class="title">{{ showAdd ? '添加' : '修改' }}详情</div>
<el-form :model="formLabelAlign" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm"> <el-form :model="formLabelAlign" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
<el-form-item label="页面显示位置:" prop="showPage"> <el-form-item label="页面显示位置:" prop="showPage">
<el-cascader <el-cascader
v-model="formLabelAlign.showPage" v-model="formLabelAlign.showPage"
@ -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 ref="editor" /> <editor ref="editor" :content="content" />
<!-- <el-input <!-- <el-input
type="textarea" type="textarea"
:rows="2" :rows="2"
@ -48,9 +48,9 @@
return { return {
labelPosition: 'right', labelPosition: 'right',
formLabelAlign: { formLabelAlign: {
showPage: ['00', '0000'], showPage: ['00', '0000']
content: ''
}, },
content: '',
BASE_API, BASE_API,
tabList, tabList,
props: { props: {
@ -91,7 +91,7 @@
this.$refs.ruleForm.validate((valid) => { this.$refs.ruleForm.validate((valid) => {
if (valid) { if (valid) {
const child = this.$refs['editor'] const child = this.$refs['editor']
formName.content = child.getValue(); this.content = child.getValue();
if(this.showAdd){ if(this.showAdd){
this.addCarousel(formName) this.addCarousel(formName)
@ -109,7 +109,8 @@
* 添加详情 * 添加详情
*/ */
async addCarousel(formName){ async addCarousel(formName){
const { showPage, content } = formName; const { showPage } = formName;
const { content } = this;
const params = { const params = {
showPage: showPage[1], showPage: showPage[1],
content content
@ -128,7 +129,8 @@
* 修改详情 * 修改详情
*/ */
async updateCarousel(formName){ async updateCarousel(formName){
const { detailId, showPage, content } = formName; const { detailId, showPage } = formName;
const { content } = this;
const params = { const params = {
detailId, detailId,
showPage: showPage[1], showPage: showPage[1],
@ -158,7 +160,7 @@
}; };
await QUERY_DETAIL(params).then(res => { await QUERY_DETAIL(params).then(res => {
if(res.code === 200){ if(res.code === 200){
this.formLabelAlign.content = res.data.content this.content = res.data.content
}else{ }else{
Alert.fail(res.msg || '详情获取失败'); Alert.fail(res.msg || '详情获取失败');
} }

24
src/components/Detail/editor.vue

@ -1,5 +1,5 @@
<template> <template>
<div id="editorSection" @change="handleChange"></div> <div id="editorSection"></div>
</template> </template>
<script> <script>
@ -12,8 +12,24 @@ import { init } from "echarts/lib/echarts";
export default { export default {
name: "mytuieditor", name: "mytuieditor",
props:{
content:{
type: String,
default: ''
}
},
watch: {
content(val){
if(val){
this.setValue(val)
}
}
},
mounted() { mounted() {
this.initialize(); this.initialize();
this.$nextTick(() => {
this.setValue(this.content)
})
}, },
beforeDestroy() { beforeDestroy() {
this.tuieditor = null; this.tuieditor = null;
@ -32,11 +48,11 @@ export default {
} }
}, },
handleChange(value){
console.log('value: ', value);
},
getValue() { getValue() {
return this.tuieditor.getHtml() return this.tuieditor.getHtml()
},
setValue(val) {
this.tuieditor.setHtml(val);
} }
} }
}; };

7
src/components/Detail/index.vue

@ -206,7 +206,12 @@
if(res.code === 200){ if(res.code === 200){
this.content = res.data.content this.content = res.data.content
if(this.keys.length){ if(this.keys.length){
this.keys.splice(0, 1, row.detailId) const index = this.keys.findIndex(key => key === row.detailId)
if(index !== -1){
this.keys = []
}else{
this.keys.splice(0, 1, row.detailId)
}
}else{ }else{
this.keys.push(row.detailId) this.keys.push(row.detailId)
} }

7
src/components/News/index.vue

@ -208,7 +208,12 @@
if(res.code === 200){ if(res.code === 200){
this.detailContent = res.data this.detailContent = res.data
if(this.keys.length){ if(this.keys.length){
this.keys.splice(0, 1, row.introId) const index = this.keys.findIndex(key => key === row.introId)
if(index !== -1){
this.keys = []
}else{
this.keys.splice(0, 1, row.introId)
}
}else{ }else{
this.keys.push(row.introId) this.keys.push(row.introId)
} }

1
src/views/lists/index.vue

@ -37,7 +37,6 @@
}, },
methods: { methods: {
handleClick(value) { handleClick(value) {
console.log('value: ', value);
this.activeName =value this.activeName =value
if(value === 'IMAGE'){ if(value === 'IMAGE'){
this.$refs.banner.getList() this.$refs.banner.getList()

Loading…
Cancel
Save