瓶中沙 2024-06-27 10:04:04 +08:00
commit 610e3c0c1b
7 changed files with 45 additions and 33 deletions

View File

@ -110,10 +110,10 @@ export default {
const res = props.type === 'I' ? await infoApi.saveTx(req_data) : await infoApi.updateTx(req_data); const res = props.type === 'I' ? await infoApi.saveTx(req_data) : await infoApi.updateTx(req_data);
const ret = response.decode(new Uint8Array(res)); const ret = response.decode(new Uint8Array(res));
if(ret.code == 0) { if(ret.code == 0) {
ElMessage.success(res.msg || '请求成功'); ElMessage.success(res.message || '请求成功');
ctx.emit("dialogSuccess"); ctx.emit("dialogSuccess");
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
} else { } else {
} }

View File

@ -2,20 +2,19 @@
<el-dialog v-model="visible" title="设备管理" width="40%" :before-close="closeDialog"> <el-dialog v-model="visible" title="设备管理" width="40%" :before-close="closeDialog">
<el-form :model="addForm" label-width="100px" :rules="rules" ref="ruleFormRef" size="large"> <el-form :model="addForm" label-width="100px" :rules="rules" ref="ruleFormRef" size="large">
<el-form-item label="设备名称:" prop="name"> <el-form-item label="设备名称:" prop="name">
<el-input v-model="addForm.name" placeholder="请输入设备名称" clearable :disabled="type!=='I'"/> <el-input v-model="addForm.name" placeholder="请输入设备名称不超过10" maxlength="10" clearable :disabled="type !== 'I'" />
</el-form-item> </el-form-item>
<el-form-item label="设备id:" prop="id"> <el-form-item label="设备id:" prop="id">
<el-input v-model="addForm.id" placeholder="请输入设备id:1-255" clearable type="number" /> <el-input v-model="addForm.id" placeholder="请输入设备id:1-255" clearable type="number" />
</el-form-item> </el-form-item>
<el-form-item label="模板名称:" prop="template_name"> <el-form-item label="模板名称:" prop="template_name">
<el-select v-model="addForm.template_name" size="mini" placeholder="请选择模板名称"> <el-select v-model="addForm.template_name" size="mini" placeholder="请选择模板名称">
<el-option v-for="item in modelArr" :key="item.name" :label="item.name" <el-option v-for="item in modelArr" :key="item.name" :label="item.name" :value="item.name" />
:value="item.name" />
</el-select> </el-select>
</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="请输入点位描述不超过50" maxlength="50" clearable />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>

View File

@ -396,7 +396,7 @@ export default {
ElMessage.success(res.msg || '请求成功'); ElMessage.success(res.msg || '请求成功');
ctx.emit("dialogSuccess"); ctx.emit("dialogSuccess");
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
} else { } else {
} }

View File

@ -5,7 +5,7 @@
<span>通讯名称{{ formData.name }}</span> <span>通讯名称{{ formData.name }}</span>
<span>通讯描述{{ formData.description }}</span> <span>通讯描述{{ formData.description }}</span>
<span>通信驱动{{ qudongOptions[formData.type] }}</span> <span>通信驱动{{ qudongOptions[formData.type] }}</span>
<span>设备数量{{ propertiesData.length }}</span> <span>设备数量{{ driverInfo.device_count }}</span>
</el-card> </el-card>
<div class="top-btn"> <div class="top-btn">
<el-button type="primary" size="large" @click="manageData"> <el-button type="primary" size="large" @click="manageData">
@ -30,7 +30,7 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="180" show-overflow-tooltip> <el-table-column label="操作" align="center" width="180" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<el-button type="primary" 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)">
@ -61,7 +61,8 @@ export default {
formData1: {}, formData1: {},
setData: {}, setData: {},
dialogVisible1: false, dialogVisible1: false,
type: 'I' type: 'I',
driverInfo: {}
}); });
const visible = computed(() => { const visible = computed(() => {
return props.dialogVisible; return props.dialogVisible;
@ -72,12 +73,24 @@ export default {
}); });
const getSet = async () => { const getSet = async () => {
state.propertiesData = [];
const parm = { const parm = {
driver_name: props.formData.name driver_name: props.formData.name
} }
const res = await infoApi.getSet(parm); const res = await infoApi.getSet(parm);
if (res.code == 0) { if (res.code == 0) {
state.propertiesData = res.data || []; state.driverInfo = res.data;
let devices = res.data.devices
if (devices) {
for (let key in devices) {
if (devices.hasOwnProperty(key)) {
state.propertiesData.push(devices[key]);
}
}
state.propertiesData = state.propertiesData.sort((a, b) => {
return (a.name > b.name ? 1 : -1)
});
}
} else { } else {
ElMessage.error(res.data || res.message); ElMessage.error(res.data || res.message);
} }
@ -102,7 +115,7 @@ export default {
ElMessage.success(res.message || "删除成功"); ElMessage.success(res.message || "删除成功");
getSet(); getSet();
} else { } else {
ElMessage.error(res.message | "删除失败"); ElMessage.error(res.data | res.message);
} }
}) })
.catch(() => { .catch(() => {

View File

@ -47,9 +47,9 @@
<el-button type="danger" size="large" @click="delData(scope.row)"> <el-button type="danger" size="large" @click="delData(scope.row)">
删除 删除
</el-button> </el-button>
<!-- <el-button type="primary" size="large" @click="viewData(scope.row)"> <el-button type="primary" size="large" @click="viewData(scope.row)">
设备 设备
</el-button> --> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -254,10 +254,10 @@ export default {
} }
const res = !item.enable ? await infoApi.startStatus(param) : await infoApi.stopStatus(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.message || "请求成功");
getTableData(); getTableData();
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
}; };

View File

@ -170,10 +170,10 @@ export default {
const res = await infoApi.delSc(req_data); const res = await infoApi.delSc(req_data);
const ret = response.decode(new Uint8Array(res)); const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) { if (ret.code == 0) {
ElMessage.success(res.msg || "请求成功"); ElMessage.success(res.message || "请求成功");
getTableData(); getTableData();
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
}) })
.catch(() => { .catch(() => {
@ -187,10 +187,10 @@ export default {
}; };
const res = await infoApi.stopSc(param); const res = await infoApi.stopSc(param);
if (res.code == 0) { if (res.code == 0) {
ElMessage.success(res.msg || "请求成功"); ElMessage.success(res.message || "请求成功");
getTableData(); getTableData();
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
}; };

View File

@ -131,10 +131,10 @@ export default {
const res = await infoApi.postRules(req_data1); const res = await infoApi.postRules(req_data1);
const ret = response.decode(new Uint8Array(res)); const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) { if (ret.code == 0) {
ElMessage.success(res.msg || "请求成功"); ElMessage.success(res.message || "请求成功");
getTableData(); getTableData();
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
}) })
.catch(() => { .catch(() => {
@ -175,10 +175,10 @@ export default {
const res = item.enable==='启动' ? await infoApi.postRules(req_data2) : await infoApi.postRules(req_data1); const res = item.enable==='启动' ? await infoApi.postRules(req_data2) : await infoApi.postRules(req_data1);
const ret = response.decode(new Uint8Array(res)); const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) { if (ret.code == 0) {
ElMessage.success(res.msg || "更新成功"); ElMessage.success(res.message || "更新成功");
getTableData(); getTableData();
} else { } else {
ElMessage.error(res.msg); ElMessage.error(res.message);
} }
}; };
const dialogClose = () => { const dialogClose = () => {