瓶中沙 2024-08-15 11:36:51 +08:00
parent 5557446d27
commit d903cd1544
6 changed files with 264 additions and 88 deletions

View File

@ -188,6 +188,30 @@ const infoApi = {
// //
stopDevice(params) { stopDevice(params) {
return postPBRequest("/data", params, 56102); return postPBRequest("/data", params, 56102);
} },
//
resetHealth(params) {
return postPBRequest("/data", params, 56007);
},
//
setHis(params) {
return postPBRequest("/data", params, 56004);
},
//
startHis(params) {
return postPBRequest("/data", params, 56002);
},
//
exportHis(params) {
return postPBRequest("/data", params, 56006);
},
//
clearHis(params) {
return postPBRequest("/data", params, 56005);
},
//
writeValue(params) {
return postPBRequest("/data", params, 56001);
},
}; };
export default infoApi; export default infoApi;

View File

@ -1,54 +1,56 @@
<template> <template>
<el-drawer v-model="visible" direction="rtl" :before-close="closeDialog"> <el-drawer v-model="visible" direction="rtl" :before-close="closeDialog">
<div class="btns">
<el-button type="primary" size="large" @click="resetCount"></el-button> <fieldset class="box2 title_box2">
</div> <legend class="box-ht">点位名称</legend>
<span>{{ formData.point_name }}</span>
<el-button type="primary" size="large" @click="resetHealth"></el-button>
</fieldset>
<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">
<el-form-item label="总计数"> <el-form-item label="总计数">
<el-input disabled v-model="health[healthObj.status]"></el-input> <el-input disabled v-model="formData.read_health.total_count"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="成功计数"> <el-form-item label="成功计数">
<el-input disabled v-model="health[healthObj.status]"></el-input> <el-input disabled v-model="formData.read_health.success_count"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="最后一次成功时间"> <el-form-item label="最后一次成功时间">
<el-input disabled v-model="healthObj.last_success_time"></el-input> <el-input disabled v-model="formData.read_health.last_success_time"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="失败计数"> <el-form-item label="失败计数">
<el-input disabled v-model="health[healthObj.status]"></el-input> <el-input disabled v-model="formData.read_health.failure_count"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="最后一次失败时间"> <el-form-item label="最后一次失败时间">
<el-input disabled v-model="healthObj.last_failure_ctime"></el-input> <el-input disabled v-model="formData.read_health.last_failure_ctime"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="最后一次失败原因"> <el-form-item label="最后一次失败原因">
<el-input disabled v-model="healthObj.last_failure_cause"></el-input> <el-input disabled v-model="formData.read_health.last_failure_cause"></el-input>
</el-form-item> </el-form-item>
</el-form> --> </el-form>
</fieldset> </fieldset>
<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">
<el-form-item label="总计数"> <el-form-item label="总计数">
<el-input disabled v-model="health[healthObj.status]"></el-input> <el-input disabled v-model="formData.write_health.total_count"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="成功计数"> <el-form-item label="成功计数">
<el-input disabled v-model="health[healthObj.status]"></el-input> <el-input disabled v-model="formData.write_health.success_count"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="最后一次成功时间"> <el-form-item label="最后一次成功时间">
<el-input disabled v-model="healthObj.last_success_time"></el-input> <el-input disabled v-model="formData.write_health.last_success_time"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="失败计数"> <el-form-item label="失败计数">
<el-input disabled v-model="health[healthObj.status]"></el-input> <el-input disabled v-model="formData.write_health.failure_count"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="最后一次失败时间"> <el-form-item label="最后一次失败时间">
<el-input disabled v-model="healthObj.last_failure_ctime"></el-input> <el-input disabled v-model="formData.write_health.last_failure_ctime"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="最后一次失败原因"> <el-form-item label="最后一次失败原因">
<el-input disabled v-model="healthObj.last_failure_cause"></el-input> <el-input disabled v-model="formData.write_health.last_failure_cause"></el-input>
</el-form-item> </el-form-item>
</el-form> --> </el-form>
</fieldset> </fieldset>
</el-drawer> </el-drawer>
</template> </template>
@ -74,27 +76,17 @@ export default {
}); });
onMounted(() => { onMounted(() => {
getD();
}); });
const getD = async () => { const resetHealth = async () => {
// const parm = { const parm = {
// driver_name: props.formData.driver_name driver_name: props.formData.driver_name,
// } device_name: props.formData.device_name,
// const res = await infoApi.getD(parm); point_name: props.formData.point_name
// if (res.code == 0) { }
// state.name = res.data.name const res = await infoApi.resetHealth(parm);
// state.healthObj = res.data.health; if (res.code == 0) {
// state.countObj = res.data.count; ElMessage.success(res.message || "请求成功");
// } }
};
const resetCount = async () => {
// const parm = {
// name: props.formData.name
// }
// const res = await infoApi.resetCount(parm);
// if (res.code == 0) {
// getD();
// }
} }
const closeDialog = () => { const closeDialog = () => {
ctx.emit("dialogClose"); ctx.emit("dialogClose");
@ -105,13 +97,13 @@ export default {
...toRefs(state), ...toRefs(state),
visible, visible,
closeDialog, closeDialog,
getD, resetHealth
resetCount
}; };
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .el-form-item__content { ::v-deep .el-form-item__content {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
@ -120,4 +112,9 @@ export default {
margin-left: 10px; margin-left: 10px;
} }
} }
.title_box2 {
display: flex;
justify-content: space-between;
}
</style> </style>

