// 验证用户是否具备某权限
this.$auth.hasPermi("system:user:add");
设置对接的按钮权限
<el-table-column label="是否推荐" align="center" width="100">
<template slot-scope="scope">
<el-switch
v-model="scope.row.isRecommend"
:active-value="1"
:inactive-value="0"
@click.native="handleTypeChange(scope.row)"
></el-switch>
</template>
</el-table-column>
handleTypeChange(row) {
//console.log(this.$auth.hasPermi("system:product:recommend"),'77777');
// console.log(this.$store.getters.userData.userId,'66778898');
if(this.$auth.hasPermi("system:product:recommend")){
let text = row.isRecommend === 0 ? "不推荐" : "推荐";
this.$modal
.confirm('确认要"' + text + '"该商品吗?')
.then(function () {
// 调用 商品 是否推荐 接口,
return updateShopType({
pId: row.pId,
isRecommend: row.isRecommend,
});
})
.then(() => {
this.$modal.msgSuccess(text + "成功");
this.getList();
})
.catch(function () {
row.isRecommend = row.isRecommend === 0 ? 1 : 0;
});
}else{
this.$message.warning("暂无权限")
row.isRecommend = row.isRecommend === 0 ? 1 : 0;
}
},