45 Star 0 Fork 0

天一_生水/jqr-school-3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rolePermission.vue 4.39 KB
一键复制 编辑 原始数据 按行查看 历史
许木伟 提交于 2023-05-24 15:42 . roleRermission
<template>
<div>
<el-button type="primary" @click="add">添加用户</el-button>
<el-table :data="tableData">
<el-table-column prop="id" label="id" align="center" />
<el-table-column prop="roleId" label="roleId" align="center" />
<el-table-column prop="permissionIds" label="permissionIds" align="center" />
<el-table-column prop="createTime" label="createTime" align="center" />
<el-table-column prop="updateTime" label="updateTime" align="center" />
<el-table-column label="操作">
<template #default="scope">
<el-button type="primary" @click="edit(scope.row)">编辑</el-button>
<el-button type="danger" @click="del(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog v-model="dialogFormVisible" :title="state ? '添加学生信息' : '修改学生信息'">
<el-form :model="form">
<el-form-item label="id" prop="id">
<el-input v-model="form.id" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="roleId" prop="roleId">
<el-input v-model="form.roleId" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="permissionIds" prop="permissionIds">
<el-input v-model="form.permissionIds" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="sure('form')">
确定
</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { onMounted, ref, reactive } from 'vue';
import { roleGetall, roleAdd, roleDel, roleEdit } from '../../http/rolePermission'
import { ElMessage, ElMessageBox } from 'element-plus';
const dialogFormVisible = ref(false)
const tableData = ref([])
const state = ref(true)
const form = ref({
id: '',
roleId:'',
permissionIds:'',
// createTime: '',
// updateTime: ''
});
onMounted(() => {
Getall()
})
const Getall = async () => {
const data = await roleGetall()
if (data.code !== 1) {
return ElMessage('数据获取失败')
}
tableData.value = data.data.rolePermissions
console.log(data);
console.log(data.code);
}
const add = () => {
form.value = {
id: '',
roleId:'',
permissionIds:'',
// createTime: '',
// updateTime: ''
}
state.value = true
dialogFormVisible.value = true
}
const sure = async (form) => {
if (state) {
const data = await roleAdd(form.value)
console.log(data);
} else {
const data = await roleEdit(form.value)
console.log(data);
}
}
const edit = (row) => {
state.value = false
dialogFormVisible.value = true
form.value = { ...row };
console.log(row);
}
const del = async (row) => {
ElMessageBox.confirm("是否删除该用户?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
//调用删除接口
del({
id: val.id
}).then(res => {
if (res.code === 1) {
ElMessage({
type: 'success',
message: '删除成功',
})
this.findPage()
} else {
ElMessage({
type: 'error',
message: '删除失败',
})
}
})
}).catch(() => {
ElMessage({
type: 'info',
message: '取消删除',
})
})
}
</script>
<style lang="scss" scoped>
.home {
background-color: $blue;
}
.index {
background-color: red;
}
</style>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/wuzongbo/jqr-school-3.git
git@gitee.com:wuzongbo/jqr-school-3.git
wuzongbo
jqr-school-3
jqr-school-3
master

搜索帮助