View File

@ -1,13 +1,25 @@
<template> <template>
<el-drawer v-model="visible" direction="rtl" :before-close="closeDialog"> <el-drawer v-model="visible" direction="rtl" :before-close="closeDialog">
<div class="btns"> <div class="count-status">
<el-button type="primary" size="large" @click="set"></el-button> <el-tag>最大计数: {{ formData.history && formData.history.max }}</el-tag>
<el-button type="primary" size="large" @click="start"></el-button> <el-tag>状态: {{ formData.history && !formData.history.enable?"启用":"禁用" }}</el-tag>
<el-button type="primary" size="large" @click="expor"></el-button>
<el-button type="primary" size="large" @click="clear"></el-button>
</div> </div>
<div>
<el-table :data="tableData" height="400" border
:header-cell-style="{ background: '#F6F7FC' }" size="large">
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="timestamp" label="时间戳" align="center" />
<el-table-column prop="value" label="点位值" align="center" />
</el-table>
</div>
<div class="btns">
<el-button type="primary" size="large" @click="setHis"></el-button>
<el-button type="primary" size="large" @click="startHis"></el-button>
<el-button type="primary" size="large" @click="exportHis"></el-button>
<el-button type="primary" size="large" @click="clearHis"></el-button>
</div>
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
@ -18,40 +30,71 @@ export default {
props: ["dialogVisible", "formData"], props: ["dialogVisible", "formData"],
emits: ["dialogClose", "dialogSuccess"], emits: ["dialogClose", "dialogSuccess"],
setup(props, ctx) { setup(props, ctx) {
const ruleFormRef = ref(null);
const state = reactive({ const state = reactive({
tableData: [],
}) })
const ruleFormRef = ref(null);
const visible = computed(() => { const visible = computed(() => {
return props.dialogVisible; return props.dialogVisible;
}); });
onMounted(() => { onMounted(() => {
getHis(); console.log(props.formData)
state.tableData = props.formData.history.history_value
}); });
const getHis = async () => {
// const parm = {
// driver_name: props.formData.driver_name
// }
// const res = await infoApi.getD(parm);
// if (res.code == 0) {
// state.name = res.data.name
// state.healthObj = res.data.health;
// state.countObj = res.data.count;
// }
};
const set = async () => {
const setHis = async () => {
const parm = {
driver_name: props.formData.driver_name,
device_name: props.formData.device_name,
point_name: props.formData.point_name,
history: {
max: props.formData.history.max
} }
const start = async () => {
} }
const expor = async () => { const res = await infoApi.setHis(parm);
if (res.code == 0) {
state.name = res.data.name
ElMessage.success(res.message || "请求成功");
ctx.emit("dialogClose");
}
}
const startHis = async () => {
const parm = {
driver_name: props.formData.driver_name,
device_name: props.formData.device_name,
point_name: props.formData.point_name,
}
const res = await infoApi.startHis(parm);
if (res.code == 0) {
ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose");
}
}
const exportHis = async () => {
const parm = {
driver_name: props.formData.driver_name,
device_name: props.formData.device_name,
point_name: props.formData.point_name,
}
const res = await infoApi.exportHis(parm);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ctx.emit("dialogClose");
}
}
const clearHis = async () => {
const parm = {
driver_name: props.formData.driver_name,
device_name: props.formData.device_name,
point_name: props.formData.point_name,
}
const res = await infoApi.clearHis(parm);
if (res.code == 0) {
ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose");
} }
const clear = async () => {
} }
const closeDialog = () => { const closeDialog = () => {
ctx.emit("dialogClose"); ctx.emit("dialogClose");
@ -62,11 +105,10 @@ export default {
...toRefs(state), ...toRefs(state),
visible, visible,
closeDialog, closeDialog,
getHis, setHis,
set, startHis,
start, exportHis,
expor, clearHis
clear
}; };
}, },
}; };
@ -80,4 +122,8 @@ export default {
margin-left: 10px; margin-left: 10px;
} }
} }
.count-status {
display: flex;
justify-content: space-around;
}
</style> </style>

