瓶中沙 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 ret = response.decode(new Uint8Array(res));
if(ret.code == 0) {
ElMessage.success(res.msg || '请求成功');
ElMessage.success(res.message || '请求成功');
ctx.emit("dialogSuccess");
} else {
ElMessage.error(res.msg);
ElMessage.error(res.message);
}
} else {
}

View File

@ -2,20 +2,19 @@
<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-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 label="设备id:" prop="id">
<el-input v-model="addForm.id" placeholder="请输入设备id:1-255" clearable type="number" />
</el-form-item>
<el-form-item label="模板名称:" prop="template_name">
<el-select v-model="addForm.template_name" size="mini" placeholder="请选择模板名称">
<el-option v-for="item in modelArr" :key="item.name" :label="item.name"
:value="item.name" />
<el-option v-for="item in modelArr" :key="item.name" :label="item.name" :value="item.name" />
</el-select>
</el-form-item>
<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>
<template #footer>
@ -51,9 +50,9 @@ export default {
name: [{ required: true, message: "请输入设备名称", trigger: "blur" }],
template_name: [{ required: true, message: "请选择模板名称", trigger: "blur" }],
id: [
{ required: true, message: "请输入设备ID", trigger: "blur" },
{ required: true, validator: checkSetId, trigger: "blur" }
],
{ required: true, message: "请输入设备ID", trigger: "blur" },
{ required: true, validator: checkSetId, trigger: "blur" }
],
},
});
const visible = computed(() => {
@ -75,12 +74,12 @@ export default {
state.modelArr = [];
const data = res.data;
for (let i in data) {
let obj = {
key: Number(i),
name: data[i]
let obj = {
key: Number(i),
name: data[i]
}
state.modelArr.push(obj);
}
state.modelArr.push(obj);
}
state.addForm.template_name = state.modelArr[0].name;
} else {
ElMessage.error(res.data || res.message);
@ -100,7 +99,7 @@ export default {
...state.addForm,
id: Number(state.addForm.id)
}
const res = props.type === 'I' ? await infoApi.addSet(param): await infoApi.editSet(param);
const res = props.type === 'I' ? await infoApi.addSet(param) : await infoApi.editSet(param);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ctx.emit("dialogSuccess");

View File

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

View File

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

View File

@ -47,9 +47,9 @@
<el-button type="danger" size="large" @click="delData(scope.row)">
删除
</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>
</el-table-column>
</el-table>
@ -254,10 +254,10 @@ export default {
}
const res = !item.enable ? await infoApi.startStatus(param) : await infoApi.stopStatus(param);
if (res.code == 0) {
ElMessage.success(res.msg || "请求成功");
ElMessage.success(res.message || "请求成功");
getTableData();
} 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 ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
ElMessage.success(res.msg || "请求成功");
ElMessage.success(res.message || "请求成功");
getTableData();
} else {
ElMessage.error(res.msg);
ElMessage.error(res.message);
}
})
.catch(() => {
@ -187,10 +187,10 @@ export default {
};
const res = await infoApi.stopSc(param);
if (res.code == 0) {
ElMessage.success(res.msg || "请求成功");
ElMessage.success(res.message || "请求成功");
getTableData();
} 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 ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
ElMessage.success(res.msg || "请求成功");
ElMessage.success(res.message || "请求成功");
getTableData();
} else {
ElMessage.error(res.msg);
ElMessage.error(res.message);
}
})
.catch(() => {
@ -175,10 +175,10 @@ export default {
const res = item.enable==='启动' ? await infoApi.postRules(req_data2) : await infoApi.postRules(req_data1);
const ret = response.decode(new Uint8Array(res));
if (ret.code == 0) {
ElMessage.success(res.msg || "更新成功");
ElMessage.success(res.message || "更新成功");
getTableData();
} else {
ElMessage.error(res.msg);
ElMessage.error(res.message);
}
};
const dialogClose = () => {