加入了导入导出设定值
This commit is contained in:
		
							parent
							
								
									a054233450
								
							
						
					
					
						commit
						4874e158d8
					
				| @ -615,5 +615,20 @@ getIccid(data){ | ||||
|   manageUploadImage(data) { | ||||
|     return sendUploadRequest(`/user/upload`, data) | ||||
|   }, | ||||
|   | ||||
|    //施肥机系统导入txt的
 | ||||
|    upLoadFsdataWriteValue(data) { | ||||
|     return sendUploadRequest(`/Fsdata/write/value`, data) | ||||
|   }, | ||||
|   //施肥机系统下载txt
 | ||||
|   FsdataReadValuedownload(data) { | ||||
|     return sendPostRequest(`/Fsdata/read/value?devicecode=${data}`,'') | ||||
|   }, | ||||
|   //控制器系统导入
 | ||||
|   upLoadControlWriteValue(data) { | ||||
|     return sendUploadRequest(`/control/write/value`, data) | ||||
|   }, | ||||
|    //控制器系统下载txt
 | ||||
|   controlReadValuedownload(data) { | ||||
|     return sendPostRequest(`/control/read/value?devicecode=${data}`,'') | ||||
|   }, | ||||
| }; | ||||
|  | ||||
| @ -84,6 +84,28 @@ | ||||
|   border: none !important; | ||||
| } | ||||
| 
 | ||||
| .formula .page-content { | ||||
|   position: relative; | ||||
| } | ||||
| 
 | ||||
| .formula .page-content .export { | ||||
|   position: absolute; | ||||
|   right: 30px; | ||||
|   top: 20px; | ||||
|   display: flex; | ||||
|   align-items: center; | ||||
| } | ||||
| 
 | ||||
| .formula .page-content .export .export-btn { | ||||
|   height: 44px; | ||||
|   background: rgba(0, 186, 255, 0.15); | ||||
|   border: 2px solid rgba(0, 186, 255, 0.4); | ||||
|   line-height: 42px; | ||||
|   margin-left: 20px; | ||||
|   padding: 0 10px; | ||||
|   cursor: pointer; | ||||
| } | ||||
| 
 | ||||
| .collapse .el-collapse { | ||||
|   border: none; | ||||
| } | ||||
|  | ||||
							
								
								
									
										2
									
								
								src/assets/css/main.min.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/assets/css/main.min.css
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -93,7 +93,25 @@ | ||||
| .border-none { | ||||
|     border: none !important; | ||||
| } | ||||
| 
 | ||||
