新闻调整

This commit is contained in:
刘仕伟
2022-02-28 16:25:36 +08:00
parent 82b11cd362
commit da306f69ea
6 changed files with 117 additions and 113 deletions

View File

@@ -1,33 +1,34 @@
<template>
<ai-detail class="add-article">
<template slot="title">
<ai-title :title="isEdit?'编辑文章':'发布文章'" :isShowBack="true" :isShowBottomBorder="true"
<ai-title :title="isEdit?'编辑新闻':'发布新闻'" :isShowBack="true" :isShowBottomBorder="true"
@onBackClick="$emit('goBack')"></ai-title>
</template>
<template slot="content">
<ai-card title="发布文章">
<ai-card title="发布新闻">
<template #content>
<el-form ref="ruleForm" :model="articInfo" :rules="rules" label-width="120px" label-position="right">
<el-form-item prop="title" label="标题:">
<el-input v-model="articInfo.title" size="small" placeholder="请输入…" maxlength="30"
show-word-limit></el-input>
</el-form-item>
<el-form-item prop="policyType" label="类型">
<el-form-item prop="description" label="摘要">
<el-input type="textarea" v-model="articInfo.description" size="small" placeholder="请输入…" maxlength="255"
show-word-limit></el-input>
</el-form-item>
<el-form-item prop="category" label="分类:">
<ai-select
v-model="articInfo.policyType"
placeholder="选择新闻类"
:selectList="dict.getDict('newsCenterPolicyType')">
v-model="articInfo.category"
placeholder="选择新闻类"
:selectList="dict.getDict('appNewsCategory')">
</ai-select>
</el-form-item>
<!-- <el-form-item label="发布地区:" prop="areaId">-->
<!-- <ai-area-get v-model="articInfo.areaId" :instance="instance" :root="areaId"/>-->
<!-- </el-form-item>-->
<el-form-item prop="content" label="正文:">
<ai-editor v-model="articInfo.content" :instance="instance"/>
</el-form-item>
<el-form-item prop="coverFile" label="封面:">
<ai-uploader :instance="instance" v-model="articInfo.coverFile" :limit="1" :isShowTip="true"
@change="$refs['ruleForm'].clearValidate('coverFile')" :cropOps="cropOps" is-crop>
<el-form-item prop="thumbUrl" label="封面:">
<ai-uploader :instance="instance" v-model="articInfo.thumbUrl" :limit="1" :isShowTip="true"
@change="$refs['ruleForm'].clearValidate('thumbUrl')" :cropOps="cropOps" is-crop>
<template slot="tips">最多上传1张图片,单个文件最大10MB支持jpgjpegpng<br/>格式图片比例1.61</template>
</ai-uploader>
</el-form-item>
@@ -37,7 +38,6 @@
</template>
<template slot="footer">
<el-button class="footer_btn" @click="$emit('goBack')">取消</el-button>
<el-button type="primary" class="footer_btn" @click="handleSubmit('1')" v-if="!isEdit">发布</el-button>
<el-button class="footer_btn" @click="handleSubmit('0')">保存</el-button>
</template>
</ai-detail>
@@ -50,24 +50,24 @@ export default {
instance: Function,
dict: Object,
permissions: Function,
areaId: String,
detail: Object,
},
data() {
return {
articInfo: {
areaId: '',
id: "",
title: "",
content: "",
policyType: '',
coverFile: [],
description: "",
category: '',
thumbUrl: '',
},
rules: {
title: {required: true, message: '请输入标题', trigger: 'blur'},
areaId: {required: true, message: '请选择 发布地区', trigger: 'blur'},
policyType: {required: true, message: '请选择类', trigger: 'change'},
description: {required: true, message: '请输入摘要', trigger: 'blur'},
category: {required: true, message: '请选择类', trigger: 'change'},
content: {required: true, message: '请填写内容', trigger: 'blur'},
coverFile: {required: true, message: '请上传封面', trigger: 'blur'},
thumbUrl: {required: true, message: '请上传封面', trigger: 'blur'},
},
cropOps: {
fixedNumber: [1.8, 1],
@@ -97,15 +97,17 @@ export default {
* 新增、修改
* */
addOrUpdate(status) {
if (Array.isArray(this.articInfo.thumbUrl)) {
this.articInfo.thumbUrl = this.articInfo.thumbUrl[0].url
}
const msg = +status ? '发布成功' : this.isEdit ? '编辑成功' : '保存成功';
this.instance.post(`/app/appnewscenterinfo/addOrUpdate`, {
this.instance.post(`/app/appnews/addOrUpdate`, {
...this.articInfo,
coverFile: {
id: this.articInfo.coverFile[0].id
},
thumbUrl: this.articInfo.thumbUrl,
category: this.articInfo.category,
type: 0,
id: this.$route.query.id,
status: status
id: this.articInfo.id,
status: this.articInfo.status
}).then(res => {
if (res.code == 0) {
this.$message.success(msg);
@@ -119,16 +121,16 @@ export default {
*/
getDetail() {
let {id} = this.$route.query
id && this.instance.post(`/app/appnewscenterinfo/queryDetailById`, null, {
id && this.instance.post(`/app/appnews/getById`, null, {
params: {id}
}).then(res => {
if (res?.data) {
this.articInfo = res.data
this.articInfo.areaId = res.data.areaId
this.articInfo.id = res.data.id
this.articInfo.title = res.data.title;
this.articInfo.content = res.data.content;
this.articInfo.policyType = res.data.policyType
this.articInfo.coverFile = [{...res.data.coverFile, url: res.data.coverFile.accessUrl}];
this.articInfo.category = res.data.category
this.articInfo.thumbUrl = [{url: res.data.thumbUrl}]
}
})
}