main
parent
95f95f2417
commit
c5ee7b915c
|
@ -175,6 +175,10 @@ const infoApi = {
|
||||||
startHis(params) {
|
startHis(params) {
|
||||||
return postPBRequest("/data", params, 56002);
|
return postPBRequest("/data", params, 56002);
|
||||||
},
|
},
|
||||||
|
// 禁用
|
||||||
|
endHis(params) {
|
||||||
|
return postPBRequest("/data", params, 56003);
|
||||||
|
},
|
||||||
// 导出
|
// 导出
|
||||||
exportHis(params) {
|
exportHis(params) {
|
||||||
return postPBRequest("/data", params, 56006);
|
return postPBRequest("/data", params, 56006);
|
||||||
|
|
|
@ -2,128 +2,153 @@
|
||||||
<el-drawer v-model="visible" direction="rtl" :before-close="closeDialog">
|
<el-drawer v-model="visible" direction="rtl" :before-close="closeDialog">
|
||||||
<div class="count-status">
|
<div class="count-status">
|
||||||
<el-tag>最大计数: {{ formData.history && formData.history.max }}</el-tag>
|
<el-tag>最大计数: {{ formData.history && formData.history.max }}</el-tag>
|
||||||
<el-tag>状态: {{ formData.history && !formData.history.enable?"启用":"禁用" }}</el-tag>
|
<el-tag>状态: {{ formData.history && formData.history.enable ? "启用" : "禁用" }}</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<el-table :data="tableData" height="400" border
|
<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="timestamp" label="时间戳" align="center" />
|
||||||
<el-table-column prop="timestamp" label="时间戳" align="center" />
|
<el-table-column prop="value" label="点位值" align="center" />
|
||||||
<el-table-column prop="value" label="点位值" align="center" />
|
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
<el-button type="primary" size="large" @click="setHis">设定</el-button>
|
<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="startHis" v-if="formData.history &&
|
||||||
|
!formData.history.enable">启用</el-button>
|
||||||
|
<el-button type="danger" size="large" v-else @click="startHis">禁用</el-button>
|
||||||
<el-button type="primary" size="large" @click="exportHis">导出</el-button>
|
<el-button type="primary" size="large" @click="exportHis">导出</el-button>
|
||||||
<el-button type="primary" size="large" @click="clearHis">清空</el-button>
|
<el-button type="primary" size="large" @click="clearHis">清空</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<SetHis :dialogVisible="dialogVisible1" :formData="formData" v-if="dialogVisible1"
|
||||||
|
@dialogClose="dialogVisible1 = false" @dialogSuccess="dialogSuccess1">
|
||||||
|
</SetHis>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
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 SetHis from '@/components/SetHis.vue'
|
||||||
|
import axios from "axios";
|
||||||
export default {
|
export default {
|
||||||
props: ["dialogVisible", "formData"],
|
components: {
|
||||||
emits: ["dialogClose", "dialogSuccess"],
|
SetHis
|
||||||
setup(props, ctx) {
|
},
|
||||||
const state = reactive({
|
props: ["dialogVisible", "formData"],
|
||||||
tableData: [],
|
emits: ["dialogClose", "dialogSuccess"],
|
||||||
})
|
setup(props, ctx) {
|
||||||
const ruleFormRef = ref(null);
|
const state = reactive({
|
||||||
|
tableData: [],
|
||||||
|
dialogVisible1: false,
|
||||||
|
})
|
||||||
|
const ruleFormRef = ref(null);
|
||||||
|
|
||||||
const visible = computed(() => {
|
const visible = computed(() => {
|
||||||
return props.dialogVisible;
|
return props.dialogVisible;
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(props.formData)
|
console.log(props.formData)
|
||||||
state.tableData = props.formData.history.history_value
|
state.tableData = props.formData.history.history_value
|
||||||
});
|
});
|
||||||
|
|
||||||
const setHis = async () => {
|
const dialogSuccess1 = () => {
|
||||||
const parm = {
|
state.dialogVisible1 = false;
|
||||||
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 res = await infoApi.setHis(parm);
|
|
||||||
if (res.code == 0) {
|
|
||||||
state.name = res.data.name
|
|
||||||
ElMessage.success(res.message || "请求成功");
|
|
||||||
ctx.emit("dialogClose");
|
ctx.emit("dialogClose");
|
||||||
|
};
|
||||||
|
|
||||||
|
const setHis = async () => {
|
||||||
|
state.dialogVisible1 = true;
|
||||||
}
|
}
|
||||||
}
|
const startHis = async () => {
|
||||||
const startHis = async () => {
|
const parm = {
|
||||||
const parm = {
|
driver_name: props.formData.driver_name,
|
||||||
driver_name: props.formData.driver_name,
|
device_name: props.formData.device_name,
|
||||||
device_name: props.formData.device_name,
|
point_name: props.formData.point_name,
|
||||||
point_name: props.formData.point_name,
|
}
|
||||||
|
const res = props.formData.history && !props.formData.history.enable ? await infoApi.startHis(parm) : await infoApi.endHis(parm);
|
||||||
|
if (res.code == 0) {
|
||||||
|
ElMessage.success(res.data || "请求成功");
|
||||||
|
ctx.emit("dialogClose");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const res = await infoApi.startHis(parm);
|
const exportHis = async () => {
|
||||||
if (res.code == 0) {
|
// const parm = {
|
||||||
ElMessage.success(res.data || "请求成功");
|
// driver_name: props.formData.driver_name,
|
||||||
|
// device_name: props.formData.device_name,
|
||||||
|
// point_name: props.formData.point_name,
|
||||||
|
// }
|
||||||
|
// const res = await infoApi.exportHis(parm);
|
||||||
|
|
||||||
|
// const url = window.URL.createObjectURL(new Blob([res]));
|
||||||
|
|
||||||
|
// window.open(url);
|
||||||
|
const params = {
|
||||||
|
driver_name: props.formData.driver_name,
|
||||||
|
device_name: props.formData.device_name,
|
||||||
|
point_name: props.formData.point_name,
|
||||||
|
};
|
||||||
|
axios({
|
||||||
|
method: "post",
|
||||||
|
url: '/data',
|
||||||
|
headers: {
|
||||||
|
"action": 56006,
|
||||||
|
},
|
||||||
|
data: params,
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
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 closeDialog = () => {
|
||||||
ctx.emit("dialogClose");
|
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);
|
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(new Blob([res]));
|
|
||||||
|
|
||||||
window.open(url);
|
|
||||||
}
|
|
||||||
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 closeDialog = () => {
|
|
||||||
ctx.emit("dialogClose");
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...toRefs(state),
|
...toRefs(state),
|
||||||
visible,
|
visible,
|
||||||
closeDialog,
|
closeDialog,
|
||||||
setHis,
|
setHis,
|
||||||
startHis,
|
startHis,
|
||||||
exportHis,
|
exportHis,
|
||||||
clearHis
|
clearHis,
|
||||||
};
|
dialogSuccess1
|
||||||
},
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</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;
|
||||||
|
|
||||||
>span {
|
>span {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
|
||||||
}
|
|
||||||
.count-status {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-around;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.count-status {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -54,7 +54,8 @@
|
||||||
<legend class="box-ht">专属配置</legend>
|
<legend class="box-ht">专属配置</legend>
|
||||||
<el-form-item label="COM" prop="com_name">
|
<el-form-item label="COM" prop="com_name">
|
||||||
<el-select v-model="form2.com_name" clearable>
|
<el-select v-model="form2.com_name" clearable>
|
||||||
<el-option v-for="item in comArr" :label="item.name" :value="item.name" :key="item.name"></el-option>
|
<el-option v-for="item in comArr" :label="item.name" :value="item.name" :key="item.name" :disabled="item.occupied">
|
||||||
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="数据位" prop="dataBits" clearable>
|
<el-form-item label="数据位" prop="dataBits" clearable>
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog v-model="visible" title="设定" width="25%" :before-close="closeDialog">
|
||||||
|
<el-form :model="addForm" label-width="100px" :rules="rules" ref="ruleFormRef" size="large" label-position="top">
|
||||||
|
<el-form-item label="历史记录最大数量:" prop="max">
|
||||||
|
<el-input v-model="addForm.max" placeholder="请输入历史记录最大数量" clearable type="number" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<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 checkMax = (rule, value, callback) => {
|
||||||
|
let num = Number(value);
|
||||||
|
if (value && (num >= 50 && num <= 250)) {
|
||||||
|
callback();
|
||||||
|
} else {
|
||||||
|
callback(new Error("最大值50-250"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const ruleFormRef = ref(null);
|
||||||
|
const state = reactive({
|
||||||
|
addForm: {
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
max: [
|
||||||
|
{ required: true, message: "请输入历史记录最大数量", trigger: "blur" },
|
||||||
|
{ required: true, validator: checkMax, trigger: "blur" }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const visible = computed(() => {
|
||||||
|
return props.dialogVisible;
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
});
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
ctx.emit("dialogClose");
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveP = async () => {
|
||||||
|
await ruleFormRef.value.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
const parm = {
|
||||||
|
driver_name: props.formData.driver_name,
|
||||||
|
device_name: props.formData.device_name,
|
||||||
|
point_name: props.formData.point_name,
|
||||||
|
history: {
|
||||||
|
max: Number(state.addForm.max)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const res = await infoApi.setHis(parm);
|
||||||
|
if (res.code == 0) {
|
||||||
|
ElMessage.success(res.data || "请求成功");
|
||||||
|
ctx.emit("dialogSuccess");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
visible,
|
||||||
|
closeDialog,
|
||||||
|
saveP,
|
||||||
|
ruleFormRef,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.top-title {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
::v-deep .el-card__body {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns {
|
||||||
|
padding: 15px 0;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-center {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 10px 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -160,9 +160,9 @@ export default {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getTxStatus();
|
getTxStatus();
|
||||||
getPointType();
|
getPointType();
|
||||||
|
getDriverData()
|
||||||
state.intervalId = setInterval(() =>
|
// state.intervalId = setInterval(() =>
|
||||||
getDriverData(), 1000);
|
// getDriverData(), 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|
|
@ -38,8 +38,8 @@ export default ({ mode }) => defineConfig({
|
||||||
// target: 'http://cdcm_test_api.shikicc.com:58909',
|
// target: 'http://cdcm_test_api.shikicc.com:58909',
|
||||||
// target: 'http://frp.shikicc.com:58951',
|
// target: 'http://frp.shikicc.com:58951',
|
||||||
// target: 'https://cdcm_api2.shikicc.com',
|
// target: 'https://cdcm_api2.shikicc.com',
|
||||||
// target: 'https://cdcm_api.shikicc.com',
|
target: 'https://cdcm_api.shikicc.com',
|
||||||
target: 'http://localhost:8088',
|
// target: 'http://localhost:8088',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: path => path.replace(/^\/api/, '/api')
|
rewrite: path => path.replace(/^\/api/, '/api')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue