**
以下为Vue部分
**
handleSelectionChange(val) {
this.multipleSelection = val;
},
var ids = []
this.multipleSelection.forEach(row => {
ids.push(row.id)//将选中行的id进行循环遍历存入自定义的ids数组中
})
this.form2 = {
idArr:ids,//将存放id的数组传给后台新建的一个idArr字段
testmachine:_self.testmachine_input,
testtime:_self.testtime_input,
jobnum:_self.jobnum,
moduser:_self.userId,
testresult:_self.form2.testresult2
}
this.$http({
method: 'post',
url: '/SerialnumberCheckinfoLink/UpdateSerialnumberCheckinfoLinkAll/',
data: _self.form2
})
插入element ui官方的自带属性
分别插入 :row-key="(row)=>{ return row.id}", :reserve-selection=“true” 属性为分页自动保留多选选中状态
以下为c#部分
public int [] idArr { get; set; }//另外再定义的一个存放前端传来的id数组(就是前面的ids)
业务层方法
public VmWebResponse<SerialnumberCheckinfoLink> UpdateSerialnumberCheckinfoLinkAll(SerialnumberCheckinfoLink serialnumberCheckinfoLink)
{
try
{
SerialnumberCheckinfoLinkDao serialnumberCheckinfoLinkDao = new SerialnumberCheckinfoLinkDao(conn);
//List<SerialnumberCheckinfoLink> serialnumberCheckinfoLinklist = serialnumberCheckinfoLinkDao.GetById(serialnumberCheckinfoLink.id);
for (int i = 0; i < serialnumberCheckinfoLink.idArr.Length; i++)
{
serialnumberCheckinfoLink.moddate = DateTime.Now;
serialnumberCheckinfoLink.id = serialnumberCheckinfoLink.idArr[i];//循环每次传入的id数组赋值给id去数据库查找
serialnumberCheckinfoLinkDao.Updateall(serialnumberCheckinfoLink);
}
return new VmWebResponse<SerialnumberCheckinfoLink>(serialnumberCheckinfoLink);
}
catch (Exception ex)
{
return new VmWebResponse<SerialnumberCheckinfoLink>(1, ex);
}
}