|
@@ -77,15 +77,24 @@
|
|
<el-form-item>
|
|
<el-form-item>
|
|
<div style="float: right">
|
|
<div style="float: right">
|
|
<el-button type="info" plain @click="$router.back()">取消</el-button>
|
|
<el-button type="info" plain @click="$router.back()">取消</el-button>
|
|
- <el-button type="primary" @click="submit">{{id ? '修改' : '新增'}}</el-button>
|
|
|
|
|
|
+ <el-button type="warning" plain @click="submit(0)">预览</el-button>
|
|
|
|
+ <el-button type="primary" @click="submit(1)">{{id ? '修改' : '新增'}}</el-button>
|
|
</div>
|
|
</div>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
|
|
+ <div class="preview" v-if="previewData">
|
|
|
|
+ <i class="el-icon-close" @click="previewData = null"></i>
|
|
|
|
+ <div class="preview-layer">
|
|
|
|
+ <preview :activep="previewData" class="layer"/>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import {root} from '@/util/http'
|
|
import {root} from '@/util/http'
|
|
|
|
+import preview from '../preview'
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
@@ -101,7 +110,8 @@ export default {
|
|
language: null,
|
|
language: null,
|
|
on_language: null,
|
|
on_language: null,
|
|
redire: 1,
|
|
redire: 1,
|
|
- root
|
|
|
|
|
|
+ root,
|
|
|
|
+ previewData: null
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -110,7 +120,7 @@ export default {
|
|
handleCoverSuccess (data) {
|
|
handleCoverSuccess (data) {
|
|
this.coverUrl = data.content
|
|
this.coverUrl = data.content
|
|
},
|
|
},
|
|
- async submit () {
|
|
|
|
|
|
+ async submit (oper) {
|
|
if (!this.title) {
|
|
if (!this.title) {
|
|
return this.$error('请填写标题')
|
|
return this.$error('请填写标题')
|
|
} else if (!this.adate) {
|
|
} else if (!this.adate) {
|
|
@@ -138,17 +148,21 @@ export default {
|
|
body.chinese_id = this.on_language
|
|
body.chinese_id = this.on_language
|
|
}
|
|
}
|
|
|
|
|
|
- try {
|
|
|
|
- if (this.id) {
|
|
|
|
- body.id = this.id
|
|
|
|
- await this.$http.put('/news', body)
|
|
|
|
- this.$success('修改成功')
|
|
|
|
- } else {
|
|
|
|
- await this.$http.post('/news', body)
|
|
|
|
- this.$router.back()
|
|
|
|
|
|
+ if (oper) {
|
|
|
|
+ try {
|
|
|
|
+ if (this.id) {
|
|
|
|
+ body.id = this.id
|
|
|
|
+ await this.$http.put('/news', body)
|
|
|
|
+ this.$success('修改成功')
|
|
|
|
+ } else {
|
|
|
|
+ await this.$http.post('/news', body)
|
|
|
|
+ this.$router.back()
|
|
|
|
+ }
|
|
|
|
+ } catch (e) {
|
|
|
|
+ this.$error(e.msg)
|
|
}
|
|
}
|
|
- } catch (e) {
|
|
|
|
- this.$error(e.msg)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ this.previewData = body
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async getInfo () {
|
|
async getInfo () {
|
|
@@ -191,7 +205,8 @@ export default {
|
|
await this.getInfo()
|
|
await this.getInfo()
|
|
editor.txt.html(this.content)
|
|
editor.txt.html(this.content)
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ components: {preview}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|