Commit 1785f837 authored by xhx's avatar xhx

fix: news

parent b7170d35
...@@ -52,6 +52,9 @@ export default Vue.extend({ ...@@ -52,6 +52,9 @@ export default Vue.extend({
this.imageUrl = newV this.imageUrl = newV
} }
}, },
created() {
this.imageUrl = this.path
},
data(){ data(){
return{ return{
imageUrl: "", imageUrl: "",
......
...@@ -47,7 +47,8 @@ export default Vue.extend({ ...@@ -47,7 +47,8 @@ export default Vue.extend({
}, },
extensions: [StarterKit, Timage], extensions: [StarterKit, Timage],
autofocus: "start", autofocus: "start",
}); })
this.editor.commands.setContent(this.text)
}, },
beforeDestroy() { beforeDestroy() {
this.editor.destroy(); this.editor.destroy();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- 搜索框 --> <!-- 搜索框 -->
<a-input placeholder="标题模糊搜索" v-model="searchPageReqParams.title" style="width: 150px; margin-right:10px;"/> <a-input placeholder="标题模糊搜索" v-model="searchPageReqParams.title" style="width: 150px; margin-right:10px;"/>
<!-- timepicker --> <!-- timepicker -->
<span class=" font-semibold">注册时间:</span> <span class=" font-semibold">发布时间:</span>
<timerange class=" mr-3" :startTime="searchPageReqParams.start_time" :endTime="searchPageReqParams.end_time" <timerange class=" mr-3" :startTime="searchPageReqParams.start_time" :endTime="searchPageReqParams.end_time"
@getNewTime="getNewTime"/> @getNewTime="getNewTime"/>
<!-- 咨询分类 --> <!-- 咨询分类 -->
...@@ -53,13 +53,13 @@ ...@@ -53,13 +53,13 @@
@click="remove(record)"> @click="remove(record)">
下架 下架
</a> </a>
<a-divider type="vertical" /> <a-divider v-show="record.article_status==1" type="vertical" />
<a v-show="record.article_status==1" <a v-show="record.article_status==1"
@click="release(record.uuid, searchPageReqParams.article_type)"> @click="release(record, searchPageReqParams.article_type)">
编辑 编辑
</a> </a>
<a-divider v-show="record.article_status==1" type="vertical" /> <a-divider v-show="record.article_status==1" type="vertical" />
<a @click="onDelete(record)"> <a v-show="record.article_status==1" @click="onDelete(record)">
删除 删除
</a> </a>
</span> </span>
...@@ -190,9 +190,9 @@ export default Vue.extend({ ...@@ -190,9 +190,9 @@ export default Vue.extend({
this.searchPageReqParams.end_time = undefined this.searchPageReqParams.end_time = undefined
this. query() this. query()
}, },
release(key?:string, type?:string){ release(item?: any, type?:string){
if (key && type) { if (item && type) {
this.$router.push({name:'publishNews', query: {key, type}}) this.$router.push({name:'publishNews', query: {msg: JSON.stringify(item), type}})
} else { } else {
this.$router.push({name:'publishNews'}) this.$router.push({name:'publishNews'})
} }
......
...@@ -66,22 +66,26 @@ export default Vue.extend({ ...@@ -66,22 +66,26 @@ export default Vue.extend({
}, },
methods:{ methods:{
getDetails() { getDetails() {
// 新增
if (Object.keys(this.$route.query).length === 0) { if (Object.keys(this.$route.query).length === 0) {
this.type = undefined this.type = undefined
return return
} }
const type = this.$route.query.type const type = this.$route.query.type
const id = this.$route.query.key as string
this.type = +type this.type = +type
if (+type === 1) { const msg = JSON.parse(this.$route.query.msg as string)
news.searchPolicy(id).then(res => { this.initData(msg)
this.initData(res.data) // 编辑
})
} else { // if (+type === 1) {
news.searchNews(id).then(res => { // news.searchPolicy(id).then(res => {
this.initData(res.data) // this.initData(res.data)
}) // })
} // } else {
// news.searchNews(id).then(res => {
// this.initData(res.data)
// })
// }
}, },
initData(res: any) { initData(res: any) {
this.title = res.title this.title = res.title
...@@ -90,6 +94,8 @@ export default Vue.extend({ ...@@ -90,6 +94,8 @@ export default Vue.extend({
this.imageUrl = new FileService().getImageSrc(res.file_name) this.imageUrl = new FileService().getImageSrc(res.file_name)
this.summary = res.desc this.summary = res.desc
this.editableContent = res.content this.editableContent = res.content
console.log('res', res)
console.log('imageUrl', this.imageUrl)
}, },
getContent(value:string){ getContent(value:string){
this.content = value this.content = value
...@@ -115,6 +121,7 @@ export default Vue.extend({ ...@@ -115,6 +121,7 @@ export default Vue.extend({
}) })
}, },
editForm() { editForm() {
const msg = JSON.parse(this.$route.query.msg as string)
const params = { const params = {
article_type: this.type, article_type: this.type,
content: this.content, content: this.content,
...@@ -122,7 +129,7 @@ export default Vue.extend({ ...@@ -122,7 +129,7 @@ export default Vue.extend({
file_name: this.imgUrl, file_name: this.imgUrl,
title: this.title, title: this.title,
writer: this.author, writer: this.author,
uuid: this.$route.query.key as string uuid: msg.uuid as string
} }
news.editArticle(params).then(res => { news.editArticle(params).then(res => {
if (res.code === 200) { if (res.code === 200) {
...@@ -133,7 +140,7 @@ export default Vue.extend({ ...@@ -133,7 +140,7 @@ export default Vue.extend({
}, },
onSubmit() { onSubmit() {
console.log(this.content) console.log(this.content)
if (this.$route.query.key) { if (this.$route.query.msg) {
this.editForm() this.editForm()
} else { } else {
this.addForm() this.addForm()
......
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