70
src/components/Write.vue Normal file
View File

@ -0,0 +1,70 @@
<template>
<el-drawer v-model="visible" direction="rtl" :before-close="closeDialog">
<div class="count-status">
<el-input-number v-model="writeV" style="width: 240px" placeholder="请输入点位值" />
</div>
<div class="btns">
<el-button type="primary" size="large" @click="writeValue"></el-button>
</div>
</el-drawer>
</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: ["dialogVisible", "formData"],
emits: ["dialogClose", "dialogSuccess"],
setup(props, ctx) {
const state = reactive({
writeV: '',
})
const visible = computed(() => {
return props.dialogVisible;
});
onMounted(() => {
});
const writeValue = async () => {
const parm = {
driver_name: props.formData.driver_name,
device_name: props.formData.device_name,
point_name: props.formData.point_name,
point_in_value: state.writeV
}
const res = await infoApi.writeValue(parm);
if (res.code == 0) {
ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose");
}
}
const closeDialog = () => {
ctx.emit("dialogClose");
};
return {
...toRefs(state),
visible,
closeDialog,
writeValue
};
},
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__content {
display: flex;
flex-wrap: nowrap;
>span {
margin-left: 10px;
}
}
.count-status {
display: flex;
justify-content: space-around;
}
</style>

View File

