加入了导入导出设定值 #160

Merged
xiaomeng merged 1 commits from pc-master into portal 2024-07-22 08:09:55 +00:00
6 changed files with 209 additions and 4 deletions

View File

@ -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}`,'')
},
};

View File

@ -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;
}

File diff suppressed because one or more lines are too long

View File

@ -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;

View File

@ -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 = {

View File

@ -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>