新闻调整
This commit is contained in:
		| @@ -2,7 +2,7 @@ | ||||
| const install = function(Vue) { | ||||
| 	if (install.installed) return Promise.resolve(); | ||||
| 	else { | ||||
| 		let contexts = require.context('../project/shandong10086/apps', true, /(\/.+)\/App[^\/]+\.vue$/); | ||||
| 		let contexts = require.context('../project/xiushan/apps', true, /(\/.+)\/App[^\/]+\.vue$/); | ||||
| 		if (contexts) { | ||||
| 			contexts.keys().map((e) => { | ||||
| 				if (contexts(e).default) { | ||||
|   | ||||
| @@ -85,7 +85,7 @@ export default { | ||||
|   }, | ||||
|   created() { | ||||
|     this.areaId = this.user.info.areaId | ||||
|     this.dict.load("appNewsType", "appNewsStatus") | ||||
|     this.dict.load("appNewsType", "appNewsStatus", "appNewsCategory") | ||||
|   } | ||||
| } | ||||
| </script> | ||||
|   | ||||
| @@ -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,支持jpg、jpeg、png<br/>格式图片比例:1.6:1</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}] | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   | ||||
| @@ -12,20 +12,21 @@ | ||||
|               <el-input v-model="newsInfo.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="newsInfo.description" size="small" placeholder="请输入…" maxlength="255" | ||||
|                         show-word-limit></el-input> | ||||
|             </el-form-item> | ||||
|             <el-form-item prop="category" label="分类:"> | ||||
|               <ai-select | ||||
|                   v-model="newsInfo.policyType" | ||||
|                   placeholder="选择新闻类型" | ||||
|                   :selectList="$dict.getDict('newsCenterPolicyType')"> | ||||
|                   v-model="newsInfo.category" | ||||
|                   placeholder="选择新闻分类" | ||||
|                   :selectList="$dict.getDict('appNewsCategory')"> | ||||
|               </ai-select> | ||||
|             </el-form-item> | ||||
| <!--            <el-form-item label="发布地区:" prop="areaId">--> | ||||
|             <!--              <ai-area-get v-model="newsInfo.areaId" :instance="instance" :root="areaId"/>--> | ||||
|             <!--            </el-form-item>--> | ||||
|             <el-form-item prop="videoFile" label="视频:"> | ||||
|             <el-form-item prop="videoUrl" label="视频:"> | ||||
|               <el-upload :show-file-list="false" ref="upload1" | ||||
|                          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"> | ||||
|                     <ai-icon type="svg" icon="iconVideo"/> | ||||
|                     <span>上传视频</span> | ||||
| @@ -34,15 +35,15 @@ | ||||
|                 </div> | ||||
|               </el-upload> | ||||
|               <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" | ||||
|                          :limit="1" v-if="newsInfo.videoFile.length"> | ||||
|                          :limit="1" v-if="newsInfo.videoUrl"> | ||||
|                 <el-button style="margin-top: 10px;">重新选择</el-button> | ||||
|               </el-upload> | ||||
|             </el-form-item> | ||||
|             <el-form-item prop="coverFile" label="封面:"> | ||||
|               <ai-uploader :instance="instance" v-model="newsInfo.coverFile" :limit="1" | ||||
|                            @change="$refs['ruleForm'].clearValidate('coverFile')" :cropOps="cropOps" is-crop> | ||||
|             <el-form-item prop="thumbUrl" label="封面:"> | ||||
|               <ai-uploader :instance="instance" v-model="newsInfo.thumbUrl" :limit="1" | ||||
|                            @change="$refs['ruleForm'].clearValidate('thumbUrl')" :cropOps="cropOps" is-crop> | ||||
|                 <template slot="tips">图片比例:1.8:1</template> | ||||
|               </ai-uploader> | ||||
|             </el-form-item> | ||||
| @@ -52,14 +53,12 @@ | ||||
|     </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> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import mp4box from 'mp4box' | ||||
|  | ||||
| export default { | ||||
|   name: "addVideo", | ||||
| @@ -75,17 +74,18 @@ export default { | ||||
|       newsInfo: { | ||||
|         areaId: '', | ||||
|         title: "", | ||||
|         policyType: '', | ||||
|         videoFile: [], | ||||
|         coverFile: [] | ||||
|         description: "", | ||||
|         category: '', | ||||
|         videoUrl: '', | ||||
|         thumbUrl: '' | ||||
|       }, | ||||
|       accept: ".mp4", | ||||
|       rules: { | ||||
|         title: {required: true, message: '请输入标题', trigger: 'blur'}, | ||||
|         areaId: {required: true, message: '请选择 发布地区', trigger: 'blur'}, | ||||
|         policyType: {required: true, message: '请选择类型', trigger: 'change'}, | ||||
|         videoFile: {required: true, message: '请上传视频', trigger: 'blur'}, | ||||
|         coverFile: {required: true, message: '请上传封面', trigger: 'blur'}, | ||||
|         description: {required: true, message: '请输入摘要', trigger: 'blur'}, | ||||
|         category: {required: true, message: '请选择分类', trigger: 'change'}, | ||||
|         videoUrl: {required: true, message: '请上传视频', trigger: 'blur'}, | ||||
|         thumbUrl: {required: true, message: '请上传封面', trigger: 'blur'}, | ||||
|       }, | ||||
|       cropOps: { | ||||
|         width: "320px", | ||||
| @@ -113,60 +113,42 @@ export default { | ||||
|     submitUpload(file) { | ||||
|       this.$refs['upload1']?.clearFiles(); | ||||
|       this.$refs['upload2']?.clearFiles(); | ||||
|       this.$refs['ruleForm']?.clearValidate('videoFile'); | ||||
|       this.$refs['ruleForm']?.clearValidate('videoUrl'); | ||||
|       const fileType = file.file.name.split(".")[1]; | ||||
|       const size = file.file.size / 1024 / 1024 > 100; | ||||
|       let mp4boxfile = mp4box.createFile(); | ||||
|       const reader = new FileReader(); | ||||
|       reader.readAsArrayBuffer(file.file); | ||||
|       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) { | ||||
|           return this.$message.error("视频大小不能超过100M"); | ||||
|         } | ||||
|       if (size) { | ||||
|         return this.$message.error("视频大小不能超过100M"); | ||||
|       } | ||||
|  | ||||
|         if (fileType && this.accept.indexOf(fileType.toLocaleLowerCase()) > -1) { | ||||
|           let formData = new FormData() | ||||
|           formData.append('file', file.file); | ||||
|           this.instance.post(`/admin/file/add-unlimited`, formData).then(res => { | ||||
|             if (res && res.data) { | ||||
|               let videoList = res.data[0].split(";"); | ||||
|               this.newsInfo.videoFile.splice(0, 1, { | ||||
|                 id: videoList[1], | ||||
|                 url: videoList[0] | ||||
|               }) | ||||
|             } | ||||
|           }) | ||||
|         } else { | ||||
|           return this.$message.error("视频格式错误"); | ||||
|         } | ||||
|  | ||||
|       }; | ||||
|       if (fileType && this.accept.indexOf(fileType.toLocaleLowerCase()) > -1) { | ||||
|         let formData = new FormData() | ||||
|         formData.append('file', file.file); | ||||
|         this.instance.post(`/admin/file/add-unlimited`, formData).then(res => { | ||||
|           if (res && res.data) { | ||||
|             let videoList = res.data[0].split(";"); | ||||
|             this.newsInfo.videoUrl = videoList[0] | ||||
|           } | ||||
|         }) | ||||
|       } else { | ||||
|         return this.$message.error("视频格式错误"); | ||||
|       } | ||||
|     }, | ||||
|     addOrUpdate(status) { | ||||
|       if (Array.isArray(this.newsInfo.thumbUrl)) { | ||||
|         this.newsInfo.thumbUrl = this.newsInfo.thumbUrl[0].url | ||||
|       } | ||||
|       const msg = +status ? '发布成功' : this.isEdit ? '编辑成功' : '保存成功'; | ||||
|       this.instance.post(`/app/appnews/addOrUpdate`, { | ||||
|         ...this.newsInfo, | ||||
|         title: this.newsInfo.title, | ||||
|         videoFile: { | ||||
|           id: this.newsInfo.videoFile[0].id | ||||
|         }, | ||||
|         coverFile: { | ||||
|           id: this.newsInfo.coverFile[0].id | ||||
|         }, | ||||
|         policyType: this.newsInfo.policyType, | ||||
|         areaId: this.areaId, | ||||
|         description: this.newsInfo.description, | ||||
|         videoUrl: this.newsInfo.videoUrl, | ||||
|         thumbUrl: this.newsInfo.thumbUrl, | ||||
|         category: this.newsInfo.category, | ||||
|         type: 1, | ||||
|         id: this.detail.id, | ||||
|         status: this.isEdit ? this.detail.status : status | ||||
|         id: this.newsInfo.id, | ||||
|         status: this.newsInfo.status | ||||
|       }).then(res => { | ||||
|         if (res.code == 0) { | ||||
|           this.$message.success(msg); | ||||
| @@ -180,11 +162,14 @@ export default { | ||||
|         params: {id} | ||||
|       }).then(res => { | ||||
|         if (res?.data) { | ||||
|           this.newsInfo = res.data | ||||
|           this.newsInfo.areaId = res.data.areaId | ||||
|           this.newsInfo.id = res.data.id | ||||
|           this.newsInfo.title = res.data.title; | ||||
|           this.newsInfo.policyType = res.data.policyType | ||||
|           this.newsInfo.videoFile = [{...res.data.videoFile, url: res.data.videoFile.accessUrl}]; | ||||
|           this.newsInfo.coverFile = [{...res.data.coverFile, url: res.data.coverFile.accessUrl}]; | ||||
|           this.newsInfo.description = res.data.description; | ||||
|           this.newsInfo.category = res.data.category | ||||
|           this.newsInfo.videoUrl = res.data.videoUrl; | ||||
|           this.newsInfo.thumbUrl = [{url: res.data.thumbUrl}]; | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|       <ai-card titlePosition="center"> | ||||
|         <template #title> | ||||
|           <h2>{{ detail.title }}</h2> | ||||
|           <p class="subTitle">类型:{{ dict.getLabel('newsCenterPolicyType', +detail.policyType) }}</p> | ||||
|           <p class="subTitle">类型:{{ dict.getLabel('appNewsCategory', +detail.category) }}</p> | ||||
|         </template> | ||||
|         <template slot="right"> | ||||
|           <el-button type="text" size="small" icon="iconfont iconEdit" @click="handleEdit">修改</el-button> | ||||
|   | ||||
| @@ -43,13 +43,12 @@ | ||||
|         <el-table-column slot="options" label="操作" fixed="right" width="260" align="center"> | ||||
|           <template slot-scope="{ row }"> | ||||
|             <div class="table-options"> | ||||
|               <el-button type="text" title="取消发布" v-if="+row.status" @click="changeStatus(row)">取消发布</el-button> | ||||
|               <el-button type="text" v-else title="发布" @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-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> | ||||
|               <el-button type="text" @click="handleDelete(row)" v-if="permissions('app_appnews_del')">删除 | ||||
|               </el-button> | ||||
|               <el-button type="text" @click="handleCopyShare(row)">小程序链接</el-button> | ||||
|             </div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
| @@ -66,8 +65,7 @@ export default { | ||||
|   props: { | ||||
|     instance: Function, | ||||
|     dict: Object, | ||||
|     permissions: Function, | ||||
|     areaId: String | ||||
|     permissions: Function | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
| @@ -94,8 +92,28 @@ export default { | ||||
|             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', | ||||
|           render: (h, {row}) => { | ||||
| @@ -181,8 +199,7 @@ export default { | ||||
|       this.instance.post(`/app/appnews/list`, null, { | ||||
|         params: { | ||||
|           ...this.page, | ||||
|           ...this.searchObj, | ||||
|           areaId: this.areaId | ||||
|           ...this.searchObj | ||||
|         } | ||||
|       }).then(res => { | ||||
|         if (res?.data) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user