增加用户授权、公司授权 以及优化部门、角色、用户接口
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<el-container class="mainBox mainBoxHeaderNoBorder">
|
||||
<el-header>
|
||||
<div class="left-panel">
|
||||
<el-button type="primary" :size="size" icon="el-icon-plus" @click="add"></el-button>
|
||||
<el-button type="primary" :size="size" icon="el-icon-plus" @click="add">新增部门</el-button>
|
||||
<el-button type="danger" :size="size" plain icon="el-icon-delete" :disabled="selection.length==0" @click="batch_del"></el-button>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
@@ -24,8 +24,7 @@
|
||||
<el-button class="noBorderBtn" icon="el-icon-more" :size="size"></el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<!-- <el-dropdown-item @click="handlerCommand(scope.row, 'see')" icon="sc-icon-See">查看 </el-dropdown-item>-->
|
||||
<!-- <el-dropdown-item @click="handlerCommand(scope.row, 'review')" icon="sc-icon-Review" v-if="scope.row.review_status == 0">审核</el-dropdown-item>-->
|
||||
<!-- <el-dropdown-item @click="handlerCommand(scope.row, 'review')" icon="sc-icon-Review">审核</el-dropdown-item>-->
|
||||
<!-- <el-dropdown-item @click="handlerCommand(scope.row, 'cancel')" icon="sc-icon-Revoke">撤回</el-dropdown-item>-->
|
||||
<el-dropdown-item @click="table_edit(scope.row, 'edit')" icon="sc-icon-Edit">修改</el-dropdown-item>
|
||||
<el-dropdown-item @click="table_del(scope.row, 'delete')" icon="sc-icon-Delete" divided>删除</el-dropdown-item>
|
||||
@@ -97,18 +96,17 @@
|
||||
status: row.active_status,
|
||||
};
|
||||
const res = await this.$API.system.dept.status.post(params);
|
||||
if(res.code ==200){
|
||||
console.log(res.data)
|
||||
}else{
|
||||
if(res.code !=200){
|
||||
row.active_status = !row.active_status;
|
||||
}
|
||||
delete row.$switch_status;
|
||||
delete row.$switch_yx;
|
||||
}, 500);
|
||||
},
|
||||
//删除
|
||||
async table_del(row){
|
||||
const reqData = {id: row.id};
|
||||
const res = await this.$API.demo.post.post(reqData);
|
||||
const res = await this.$API.system.dept.delete.post(reqData);
|
||||
if(res.code == 200){
|
||||
this.$refs.table.refresh()
|
||||
this.$message.success("删除成功")
|
||||
@@ -120,11 +118,15 @@
|
||||
async batch_del(){
|
||||
this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?如果删除项中含有子集将会被一并删除`, '提示', {
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
}).then(async () => {
|
||||
const loading = this.$loading();
|
||||
this.$refs.table.refresh()
|
||||
const params = {ids: this.selection.map(em => em.id)};
|
||||
const res = await this.$API.system.dept.delete.post(params);
|
||||
if (res.code == 200) {
|
||||
this.$refs.table.refresh()
|
||||
this.$message.success("删除成功")
|
||||
}
|
||||
loading.close();
|
||||
this.$message.success("操作成功")
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<el-dialog :title="titleMap[mode]" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
|
||||
<el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="100px">
|
||||
<el-form-item label="上级部门" prop="parentId">
|
||||
<el-cascader v-model="form.parentId" :options="groups" :props="groupsProps" :show-all-levels="false" clearable style="width: 100%;"></el-cascader>
|
||||
<el-form-item label="上级部门" prop="parent_id">
|
||||
<el-cascader v-model="form.parent_id" :options="depts" :props="deptsProps" :show-all-levels="false" clearable style="width: 100%;"></el-cascader>
|
||||
</el-form-item>
|
||||
<el-form-item label="部门名称" prop="label">
|
||||
<el-input v-model="form.label" placeholder="请输入部门名称" clearable></el-input>
|
||||
<el-form-item label="部门名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入部门名称" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否有效" prop="status">
|
||||
<el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
|
||||
<el-form-item label="状态" prop="active_status">
|
||||
<el-switch v-model="form.active_status" :active-value="true" :inactive-value="false"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" clearable type="textarea"></el-input>
|
||||
@@ -16,7 +16,7 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="visible=false" >取 消</el-button>
|
||||
<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
|
||||
<el-button v-if="mode!='show'" type="primary" :loading="isSave" @click="submit()">保 存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -33,28 +33,27 @@
|
||||
show: '查看'
|
||||
},
|
||||
visible: false,
|
||||
isSaveing: false,
|
||||
isSave: false,
|
||||
//表单数据
|
||||
form: {
|
||||
parent_id: "",
|
||||
id:"",
|
||||
parentId: "",
|
||||
label: "",
|
||||
sort: 1,
|
||||
status: "1",
|
||||
name: "",
|
||||
active_status: true,
|
||||
remark: ""
|
||||
},
|
||||
//验证规则
|
||||
rules: {
|
||||
sort: [
|
||||
{required: true, message: '请输入排序', trigger: 'change'}
|
||||
],
|
||||
label: [
|
||||
name: [
|
||||
{required: true, message: '请输入部门名称'}
|
||||
]
|
||||
],
|
||||
active_status: [
|
||||
{required: true,}
|
||||
],
|
||||
},
|
||||
//所需数据选项
|
||||
groups: [],
|
||||
groupsProps: {
|
||||
depts: [],
|
||||
deptsProps: {
|
||||
value: "id",
|
||||
emitPath: false,
|
||||
checkStrictly: true
|
||||
@@ -73,37 +72,35 @@
|
||||
},
|
||||
//加载树数据
|
||||
async getGroup(){
|
||||
var res = await this.$API.system.dept.list.get();
|
||||
this.groups = res.data;
|
||||
const res = await this.$API.system.dept.active.post();
|
||||
if(res.code == 200){
|
||||
this.depts = res.data;
|
||||
}
|
||||
},
|
||||
//表单提交方法
|
||||
submit(){
|
||||
this.$refs.dialogForm.validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.isSaveing = true;
|
||||
var res = await this.$API.demo.post.post(this.form);
|
||||
this.isSaveing = false;
|
||||
this.isSave = true;
|
||||
const res = await this.$API.system.dept.add.post(this.form);
|
||||
this.isSave = false;
|
||||
if(res.code == 200){
|
||||
this.$emit('success', this.form, this.mode)
|
||||
this.visible = false;
|
||||
this.$message.success("操作成功")
|
||||
}else{
|
||||
this.$alert(res.message, "提示", {type: 'error'})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//表单注入数据
|
||||
setData(data){
|
||||
this.form.id = data.id
|
||||
this.form.label = data.label
|
||||
this.form.status = data.status
|
||||
this.form.sort = data.sort
|
||||
this.form.parentId = data.parentId
|
||||
this.form.remark = data.remark
|
||||
|
||||
//可以和上面一样单个注入,也可以像下面一样直接合并进去
|
||||
//Object.assign(this.form, data)
|
||||
async setData(data) {
|
||||
let params = {
|
||||
id: data.id
|
||||
}
|
||||
const res = await this.$API.system.dept.info.post(params);
|
||||
if (res.code == 200) {
|
||||
this.form = res.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user