From 9e79fe65b9f6a59aec4c5adade592b209391f775 Mon Sep 17 00:00:00 2001
From: kimi <kimi42345@gmail.com>
Date: 星期三, 22 一月 2020 18:38:33 +0800
Subject: [PATCH] upload

---
 src/components/square.vue |  119 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 82 insertions(+), 37 deletions(-)

diff --git a/src/components/square.vue b/src/components/square.vue
index 4c833af..1f95f88 100644
--- a/src/components/square.vue
+++ b/src/components/square.vue
@@ -58,18 +58,19 @@
 	<el-dialog title="鍒涘缓璇濋" :visible.sync="dialogFormVisible">
 	  <el-form :model="form">
 	    <el-form-item label="璇濋鍚嶇О" :label-width="formLabelWidth">
-	      <el-input v-model="form.name" autocomplete="off"></el-input>
+	      <el-input v-model="form.title" autocomplete="off"></el-input>
 	    </el-form-item>
 	    <el-form-item label="璇濋鍐呭" :label-width="formLabelWidth">
 	        <el-input type="textarea"  v-model="form.desp" autocomplete="off"></el-input>
 	    </el-form-item>
 		<el-upload
 		  class="upload-demo"
+		  :action="uploadUrl"
 		  :on-preview="handlePreview"
-		  :on-remove="handleRemove"
-		  :before-remove="beforeRemove"
-		  :limit="1"
+		  :data="form"
+		  :limit="3"
 		  :auto-upload='false'
+		  ref="upload"
 		  :on-exceed="handleExceed"
 		  :file-list="fileList">
 		  <el-button size="small" type="primary">鐐瑰嚮涓婁紶</el-button>
@@ -78,7 +79,7 @@
 	  </el-form>
 	  <div slot="footer" class="dialog-footer">
 	    <el-button @click="dialogFormVisible = false">鍙� 娑�</el-button>
-	    <el-button type="primary" @click="dialogFormVisible = false">纭� 瀹�</el-button>
+	    <el-button type="primary" @click="createTopic">纭� 瀹�</el-button>
 	  </div>
 	</el-dialog>
 	
