Compare commits
No commits in common. "ac0559f5bbec29b67c6f6ba1daa589ea24b7ba79" and "fcab2e8bc0f9f9e13a1fbad7d997ac99096f2d3d" have entirely different histories.
ac0559f5bb
...
fcab2e8bc0
|
@ -137,8 +137,8 @@ const infoApi = {
|
|||
return postPBRequest("/driver", params, 53202);
|
||||
},
|
||||
//保存配置
|
||||
addPz(params, header) {
|
||||
return postPBRequest("/driver", params, 54201, header.driver_name);
|
||||
addPz(params) {
|
||||
return postPBRequest("/driver", params, 54201, params.driver_name);
|
||||
},
|
||||
// 获取com
|
||||
getCom() {
|
||||
|
|
|
@ -1,34 +1,69 @@
|
|||
<template>
|
||||
<el-drawer v-model="visible" :title= "pztype + '类型 配置管理'" direction="rtl" :before-close="closeDialog">
|
||||
<!-- 1 -->
|
||||
<el-form :model="form" label-width="120px" :rules="rules" ref="ruleFormRef" v-if="pztypecode === 1">
|
||||
<el-form :model="form" label-width="120px" :rules="rules" ref="ruleFormRef" v-if="pztypecode === 2">
|
||||
<el-form-item label="轮询时间" prop="polling_time">
|
||||
<el-input-number v-model="form.polling_time" :min="1" placeholder="(单位:秒)" clearable/><span>秒</span>
|
||||
<el-input v-model="form.polling_time" clearable/><span>秒</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="失败重试时间" prop="faile_retry_time">
|
||||
<el-input-number v-model="form.faile_retry_time" :min="1" placeholder="(单位:秒)" clearable/><span>秒</span>
|
||||
<el-input v-model="form.faile_retry_time" clearable/><span>秒</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="主机地址" prop="host">
|
||||
<el-input v-model="form.host" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item label="端口号" prop="port">
|
||||
<el-input-number v-model="form.port" :min="1" clearable />
|
||||
<el-input v-model="form.port" clearable />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="faile_retry_time">
|
||||
<el-select v-model="form.region" placeholder="please select your zone">
|
||||
<el-option label="Zone one" value="shanghai" />
|
||||
<el-option label="Zone two" value="beijing" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="Activity time">
|
||||
<el-col :span="11">
|
||||
<el-date-picker v-model="form.date1" type="date" placeholder="Pick a date" style="width: 100%" />
|
||||
</el-col>
|
||||
<el-col :span="2" class="text-center">
|
||||
<span class="text-gray-500">-</span>
|
||||
</el-col>
|
||||
<el-col :span="11">
|
||||
<el-time-picker v-model="form.date2" placeholder="Pick a time" style="width: 100%" />
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
<el-form-item label="Instant delivery">
|
||||
<el-switch v-model="form.delivery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Activity type">
|
||||
<el-checkbox-group v-model="form.type">
|
||||
<el-checkbox label="Online activities" name="type" />
|
||||
<el-checkbox label="Promotion activities" name="type" />
|
||||
<el-checkbox label="Offline activities" name="type" />
|
||||
<el-checkbox label="Simple brand exposure" name="type" />
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="Resources">
|
||||
<el-radio-group v-model="form.resource">
|
||||
<el-radio label="Sponsor" />
|
||||
<el-radio label="Venue" />
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="Activity form">
|
||||
<el-input v-model="form.desc" type="textarea" />
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit">保存</el-button>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 2: 'modbus_rtu' -->
|
||||
<el-form :model="form2" label-width="120px" :rules="rules2" ref="ruleFormRef2" v-if="pztypecode === 2">
|
||||
<el-form :model="form1" label-width="120px" :rules="rules1" ref="ruleFormRef1" v-if="pztypecode === 1">
|
||||
<el-form-item label="轮询时间" prop="polling_time">
|
||||
<el-input-number v-model="form2.polling_time" :min="1" placeholder="(单位:秒)" clearable/><span>秒</span>
|
||||
<el-input v-model="form1.polling_time" clearable/><span>秒</span>
|
||||
</el-form-item>
|
||||
<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 v-model="form1.faile_retry_time" clearable/><span>秒</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="COM" prop="driver_name">
|
||||
<el-select v-model="form2.driver_name" clearable>
|
||||
<el-select v-model="form1.driver_name" clearable>
|
||||
<el-option
|
||||
v-for="item in comArr"
|
||||
:label="item.name"
|
||||
|
@ -38,7 +73,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据位" prop="dataBits" clearable>
|
||||
<el-select v-model="form2.dataBits">
|
||||
<el-select v-model="form1.dataBits">
|
||||
<el-option
|
||||
v-for="item in dataBitsArr"
|
||||
:label="item.name"
|
||||
|
@ -49,7 +84,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="波特率" prop="baudRate" clearable>
|
||||
<el-select v-model="form2.baudRate">
|
||||
<el-select v-model="form1.baudRate">
|
||||
<el-option
|
||||
v-for="item in baudRateArr"
|
||||
:label="item.name"
|
||||
|
@ -60,7 +95,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="停止位" prop="stopBits" clearable>
|
||||
<el-select v-model="form2.stopBits">
|
||||
<el-select v-model="form1.stopBits">
|
||||
<el-option
|
||||
v-for="item in stopBitsArr"
|
||||
:label="item.name"
|
||||
|
@ -71,7 +106,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="校验类型" prop="parity" clearable>
|
||||
<el-select v-model="form2.parity">
|
||||
<el-select v-model="form1.parity">
|
||||
<el-option
|
||||
v-for="item in parityArr"
|
||||
:label="item.name"
|
||||
|
@ -81,32 +116,6 @@
|
|||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit">保存</el-button>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
</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-item label="轮询时间" prop="polling_time">
|
||||
<el-input-number v-model="form3.polling_time" :min="1" placeholder="(单位:秒)" clearable/><span>秒</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="失败重试时间" prop="faile_retry_time">
|
||||
<el-input-number v-model="form3.faile_retry_time" :min="1" placeholder="(单位:秒)" clearable/><span>秒</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="主机地址" prop="host">
|
||||
<el-input v-model="form3.host" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item label="机架号" prop="rack">
|
||||
<el-input-number v-model="form3.rack" :min="1" :max="20" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="插槽号" prop="slot">
|
||||
<el-input-number v-model="form3.slot" :min="1" :max="20" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit">保存</el-button>
|
||||
<el-button @click="closeDialog">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
||||
|
@ -116,7 +125,7 @@
|
|||
import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue";
|
||||
import infoApi from "@/api/infoApi.js";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
export default {
|
||||
export default {//2: 'modbus_rtu', 3: 'plc_s7'
|
||||
props: ["formData", "dialogVisible", "pztype", "pztypecode"],
|
||||
emits: ["dialogClose", "dialogSuccess"],
|
||||
setup(props, ctx) {
|
||||
|
@ -129,23 +138,14 @@ export default {
|
|||
port: '',
|
||||
id: 1,
|
||||
},
|
||||
form2: {
|
||||
form1: {
|
||||
polling_time: "",
|
||||
faile_retry_time: "",
|
||||
driver_name: '',
|
||||
dataBits: 5,
|
||||
baudRate: 2480,
|
||||
stopBits: 1,
|
||||
parity: 'N',
|
||||
id: 1
|
||||
},
|
||||
form3: {
|
||||
polling_time: "",
|
||||
faile_retry_time: "",
|
||||
host: '',
|
||||
slot: '',
|
||||
rack: 1,
|
||||
id: 1
|
||||
dataBits: '',
|
||||
baudRate: '',
|
||||
stopBits: '',
|
||||
parity: ''
|
||||
},
|
||||
comArr: [],// com
|
||||
baudRateArr: [{
|
||||
|
@ -221,7 +221,7 @@ export default {
|
|||
}}, trigger: 'blur' }],
|
||||
port: [{ required: true, message: "请输入端口号", trigger: "blur" }]
|
||||
},
|
||||
rules2: {
|
||||
rules1: {
|
||||
polling_time: [{ required: true, message: "请输入轮询时间", trigger: "blur" }],
|
||||
faile_retry_time: [{ required: true, message: "请输入失败重试时间", trigger: "blur" }],
|
||||
driver_name: [{ required: true, message: "请选择COM口", trigger: "blur" }],
|
||||
|
@ -230,37 +230,21 @@ export default {
|
|||
stopBits: [{ required: true, message: "请选择停止位", trigger: "blur" }],
|
||||
parity: [{ required: true, message: "请选择校验类型", trigger: "blur" }]
|
||||
},
|
||||
rules3: {
|
||||
polling_time: [{ required: true, message: "请输入轮询时间", trigger: "blur" }],
|
||||
faile_retry_time: [{ required: true, message: "请输入失败重试时间", trigger: "blur" }],
|
||||
host: [{ required: true, validator: (rule, value, callback) => {
|
||||
// 只能输入英文字母
|
||||
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
||||
if (value && reg.test(value) ) {
|
||||
callback();
|
||||
} else {
|
||||
callback(new Error("请输入正确的ip地址"));
|
||||
}}, trigger: 'blur' }],
|
||||
rack: [{ required: true, message: "请输入机架号", trigger: "blur" }],
|
||||
slot: [{ required: true, message: "请输入插槽号", trigger: "blur" }]
|
||||
},
|
||||
});
|
||||
const onSubmit = async () => {
|
||||
console.log(555, props.formData.name);
|
||||
var header = {
|
||||
driver_name: props.formData.name
|
||||
}
|
||||
if (props.pztypecode === 1) {
|
||||
await ruleFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
var param = {
|
||||
const param = {
|
||||
driver_name: props.formData.name,
|
||||
polling_time:Number(state.form.polling_time),
|
||||
faile_retry_time: Number(state.form.faile_retry_time),
|
||||
host: state.form.host,
|
||||
port: Number(state.form.port),
|
||||
id: Number(state.form.id)
|
||||
}
|
||||
const res = await infoApi.addPz(param, header);
|
||||
console.log(777, param);
|
||||
const res = await infoApi.addPz(param);
|
||||
if (res.code == 0) {
|
||||
ElMessage.success(res.message || "请求成功");
|
||||
ctx.emit("dialogClose");
|
||||
|
@ -271,54 +255,6 @@ export default {
|
|||
console.log("error submit!");
|
||||
}
|
||||
});
|
||||
} 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)
|
||||
}
|
||||
const res = await infoApi.addPz(param, header);
|
||||
if (res.code == 0) {
|
||||
ElMessage.success(res.message || "请求成功");
|
||||
ctx.emit("dialogClose");
|
||||
} else {
|
||||
ElMessage.error(res.message);
|
||||
}
|
||||
} else {
|
||||
console.log("error submit!");
|
||||
}
|
||||
});
|
||||
} else if (props.pztypecode === 3) {
|
||||
await ruleFormRef3.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
var param = {
|
||||
polling_time:Number(state.form3.polling_time),
|
||||
faile_retry_time: Number(state.form3.faile_retry_time),
|
||||
host: state.form3.host,
|
||||
rack: Number(state.form3.rack),
|
||||
slot: Number(state.form3.slot),
|
||||
id: Number(state.form3.id)
|
||||
}
|
||||
const res = await infoApi.addPz(param, header);
|
||||
if (res.code == 0) {
|
||||
ElMessage.success(res.message || "请求成功");
|
||||
ctx.emit("dialogClose");
|
||||
} else {
|
||||
ElMessage.error(res.message);
|
||||
}
|
||||
} else {
|
||||
console.log("error submit!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
const visible = computed(() => {
|
||||
return props.dialogVisible;
|
||||
|
@ -332,7 +268,9 @@ export default {
|
|||
if (res.code == 0) {
|
||||
state.comArr = res.data;
|
||||
console.log(44, state.comArr);
|
||||
state.form2.driver_name = state.comArr[0].name;
|
||||
nextTick(() => {
|
||||
drawEchart();
|
||||
});
|
||||
}
|
||||
};
|
||||
const closeDialog = () => {
|
||||
|
@ -359,7 +297,7 @@ export default {
|
|||
::v-deep .el-form-item__content {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
>span {
|
||||
span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue