<el-table
v-loading="loading"
:data="productList"
lazy
ref="dataTreeList"
:row-key="getRowkey"
:load="load"
:expand-row-keys="expands"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
@selection-change="handleSelectionChange"
:cell-class-name="addClass2"
>
@selection-change="handleSelectionChange"
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id);
console.log(selection);
this.formValue = selection[0];
console.log(this.ids);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
handleUpdate(row) {
this.reset();
if (row) {
this.form = { ...row };
this.open = true;
this.title = "修改下发配置页面";
} else {
this.form = this.formValue;
this.open = true;
this.title = "修改下发配置页面";
}
},
**调新增接口,判断是否有id,没有就调新增接口** 这个字段id 和后端定义好是哪个就判断按
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != undefined) {
updateDevice(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addDevice(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
handleDelete(row) {
const deviceids = row.id || this.ids;
this.$confirm(
'是否确认删除下发配置编号为"' + deviceids + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}
)
.then(function() {
return delDevice(deviceids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
})
.catch(function() {});
}
}
};