@@ -89,10 +90,14 @@
 	export default {
 		data() {
 			return {
+				uploadUrl:"/api/api/file/topicUpload",
 				form:{},
-				 fileList: [],
-				 dialogVisible: false,
-				 dialogFormVisible: false,
+				pageno:1,
+				total:0,
+				maxPage:0,
+				fileList: [],
+				dialogVisible: false,
+				dialogFormVisible: false,
 				labelPosition: "right",
 				formInline:{},
 				selectOne:{
@@ -101,28 +106,61 @@
 					attachment:"222"
 				},
 				dataList: [
-					{id:1,attachment:"222",title:"鏍囬", desp:"鎻忚堪鏃跺彂鐢熺籂绾峰徃绗﹀悎鍙屾柟閰掑彑鍙戝姩鏈烘椂浠e嘲宄婚厤鐢甸棿 鍒�鐗囨満姘寸數璐规悳璞嗚厫鐨悳鐨勭湅娉曟垜閮藉彨鎵撶牬鏄寰楁壒鍙戝晢闄勫姞璐圭涓夊搴︾牬鍙戞帴鏀跺埌鍙戝湴鏂瑰氨鎼滃埌鍒板洓鐐瑰垎鍙戝伓璇诲洤", time:"12鍒嗛挓鍓�"},
-					{id:1,attachment:"222",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-					{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
-				],
-				loading: false
+				// 	{id:1,attachment:"222",title:"鏍囬", desp:"鎻忚堪鏃跺彂鐢熺籂绾峰徃绗﹀悎鍙屾柟閰掑彑鍙戝姩鏈烘椂浠e嘲宄婚厤鐢甸棿 鍒�鐗囨満姘寸數璐规悳璞嗚厫鐨悳鐨勭湅娉曟垜閮藉彨鎵撶牬鏄寰楁壒鍙戝晢闄勫姞璐圭涓夊搴︾牬鍙戞帴鏀跺埌鍙戝湴鏂瑰氨鎼滃埌鍒板洓鐐瑰垎鍙戝伓璇诲洤", time:"12鍒嗛挓鍓�"},
+				// 	{id:1,attachment:"222",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				// 	{id:1,attachment:"",title:"11", desp:"111", time:"11111"},
+				 ],
+				loading: false,
+				
 			}
 		},
 		computed: {
 			noMore() {
-				return this.count >= 20
+				return this.maxPage == this.pageno 
 			},
 			disabled() {
 				return this.loading || this.noMore
 			}
 		},
+		mounted() {
+			this.getData();
+		},
 		methods: {
+			createTopic() {
+				let me = this;
+				var userId = localStorage.getItem('userId');
+				if(!userId) {
+					this.$router.push('/login');
+				}
+				this.form.userId = userId;
+				let params = this.form;
+				
+				if(this.fileList.length == 0) {
+					//涓嶅甫闄勪欢
+					let url = "/api/topic/add";
+					this.$axios.get(url, {
+							params
+						})
+						.then(data_ => {
+							if(data_.data.success) {
+								this.$message('鍒涘缓鎴愬姛');
+								me.dialogFormVisible = false;
+							}else {
+								this.$message({message:'璇濋鍒涘缓澶辫触', type: 'warning'});
+							}
+						}).catch(error => {
+							console.log(error);
+						})
+				}else {
+					this.$refs.upload.submit();
+				}
+			},
 			 handleRemove(file, fileList) {
 			        console.log(file, fileList);
 			      },
@@ -130,17 +168,19 @@
 			        console.log(file);
 			      },
 			      handleExceed(files, fileList) {
-			        this.$message.warning(`褰撳墠闄愬埗閫夋嫨 3 涓枃浠讹紝鏈閫夋嫨浜� ${files.length} 涓枃浠讹紝鍏遍�夋嫨浜� ${files.length + fileList.length} 涓枃浠禶);
+			        this.$message.warning(`褰撳墠闄愬埗閫夋嫨 1 涓枃浠讹紝鏈閫夋嫨浜� ${files.length} 涓枃浠讹紝鍏遍�夋嫨浜� ${files.length + fileList.length} 涓枃浠禶);
 			      },
 			      beforeRemove(file, fileList) {
 			        return this.$confirm(`纭畾绉婚櫎 ${ file.name }锛焋);
 			      },
 			load() {
-				// this.loading = true
-				// setTimeout(() => {
-				// 	this.count += 2
-				// 	this.loading = false
-				// }, 2000)
+				
+				if(me.pageno < me.maxPage) {
+					me.pageno++;
+				}
+				query_();
+				
+			
 			},
 			showItem(one) {
 				this.dialogVisible = true;
@@ -157,28 +197,33 @@
 				this.getData(this.formInline);
 			},
 			getData(query) {
+				let me = this;
+				this.loading = true
 				this.loading_table = true;
 				let pageno = this.pagenum;
-				let url = "/api/scheme/page/" + pageno;
-				let params =  {
-					pageSize: this.pagesize
-				};
+				let url = "/api/topic/page/" + this.pageno;
+				let params =  {};
 				if(query){
-					params.name = query.name;
-					params.delay = query.delay;
-					params.finish = query.fiish;
-					params.type = query.type;
+					params.title = query.title;
+					params.desp = query.desp;
 				}
 				this.$axios.get(url, {
 						params
 					})
 					.then(data_ => {
 						console.log(data_);
-						this.tableData = data_.data.data.records; //缁檛ableData璧嬪��
-						this.total = data_.data.data.total;
-						this.loading_table = false;
+						if(data_.data.success) {
+							me.dataList.push.apply(me.dataList, data_.data.data.records)
+							me.total = data_.data.data.total;
+							me.pageno = data_.data.data.pageno;
+							me.maxPage = data_.data.data.maxPage;
+							
+							
+						}
+							me.loading = false
 					}).catch(error => {
 						console.log(error);
+							me.loading = false
 					})
 			},
 		}

--
Gitblit v1.8.0