| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 | <!DOCTYPE html><html><head>  <meta charset="UTF-8">  <!-- 引入样式 -->  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">  <style type="text/css">  	.upload-demo{text-align: center;margin-top: 80px;}  </style></head><body>  <div id="app">  	<el-upload		class="upload-demo"		drag		action="/api/common/update_file"		:on-success="uploadFileSuc"		:data="fileData"		multiple>		<i class="el-icon-upload"></i>		<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>		<div class="el-upload__tip" slot="tip">请上传固件文件</div>	</el-upload>    <el-form ref="form" :model="form" label-width="100px" style="margin: 50px auto;display: block;width: 1200px;">    	<el-form-item label="设备类型:">		    <el-select v-model="form.devType" placeholder="请选择设备类型">		      <el-option label="网关" value="0"></el-option>		      <el-option label="Light" value="1"></el-option>		      <el-option label="Circadian light" value="2"></el-option>		    </el-select>		  </el-form-item>	  <el-form-item label="固件版本:">	    <el-input v-model="form.version" style="width: 200px;display: inline-block;" placeholder="请输入固件版本"></el-input>	  </el-form-item>	  <el-form-item>	    <el-button type="primary" @click="onSubmit" :loading="isLoading">提交固件</el-button>	  </el-form-item>	</el-form>  </div></body>  <!-- 先引入 Vue -->  <script src="https://unpkg.com/vue/dist/vue.js"></script>  <!-- 引入组件库 -->  <script src="https://unpkg.com/element-ui/lib/index.js"></script>  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>  <script>    new Vue({		el: '#app',		data: function() {		return { 			form: {				version: '',				path: '',				devType: '0'			},			isLoading: false,			fileData: {fileType:1}		}		},    	methods: {    		onSubmit: function(){    			if (this.form.path == "") {    				this.$message({			          message: '请上传固件文件',			          type: 'warning'			        });			        return;    			}    			if (this.form.version == "") {    				this.$message({			          message: '请填写固件版本',			          type: 'warning'			        });			        return;    			}    			this.isLoading = true    			var t = this    			axios.post('/api/common/uploadFilewalld', this.form)				.then(function (response) {				  t.isLoading = false				  if (response.data.code == '0000') {				  	t.form.path = '';				  	t.form.version = '';				  	t.$message({			          message: '上传成功',			          type: 'success'			        });				  }else{				  	t.$message.error(response.data.msg);				  }				})				.catch(function (error) {				  console.log(error);				});			},			clearData: function(){				this.form.backInfo = ''			},			uploadFileSuc:function(response, file, fileList){				var path = response.data.path;				this.form.path = path;				console.log(path);			},			get_time: function() {				var myDate = new Date();				var year = myDate.getFullYear();				var month = myDate.getMonth() + 1;				month = month < 10 ? '0'+month : month;				var day = myDate.getDate();				day = day < 10 ? '0'+day : day;				var h = myDate.getHours();				h = h < 10 ? '0'+h : h;				var m = myDate.getMinutes();				m = m < 10 ? '0'+m : m;				var s = myDate.getSeconds();				s = s < 10 ? '0'+s : s;				return year+'-'+month+'-'+day+' '+h+':'+m+':'+s;			}	    }    })  </script></html>
 |