<el-table-column label="状态">
<template #default="scope">
<el-switch :modelValue="scope.row.status"
:active-value="1"
:inactive-value="0"
@change="handleStatus($event, scope.row)">
</el-switch>
</template>
</el-table-column>
//改变商品规格状态
const handleStatus = (status,row)=>{
console.log(status,row);
updateSkusStatus(row.id,status).then(res=>{
toast('修改状态成功')
row.status = status
})
}
接口信息:
export function updateSkusStatus(id,status){
return service.post(`/admin/skus/${id}/update_status`,{
status
})
}