| .formula .page-content{ | ||||
|     position: relative; | ||||
|     .export{ | ||||
|         position: absolute; | ||||
|         right: 30px; | ||||
|         top: 20px;       | ||||
|         display: flex; | ||||
|         align-items: center; | ||||
|         .export-btn{ | ||||
|             height: 44px; | ||||
|             background: rgba(0, 186, 255, 0.15); | ||||
|     border: 2px solid rgba(0, 186, 255, 0.4); | ||||
|     line-height: 42px; | ||||
|     margin-left: 20px; | ||||
|     padding: 0 10px; | ||||
|     cursor: pointer; | ||||
|         }  | ||||
|     } | ||||
| } | ||||
| .collapse { | ||||
|     .el-collapse { | ||||
|         border: none; | ||||
|  | ||||
| @ -1,5 +1,12 @@ | ||||
| <template> | ||||
|     <div class="systemSet-con"> | ||||
|         <div class="export"> | ||||
|                 <label for="upInput"> | ||||
|                     <div class="export-btn">导入设定值</div> | ||||
|                 </label> | ||||
|                 <div class="export-btn" @click="downLoadData">导出设定值</div> | ||||
|                 <input ref="fileInput" style="display: none" multiple id="upInput" type="file" accept=".txt" @change="changeTxt" /> | ||||
|             </div> | ||||
|         <div class="table-title"> | ||||
|             <img src="../../assets/image/system.png" alt=""> 系统参数设置 | ||||
|         </div> | ||||
| @ -119,6 +126,73 @@ this.dataInit(); | ||||
|         } | ||||
|     }, | ||||
|     methods: { | ||||
|          //文件下载导出 | ||||
|          downLoadData() { | ||||
|             this.loading = this.$loading({ | ||||
|                 lock: true, | ||||
|                 text: '加载中', | ||||
|                 spinner: 'el-icon-loading', | ||||
|                 background: 'rgba(0, 0, 0, 0.7)' | ||||
|             }); | ||||
|             var store = this.$store.state | ||||
|             var index = store.equipmentIndex; | ||||
|             var devicecode=store.equipmentList[index - 1].deviceId | ||||
|             this.api.controlReadValuedownload(devicecode).then(res => { | ||||
|                 // 创建一个blob对象 | ||||
|                 this.loading.close() | ||||
|                 console.log(res,111); | ||||
|                 const blob = new Blob([res.data], { type: 'text/txt' }); | ||||
|                 console.log(blob,111); | ||||
|                 // 创建一个a标签 | ||||
|                 const url = window.URL.createObjectURL(blob); | ||||
|                 const link = document.createElement('a'); | ||||
|                 link.href = url; | ||||
| 
 | ||||
|                 // 设置文件名 | ||||
|                 link.setAttribute('download', `${devicecode}.txt`); | ||||
| 
 | ||||
|                 // 模拟点击下载 | ||||
|                 document.body.appendChild(link); | ||||
|                 link.click(); | ||||
| 
 | ||||
|                 // 清理资源 | ||||
|                 document.body.removeChild(link); | ||||
|                 window.URL.revokeObjectURL(url); | ||||
|             }) | ||||
|         }, | ||||
|             // 文件上传 | ||||
|             changeTxt(e) { | ||||
|                 this.loading = this.$loading({ | ||||
|                 lock: true, | ||||
|                 text: '加载中', | ||||
|                 spinner: 'el-icon-loading', | ||||
|                 background: 'rgba(0, 0, 0, 0.7)' | ||||
|             }); | ||||
|             var store = this.$store.state | ||||
|             var deviceId=store.equipmentList[store.equipmentIndex - 1].deviceId | ||||
|          | ||||
|       const files = e.target.files | ||||
| 
 | ||||
|       const that = this | ||||
|       for (let i = 0; i < files.length; i++) { | ||||
|         const formData = new FormData() | ||||
|         console.log(files[i]) | ||||
|         formData.append('file', files[i]) | ||||
|         const fileContent = URL.createObjectURL(files[i]) | ||||
|         formData.append('devicecode', deviceId) | ||||
|        this.api.upLoadControlWriteValue(formData).then((res) => { | ||||
|         this.loading.close() | ||||
|           if (res.data.code == 200) { | ||||
|             this.$message.success(res.data.msg); | ||||
|           }else{ | ||||
|             this.$message.error(res.data.msg); | ||||
|           } | ||||
|         }) | ||||
|       } | ||||
|       setTimeout(() => { | ||||
|         this.$refs.fileInput.value = '' | ||||
|       }, 100) | ||||
|     }, | ||||
|         change16to10(code, el) { | ||||
|             var num = parseInt(el.target.value, 16) | ||||
|             var dataNum = { | ||||
|  | ||||
| @ -2,6 +2,13 @@ | ||||
|     <div class="formula irrigateSet systemSet"> | ||||
|         <set-params></set-params> | ||||
|         <div class="page-content "> | ||||
|             <div class="export"> | ||||
|                 <label for="upInput"> | ||||
|                     <div class="export-btn">导入设定值</div> | ||||
|                 </label> | ||||
|                 <div class="export-btn" @click="downLoadData">导出设定值</div> | ||||
|                 <input ref="fileInput" style="display: none" multiple id="upInput" type="file" accept=".txt" @change="changeTxt" /> | ||||
|             </div> | ||||
|             <div class="table-title"> | ||||
|                 <img src="../../assets/image/system.png" alt=""> 系统参数设置 | ||||
|             </div> | ||||
| @ -103,6 +110,73 @@ export default { | ||||
|    } | ||||
|          }, | ||||
|     methods: { | ||||
|              //文件下载导出 | ||||
|              downLoadData() { | ||||
|             this.loading = this.$loading({ | ||||
|                 lock: true, | ||||
|                 text: '加载中', | ||||
|                 spinner: 'el-icon-loading', | ||||
|                 background: 'rgba(0, 0, 0, 0.7)' | ||||
|             }); | ||||
|             var store = this.$store.state | ||||
|             var index = store.equipmentIndex; | ||||
|             var devicecode=store.equipmentList[index - 1].deviceId | ||||
|             this.api.FsdataReadValuedownload(devicecode).then(res => { | ||||
|                 // 创建一个blob对象 | ||||
|                 this.loading.close() | ||||
|                 console.log(res,111); | ||||
|                 const blob = new Blob([res.data], { type: 'text/txt' }); | ||||
|                 console.log(blob,111); | ||||
|                 // 创建一个a标签 | ||||
|                 const url = window.URL.createObjectURL(blob); | ||||
|                 const link = document.createElement('a'); | ||||
|                 link.href = url; | ||||
| 
 | ||||
|                 // 设置文件名 | ||||
|                 link.setAttribute('download', `${devicecode}.txt`); | ||||
| 
 | ||||
|                 // 模拟点击下载 | ||||
|                 document.body.appendChild(link); | ||||
|                 link.click(); | ||||
| 
 | ||||
|                 // 清理资源 | ||||
|                 document.body.removeChild(link); | ||||
|                 window.URL.revokeObjectURL(url); | ||||
|             }) | ||||
|         }, | ||||
|         // 文件上传 | ||||
|         changeTxt(e) { | ||||
|             this.loading = this.$loading({ | ||||
|                 lock: true, | ||||
|                 text: '加载中', | ||||
|                 spinner: 'el-icon-loading', | ||||
|                 background: 'rgba(0, 0, 0, 0.7)' | ||||
|             }); | ||||
|             var store = this.$store.state | ||||
|             var deviceId=store.equipmentList[store.equipmentIndex - 1].deviceId | ||||
|          | ||||
|       const files = e.target.files | ||||
| 
 | ||||
|       const that = this | ||||
|       for (let i = 0; i < files.length; i++) { | ||||
|         const formData = new FormData() | ||||
|         console.log(files[i]) | ||||
|         formData.append('file', files[i]) | ||||
|         const fileContent = URL.createObjectURL(files[i]) | ||||
|         formData.append('devicecode', deviceId) | ||||
|        this.api.upLoadFsdataWriteValue(formData).then((res) => { | ||||
|         this.loading.close() | ||||
|           if (res.data.code == 200) { | ||||
|             this.$message.success(res.data.msg); | ||||
|           }else{ | ||||
|             this.$message.error(res.data.msg); | ||||
|           } | ||||
|         }) | ||||
|       } | ||||
|       setTimeout(() => { | ||||
|         this.$refs.fileInput.value = '' | ||||
|       }, 100) | ||||
|     }, | ||||
|         change16to10(code,el){ | ||||
|             var num=parseInt(el.target.value,16) | ||||
|             var dataNum={ | ||||
| @ -240,5 +314,7 @@ export default { | ||||
| 
 | ||||
| } | ||||
| </script> | ||||
| <style lang="scss"></style> | ||||
| <style lang="scss"> | ||||
| 
 | ||||
| </style> | ||||
|      | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 wb-zhuangyuehuang-vjzzZ
						wb-zhuangyuehuang-vjzzZ