main
wangqiujuan0808 2024-05-08 22:11:17 +08:00
parent e7d50d77bf
commit dc1d9e1995
8 changed files with 103 additions and 126 deletions

View File

@ -29,10 +29,6 @@ const infoApi = {
// getFree(params) {
// return getRequest('/com/free', params)
// },
//
getTxSupport() {
return postPBRequest('/driver', null, 53001)
},
// // api/com
// getCom(params) {
@ -42,9 +38,7 @@ const infoApi = {
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// editTx(params) {
// return putRequest("/tx", params);
// },
// //
// stopTc(params) {
// return putRequest("/tc", params);
@ -55,11 +49,11 @@ const infoApi = {
// },
//
getMb(params) {
return postPBRequest('/template', params, 55000)
return postPBRequest('/template', params, 53000)
},
//
addMb(params) {
return postPBRequest('/template', params, 55100)
return postPBRequest('/template', params, 53100)
},
//
editMb(params) {
@ -67,24 +61,24 @@ const infoApi = {
},
//
delMb(params) {
return postPBRequest('/template', params, 55300)
return postPBRequest('/template', params, 53300)
},
//
addP(params) {
return postPBRequest('/template', params, 56100)
return postPBRequest('/template', params, 53110, params.template_name)
},
//
getTemplateType(params) {
return postPBRequest('/template', params, 55001)
return postPBRequest('/template', params, 53001)
},
//
getP(params) {
return postPBRequest('/template', params, 56000)
return postPBRequest('/template', params, 53010, params.template_name)
},
//
detP(params) {
return postPBRequest('/template', params, 56300)
return postPBRequest('/template', params, 53310, params.template_name)
},
// //
// getSet(params) {
@ -96,30 +90,39 @@ const infoApi = {
// },
//
getTx(params) {
return postPBRequest('/driver', params, 53000)
return postPBRequest('/driver', params, 54000)
},
//
//
saveTx(params) {
return postPBRequest("/driver", params, 53100);
return postPBRequest("/driver", params, 54100);
},
//
getSupportTx(params) {
return postPBRequest("/driver", params, 53001);
//
editTx(params) {
return postPBRequest("/driver", params, 54200);
},
//
delTx(params) {
return postPBRequest(`/driver`, params, 54300);
},
//
getTxSupport() {
return postPBRequest('/driver', null, 54001)
},
//
getTxConfig(params) {
return postPBRequest("/driver", params, 53002);
}
},
// // ,
// changeStatus(params) {
// return postJsonRequest(`/tx/${params.url}/${params.name}`, params);
// },
// ,
startStatus(params) {
return postPBRequest("/driver", params,53201);
},
//
stopStatus(params) {
return postPBRequest("/driver", params,53202);
}
// //
// delTx(params) {
// return deleteRequest(`/tx`, params);
// },
// //
// getSc(params) {
// return getRequest('/sb/list', params)

View File

@ -7,45 +7,40 @@
>
<el-form
label-position="top"
:model="formData"
:model="addForm"
label-width="150px"
:rules="rules"
ref="ruleFormRef"
>
<el-form-item label="通讯名称:" prop="index">
<el-form-item label="通讯名称:" prop="name">
<el-input
v-model="formData.index"
v-model="addForm.name"
placeholder="请输入驱动名称"
clearable
:disabled="type == '1'"
/>
</el-form-item>
<el-form-item label="通讯驱动:" prop="drive" >
<el-form-item label="通讯驱动:" prop="type" >
<el-select
v-model="formData.drive"
v-model="addForm.type"
value-key="name"
clearable
placeholder="请选择通讯驱动"
@change="driveChange"
:disabled="type == '1'"
>
<el-option
v-for="(item, index) of qudongOptions"
:key="index"
:label="item.name"
:value="item"
/>
<el-option v-for="(item, index) of typeOptions" :key="index" :label="item.name" :value="item.key" />
</el-select>
</el-form-item>
<el-form-item label="驱动描述:" prop="Description">
<el-form-item label="驱动描述:" prop="description">
<el-input
v-model="formData.Description"
v-model="addForm.description"
placeholder="请输入描述"
clearable
></el-input>
</el-form-item>
<!-- 驱动1 -->
<div v-if="serialConfig">
<!-- <div v-if="serialConfig">
<el-form-item label="COM口:">
<el-select
v-model="configData.name"
@ -132,9 +127,9 @@
/>
</el-select>
</el-form-item>
</div>
</div> -->
<!-- 驱动2 -->
<div v-if="modbusTCPConfig">
<!-- <div v-if="modbusTCPConfig">
<el-form-item label="主机地址:">
<el-input
v-model="configData1.port"
@ -149,7 +144,7 @@
clearable
/>
</el-form-item>
</div>
</div> -->
</el-form>
@ -180,6 +175,8 @@ export default {
}
};
const state = reactive({
addForm: {},
typeOptions: [],
serialConfig: false,
modbusTCPConfig: false,
com_select: [],
@ -206,12 +203,12 @@ export default {
stop_bits_select: [1, 2],
timeout_select: [0, 100, 200, 500, 1000, 2000],
rules: {
index: [
name: [
{ required: true, message: "请输入通讯名称", trigger: "blur" },
{ required: true, validator: validName, trigger: "blur" },
],
description: [{ required: true, message: "请输入驱动描述", trigger: "blur" }],
drive: [{ required: true, message: "请选择通讯驱动", trigger: "blur" }],
type: [{ required: true, message: "请选择通讯驱动", trigger: "blur" }],
// com: [{ required: true, message: "COM", trigger: "blur" }],
// baudRate: [{ required: true, message: "", trigger: "blur" }],
// parity: [{ required: true, message: "", trigger: "blur" }],
@ -227,69 +224,47 @@ 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]
}
}
}
}
// 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();
});
const getTypeOptions = () => {
state.typeOptions = [];
for (let i in props.qudongOptions) {
let obj = {
key: Number(i),
name: props.qudongOptions[i]
}
state.typeOptions.push(obj);
console.log(33,state.typeOptions);
}
}
const closeDialog = () => {
ctx.emit("dialogClose");
};
const saveData = async () => {
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
let req_configbuf;
if (props.type==='0') { //
if (props.formData.drive.serial) {
req_configbuf = state.configData
} else {
if (props.formData.drive.name == "modbusTCP") {
req_configbuf = state.configData1;
}
}
var obj = {
index: props.formData.index,
drive: props.formData.drive.name,
Description: props.formData.Description,
serial: props.formData.drive.serial,
config: req_configbuf,
};
console.log('编辑数据3', obj);
} else { //
console.log('编辑数据1', state.configData)
console.log('编辑数据2', state.configData1)
if (props.formData.serial) {
req_configbuf = state.configData
} else {
if (props.formData.drive == "modbusTCP") {
req_configbuf = state.configData1;
}
}
obj = {
name: props.formData.name,
drive: props.formData.drive,
description: props.formData.description,
serial: props.formData.serial,
config: req_configbuf,
};
console.log('编辑数据3', obj);
}
const res = props.type === '0' ? await infoApi.saveTx(obj) : await infoApi.editTx(obj);
const res = props.type === '0' ? await infoApi.saveTx(state.addForm) : await infoApi.editTx(state.addForm);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ctx.emit("dialogSuccess");

View File

@ -2,14 +2,14 @@
<el-dialog v-model="visible" :title="type === 'I' ? '新增模板' : '编辑模板'" width="30%" :before-close="closeDialog">
<el-form :model="addForm" label-width="100px" :rules="rules" ref="ruleFormRef">
<el-form-item label="模板名称:" prop="name">
<el-input v-model="addForm.name" placeholder="请输入模板名称" clearable :disabled="type === 'I' ? false : true" />
<el-input v-model="addForm.name" placeholder="请输入模板名称" clearable :disabled="type !== 'I'" />
</el-form-item>
<el-form-item label="模板描述:" prop="description">
<el-input v-model="addForm.description" placeholder="请输入模板描述" clearable />
</el-form-item>
<el-form-item label="模板类型:" prop="type">
<el-select v-model="addForm.type" clearable placeholder="请选择模板类型" @change="driveChange" :disabled="type !== 'I'">
<el-select v-model="addForm.type" placeholder="请选择模板类型" @change="driveChange" :disabled="type !== 'I'">
<el-option v-for="(item, index) of typeOptions" :key="index" :label="item.name" :value="item.key" />
</el-select>
</el-form-item>

View File

@ -147,13 +147,9 @@ export default {
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
const param = {
point_name: props.formData.name + '/' + state.addForm.name,
point: {
description: state.addForm.description,
address: Number(state.addForm.address),
type: state.addForm.type,
byte_order: state.addForm.byte_order
}
template_name: props.formData.name,
...state.addForm,
address: Number(state.addForm.address)
}
const res = await infoApi.addP(param);
if (res.code == 0) {

View File

@ -78,11 +78,15 @@ export default {
const getPointList = async () => {
const parm = {
name: props.formData.name
template_name: props.formData.name
}
const res = await infoApi.getP(parm);
if (res.code == 0) {
state.propertiesData = res.data;
state.propertiesData = [];
const pointData = res.data;
for (let i in pointData) {
state.propertiesData.push(pointData[i]);
}
} else {
console.log(res);
}
@ -99,7 +103,8 @@ export default {
})
.then(async () => {
let param = {
point_name: item.name
template_name: props.formData.name,
name: item.name
}
const res = await infoApi.detP(param);
if (res.code == 0) {

View File

@ -56,13 +56,14 @@ axios.interceptors.response.use(
}
);
// post
export function postPBRequest(url, params, actionNum) {
export function postPBRequest(url, params, actionNum,template_name) {
return axios({
method: "post",
url: url,
data: params,
headers: {
"action": actionNum,
"template_name": template_name
},
});
}

View File

@ -32,7 +32,7 @@
</el-table-column>
</el-table>
</div>
<AddMb :type="type" :formData="formData" :dialogVisible="dialogVisible" v-if="dialogVisible"
<AddMb :type="type" :formData="formData" :templateData="templateData" :dialogVisible="dialogVisible" v-if="dialogVisible"
@dialogClose="dialogClose" @dialogSuccess="dialogSuccess">
</AddMb>
<AddPoint :formData="formData1" :dialogVisible="dialogVisible1" v-if="dialogVisible1" @dialogClose="dialogClose"

View File

@ -14,14 +14,14 @@
>
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column
prop="index"
prop="name"
label="通讯名称"
width="200"
align="center"
show-overflow-tooltip
/>
<el-table-column
prop="Description"
prop="description"
label="通讯描述"
width="200"
align="center"
@ -38,13 +38,13 @@
<span>{{ qudongOptions[scope.row.type]}}</span>
</template>
</el-table-column>
<el-table-column
<!-- <el-table-column
prop="host"
label="主机地址"
width="200"
align="center"
show-overflow-tooltip
/>
/> -->
<el-table-column
prop="status"
label="通讯状态"
@ -181,10 +181,8 @@ export default {
const addData = () => {
state.formData = {
name: '',
drive: '',
type: 1,
description: '',
serial: false,
config: '',
};
state.dialogVisible = true;
state.type = '0';
@ -229,9 +227,8 @@ export default {
console.log(item.enable);
const param = {
name: item.name,
url: item.enable ? 'start': 'stop'
}
const res = await infoApi.changeStatus(param);
const res = item.enable ? await infoApi.startStatus(param) : await infoApi.stopStatus(param);
if (res.code == 0) {
ElMessage.success(res.msg || "请求成功");
getTableData();