导入导出
parent
b05fb583ed
commit
e2333edf17
|
@ -85,9 +85,13 @@ const infoApi = {
|
|||
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) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<label class="filelabel" for="fileinput1">上传</label>
|
||||
<div class="fileName">
|
||||
<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>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
|
@ -25,7 +25,7 @@ export default {
|
|||
|
||||
const state = reactive({
|
||||
fileName: '',
|
||||
formData: new FormData()
|
||||
importData: new FormData()
|
||||
});
|
||||
const visible = computed(() => {
|
||||
return props.dialogVisible;
|
||||
|
@ -39,16 +39,20 @@ export default {
|
|||
};
|
||||
|
||||
const saveP = async () => {
|
||||
const res = await infoApi.importP(state.formData);
|
||||
ctx.emit("dialogSuccess");
|
||||
const res = await infoApi.importP(state.importData, props.formData.name);
|
||||
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];
|
||||
state.fileName = file.name;
|
||||
state.formData.append("file", file);
|
||||
state.formData.append("folderName", file.name);
|
||||
state.importData.append("file", file);
|
||||
}
|
||||
|
||||
const delFile = () => {
|
||||
|
@ -68,17 +72,18 @@ export default {
|
|||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.filelabel {
|
||||
background: #1890ff;
|
||||
border: 1px solid #1890ff;
|
||||
font-weight: 500;
|
||||
padding: 5px 15px 5px;
|
||||
margin: 0 2px 0 6px;
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
}
|
||||
.fileName {
|
||||
margin: 15px 0;
|
||||
font-size:16px;
|
||||
}
|
||||
background: #1890ff;
|
||||
border: 1px solid #1890ff;
|
||||
font-weight: 500;
|
||||
padding: 5px 15px 5px;
|
||||
margin: 0 2px 0 6px;
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.fileName {
|
||||
margin: 15px 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -59,11 +59,13 @@
|
|||
<AddPoint :type="type" :formData="formData1" :pointData="pointData" :dialogVisible="dialogVisible1"
|
||||
v-if="dialogVisible1" @dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
|
||||
</AddPoint>
|
||||
<ExportPoint :formData="formData1" :dialogVisible="dialogVisible2" v-if="dialogVisible2" @dialogClose="dialogVisible2 = false"
|
||||
@dialogSuccess="dialogSuccess2"></ExportPoint>
|
||||
<ExportPoint :formData="formData1" :dialogVisible="dialogVisible2" v-if="dialogVisible2"
|
||||
@dialogClose="dialogVisible2 = false" @dialogSuccess="dialogSuccess2"></ExportPoint>
|
||||
</el-drawer>
|
||||
</template>
|
||||
<script>
|
||||
import { Base64 } from 'js-base64';
|
||||
import axios from "axios";
|
||||
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
|
||||
import infoApi from "@/api/infoApi.js";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
|
@ -199,8 +201,30 @@ export default {
|
|||
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 {
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
<el-button type="primary" @click="manageData">
|
||||
新增设备
|
||||
</el-button>
|
||||
<div>
|
||||
<!-- <div>
|
||||
<el-button type="primary" @click="importData"> 导入 </el-button>
|
||||
<el-button type="primary" @click="exportData"> 导出 </el-button>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<el-table :data="propertiesData" height="640" style="width: 100%" border stripe
|
||||
:header-cell-style="{ background: '#F6F7FC' }">
|
||||
|
|
Loading…
Reference in New Issue