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

View File

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

View File

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

View File

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

View File

@ -78,11 +78,15 @@ export default {
const getPointList = async () => { const getPointList = async () => {
const parm = { const parm = {
name: props.formData.name template_name: props.formData.name
} }
const res = await infoApi.getP(parm); const res = await infoApi.getP(parm);
if (res.code == 0) { 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 { } else {
console.log(res); console.log(res);
} }
@ -99,7 +103,8 @@ export default {
}) })
.then(async () => { .then(async () => {
let param = { let param = {
point_name: item.name template_name: props.formData.name,
name: item.name
} }
const res = await infoApi.detP(param); const res = await infoApi.detP(param);
if (res.code == 0) { if (res.code == 0) {

View File

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

View File

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