@ -319,3 +319,6 @@ s {
.height100 { .height100 {
height:100%; height:100%;
} }
.el-drawer__header {
margin-bottom: 0 !important;
}

View File

@ -15,7 +15,7 @@
<el-tag>通讯名称: {{ curDriver.driver_name }}</el-tag> <el-tag>通讯名称: {{ curDriver.driver_name }}</el-tag>
<el-tag>通讯总计数: {{ curDriver.health && curDriver.health.total_count }}</el-tag> <el-tag>通讯总计数: {{ curDriver.health && curDriver.health.total_count }}</el-tag>
<el-tag>通讯描述: {{ curDriver.driver_description }}</el-tag> <el-tag>通讯描述: {{ curDriver.driver_description }}</el-tag>
<el-tag>通讯状态: {{ curDriver.driver_status }}</el-tag> <el-tag>通讯状态: {{ txStatus[curDriver.driver_status] }}</el-tag>
<el-tag>通讯成功计数: {{ curDriver.health && curDriver.health.success_count }}</el-tag> <el-tag>通讯成功计数: {{ curDriver.health && curDriver.health.success_count }}</el-tag>
<el-tag>通讯失败计数: {{ curDriver.health && curDriver.health.failure_count }}</el-tag> <el-tag>通讯失败计数: {{ curDriver.health && curDriver.health.failure_count }}</el-tag>
<el-tag>通讯最后一次成功时间: {{ curDriver.health && curDriver.health.last_success_time }}</el-tag> <el-tag>通讯最后一次成功时间: {{ curDriver.health && curDriver.health.last_success_time }}</el-tag>
@ -45,16 +45,16 @@
<div class="box-info"> <div class="box-info">
<el-tag>设备名称: {{ curDevice.device_name }}</el-tag> <el-tag>设备名称: {{ curDevice.device_name }}</el-tag>
<el-tag>设备描述: {{ curDevice.device_description }}</el-tag> <el-tag>设备描述: {{ curDevice.device_description }}</el-tag>
<el-button type="danger" @click="doDevice">{{!curDevice.device_disable? '' : ''}}</el-button> <el-button type="danger" @click="doDevice">{{!curDevice.device_disable? '' : ''}}</el-button>
</div> </div>
</div> </div>
<el-table :data="tableData" height="400" border :row-class-name="tableRowClassName" <el-table :data="tableData" height="400" border
:header-cell-style="{ background: '#F6F7FC' }" size="large"> :header-cell-style="{ background: '#F6F7FC' }" size="large">
<el-table-column type="index" label="序号" width="80" align="center" /> <el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="point_name" label="名称" width="150" align="center" show-overflow-tooltip /> <el-table-column prop="point_name" label="名称" width="150" align="center" show-overflow-tooltip />
<el-table-column prop="point_description" label="描述" align="center" show-overflow-tooltip /> <el-table-column prop="point_description" label="描述" align="center" show-overflow-tooltip />
<el-table-column prop="point_quality" label="质量" width="100" align="center" show-overflow-tooltip /> <el-table-column prop="point_quality" label="质量" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="point_value" label="值" width="100" align="center" show-overflow-tooltip /> <el-table-column prop="point_in_value" label="点位值" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="point_unit" label="单位" width="100" align="center" show-overflow-tooltip /> <el-table-column prop="point_unit" label="单位" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="point_type" label="类型" width="100" align="center" show-overflow-tooltip /> <el-table-column prop="point_type" label="类型" width="100" align="center" show-overflow-tooltip />
<el-table-column prop="point_timestamp" label="时间戳" width="200" align="center" show-overflow-tooltip /> <el-table-column prop="point_timestamp" label="时间戳" width="200" align="center" show-overflow-tooltip />
@ -63,10 +63,10 @@
<el-button type="success" size="large" @click="openHis(scope.row)"> <el-button type="success" size="large" @click="openHis(scope.row)">
历史 历史
</el-button> </el-button>
<el-button type="warning" size="large" @click="openDe(scope.row)" v-if="scope.row.point_permissions ==2"> <el-button type="warning" size="large" @click="openDe(scope.row)" >
详情 详情
</el-button> </el-button>
<el-button type="primary" size="large" v-if="scope.row.point_permissions ==2"> <el-button type="primary" size="large" @click="openWrite(scope.row)" >
写值 写值
</el-button> </el-button>
</template> </template>
@ -93,6 +93,14 @@
@dialogSuccess="dialogSuccess" @dialogSuccess="dialogSuccess"
> >
</His> </His>
<Write
:formData="formData"
:dialogVisible="dialogVisible2"
v-if="dialogVisible2"
@dialogClose="dialogClose"
@dialogSuccess="dialogSuccess"
>
</Write>
</el-card> </el-card>
</template> </template>
@ -102,10 +110,13 @@ import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import De from "@/components/De.vue"; import De from "@/components/De.vue";
import His from "@/components/His.vue"; import His from "@/components/His.vue";
import Write from "@/components/Write.vue";
export default { export default {
name: "data", name: "data",
components: { components: {
De De,
His,
Write
}, },
setup() { setup() {
@ -128,10 +139,13 @@ export default {
formData: {}, formData: {},
dialogVisible: false, dialogVisible: false,
dialogVisible1: false, dialogVisible1: false,
dialogVisible2: false,
txStatus: [] //
}); });
onMounted(() => { onMounted(() => {
getDriverData(); getDriverData();
getTxStatus();
}); });
const getDriverData = async () => { const getDriverData = async () => {
@ -147,6 +161,16 @@ export default {
} }
//
const getTxStatus = async () => {
const res = await infoApi.getTxStatus();
if (res.code == 0) {
state.txStatus = res.data;
}
};
const changeQd = (i, item) => { const changeQd = (i, item) => {
state.indexi = i; state.indexi = i;
state.curDriver = item; state.curDriver = item;
@ -191,26 +215,30 @@ export default {
} }
} }
//
const doDevice = async () => { const doDevice = async () => {
const param = { const param = {
driver_name: state.curDevice.driver_name, driver_name: state.curDevice.driver_name,
device_name: state.curDevice.device_name device_name: state.curDevice.device_name
} }
const res = !state.curDevice.device_disable? await infoApi.startDevice(param): await infoApi.stopDevice(param); const res = !state.curDevice.device_disable? await infoApi.stopDevice(param): await infoApi.startDevice(param);
if (res.code == 0) { if (res.code == 0) {
ElMessage.success(res.message || '请求成功'); ElMessage.success(res.message || '请求成功');
getDeviceData(state.curDevice.driver_name); getDeviceData(state.curDriver.driver_name);
getPointData(state.curDevice);
} }
} }
const dialogClose = () => { const dialogClose = () => {
state.dialogVisible = false; state.dialogVisible = false;
state.dialogVisible1 = false; state.dialogVisible1 = false;
state.dialogVisible2= false;
//
getPointData(state.curDevice);
}; };
const dialogSuccess = () => { const dialogSuccess = () => {
state.dialogVisible = false; state.dialogVisible = false;
state.dialogVisible1 = false; state.dialogVisible1 = false;
state.dialogVisible2= false;
}; };
const openDe = (item) => { const openDe = (item) => {
state.formData = JSON.parse(JSON.stringify(item)); state.formData = JSON.parse(JSON.stringify(item));
@ -221,6 +249,11 @@ export default {
state.formData = JSON.parse(JSON.stringify(item)); state.formData = JSON.parse(JSON.stringify(item));
state.dialogVisible1 = true; state.dialogVisible1 = true;
}
const openWrite = (item) => {
state.formData = JSON.parse(JSON.stringify(item));
state.dialogVisible2 = true;
} }
return { return {
...toRefs(state), ...toRefs(state),
@ -231,7 +264,9 @@ export default {
dialogClose, dialogClose,
dialogSuccess, dialogSuccess,
openDe, openDe,
openHis openHis,
openWrite,
getTxStatus
}; };
}, },
}; };
@ -321,6 +356,7 @@ export default {
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 0 10px;
.el-tag { .el-tag {
margin: 10px; margin: 10px;
} }