From 10572998aa54d61c45df3e334eb01e44a15df729 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Wed, 10 Aug 2022 18:35:59 +0800
Subject: [PATCH] 常量提取,优化视频模块布局

---
 src/components/mini/box10-add.vue |   49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/components/mini/box10-add.vue b/src/components/mini/box10-add.vue
index 5a8b1f0..705e398 100644
--- a/src/components/mini/box10-add.vue
+++ b/src/components/mini/box10-add.vue
@@ -21,17 +21,11 @@
 				</span>
 			</a-form-model-item>
 
-
 			<a-form-model-item label="日志文件" v-show="!form.online">
-				<!-- <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
-					:default-file-list="form.blogFileList">
-					<a-button>
-						<a-icon type="upload" /> 限 markdown/html
-					</a-button>
-				</a-upload> -->
 
 				<a-upload :customRequest="customRequest" name="file" :showUploadList="true" @change="handleChange"
-					:default-file-list="form.blogFileList" :beforeUpload="beforeUpload">
+					:default-file-list="form.blogFileList" :beforeUpload="beforeUpload"
+					:data="{'fileType':fileTypeMarkDown}">
 
 					<a-button>
 						<a-icon type="upload" />限 markdown/html
@@ -69,13 +63,16 @@
 				<a-form-model-item label=" 日志类型">
 					<a-select v-model="form.blogType" mode="default" placeholder=""
 						:getPopupContainer="getCalendarContainer()">
-						<a-select-option   value="1">
+						<a-select-option value="1">
 							markdown
 						</a-select-option>
-						<a-select-option   value="2">
+						<a-select-option value="2">
 							html
 						</a-select-option>
-						<a-select-option   value="5">
+						<a-select-option value="3">
+							video
+						</a-select-option>
+						<a-select-option value="5">
 							fast(闪念)
 						</a-select-option>
 					</a-select>
@@ -106,16 +103,9 @@
 
 
 				<a-form-model-item label="封面">
-					<!-- <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76" list-type="picture"
-						:default-file-list="form.coverFileList" class="upload-list-inline">
-						<a-button>
-							<a-icon type="upload" /> jpg/png/jpeg..
-						</a-button>
-					</a-upload> -->
-
 					<a-upload :customRequest="customRequest" name="file" :showUploadList="true" list-type="picture"
-						@change="handleChangeCoverFile"
-						:default-file-list="form.coverFileList">
+						@change="handleChangeCoverFile" :default-file-list="form.coverFileList" 
+						:beforeUpload="beforeUploadCover" :data="{'fileType':fileTypeCover}">
 						<a-button>
 							<a-icon type="upload" />jpg/png/jpeg..
 						</a-button>
@@ -188,13 +178,15 @@
 <script>
 	import moment from "moment";
 	import {
-		sysFileInfoUpload
+		sysFileInfoUpload,
+		myFileInfoUpload
 	} from '../../api/fileManage.js';
 
 	import {
 		queryBlogArticleType
 	} from '../../api/blogArticleType.js'
 
+	import myConstant from "../../config/myConstant.js"
 
 	export default {
 		beforeMount() {
@@ -222,6 +214,8 @@
 			};
 
 			return {
+				fileTypeMarkDown: myConstant.fileTypeMarkDown,
+				fileTypeCover: myConstant.fileTypeCover,
 				blogArticleType: [],
 				tags: [],
 				inputVisible: false,
@@ -244,7 +238,7 @@
 					publishDate: "",
 					lock: false,
 					top: false,
-					sliderValue:50,
+					sliderValue: 50,
 					auth: 1,
 					password: "",
 					fileId: null,
@@ -295,6 +289,13 @@
 			};
 		},
 		methods: {
+
+			beforeUploadCover(file, fileList) {
+				if (this.form.coverFileList.length > 1) {
+					this.$message.error('这里最多上传一个文件');
+					return false;
+				}
+			},
 			beforeUpload(file, fileList) {
 				return new Promise((resolve, reject) => {
 					if (this.form.fileId != null) {
@@ -345,7 +346,9 @@
 			customRequest(option) {
 				const formData = new FormData()
 				formData.append('file', option.file)
-				sysFileInfoUpload(formData).then((res) => {
+				formData.append('fileType', option.data.fileType)
+				formData.append('authCode', this.form.secret)
+				myFileInfoUpload(formData).then((res) => {
 					if (res.success) {
 						this.$message.success('上传成功')
 

--
Gitblit v1.9.1