/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
// 把数组转为字符串以逗号分隔
if (this.form.userIds && this.form.userIds.length > 0) {
this.form.userIds = this.form.userIds.join(",");
}
if (this.form.id != undefined) {
updateGroup(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addGroup(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
给返回值新增字段
response.rows.forEach(r => {
r.streetid = '';
r.AEE = '';
});
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
console.log('row',row);
this.form = { ...row };
// 所属区属回显
this.form.companyaddress = [
row.groupExt1Id,
row.groupExt2Id,
row.groupExt3Id,
row.groupAreaId
];
// 群组人员回显
if (this.form.userIds) {
this.$set(
this.form,
"userIds",
this.form.userIds.split(",").map(item => (item = parseInt(item)))
);
}
this.open = true;
this.title = "修改群组";
},
下拉框多选的时候 会造出样式布局问题 添加样式
<el-form-item label="群组人员">
<el-select
v-model="form.userIds"
multiple
placeholder="请选择群组人员"
clearable
>
<el-option
v-for="item in users"
:key="item.userId"
:label="item.nickName"
:value="parseInt(item.userId)"
>
</el-option>
</el-select>
::v-deep .el-select__tags {
max-height: 56px;
max-width: none !important;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
}
接口数据去重
**getDevice() {
listDeviceNew({ ...this.queryParams, queryParam: 1 }).then(res => {
var tempData = res.data.totalList.rows;
var hash = {};
// 去重
tempData = tempData.reduce(function(item, index) {
hash[index.devicename]
? ""
: (hash[index.devicename] = true && item.push(index));
return item;
}, []);
// 把后端返回的空值过滤
this.deviceList = tempData.filter(r => {
return r.devicename;
});
});
},**