main
wangqiujuan0808 2024-10-23 00:09:00 +08:00
parent 06f466773e
commit dbddfcb547
5 changed files with 68 additions and 105 deletions

View File

@ -17,36 +17,6 @@ const infoApi = {
reboot() { reboot() {
return postPBRequest("/system", null, 57202); return postPBRequest("/system", null, 57202);
}, },
// //
// getTc(params) {
// return getRequest('/tc', params)
// },
// //
// getSupport(params) {
// return getRequest('/tc/support', params)
// },
// //
// getFree(params) {
// return getRequest('/com/free', params)
// },
// // api/com
// getCom(params) {
// return getRequest('/com', params)
// },
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// //
// stopTc(params) {
// return putRequest("/tc", params);
// },
// //
// delTc(params) {
// return deleteRequest("/tc", params);
// },
// //
getMb(params) { getMb(params) {
return postPBRequest('/template', params, 53000) return postPBRequest('/template', params, 53000)
@ -170,7 +140,7 @@ const infoApi = {
}, },
// com // com
getCom(params) { getCom(params) {
return postPBRequest("/info", null, 51001, params.name); return postPBRequest("/system", null, 57002, params.name);
}, },
// //
// //

View File

@ -44,7 +44,7 @@
<fieldset class="box2"> <fieldset class="box2">
<legend class="box-ht">通用配置</legend> <legend class="box-ht">通用配置</legend>
<el-form-item label="轮询时间" prop="polling_time"> <el-form-item label="轮询时间" prop="polling_time">
<el-input-number v-model="form2.polling_time" :min="1" placeholder="(单位:秒)" clearable /><span></span> <el-input-number v-model="form2.polling_time" :min="1" placeholder="(单位:秒)" clearable /><span></span>
</el-form-item> </el-form-item>
<el-form-item label="失败重试时间" prop="faile_retry_time"> <el-form-item label="失败重试时间" prop="faile_retry_time">
<el-input-number v-model="form2.faile_retry_time" :min="1" placeholder="(单位:秒)" clearable /><span></span> <el-input-number v-model="form2.faile_retry_time" :min="1" placeholder="(单位:秒)" clearable /><span></span>
@ -283,7 +283,7 @@ export default {
var header = { var header = {
driver_name: props.formData.driver_name driver_name: props.formData.driver_name
} }
if (props.pztypecode === 2) { if (props.pztypecode === 2) { //modbus_tcp
await ruleFormRef.value.validate(async (valid) => { await ruleFormRef.value.validate(async (valid) => {
if (valid) { if (valid) {
var param = { var param = {
@ -295,27 +295,17 @@ export default {
} }
const res = await infoApi.addPz(param, header); const res = await infoApi.addPz(param, header);
if (res.code == 0) { if (res.code == 0) {
ElMessage.success(res.message || "请求成功"); ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose"); ctx.emit("dialogClose");
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.data);
} }
} else { } else {
} }
}); });
} else if (props.pztypecode === 1) { } else if (props.pztypecode === 1) { // modbus_rtu
await ruleFormRef2.value.validate(async (valid) => { await ruleFormRef2.value.validate(async (valid) => {
if (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 = { var param = {
name: props.formData.name, name: props.formData.name,
polling_time: Number(state.form2.polling_time), polling_time: Number(state.form2.polling_time),
@ -330,10 +320,10 @@ export default {
} }
const res = await infoApi.addPz(param, header); const res = await infoApi.addPz(param, header);
if (res.code == 0) { if (res.code == 0) {
ElMessage.success(res.message || "请求成功"); ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose"); ctx.emit("dialogClose");
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.data);
} }
} else { } else {
} }
@ -351,10 +341,10 @@ export default {
} }
const res = await infoApi.addPz(param, header); const res = await infoApi.addPz(param, header);
if (res.code == 0) { if (res.code == 0) {
ElMessage.success(res.message || "请求成功"); ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose"); ctx.emit("dialogClose");
} else { } else {
ElMessage.error(res.message); ElMessage.error(res.data);
} }
} else { } else {
} }
@ -368,7 +358,7 @@ export default {
onMounted(() => { onMounted(() => {
getD(); getD();
// getCom(); getCom();
}); });
const getD = async () => { const getD = async () => {
const parm = { const parm = {
@ -376,8 +366,17 @@ export default {
} }
const res = await infoApi.getD(parm); const res = await infoApi.getD(parm);
if (res.code == 0) { if (res.code == 0) {
state.form = res.data; if (props.pztypecode === 2) {
console.log(state.form); state.form = res.data;
}
if (props.pztypecode === 1) {
state.form2 = res.data;
state.form2.com_name = res.data.com.name;
state.form2.dataBits = Number(res.data.com.dataBits);
state.form2.baudRate = Number(res.data.com.baudRate);
state.form2.stopBits = Number(res.data.com.stopBits);
state.form2.parity = res.data.com.parity;
}
} }
}; };
const getCom = async () => { const getCom = async () => {
@ -389,7 +388,6 @@ export default {
state.comArr = res.data.sort((a, b) => { state.comArr = res.data.sort((a, b) => {
return (a.name > b.name ? 1 : -1) return (a.name > b.name ? 1 : -1)
}); });
state.form2.com_name = state.comArr[0].name;
} }
}; };
const closeDialog = () => { const closeDialog = () => {

View File

@ -117,7 +117,7 @@
</template> </template>
<script> <script>
import { onMounted, reactive, ref, toRefs, nextTick } from "vue"; import { onMounted, reactive, ref, toRefs, nextTick,onUnmounted } 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 De from "@/components/De.vue"; import De from "@/components/De.vue";
@ -153,15 +153,22 @@ export default {
dialogVisible1: false, dialogVisible1: false,
dialogVisible2: false, dialogVisible2: false,
txStatus: [], // txStatus: [], //
pointTypeOptions: {} pointTypeOptions: {},
intervalId:null
}); });
onMounted(() => { onMounted(() => {
getDriverData();
getTxStatus(); getTxStatus();
getPointType(); getPointType();
state.intervalId = setInterval(() =>
getDriverData(), 1000);
}); });
onUnmounted(() => {
clearInterval(state.intervalId);
})
const getPointType = async () => { const getPointType = async () => {
const parm = {}; const parm = {};
const res = await infoApi.getPointType(parm); const res = await infoApi.getPointType(parm);

View File

@ -2,7 +2,7 @@
<el-card class="content-div"> <el-card class="content-div">
<div class="all-content"> <div class="all-content">
<div class="top-div"> <div class="top-div">
<el-button type="primary" size="large" v-show="tableData && tableData.length>0" @click="addData"></el-button> <el-button type="primary" size="large" @click="addData"></el-button>
</div> </div>
<el-table :data="tableData" style="width: 100%" border stripe <el-table :data="tableData" style="width: 100%" border stripe
:header-cell-style="{ background: '#F6F7FC' }" size="large"> :header-cell-style="{ background: '#F6F7FC' }" size="large">
@ -90,15 +90,15 @@ export default {
// //
const endIndex = startIndex + state.listQuery.pageNum; const endIndex = startIndex + state.listQuery.pageNum;
// //
return state.tableData1.slice(startIndex, endIndex); return state.tableData1 && state.tableData1.length > 0 && state.tableData1.slice(startIndex, endIndex);
}); });
const totalNum = computed(() => { const totalNum = computed(() => {
return state.tableData1.length; return state.tableData1 && state.tableData1.length;
}) })
const total = computed(() => { const total = computed(() => {
return Math.ceil(state.tableData1.length / state.listQuery.pageNum); return state.tableData1 && Math.ceil(state.tableData1.length / state.listQuery.pageNum);
}) })
onMounted(() => { onMounted(() => {
@ -120,7 +120,7 @@ export default {
if (res.code == 0) { if (res.code == 0) {
// //
state.tableData1 = res.data && res.data.length > 0 && res.data.sort((a,b) => { state.tableData1 = res.data && res.data.length > 0 && res.data.sort((a,b) => {
return (a.name > b.name ? 1 : -1) return (a.name > b.name ? 1 : -1) || []
}); });
} else { } else {
} }

View File

@ -4,7 +4,7 @@
<div class="top-div"> <div class="top-div">
<el-button type="primary" size="large" @click="addData"></el-button> <el-button type="primary" size="large" @click="addData"></el-button>
</div> </div>
<el-table :data="tableData" border :row-class-name="tableRowClassName" <el-table :data="tableData" border :row-class-name="tableRowClassName"
: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="driver_name" label="驱动名称" width="200" align="center" show-overflow-tooltip /> <el-table-column prop="driver_name" label="驱动名称" width="200" align="center" show-overflow-tooltip />
@ -18,7 +18,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="driver_status" label="驱动状态" width="200" align="center"> <el-table-column prop="driver_status" label="驱动状态" width="200" align="center">
<template #default="scope"> <template #default="scope">
<span> {{ txStatus[scope.row.driver_status] }} </span> <span> {{ txStatus[scope.row.driver_status] }} </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="driver_enable" label="启停控制" width="200" align="center"> <el-table-column prop="driver_enable" label="启停控制" width="200" align="center">
@ -26,7 +26,7 @@
<el-button type="primary" size="large" @click="changeStatus(scope.row)" v-if="!scope.row.driver_enable"> <el-button type="primary" size="large" @click="changeStatus(scope.row)" v-if="!scope.row.driver_enable">
启用 启用
</el-button> </el-button>
<el-button size="large" @click="changeStatus(scope.row)" v-else> <el-button size="large" @click="changeStatus(scope.row)" v-else>
停用 停用
</el-button> </el-button>
</template> </template>
@ -39,7 +39,7 @@
<el-button type="warning" size="large" @click="openPz(scope.row)"> <el-button type="warning" size="large" @click="openPz(scope.row)">
配置 配置
</el-button> </el-button>
<el-button size="large" @click="editData(scope.row)"> <el-button size="large" @click="editData(scope.row)">
编辑 编辑
</el-button> </el-button>
<el-button type="danger" size="large" @click="delData(scope.row)"> <el-button type="danger" size="large" @click="delData(scope.row)">
@ -49,44 +49,24 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<AddData <AddData :formData="formData" :type="type" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible"
:formData="formData" v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"></AddData>
:type="type" <PzSet :dialogVisible="dialogVisible3" :formData="formData" :pztype="pztype" :pztypecode="pztypecode"
:qudongOptions="qudongOptions" v-if="dialogVisible3" @dialogClose="dialogClose3" @dialogSuccess="dialogSuccess3">
:dialogVisible="dialogVisible"
v-if="dialogVisible"
@dialogClose="dialogClose"
@dialogSuccess="dialogSuccess"
></AddData>
<PzSet
:dialogVisible="dialogVisible3"
:formData="formData"
:pztype="pztype"
:pztypecode="pztypecode"
v-if="dialogVisible3"
@dialogClose="dialogClose3"
@dialogSuccess="dialogSuccess3"
>
</PzSet> </PzSet>
<Details <Details :formData="formData" :dialogVisible="dialogVisible4" v-if="dialogVisible4" @dialogClose="dialogClose4"
:formData="formData" @dialogSuccess="dialogSuccess4">
:dialogVisible="dialogVisible4"
v-if="dialogVisible4"
@dialogClose="dialogClose4"
@dialogSuccess="dialogSuccess4"
>
</Details> </Details>
<AddData :formData="formData" :type="type" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible" <AddData :formData="formData" :type="type" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible"
v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"></AddData> v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"></AddData>
<ViewSet :formData="formData" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible2" v-if="dialogVisible2" @dialogClose="dialogClose" <ViewSet :formData="formData" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible2" v-if="dialogVisible2"
@dialogSuccess="dialogSuccess"> @dialogClose="dialogClose" @dialogSuccess="dialogSuccess">
</ViewSet> </ViewSet>
</el-card> </el-card>
</template> </template>
<script> <script>
import { onMounted, reactive, ref, toRefs } from "vue"; import { onMounted, reactive, ref, toRefs, onUnmounted } 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 AddData from "@/components/AddData.vue"; import AddData from "@/components/AddData.vue";
@ -114,14 +94,21 @@ export default {
type: '0', // 0 1 type: '0', // 0 1
pztype: '', pztype: '',
pztypecode: '', pztypecode: '',
txStatus: [] // txStatus: [], //
intervalId: null
}); });
onMounted(() => { onMounted(() => {
getTxSupport(); getTxSupport();
getTableData();
getTxStatus(); getTxStatus();
// getTableData();
state.intervalId = setInterval(() =>
getTableData(), 1000);
}); });
onUnmounted(() => {
clearInterval(state.intervalId);
})
// //
const getTxSupport = async () => { const getTxSupport = async () => {
@ -145,7 +132,7 @@ export default {
const getTableData = async () => { const getTableData = async () => {
const res = await infoApi.getTx(); const res = await infoApi.getTx();
if (res.code == 0) { if (res.code == 0) {
state.tableData = res.data && res.data.length > 0 && res.data.sort((a,b) => { state.tableData = res.data && res.data.length > 0 && res.data.sort((a, b) => {
return (a.driver_name > b.driver_name ? 1 : -1) return (a.driver_name > b.driver_name ? 1 : -1)
}); });
} }
@ -203,7 +190,7 @@ export default {
}; };
const delData = (item) => { const delData = (item) => {
if(item.status == 2) { if (item.status == 2) {
ElMessage.warning("无法删除正在运行的驱动,请先手动停止后再删除"); ElMessage.warning("无法删除正在运行的驱动,请先手动停止后再删除");
return; return;
@ -262,20 +249,20 @@ export default {
const openDetails = (item) => { const openDetails = (item) => {
state.formData = JSON.parse(JSON.stringify(item)); state.formData = JSON.parse(JSON.stringify(item));
state.dialogVisible4 = true; state.dialogVisible4 = true;
} }
const tableRowClassName = ({ row, rowIndex }) => { const tableRowClassName = ({ row, rowIndex }) => {
if(row.driver_status == 1) { if (row.driver_status == 1) {
return '' return ''
} }
if(row.driver_status == 2) { if (row.driver_status == 2) {
return 'green' return 'green'
} }
if(row.driver_status == 3) { if (row.driver_status == 3) {
return 'red' return 'red'
} }
} }
return { return {
@ -317,11 +304,12 @@ export default {
border-radius: 10px; border-radius: 10px;
color: #fff; color: #fff;
} }
.stop { .stop {
color: red; color: red;
} }
.start { .start {
color: #009fa4; color: #009fa4;
} }
</style> </style>