导入导出
parent
b05fb583ed
commit
e2333edf17
|
@ -85,9 +85,13 @@ const infoApi = {
|
||||||
return postPBRequest('/template', params, 53310, params.template_name)
|
return postPBRequest('/template', params, 53310, params.template_name)
|
||||||
},
|
},
|
||||||
// 点位导入
|
// 点位导入
|
||||||
|
importP(params,template_name) {
|
||||||
|
return postPBRequest('/template', params, 53212,template_name)
|
||||||
|
},
|
||||||
|
|
||||||
importP(params) {
|
// 点位导出
|
||||||
return postPBRequest('/template', params, 53310, params.template_name)
|
exportP(params) {
|
||||||
|
return postPBRequest('/template', params, 53211, params.template_name)
|
||||||
},
|
},
|
||||||
// 驱动列表查询
|
// 驱动列表查询
|
||||||
getTx(params) {
|
getTx(params) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<label class="filelabel" for="fileinput1">上传</label>
|
<label class="filelabel" for="fileinput1">上传</label>
|
||||||
<div class="fileName">
|
<div class="fileName">
|
||||||
<span>{{ fileName }}</span>
|
<span>{{ fileName }}</span>
|
||||||
<delete style="width: 18px; height: 18px; margin-left: 8px;" @click="delFile" v-if="fileName"/>
|
<delete style="width: 18px; height: 18px; margin-left: 8px;" @click="delFile" v-if="fileName" />
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
|
@ -25,7 +25,7 @@ export default {
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
fileName: '',
|
fileName: '',
|
||||||
formData: new FormData()
|
importData: new FormData()
|
||||||
});
|
});
|
||||||
const visible = computed(() => {
|
const visible = computed(() => {
|
||||||
return props.dialogVisible;
|
return props.dialogVisible;
|
||||||
|
@ -39,16 +39,20 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveP = async () => {
|
const saveP = async () => {
|
||||||
const res = await infoApi.importP(state.formData);
|
const res = await infoApi.importP(state.importData, props.formData.name);
|
||||||
ctx.emit("dialogSuccess");
|
if (res.code == 0) {
|
||||||
|
ElMessage.success(res.message);
|
||||||
|
ctx.emit("dialogSuccess");
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.data || res.message);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const uploadFile = (e) => {
|
const uploadFile = (e) => {
|
||||||
let file = e.target.files[0];
|
let file = e.target.files[0];
|
||||||
state.fileName = file.name;
|
state.fileName = file.name;
|
||||||
state.formData.append("file", file);
|
state.importData.append("file", file);
|
||||||
state.formData.append("folderName", file.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const delFile = () => {
|
const delFile = () => {
|
||||||
|
@ -68,17 +72,18 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.filelabel {
|
.filelabel {
|
||||||
background: #1890ff;
|
background: #1890ff;
|
||||||
border: 1px solid #1890ff;
|
border: 1px solid #1890ff;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
padding: 5px 15px 5px;
|
padding: 5px 15px 5px;
|
||||||
margin: 0 2px 0 6px;
|
margin: 0 2px 0 6px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
.fileName {
|
|
||||||
margin: 15px 0;
|
.fileName {
|
||||||
font-size:16px;
|
margin: 15px 0;
|
||||||
}
|
font-size: 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -59,11 +59,13 @@
|
||||||
<AddPoint :type="type" :formData="formData1" :pointData="pointData" :dialogVisible="dialogVisible1"
|
<AddPoint :type="type" :formData="formData1" :pointData="pointData" :dialogVisible="dialogVisible1"
|
||||||
v-if="dialogVisible1" @dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
|
v-if="dialogVisible1" @dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
|
||||||
</AddPoint>
|
</AddPoint>
|
||||||
<ExportPoint :formData="formData1" :dialogVisible="dialogVisible2" v-if="dialogVisible2" @dialogClose="dialogVisible2 = false"
|
<ExportPoint :formData="formData1" :dialogVisible="dialogVisible2" v-if="dialogVisible2"
|
||||||
@dialogSuccess="dialogSuccess2"></ExportPoint>
|
@dialogClose="dialogVisible2 = false" @dialogSuccess="dialogSuccess2"></ExportPoint>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { Base64 } from 'js-base64';
|
||||||
|
import axios from "axios";
|
||||||
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
|
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
|
||||||
import infoApi from "@/api/infoApi.js";
|
import infoApi from "@/api/infoApi.js";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
@ -199,8 +201,30 @@ export default {
|
||||||
state.dialogVisible2 = true;
|
state.dialogVisible2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportData = () => {
|
const exportData = async () => {
|
||||||
|
axios({
|
||||||
|
method: "post",
|
||||||
|
url: '/template',
|
||||||
|
headers: {
|
||||||
|
"action": 53211,
|
||||||
|
'template_name': Base64.encode(props.formData.name)
|
||||||
|
},
|
||||||
|
responseType: 'blob',
|
||||||
|
}).then((response) => {
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response]));
|
||||||
|
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', props.formData.name +'_points.csv');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
// const link = document.createElement('a');
|
||||||
|
// link.href = url;
|
||||||
|
// link.setAttribute('download', '_points.csv');
|
||||||
|
// link.click();
|
||||||
|
// document.body.removechild(link);
|
||||||
|
// window.URL.revokeobjectURL(url);
|
||||||
|
}).catch(error => console.log(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
<el-button type="primary" @click="manageData">
|
<el-button type="primary" @click="manageData">
|
||||||
新增设备
|
新增设备
|
||||||
</el-button>
|
</el-button>
|
||||||
<div>
|
<!-- <div>
|
||||||
<el-button type="primary" @click="importData"> 导入 </el-button>
|
<el-button type="primary" @click="importData"> 导入 </el-button>
|
||||||
<el-button type="primary" @click="exportData"> 导出 </el-button>
|
<el-button type="primary" @click="exportData"> 导出 </el-button>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="propertiesData" height="640" style="width: 100%" border stripe
|
<el-table :data="propertiesData" height="640" style="width: 100%" border stripe
|
||||||
:header-cell-style="{ background: '#F6F7FC' }">
|
:header-cell-style="{ background: '#F6F7FC' }">
|
||||||
|
|
Loading…
Reference in New Issue