新闻调整

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

@@ -2,7 +2,7 @@
const install = function(Vue) { const install = function(Vue) {
if (install.installed) return Promise.resolve(); if (install.installed) return Promise.resolve();
else { else {
let contexts = require.context('../project/shandong10086/apps', true, /(\/.+)\/App[^\/]+\.vue$/); let contexts = require.context('../project/xiushan/apps', true, /(\/.+)\/App[^\/]+\.vue$/);
if (contexts) { if (contexts) {
contexts.keys().map((e) => { contexts.keys().map((e) => {
if (contexts(e).default) { if (contexts(e).default) {

View File

@@ -85,7 +85,7 @@ export default {
}, },
created() { created() {
this.areaId = this.user.info.areaId this.areaId = this.user.info.areaId
this.dict.load("appNewsType", "appNewsStatus") this.dict.load("appNewsType", "appNewsStatus", "appNewsCategory")
} }
} }
</script> </script>

View File

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

View File

@@ -12,20 +12,21 @@
<el-input v-model="newsInfo.title" size="small" placeholder="请输入…" maxlength="30" <el-input v-model="newsInfo.title" size="small" placeholder="请输入…" maxlength="30"
show-word-limit></el-input> show-word-limit></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="policyType" label="类型"> <el-form-item prop="description" label="摘要">
<el-input type="textarea" v-model="newsInfo.description" size="small" placeholder="请输入…" maxlength="255"
show-word-limit></el-input>
</el-form-item>
<el-form-item prop="category" label="分类:">
<ai-select <ai-select
v-model="newsInfo.policyType" v-model="newsInfo.category"
placeholder="选择新闻类" placeholder="选择新闻类"
:selectList="$dict.getDict('newsCenterPolicyType')"> :selectList="$dict.getDict('appNewsCategory')">
</ai-select> </ai-select>
</el-form-item> </el-form-item>
<!-- <el-form-item label="发布地区:" prop="areaId">--> <el-form-item prop="videoUrl" label="视频:">
<!-- <ai-area-get v-model="newsInfo.areaId" :instance="instance" :root="areaId"/>-->
<!-- </el-form-item>-->
<el-form-item prop="videoFile" label="视频:">
<el-upload :show-file-list="false" ref="upload1" <el-upload :show-file-list="false" ref="upload1"
action :http-request="submitUpload" :accept="accept" :limit="1"> action :http-request="submitUpload" :accept="accept" :limit="1">
<div class="video" v-if="!newsInfo.videoFile.length"> <div class="video" v-if="!newsInfo.videoUrl.length">
<div class="icon"> <div class="icon">
<ai-icon type="svg" icon="iconVideo"/> <ai-icon type="svg" icon="iconVideo"/>
<span>上传视频</span> <span>上传视频</span>
@@ -34,15 +35,15 @@
</div> </div>
</el-upload> </el-upload>
<video class="video-com" style="width:100%; height:100%; object-fit: fill;" muted <video class="video-com" style="width:100%; height:100%; object-fit: fill;" muted
:src="newsInfo.videoFile[0].url" controls="controls" v-if="newsInfo.videoFile.length"></video> :src="newsInfo.videoUrl" controls="controls" v-if="newsInfo.videoUrl"></video>
<el-upload :show-file-list="false" ref="upload2" action :http-request="submitUpload" :accept="accept" <el-upload :show-file-list="false" ref="upload2" action :http-request="submitUpload" :accept="accept"
:limit="1" v-if="newsInfo.videoFile.length"> :limit="1" v-if="newsInfo.videoUrl">
<el-button style="margin-top: 10px;">重新选择</el-button> <el-button style="margin-top: 10px;">重新选择</el-button>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item prop="coverFile" label="封面:"> <el-form-item prop="thumbUrl" label="封面:">
<ai-uploader :instance="instance" v-model="newsInfo.coverFile" :limit="1" <ai-uploader :instance="instance" v-model="newsInfo.thumbUrl" :limit="1"
@change="$refs['ruleForm'].clearValidate('coverFile')" :cropOps="cropOps" is-crop> @change="$refs['ruleForm'].clearValidate('thumbUrl')" :cropOps="cropOps" is-crop>
<template slot="tips">图片比例1.81</template> <template slot="tips">图片比例1.81</template>
</ai-uploader> </ai-uploader>
</el-form-item> </el-form-item>
@@ -52,14 +53,12 @@
</template> </template>
<template slot="footer"> <template slot="footer">
<el-button class="footer_btn" @click="$emit('goBack')">取消</el-button> <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> <el-button class="footer_btn" @click="handleSubmit('0')">保存</el-button>
</template> </template>
</ai-detail> </ai-detail>
</template> </template>
<script> <script>
import mp4box from 'mp4box'
export default { export default {
name: "addVideo", name: "addVideo",
@@ -75,17 +74,18 @@ export default {
newsInfo: { newsInfo: {
areaId: '', areaId: '',
title: "", title: "",
policyType: '', description: "",
videoFile: [], category: '',
coverFile: [] videoUrl: '',
thumbUrl: ''
}, },
accept: ".mp4", accept: ".mp4",
rules: { rules: {
title: {required: true, message: '请输入标题', trigger: 'blur'}, title: {required: true, message: '请输入标题', trigger: 'blur'},
areaId: {required: true, message: '请选择 发布地区', trigger: 'blur'}, description: {required: true, message: '请输入摘要', trigger: 'blur'},
policyType: {required: true, message: '请选择类', trigger: 'change'}, category: {required: true, message: '请选择类', trigger: 'change'},
videoFile: {required: true, message: '请上传视频', trigger: 'blur'}, videoUrl: {required: true, message: '请上传视频', trigger: 'blur'},
coverFile: {required: true, message: '请上传封面', trigger: 'blur'}, thumbUrl: {required: true, message: '请上传封面', trigger: 'blur'},
}, },
cropOps: { cropOps: {
width: "320px", width: "320px",
@@ -113,60 +113,42 @@ export default {
submitUpload(file) { submitUpload(file) {
this.$refs['upload1']?.clearFiles(); this.$refs['upload1']?.clearFiles();
this.$refs['upload2']?.clearFiles(); this.$refs['upload2']?.clearFiles();
this.$refs['ruleForm']?.clearValidate('videoFile'); this.$refs['ruleForm']?.clearValidate('videoUrl');
const fileType = file.file.name.split(".")[1]; const fileType = file.file.name.split(".")[1];
const size = file.file.size / 1024 / 1024 > 100; const size = file.file.size / 1024 / 1024 > 100;
let mp4boxfile = mp4box.createFile();
const reader = new FileReader(); if (size) {
reader.readAsArrayBuffer(file.file); return this.$message.error("视频大小不能超过100M");
reader.onload = (e) => { }
const arrayBuffer = e.target.result;
arrayBuffer.fileStart = 0;
mp4boxfile.appendBuffer(arrayBuffer);
};
mp4boxfile.onReady = (info) => {
let codec = info.mime.match(/codecs="(\S*),/)[1]
if (codec.indexOf('avc') === -1) {
return this.$message.error("视频编码格式不支持")
}
if (size) { if (fileType && this.accept.indexOf(fileType.toLocaleLowerCase()) > -1) {
return this.$message.error("视频大小不能超过100M"); let formData = new FormData()
} formData.append('file', file.file);
this.instance.post(`/admin/file/add-unlimited`, formData).then(res => {
if (fileType && this.accept.indexOf(fileType.toLocaleLowerCase()) > -1) { if (res && res.data) {
let formData = new FormData() let videoList = res.data[0].split(";");
formData.append('file', file.file); this.newsInfo.videoUrl = videoList[0]
this.instance.post(`/admin/file/add-unlimited`, formData).then(res => { }
if (res && res.data) { })
let videoList = res.data[0].split(";"); } else {
this.newsInfo.videoFile.splice(0, 1, { return this.$message.error("视频格式错误");
id: videoList[1], }
url: videoList[0]
})
}
})
} else {
return this.$message.error("视频格式错误");
}
};
}, },
addOrUpdate(status) { addOrUpdate(status) {
if (Array.isArray(this.newsInfo.thumbUrl)) {
this.newsInfo.thumbUrl = this.newsInfo.thumbUrl[0].url
}
const msg = +status ? '发布成功' : this.isEdit ? '编辑成功' : '保存成功'; const msg = +status ? '发布成功' : this.isEdit ? '编辑成功' : '保存成功';
this.instance.post(`/app/appnews/addOrUpdate`, { this.instance.post(`/app/appnews/addOrUpdate`, {
...this.newsInfo,
title: this.newsInfo.title, title: this.newsInfo.title,
videoFile: { description: this.newsInfo.description,
id: this.newsInfo.videoFile[0].id videoUrl: this.newsInfo.videoUrl,
}, thumbUrl: this.newsInfo.thumbUrl,
coverFile: { category: this.newsInfo.category,
id: this.newsInfo.coverFile[0].id
},
policyType: this.newsInfo.policyType,
areaId: this.areaId,
type: 1, type: 1,
id: this.detail.id, id: this.newsInfo.id,
status: this.isEdit ? this.detail.status : status status: this.newsInfo.status
}).then(res => { }).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.$message.success(msg); this.$message.success(msg);
@@ -180,11 +162,14 @@ export default {
params: {id} params: {id}
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {
this.newsInfo = res.data
this.newsInfo.areaId = res.data.areaId this.newsInfo.areaId = res.data.areaId
this.newsInfo.id = res.data.id
this.newsInfo.title = res.data.title; this.newsInfo.title = res.data.title;
this.newsInfo.policyType = res.data.policyType this.newsInfo.description = res.data.description;
this.newsInfo.videoFile = [{...res.data.videoFile, url: res.data.videoFile.accessUrl}]; this.newsInfo.category = res.data.category
this.newsInfo.coverFile = [{...res.data.coverFile, url: res.data.coverFile.accessUrl}]; this.newsInfo.videoUrl = res.data.videoUrl;
this.newsInfo.thumbUrl = [{url: res.data.thumbUrl}];
} }
}) })
} }

View File

@@ -7,7 +7,7 @@
<ai-card titlePosition="center"> <ai-card titlePosition="center">
<template #title> <template #title>
<h2>{{ detail.title }}</h2> <h2>{{ detail.title }}</h2>
<p class="subTitle">类型{{ dict.getLabel('newsCenterPolicyType', +detail.policyType) }}</p> <p class="subTitle">类型{{ dict.getLabel('appNewsCategory', +detail.category) }}</p>
</template> </template>
<template slot="right"> <template slot="right">
<el-button type="text" size="small" icon="iconfont iconEdit" @click="handleEdit">修改</el-button> <el-button type="text" size="small" icon="iconfont iconEdit" @click="handleEdit">修改</el-button>

View File

@@ -43,13 +43,12 @@
<el-table-column slot="options" label="操作" fixed="right" width="260" align="center"> <el-table-column slot="options" label="操作" fixed="right" width="260" align="center">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<div class="table-options"> <div class="table-options">
<el-button type="text" title="取消发布" v-if="+row.status" @click="changeStatus(row)">取消发布</el-button> <el-button type="text" title="取消发布" v-if="row.status=='1' && permissions('app_appnews_status')" @click="changeStatus(row)">取消发布</el-button>
<el-button type="text" v-else title="发布" @click="changeStatus(row)">发布</el-button> <el-button type="text" v-if="row.status=='0' && permissions('app_appnews_status')" title="发布" @click="changeStatus(row)">发布</el-button>
<el-button type="text" @click="handleEdit(row)" v-if="permissions('app_appnews_edit')">编辑 <el-button type="text" @click="handleEdit(row)" v-if="permissions('app_appnews_edit')">编辑
</el-button> </el-button>
<el-button type="text" @click="handleDelete(row)" v-if="permissions('app_appnews_del')">删除 <el-button type="text" @click="handleDelete(row)" v-if="permissions('app_appnews_del')">删除
</el-button> </el-button>
<el-button type="text" @click="handleCopyShare(row)">小程序链接</el-button>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@@ -66,8 +65,7 @@ export default {
props: { props: {
instance: Function, instance: Function,
dict: Object, dict: Object,
permissions: Function, permissions: Function
areaId: String
}, },
data() { data() {
return { return {
@@ -94,8 +92,28 @@ export default {
return h('span', null, row.viewCount >= 10000 ? ((row.viewCount / 10000).toFixed(2) + '万') : row.viewCount) return h('span', null, row.viewCount >= 10000 ? ((row.viewCount / 10000).toFixed(2) + '万') : row.viewCount)
} }
}, },
{prop: 'createUserName', label: '发布人'}, {
{prop: 'createTime', label: '发布时间'}, prop: 'type', label: '类型', align: 'center',
render: (h, {row}) => {
return h('span', {
style: {
color: row.type ? this.dict.getColor('appNewsType', row.type) : 'auto'
}
}, this.dict.getLabel('appNewsType', row.type))
}
},
{
prop: 'category', label: '分类', align: 'center',
render: (h, {row}) => {
return h('span', {
style: {
color: row.category ? this.dict.getColor('appNewsCategory', row.category) : 'auto'
}
}, this.dict.getLabel('appNewsCategory', row.category))
}
},
{prop: 'publishUserName', label: '发布人'},
{prop: 'publishTime', label: '发布时间'},
{ {
prop: 'status', label: '发布状态', align: 'center', prop: 'status', label: '发布状态', align: 'center',
render: (h, {row}) => { render: (h, {row}) => {
@@ -181,8 +199,7 @@ export default {
this.instance.post(`/app/appnews/list`, null, { this.instance.post(`/app/appnews/list`, null, {
params: { params: {
...this.page, ...this.page,
...this.searchObj, ...this.searchObj
areaId: this.areaId
} }
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {