From fc0c102554f509989dd74b199f298a67f266c3c8 Mon Sep 17 00:00:00 2001
From: inleft <inleft@qq.com>
Date: Fri, 25 Feb 2022 12:11:27 +0800
Subject: [PATCH] 虫洞添加,统计代码添加,样式局部调整

---
 src/components/mini/box10-add.vue |  150 +++++++++++++++++++++++--------------------------
 1 files changed, 70 insertions(+), 80 deletions(-)

diff --git a/src/components/mini/box10-add.vue b/src/components/mini/box10-add.vue
index 3b34f34..ab7f4ba 100644
--- a/src/components/mini/box10-add.vue
+++ b/src/components/mini/box10-add.vue
@@ -13,8 +13,11 @@
 
 			<a-form-model-item label="模式切换" prop="common">
 				<a-switch v-model="form.online" />
-				<span class="myTip">
-					本地文件/由系统生成文件
+				<span class="myTip" v-if="form.online">
+					由系统生成文件
+				</span>
+				<span class="myTip" v-else>
+					本地文件上传
 				</span>
 			</a-form-model-item>
 
@@ -28,9 +31,7 @@
 				</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">
 
 					<a-button>
 						<a-icon type="upload" />限 markdown/html
@@ -38,7 +39,7 @@
 				</a-upload>
 			</a-form-model-item>
 
-			<a-form-model-item label="日志内容" v-show="form.online" prop="content">
+			<a-form-model-item label="日志内容" v-show="form.online">
 				<a-input v-model="form.content" type="textarea" placeholder="限10k字数" />
 			</a-form-model-item>
 
@@ -65,12 +66,12 @@
 					</span>
 				</a-form-model-item>
 
-				<a-form-model-item label=" 文件类型">
+				<a-form-model-item label=" 日志类型">
 					<a-radio-group v-model="form.blogType">
-						<a-radio value="Markdown">
+						<a-radio value="1">
 							markdown
 						</a-radio>
-						<a-radio value="Html">
+						<a-radio value="2">
 							html
 						</a-radio>
 					</a-radio-group>
@@ -109,6 +110,7 @@
 					</a-upload> -->
 
 					<a-upload :customRequest="customRequest" name="file" :showUploadList="true" list-type="picture"
+						@change="handleChangeCoverFile"
 						:default-file-list="form.coverFileList">
 						<a-button>
 							<a-icon type="upload" />jpg/png/jpeg..
@@ -154,16 +156,16 @@
 					<div v-show="form.lock ">
 						<a-form-model-item label="阅读权限">
 							<a-radio-group v-model="form.auth">
-								<a-radio value="private">
+								<a-radio value="2">
 									私人
 								</a-radio>
-								<a-radio value="password">
+								<a-radio value="3">
 									密码授权
 								</a-radio>
 							</a-radio-group>
 						</a-form-model-item>
 
-						<a-form-model-item label="授权密码" v-show="form.auth=='password'">
+						<a-form-model-item label="授权密码" v-show="form.auth==3">
 							<a-input-password v-model="form.password" autocomplete='new-password' type="password"
 								placeholder="独立密码">
 								<a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" />
@@ -184,9 +186,12 @@
 	import {
 		sysFileInfoUpload
 	} from '../../api/fileManage.js';
+
 	import {
 		queryBlogArticleType
 	} from '../../api/blogArticleType.js'
