|
@@ -7,11 +7,7 @@
|
|
|
<el-page-header @back="goBack" :content="mainDeviceInfo.name" />
|
|
|
</el-col>
|
|
|
<el-col :span="4">
|
|
|
- <el-button
|
|
|
- @click="showAddSubDevice=true"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-document-add"
|
|
|
- >添加</el-button>
|
|
|
+ <el-button @click="add" type="primary" icon="el-icon-document-add">添加</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
@@ -48,9 +44,9 @@
|
|
|
<!-- <el-form-item label="MAC/SN:">
|
|
|
<el-input v-model="form.deviceNo"></el-input>
|
|
|
</el-form-item>-->
|
|
|
- <el-form-item label="通讯ID:">
|
|
|
+ <!-- <el-form-item label="通讯ID:">
|
|
|
<el-input v-model="form.communicationId"></el-input>
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item>-->
|
|
|
<el-form-item label="通道:">
|
|
|
<el-input v-model="form.channelNo"></el-input>
|
|
|
</el-form-item>
|
|
@@ -67,7 +63,7 @@
|
|
|
|
|
|
<el-form-item>
|
|
|
<el-button @click="onCancel">取 消</el-button>
|
|
|
- <el-button type="primary" @click="addSubDevice">保 存</el-button>
|
|
|
+ <el-button type="primary" @click="saveSubDevice()">保 存</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
@@ -86,12 +82,11 @@ export default {
|
|
|
subDeviceList: [], // 子设备信息列表
|
|
|
showAddSubDevice: false,
|
|
|
form: {
|
|
|
- // deviceNo: "",
|
|
|
- communicationId: '',
|
|
|
channelNo: "",
|
|
|
- // hardTypeId: null,
|
|
|
enable: 1
|
|
|
- }
|
|
|
+ },
|
|
|
+ isAdd: null, // 是添加还是编辑 标识符
|
|
|
+ editParmas: {} // 保存编辑的 请求参数
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -122,11 +117,16 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- // 编辑
|
|
|
- edit(row) {
|
|
|
- console.log("编辑", row);
|
|
|
+
|
|
|
+ add() {
|
|
|
this.showAddSubDevice = true;
|
|
|
+ this.isAdd = true;
|
|
|
+ this.form = {
|
|
|
+ channelNo: "",
|
|
|
+ enable: 1
|
|
|
+ };
|
|
|
},
|
|
|
+
|
|
|
// 删除 (接口有问题)
|
|
|
del(row) {
|
|
|
console.log("删除 未完成", row);
|
|
@@ -143,26 +143,54 @@ export default {
|
|
|
},
|
|
|
fail: err => {
|
|
|
console.log(err);
|
|
|
- if (err.errCode == '200') {
|
|
|
+ if (err.errCode == "200") {
|
|
|
this.$message.error(err.errMsg);
|
|
|
// 获取子设备信息列表
|
|
|
this.doSubDeviceList();
|
|
|
- } else if(err.errMsg) {
|
|
|
+ } else if (err.errMsg) {
|
|
|
this.$message.success(err.errMsg);
|
|
|
} else this.$message.error("服务器发生异常");
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 编辑 /device-slave/update
|
|
|
+ edit(row) {
|
|
|
+ console.log("编辑", row);
|
|
|
+ this.isAdd = false;
|
|
|
+ this.showAddSubDevice = true;
|
|
|
+ this.form.channelNo = row.channelNo;
|
|
|
+ this.form.enable = row.enable;
|
|
|
+ this.editParmas = {
|
|
|
+ id: row.id,
|
|
|
+ communicationId: row.communicationId,
|
|
|
+ deviceNo: row.deviceNo,
|
|
|
+ hardTypeId: row.hardTypeId
|
|
|
+ };
|
|
|
+ },
|
|
|
// 保存 添加子设备信息 (接口有问题)
|
|
|
- addSubDevice() {
|
|
|
- console.log("保存 添加子设备信息", this.form);
|
|
|
- let data = Object.assign(this.form, {
|
|
|
- deviceNo: this.mainDeviceInfo.deviceNo,
|
|
|
- hardTypeId: this.mainDeviceInfo.hardTypeId
|
|
|
- });
|
|
|
+ saveSubDevice() {
|
|
|
+ let data, api, method;
|
|
|
+ // 是添加
|
|
|
+ if (this.isAdd) {
|
|
|
+ api = "/device/device-slave/add";
|
|
|
+ method = "POST";
|
|
|
+ data = Object.assign(this.form, {
|
|
|
+ communicationId: this.mainDeviceInfo.id,
|
|
|
+ deviceNo: this.mainDeviceInfo.deviceNo,
|
|
|
+ hardTypeId: this.mainDeviceInfo.hardTypeId
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 是编辑
|
|
|
+ api = "/device/device-slave/update";
|
|
|
+ method = "POST";
|
|
|
+ data = Object.assign(this.form, this.editParmas);
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(this.isAdd ? "添加" : "编辑");
|
|
|
+
|
|
|
this.fetch({
|
|
|
- api: "/device/device-slave/add",
|
|
|
- method: "POST",
|
|
|
+ api,
|
|
|
+ method,
|
|
|
data,
|
|
|
success: res => {
|
|
|
console.log(res);
|
|
@@ -170,11 +198,11 @@ export default {
|
|
|
this.doSubDeviceList();
|
|
|
this.showAddSubDevice = false;
|
|
|
this.form = {
|
|
|
- communicationId: null,
|
|
|
+ communicationId: "",
|
|
|
channelNo: "",
|
|
|
enable: 1
|
|
|
};
|
|
|
- this.$message.success("添加子设备信息成功");
|
|
|
+ this.$message.success(this.isAdd?"添加子设备信息成功!":"编辑子设备信息成功!");
|
|
|
},
|
|
|
fail: err => {
|
|
|
console.log(err);
|