瓶中沙 2024-06-25 15:33:15 +08:00
parent b026d8f8cf
commit f7af27b6ed
5 changed files with 198 additions and 31 deletions

View File

@ -136,6 +136,14 @@ const infoApi = {
getSet(params) {
return postPBRequest('/driver', params, 54010, params.driver_name)
},
//
getD(params) {
return postPBRequest('/driver', params, 54003, params.driver_name)
},
//
resetCount(params) {
return postPBRequest('/driver', params, 54201, params.driver_name)
},
//
delSet(params) {
return postPBRequest('/driver', params, 54310, params.driver_name)
@ -143,19 +151,19 @@ const infoApi = {
// ,
startStatus(params) {
return postPBRequest("/driver", params, 54202,params.name);
return postPBRequest("/driver", params, 54400,params.name);
},
//
stopStatus(params) {
return postPBRequest("/driver", params, 54203,params.name);
return postPBRequest("/driver", params, 54500,params.name);
},
//
addPz(params, header) {
return postPBRequest("/driver", params, 54201, header.driver_name);
return postPBRequest("/driver", params, 54202, header.driver_name);
},
// com
getCom() {
return postPBRequest("/info", null, 51001);
getCom(params) {
return postPBRequest("/info", null, 51001, params.name);
},
// //
// getSc(params) {

109
src/components/Details.vue Normal file
View File

@ -0,0 +1,109 @@
<template>
<el-drawer v-model="visible" title= "详情" direction="rtl" :before-close="closeDialog">
<el-form label-width="130px">
<el-form-item label="驱动名称:">
{{ name }}
</el-form-item>
<el-form-item label="健康状态">
<el-input disabled v-model="health[healthObj.status]"></el-input>
</el-form-item>
<el-form-item label="最后一次成功时间">
<el-input disabled v-model="healthObj.last_success_time"></el-input>
</el-form-item>
<el-form-item label="最后一次失败时间">
<el-input disabled v-model="healthObj.last_failure_ctime"></el-input>
</el-form-item>
<el-form-item label="最后一次失败原因">
<el-input disabled v-model="healthObj.last_failure_cause"></el-input>
</el-form-item>
</el-form>
<el-form label-width="130px">
<el-form-item label="总计数">
<el-input disabled v-model="countObj.total_count"></el-input>
</el-form-item>
<el-form-item label="失败计数">
<el-input disabled v-model="countObj.failure_count"></el-input>
</el-form-item>
<el-form-item label="成功计数">
<el-input disabled v-model="countObj.success_count"></el-input>
</el-form-item>
</el-form>
<div class="btns">
<el-button type="primary" @click="resetCount"></el-button>
<el-button @click="closeDialog"></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 ruleFormRef = ref(null);
const state = reactive({
health: {
0: 'null',
1: 'ok',
2: 'error',
},
name: '',
healthObj: {},
countObj: {}
})
const visible = computed(() => {
return props.dialogVisible;
});
onMounted(() => {
getD();
});
const getD = async () => {
const parm = {
name: props.formData.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 resetCount = async () => {
const parm = {
name: props.formData.name
}
const res = await infoApi.resetCount(parm);
if (res.code == 0) {
getD();
}
}
const closeDialog = () => {
ctx.emit("dialogClose");
};
return {
...toRefs(state),
visible,
closeDialog,
getD,
resetCount
};
},
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__content {
display: flex;
flex-wrap: nowrap;
>span {
margin-left: 10px;
}
}
</style>

View File

@ -27,8 +27,8 @@
<el-form-item label="失败重试时间" prop="faile_retry_time">
<el-input-number v-model="form2.faile_retry_time" :min="1" placeholder="(单位:秒)" clearable/><span></span>
</el-form-item>
<el-form-item label="COM" prop="driver_name">
<el-select v-model="form2.driver_name" clearable>
<el-form-item label="COM" prop="com_name">
<el-select v-model="form2.com_name" clearable>
<el-option
v-for="item in comArr"
:label="item.name"
@ -87,7 +87,7 @@
</el-form-item>
</el-form>
<!-- 3: 'plc_s7' -->
<el-form :model="form3" label-width="120px" :rules="rules3" ref="ruleFormRef3" v-if="pztypecode === 3">
<!-- <el-form :model="form3" label-width="120px" :rules="rules3" ref="ruleFormRef3" v-if="pztypecode === 3">
<el-form-item label="轮询时间" prop="polling_time">
<el-input-number v-model="form3.polling_time" :min="1" placeholder="(单位:秒)" clearable/><span></span>
</el-form-item>
@ -107,7 +107,7 @@
<el-button type="primary" @click="onSubmit"></el-button>
<el-button @click="closeDialog"></el-button>
</el-form-item>
</el-form>
</el-form> -->
</el-drawer>
@ -121,6 +121,8 @@ export default {
emits: ["dialogClose", "dialogSuccess"],
setup(props, ctx) {
const ruleFormRef = ref(null);
const ruleFormRef2= ref(null);
const ruleFormRef3 = ref(null);
const state = reactive({
form: {
polling_time: "",
@ -132,12 +134,12 @@ export default {
form2: {
polling_time: "",
faile_retry_time: "",
driver_name: '',
com_name: '',
dataBits: 5,
baudRate: 2480,
baudRate: 2400,
stopBits: 1,
parity: 'N',
id: 1
id: 1,
},
form3: {
polling_time: "",
@ -149,11 +151,11 @@ export default {
},
comArr: [],// com
baudRateArr: [{
name: 2480,
value: 2480
name: 2400,
value: 2400
},{
name: 4880,
value: 4880
name: 4800,
value: 4800
},
{
name:9600,
@ -224,7 +226,7 @@ export default {
rules2: {
polling_time: [{ required: true, message: "请输入轮询时间", trigger: "blur" }],
faile_retry_time: [{ required: true, message: "请输入失败重试时间", trigger: "blur" }],
driver_name: [{ required: true, message: "请选择COM口", trigger: "blur" }],
com_name: [{ required: true, message: "请选择COM口", trigger: "blur" }],
dataBits: [{ required: true, message: "请选择数据位", trigger: "blur" }],
baudRate: [{ required: true, message: "请选择波特率", trigger: "blur" }],
stopBits: [{ required: true, message: "请选择停止位", trigger: "blur" }],
@ -274,16 +276,28 @@ export default {
} else if (props.pztypecode === 2) {
await ruleFormRef2.value.validate(async (valid) => {
if (valid) {
var param = {
polling_time:Number(state.form2.polling_time),
faile_retry_time: Number(state.form2.faile_retry_time),
dataBits: Number(state.form2.dataBits),
baudRate: Number(state.form2.baudRate),
stopBits: Number(state.form2.stopBits),
driver_name: state.form2.driver_name,
parity: state.form2.parity,
id: Number(state.form2.id)
}
// var param = {
// polling_time:Number(state.form2.polling_time),
// faile_retry_time: Number(state.form2.faile_retry_time),
// dataBits: Number(state.form2.dataBits),
// baudRate: Number(state.form2.baudRate),
// stopBits: Number(state.form2.stopBits),
// driver_name: state.form2.driver_name,
// parity: state.form2.parity,
// id: Number(state.form2.id)
// }
var param = {
name: props.formData.name,
polling_time: Number(state.form2.polling_time),
faile_retry_time: Number(state.form2.faile_retry_time),
com: {
name: state.form2.com_name,
dataBits: Number(state.form2.dataBits),
baudRate: Number(state.form2.baudRate),
stopBits: Number(state.form2.stopBits),
parity: state.form2.parity
}
}
const res = await infoApi.addPz(param, header);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
@ -328,11 +342,14 @@ export default {
getCom();
});
const getCom = async () => {
const res = await infoApi.getCom();
const parm = {
name: props.formData.name
}
const res = await infoApi.getCom(parm);
if (res.code == 0) {
state.comArr = res.data;
console.log(44, state.comArr);
state.form2.driver_name = state.comArr[0].name;
state.form2.com_name = state.comArr[0].name;
}
};
const closeDialog = () => {
@ -350,6 +367,8 @@ export default {
exportData,
onSubmit,
ruleFormRef,
ruleFormRef2,
ruleFormRef3,
getCom
};
},

View File

@ -236,3 +236,7 @@ s {
}
}
.btns {
width: 100%;
text-align: center;
}

View File

@ -41,6 +41,9 @@
</el-table-column>
<el-table-column label="操作" align="center" show-overflow-tooltip>
<template #default="scope">
<el-button type="primary" @click="openDetails(scope.row)">
详情
</el-button>
<el-button type="primary" @click="openPz(scope.row)">
配置
</el-button>
@ -77,6 +80,14 @@
@dialogSuccess="dialogSuccess3"
>
</PzSet>
<Details
:formData="formData"
:dialogVisible="dialogVisible4"
v-if="dialogVisible4"
@dialogClose="dialogClose4"
@dialogSuccess="dialogSuccess4"
>
</Details>
<AddData :formData="formData" :type="type" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible"
v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"></AddData>
<ViewSet :formData="formData" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible2" v-if="dialogVisible2" @dialogClose="dialogClose"
@ -91,12 +102,14 @@ import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import AddData from "@/components/AddData.vue";
import PzSet from "@/components/PzSet.vue";
import Details from "@/components/Details.vue";
import ViewSet from "@/components/ViewSet.vue";
export default {
name: "page",
components: {
AddData,
PzSet,
Details,
ViewSet
},
setup() {
@ -108,6 +121,7 @@ export default {
dialogVisible1: false,
dialogVisible2: false,
dialogVisible3: false,
dialogVisible4: false,
type: '0', // 0 1
pztype: '',
pztypecode: '',
@ -168,10 +182,16 @@ export default {
const dialogClose3 = () => {
state.dialogVisible3 = false;
};
const dialogClose4 = () => {
state.dialogVisible4 = false;
};
const dialogSuccess3 = () => {
state.dialogVisible3 = false;
getTableData();
};
const dialogSuccess4 = () => {
state.dialogVisible4 = false;
};
const dialogSuccess1 = () => {
state.dialogVisible1 = false;
@ -235,7 +255,7 @@ export default {
const param = {
name: item.name,
}
const res = item.enable ? await infoApi.startStatus(param) : await infoApi.stopStatus(param);
const res = !item.enable ? await infoApi.startStatus(param) : await infoApi.stopStatus(param);
if (res.code == 0) {
ElMessage.success(res.msg || "请求成功");
getTableData();
@ -251,7 +271,11 @@ export default {
state.pztypecode = item.type;
state.formData = JSON.parse(JSON.stringify(item));
}
const openDetails = (item) => {
state.formData = JSON.parse(JSON.stringify(item));
state.dialogVisible4 = true;
}
return {
...toRefs(state),
addData,
@ -264,8 +288,11 @@ export default {
dialogClose1,
dialogSuccess1,
dialogClose3,
dialogClose4,
dialogSuccess3,
dialogSuccess4,
openPz,
openDetails,
viewData
};
},