+
+
 	export default {
 		beforeMount() {
 			queryBlogArticleType({}).then((res) => {
@@ -199,25 +204,21 @@
 				if (this.form.online) {
 					console.log("内容未填");
 					this.$refs.myForm.validateField('content')
+					if (this.form.content == null || this.form.content == "") {
+						callback(new Error('内容未填'));
+					}
 				} else {
 					console.log("文件未传");
 					this.$refs.myForm.validateField('blogFileList')
+					if (this.form.fileId == null) {
+						callback(new Error('文件未传'));
+					}
 				}
 				callback();
 			};
 
 			return {
 				blogArticleType: [],
-				// blogFileList: [],
-				// coverFileList: [
-				// 	// {
-				// 	// uid: '-1',
-				// 	// name: 'xxx.png',
-				// 	// status: 'done',
-				// 	// url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
-				// 	// thumbUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
-				// 	// } 
-				// ],
 				tags: [],
 				inputVisible: false,
 				inputValue: '',
@@ -235,12 +236,15 @@
 					content: '',
 					class: [],
 					tempSave: false,
-					blogType: "Markdown",
+					blogType: "1",
 					publishDate: "",
 					lock: false,
 					top: false,
-					auth: "private",
+					sliderValue:50,
+					auth: 1,
 					password: "",
+					fileId: null,
+					coverFile: null,
 					blogFileList: [],
 					coverFileList: [],
 				},
@@ -251,7 +255,7 @@
 							trigger: 'blur'
 						},
 						{
-							min: 5,
+							min: 1,
 							max: 50,
 							message: '字数限制1~50',
 							trigger: 'blur'
@@ -266,81 +270,66 @@
 						validator: validateContent,
 						trigger: []
 					}],
-					content: [{
-						max: 10,
-						required: true,
-						message: '至少填一下上传内容',
-						trigger: 'blur'
-					}, ],
-					blogFileList: [{
-						max: 1,
-						required: true,
-						message: '文件未上传',
-					}],
+					// content: [{
+					// 	max: 10,
+					// 	required: true,
+					// 	message: '至少填一下上传内容',
+					// 	trigger: 'blur'
+					// }, ],
+					// blogFileList: [{
+					// 	max: 1,
+					// 	required: true,
+					// 	message: '文件未上传',
+					// }],
 					class: [{
 						required: true,
 						message: '至少选一个分类',
 						trigger: 'blur'
 					}, ],
-					// region: [{
-					// 	required: true,
-					// 	message: 'Please select Activity zone',
-					// 	trigger: 'change'
-					// }],
-					// date1: [{
-					// 	required: true,
-					// 	message: 'Please pick a date',
-					// 	trigger: 'change'
-					// }],
-					// type: [{
-					// 	type: 'array',
-					// 	required: true,
-					// 	message: 'Please select at least one activity type',
-					// 	trigger: 'change',
-					// }, ],
-					// resource: [{
-					// 	required: true,
-					// 	message: 'Please select activity resource',
-					// 	trigger: 'change'
-					// }, ],
-					// desc: [{
-					// 	required: true,
-					// 	message: 'Please input activity form',
-					// 	trigger: 'blur'
-					// }],
+
 				}
 			};
 		},
 		methods: {
 			beforeUpload(file, fileList) {
-				console.log(333);
-				console.log(this.blogFileList);
 				return new Promise((resolve, reject) => {
-					if(fileList.length>=2){
+					if (this.form.fileId != null) {
 						this.$message.error('这里最多上传一个文件');
 						return reject(false);
 					}
-				    // var testmsg=/^image\/(jpeg|png|jpg)$/.test(file.type)
-				    // // var testmsg=/^image\/(md|html|markdown)$/.test(file.type)
-				    // if (!testmsg) {
-				    //   this.$message.error('上传文件格式不对!');
-				    //   return reject(false);
-				    // }
-					
-				    const isLt2M = file.size / 1024 / 1024 <=2//图片大小不超过2MB
-				    if(!isLt2M) {
-				      this.$message.error('上传文件大小不能超过 2M!');
-				      return reject(false);
-				    }
-				    return resolve(true)
-				  });
-				
+					// var testmsg=/^image\/(jpeg|png|jpg)$/.test(file.type)
+					// // var testmsg=/^image\/(md|html|markdown)$/.test(file.type)
+					// if (!testmsg) {
+					//   this.$message.error('上传文件格式不对!');
+					//   return reject(false);
+					// }
+
+					const isLt2M = file.size / 1024 / 1024 <= 2 //图片大小不超过2MB
+					if (!isLt2M) {
+						this.$message.error('上传文件大小不能超过 2M!');
+						return reject(false);
+					}
+					return resolve(true)
+				});
+
 			},
 			handleChange(info) {
 				if (info.file.status !== 'uploading') {
 					console.log(info.file, info.fileList);
 				}
 				if (info.file.status === 'done') {
+					this.form.fileId = info.file.response.data;
+					this.$message.success(`${info.file.name} file uploaded successfully`);
+				} else if (info.file.status === 'error') {
+					this.$message.error(`${info.file.name} file upload failed.`);
+				}
+			},
+			handleChangeCoverFile(info) {
+				if (info.file.status !== 'uploading') {
+					console.log(info.file, info.fileList);
+				}
+				if (info.file.status === 'done') {
+					this.form.coverFile = info.file.response.data;
 					this.$message.success(`${info.file.name} file uploaded successfully`);
 				} else if (info.file.status === 'error') {
 					this.$message.error(`${info.file.name} file upload failed.`);
@@ -355,6 +344,7 @@
 				sysFileInfoUpload(formData).then((res) => {
 					if (res.success) {
 						this.$message.success('上传成功')
+
 						option.onSuccess(res, option.file)
 					} else {
 						this.$message.error('上传失败:' + res.message)

--
Gitblit v1.9.1