驱动管理
parent
78bb06db81
commit
7b67cd7221
|
@ -130,6 +130,10 @@ const infoApi = {
|
||||||
editSet(params) {
|
editSet(params) {
|
||||||
return postPBRequest('/driver', params, 54210, params.driver_name)
|
return postPBRequest('/driver', params, 54210, params.driver_name)
|
||||||
},
|
},
|
||||||
|
// 设备导入
|
||||||
|
importDevice(params,driver_name) {
|
||||||
|
return postPBRequest('/driver', params, 54212,driver_name)
|
||||||
|
},
|
||||||
|
|
||||||
// 获取设备列表
|
// 获取设备列表
|
||||||
getSet(params) {
|
getSet(params) {
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog v-model="visible" title="点位导入" width="40%" :before-close="closeDialog">
|
||||||
|
<input style="display:none" type="file" @change="uploadFile" id="fileinput1" class="fileinput" />
|
||||||
|
<label class="filelabel" for="fileinput1">上传</label>
|
||||||
|
<div class="fileName">
|
||||||
|
<span>{{ fileName }}</span>
|
||||||
|
<delete class="delete" @click="delFile" v-if="fileName" />
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button size="large" @click="closeDialog">取消</el-button>
|
||||||
|
<el-button size="large" type="primary" @click="saveP"> 保存 </el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
|
||||||
|
import infoApi from "@/api/infoApi.js";
|
||||||
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
export default {
|
||||||
|
props: ["formData", "dialogVisible"],
|
||||||
|
emits: ["dialogClose", "dialogSuccess"],
|
||||||
|
setup(props, ctx) {
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
fileName: '',
|
||||||
|
importData: new FormData()
|
||||||
|
});
|
||||||
|
const visible = computed(() => {
|
||||||
|
return props.dialogVisible;
|
||||||
|
});
|
||||||
|
const closeDialog = () => {
|
||||||
|
ctx.emit("dialogClose");
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveP = async () => {
|
||||||
|
const res = await infoApi.importDevice(state.importData, props.formData.driver_name);
|
||||||
|
if (res.code == 0) {
|
||||||
|
ElMessage.success(res.message);
|
||||||
|
ctx.emit("dialogSuccess");
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.data || res.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const uploadFile = (e) => {
|
||||||
|
let file = e.target.files[0];
|
||||||
|
state.fileName = file.name;
|
||||||
|
state.importData.append("file", file);
|
||||||
|
}
|
||||||
|
|
||||||
|
const delFile = () => {
|
||||||
|
state.fileName = '';
|
||||||
|
state.formData = new FormData();
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
visible,
|
||||||
|
closeDialog,
|
||||||
|
saveP,
|
||||||
|
uploadFile,
|
||||||
|
delFile
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</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;
|
||||||
|
.delete {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -31,9 +31,6 @@ export default {
|
||||||
return props.dialogVisible;
|
return props.dialogVisible;
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
state.addForm = props.pointData
|
|
||||||
});
|
|
||||||
const closeDialog = () => {
|
const closeDialog = () => {
|
||||||
ctx.emit("dialogClose");
|
ctx.emit("dialogClose");
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<el-drawer v-model="visible" title="驱动配置" direction="rtl" :before-close="closeDialog">
|
<el-drawer v-model="visible" direction="rtl" :before-close="closeDialog">
|
||||||
<fieldset class="box2">
|
<fieldset class="box2">
|
||||||
<legend class="box-ht">驱动名称</legend>
|
<legend class="box-ht">驱动名称</legend>
|
||||||
<el-form label-width="130px">
|
<el-form label-width="130px">
|
||||||
|
|
|
@ -38,16 +38,21 @@
|
||||||
<AddSet :type="type" :formData="formData1" :setData="setData" :dialogVisible="dialogVisible1" v-if="dialogVisible1"
|
<AddSet :type="type" :formData="formData1" :setData="setData" :dialogVisible="dialogVisible1" v-if="dialogVisible1"
|
||||||
@dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
|
@dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
|
||||||
</AddSet>
|
</AddSet>
|
||||||
|
<ExportDevice :formData="formData1" :dialogVisible="dialogVisible2" v-if="dialogVisible2"
|
||||||
|
@dialogClose="dialogVisible2 = false" @dialogSuccess="dialogSuccess2"></ExportDevice>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
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";
|
||||||
import AddSet from "@/components/AddSet.vue";
|
import AddSet from "@/components/AddSet.vue";
|
||||||
|
import ExportDevice from "@/components/ExportDevice.vue";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
AddSet
|
AddSet,
|
||||||
|
ExportDevice
|
||||||
},
|
},
|
||||||
props: ["formData", "dialogVisible", "qudongOptions"],
|
props: ["formData", "dialogVisible", "qudongOptions"],
|
||||||
emits: ["dialogClose", "dialogSuccess"],
|
emits: ["dialogClose", "dialogSuccess"],
|
||||||
|
@ -58,7 +63,8 @@ export default {
|
||||||
setData: {},
|
setData: {},
|
||||||
dialogVisible1: false,
|
dialogVisible1: false,
|
||||||
type: 'I',
|
type: 'I',
|
||||||
driverInfo: {}
|
driverInfo: {},
|
||||||
|
dialogVisible2:false
|
||||||
});
|
});
|
||||||
const visible = computed(() => {
|
const visible = computed(() => {
|
||||||
return props.dialogVisible;
|
return props.dialogVisible;
|
||||||
|
@ -142,12 +148,34 @@ export default {
|
||||||
getSet();
|
getSet();
|
||||||
};
|
};
|
||||||
|
|
||||||
const importData = () => {
|
const dialogSuccess2 = () => {
|
||||||
|
state.dialogVisible2 = false;
|
||||||
|
getSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
const importData = () => {
|
||||||
|
state.formData1 = props.formData;
|
||||||
|
state.dialogVisible2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportData = () => {
|
const exportData = () => {
|
||||||
|
axios({
|
||||||
|
method: "post",
|
||||||
|
url: '/driver',
|
||||||
|
headers: {
|
||||||
|
"action": 54211,
|
||||||
|
'driver_name': props.formData.driver_name
|
||||||
|
},
|
||||||
|
responseType: 'blob',
|
||||||
|
}).then((response) => {
|
||||||
|
let fileName = response.headers['content-disposition'].split('filename=')[1];
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `${decodeURI(fileName.split('"')[1])}`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
}).catch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,7 +188,8 @@ export default {
|
||||||
dialogSuccess1,
|
dialogSuccess1,
|
||||||
importData,
|
importData,
|
||||||
exportData,
|
exportData,
|
||||||
editData
|
editData,
|
||||||
|
dialogSuccess2
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue