diff --git a/dist.zip b/dist.zip new file mode 100644 index 0000000..0e4a403 Binary files /dev/null and b/dist.zip differ diff --git a/src/api/infoApi.js b/src/api/infoApi.js index 9f46bc4..c29488f 100644 --- a/src/api/infoApi.js +++ b/src/api/infoApi.js @@ -111,7 +111,7 @@ const infoApi = { }, // 获取通讯状态 getTxStatus(params) { - return postPBRequest(`/driver`, params, 54002); + return postPBRequest(`/driver`, params, 54003); }, // 获取支持的通讯驱动 @@ -120,7 +120,7 @@ const infoApi = { }, // 查询查询驱动下设备的可用模板列表 getTxTemplate(params) { - return postPBRequest("/driver", params, 54011, params.driver_name); + return postPBRequest("/driver", params, 54002, params.driver_name); }, // 新增设备 addSet(params) { @@ -137,7 +137,7 @@ const infoApi = { }, // 获取详情 getD(params) { - return postPBRequest('/driver', params, 54003, params.driver_name) + return postPBRequest('/driver', params, 54005, params.driver_name) }, // 重置 resetCount(params) { @@ -150,11 +150,11 @@ const infoApi = { // 通讯服务启用,停用 startStatus(params) { - return postPBRequest("/driver", params, 54400,params.name); + return postPBRequest("/driver", params, 56201,params.driver_name); }, // 通讯服务停止 stopStatus(params) { - return postPBRequest("/driver", params, 54500,params.name); + return postPBRequest("/driver", params, 56202,params.driver_name); }, //保存配置 addPz(params, header) { diff --git a/src/components/AddData.vue b/src/components/AddData.vue index 48fbe91..1006c65 100644 --- a/src/components/AddData.vue +++ b/src/components/AddData.vue @@ -13,141 +13,46 @@ :rules="rules" ref="ruleFormRef" > - + - + - + + + + + + - - - - @@ -163,55 +68,33 @@ import { onMounted, reactive, ref, toRefs, computed, nextTick } from "vue"; import infoApi from "@/api/infoApi.js"; import { ElMessage, ElMessageBox } from "element-plus"; -// import { response, tx_list, com_info, com_list, tx_drive_list, tx_add, tx_info, tx_drive_config_modbusTCP } from '../proto/data/pd' export default { props: ["formData", "dialogVisible", "type", "qudongOptions"], emits: ["dialogClose", "dialogSuccess"], setup(props, ctx) { const ruleFormRef = ref(null); const validName = (rule, value, callback) => { - var name = /^[a-zA-Z]([_\w]*)$/; + var name = /^[a-zA-Z][a-zA-Z0-9_]{2,19}$/; if (name.test(value) || !value) { callback(); } else { - callback(new Error("通讯名称格式不正确,支持英文数字和下划线")); + callback(new Error("名称只能以字母开头,仅支持字母,数字和下划线,最短3个字符起,且长度不能超过20个字符")); } }; const state = reactive({ addForm: {}, typeOptions: [], - serialConfig: false, - modbusTCPConfig: false, - com_select: [], - comArr: [], - configData: { - name: '', - baudRate: '', - parity: '', - dataBits: '', - stopBits:'', - timeout:'', - }, - configData1: { - port: '', - host: '' - }, - baud_rate_select: [9600, 115200], - parity_select:[ - { text: "无校验", value: "N" }, - { text: "偶校验", value: "E" }, - { text: "奇校验", value: "O" } - ], - data_bits_select: [5, 6, 7, 8], - stop_bits_select: [1, 2], - timeout_select: [0, 100, 200, 500, 1000, 2000], + templateOptions: [], rules: { - name: [ - { required: true, message: "请输入通讯名称", trigger: "blur" }, - // { required: true, validator: validName, trigger: "blur" }, + driver_name: [ + { required: true, message: "请输入驱动名称", trigger: "blur" }, + { required: true, validator: validName, trigger: "blur" }, ], - description: [{ required: true, message: "请输入驱动描述", trigger: "blur" }], - type: [{ required: true, message: "请选择通讯驱动", trigger: "blur" }] + template_name: [ + { required: true, message: "请选择通讯模板", trigger: "blur" }, + ], + driver_description: [{ required: true, message: "请输入驱动描述", trigger: "blur" }], + driver_type: [{ required: true, message: "请选择通讯驱动", trigger: "change" }] }, }); const visible = computed(() => { @@ -219,27 +102,9 @@ export default { }); onMounted(async () => { - // if (props.type === '1') { - // if (props.formData.serial) { - // state.serialConfig = true; - // state.modbusTCPConfig = false; - // // 获取com,比对赋值 - // getCom(); - // } else { - // state.serialConfig = false; - // if (props.formData.drive == "modbusTCP") { - // state.modbusTCPConfig = true; - // // 直接赋值 - // state.configData1 = { - // port: props.formData.host.split(":")[0], - // host: props.formData.host.split(":")[1] - // } - // } - // } - // } state.addForm = props.formData; getTypeOptions(); - + driveChange(); }); const getTypeOptions = () => { @@ -270,58 +135,19 @@ export default { }); }; const driveChange = () => { - // 如果是串口协议 - // if (props.formData.drive.serial) { - // state.serialConfig = true; - // state.modbusTCPConfig = false; - // // 获取com - // getCom(); - - // } else { - // state.serialConfig = false; - // if (props.formData.drive.name == "modbusTCP") { - // state.modbusTCPConfig = true; - // } - // } + console.log(1); + state.addForm.template_name = ''; + getTxTemplate(); } - // 获取com - const getCom = async () => { - const res = await infoApi.getCom(); - if (res.code == 0) { - state.comArr = res.data.com; - state.com_select = []; - infodata.com.forEach(e => { - if (!e.used) { - state.com_select.push(e); - } - }); - // 编辑赋值 - if (props.type === '1') { - const config = infodata.com.filter(item => item.name === props.formData.host)[0]; - state.configData = { - name: config.name, - baudRate: config.baudRate, - parity: config.parity, - dataBits: config.dataBits, - stopBits: config.stopBits, - timeout: config.timeout, - } - } - if (state.com_select.length == 0) { - ElMessage.info("没有可用串口,请选择其他驱动"); - } + + const getTxTemplate = async () => { + const param = { + driver_type: state.addForm.driver_type } - } - // 选择 com 回填数据 - const selsectCom = () => { - const c = state.comArr.filter(item => item.name === state.configData.name)[0]; - state.configData = { - name: c.name, - baudRate: c.baudRate, - parity: c.parity, - dataBits: c.dataBits, - stopBits: c.stopBits, - timeout: c.timeout, + const res = await infoApi.getTxTemplate(param); + if (res.code == 0) { + state.templateOptions = res.data; + state.addForm.template_name = state.templateOptions[0].name; } } @@ -331,9 +157,7 @@ export default { visible, saveData, closeDialog, - driveChange, - getCom, - selsectCom + driveChange }; }, }; diff --git a/src/components/AddMb.vue b/src/components/AddMb.vue index 30abca3..0c39a14 100644 --- a/src/components/AddMb.vue +++ b/src/components/AddMb.vue @@ -1,15 +1,16 @@