员工岗位修改

This commit is contained in:
2309368887@qq.com 2022-07-18 09:59:46 +08:00
parent 4e3da40fdb
commit b3c432c35d
4 changed files with 254 additions and 203 deletions

View File

@ -262,15 +262,6 @@ export default {
return await http.post(this.url,data); return await http.post(this.url,data);
} }
}, },
/*update: {
name: "更新岗位",
req: async function(id, data){
return await http.put(
`${config.API_URL}/system/post_role/${id}/`,
data
);
}
},*/
delete: { delete: {
name: "删除岗位", name: "删除岗位",
req: async function(id){ req: async function(id){

View File

@ -603,7 +603,8 @@ const routes = [
"meta": { "meta": {
"title": "相关证书", "title": "相关证书",
"icon": "el-icon-menu", "icon": "el-icon-menu",
"hidden": true "hidden": true,
"perms": ["certificates"]
}, },
"component": "hrm/certificate" "component": "hrm/certificate"
}, },

View File

@ -5,21 +5,53 @@
<el-header> <el-header>
<div class="left-panel"> <div class="left-panel">
<div style="margin-right: 20px">岗位列表</div> <div style="margin-right: 20px">岗位列表</div>
<el-button type="primary" icon="el-icon-plus" @click="add"></el-button> <el-button
type="primary"
icon="el-icon-plus"
@click="add"
></el-button>
</div> </div>
</el-header> </el-header>
<el-main class="nopadding"> <el-main class="nopadding">
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe highlightCurrentRow @row-click="rowClick" <scTable
:hidePagination="true"> ref="table"
:apiObj="apiObj"
row-key="id"
stripe
highlightCurrentRow
@row-click="rowClick"
:hidePagination="true"
>
<!-- <el-table-column type="selection" width="50"></el-table-column> --> <!-- <el-table-column type="selection" width="50"></el-table-column> -->
<el-table-column label="" type="index"></el-table-column> <el-table-column label="" type="index"></el-table-column>
<el-table-column label="名称" prop="name" width="120"></el-table-column> <el-table-column
<el-table-column label="标识" prop="code" width="60"></el-table-column> label="名称"
<el-table-column label="最短在岗(h)" prop="min_hour" width="100"></el-table-column> prop="name"
<el-table-column label="最长在岗(h)" prop="max_hour" width="100"></el-table-column> width="120"
></el-table-column>
<el-table-column
label="标识"
prop="code"
width="60"
></el-table-column>
<el-table-column
label="最短在岗(h)"
prop="min_hour"
width="100"
></el-table-column>
<el-table-column
label="最长在岗(h)"
prop="max_hour"
width="100"
></el-table-column>
<el-table-column label="操作" fixed="right" align="right"> <el-table-column label="操作" fixed="right" align="right">
<template #default="scope"> <template #default="scope">
<el-button type="warning" link size="small" @click="table_edit(scope.row)">编辑 <el-button
type="warning"
link
size="small"
@click="table_edit(scope.row)"
>编辑
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -31,28 +63,49 @@
<el-header> <el-header>
<div class="left-panel"> <div class="left-panel">
<div style="margin-right: 20px">岗位权限</div> <div style="margin-right: 20px">岗位权限</div>
<el-button type="primary" icon="el-icon-plus" @click="addPostRole"></el-button> <el-button
<el-button type="danger" plain icon="el-icon-delete" @click="delPostRole"></el-button> type="primary"
icon="el-icon-plus"
@click="addPostRole"
></el-button>
<el-button
type="danger"
plain
icon="el-icon-delete"
@click="delPostRole"
></el-button>
</div> </div>
</el-header> </el-header>
<el-main class="nopadding"> <el-main class="nopadding">
<scTable ref="table2" :apiObj="apiObj2" row-key="id" stripe :hidePagination="true"> <scTable
ref="table2"
:apiObj="apiObj2"
row-key="id"
stripe
:hidePagination="true"
>
<!-- <el-table-column type="selection" width="50"></el-table-column> --> <!-- <el-table-column type="selection" width="50"></el-table-column> -->
<el-table-column label="" type="index"></el-table-column> <el-table-column label="" type="index"></el-table-column>
<el-table-column label="所属岗位" prop="post" min-width="80"> <el-table-column label="所属岗位" prop="post" min-width="80">
<template #default="scope">{{scope.row.post_.name}}</template> <template #default="scope">{{ scope.row.post_.name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="拥有角色" prop="role" min-width="80"> <el-table-column label="拥有角色" prop="role" min-width="80">
<template #default="scope">{{scope.row.role_.name}}</template> <template #default="scope">{{ scope.row.role_.name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="权限范围" prop="data_range" min-width="80"> <el-table-column label="权限范围" prop="data_range" min-width="80">
<template #default="scope">{{options[scope.row.data_range]}}</template> <template #default="scope">{{
options[scope.row.data_range]
}}</template>
</el-table-column> </el-table-column>
<el-table-column label="操作" fixed="right" align="right"> <el-table-column label="操作" fixed="right" align="right">
<template #default="scope"> <template #default="scope">
<el-button type="warning" link size="small" @click="postRoleEdit(scope.row)">编辑
</el-button> <el-button
<el-button type="warning" link size="small" @click="postRoleDel(scope.row)">删除 type="warning"
link
size="small"
@click="postRoleDel(scope.row)"
>删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -60,18 +113,25 @@
</el-main> </el-main>
</el-container> </el-container>
</el-container> </el-container>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess" <save-dialog
@closed="dialog.save=false"></save-dialog> v-if="dialog.save"
<save-role-dialog v-if="dialog.roleSave" ref="saveRoleDialog" @success="handleSaveRoleSuccess" ref="saveDialog"
@closed="dialog.roleSave=false"></save-role-dialog> @success="handleSaveSuccess"
@closed="dialog.save = false"
></save-dialog>
<save-role-dialog
v-if="dialog.roleSave"
ref="saveRoleDialog"
@success="handleSaveRoleSuccess"
@closed="dialog.roleSave = false"
></save-role-dialog>
</template> </template>
<script> <script>
import saveDialog from './post_form.vue' import saveDialog from "./post_form.vue";
import saveRoleDialog from './post_role_form.vue' import saveRoleDialog from "./post_role_form.vue";
export default { export default {
name: 'listSon', name: "listSon",
components: { components: {
saveDialog, saveDialog,
saveRoleDialog, saveRoleDialog,
@ -85,64 +145,67 @@
roleSave: false, roleSave: false,
}, },
selection: [], selection: [],
postId:'', postId: "",
options: { options: {
10: "全部", 10: "全部",
20: "自定义", 20: "自定义",
30: "同级及以下", 30: "同级及以下",
40: "本级及以下", 40: "本级及以下",
50: "本级", 50: "本级",
60: "仅本人" 60: "仅本人",
}, },
} };
}, },
methods: { methods: {
rowClick(row) { rowClick(row) {
let params = { let params = {
post: row.id post: row.id,
}; };
this.apiObj2 = this.$API.system.postrole.list;
this.postId = row.id; this.postId = row.id;
this.$refs.table2.reload(params) this.$refs.table2.reload(params);
}, },
// //
add() { add() {
this.dialog.save = true; this.dialog.save = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.saveDialog.open() this.$refs.saveDialog.open();
}) });
}, },
// //
table_edit(row) { table_edit(row) {
this.dialog.save = true; this.dialog.save = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.saveDialog.open('edit').setData(row) this.$refs.saveDialog.open("edit").setData(row);
}) });
}, },
// //
async batch_del() { async batch_del() {
var confirmRes = await this.$confirm(`确定删除选中的 ${this.selection.length} 项吗?`, '提示', { var confirmRes = await this.$confirm(
type: 'warning', `确定删除选中的 ${this.selection.length} 项吗?`,
confirmButtonText: '删除', "提示",
confirmButtonClass: 'el-button--danger' {
}).catch(() => { type: "warning",
}) confirmButtonText: "删除",
confirmButtonClass: "el-button--danger",
}
).catch(() => {});
if (!confirmRes) { if (!confirmRes) {
return false return false;
} }
var ids = this.selection.map(v => v.id) var ids = this.selection.map((v) => v.id);
this.$refs.table.removeKeys(ids) this.$refs.table.removeKeys(ids);
this.$message.success("操作成功") this.$message.success("操作成功");
}, },
// //
handleSaveSuccess(data, mode) { handleSaveSuccess(data, mode) {
// //
if (mode == 'add') { if (mode == "add") {
this.$refs.table.unshiftRow(data) this.$refs.table.unshiftRow(data);
} else if (mode == 'edit') { } else if (mode == "edit") {
this.$refs.table.updateKey(data) this.$refs.table.updateKey(data);
} }
// //
@ -150,50 +213,47 @@
}, },
// //
handleSaveRoleSuccess() { handleSaveRoleSuccess() {
this.$refs.table2.refresh()
},
addPostRole(){
this.dialog.roleSave = true;
this.$nextTick(() => {
this.$refs.saveRoleDialog.open("add").setData({postId:this.postId})
})
},
postRoleEdit(row){
this.dialog.roleSave = true;
this.$nextTick(() => {
this.$refs.saveRoleDialog.open("edit").setData(row)
})
},
delPostRole(){
},
closed(){
this.dialog.save = false;
this.dialog.roleSave = false;
this.postId = '';
this.$refs.table2.refresh(); this.$refs.table2.refresh();
}, },
postRoleDel(row){ addPostRole() {
this.$confirm(`确定删除选中的岗位关系吗?`, '提示', { this.dialog.roleSave = true;
type: 'warning' this.$nextTick(() => {
}).then(() => { this.$refs.saveRoleDialog.open("add").setData({ postId: this.postId });
this.$API.system.postrole.delete.req(row.id).then(res=>{ });
if(res.err_msg){ },
this.$message.error(res.err_msg) postRoleEdit(row) {
}else{ this.dialog.roleSave = true;
this.$nextTick(() => {
this.$refs.saveRoleDialog.open("edit").setData(row);
});
},
delPostRole() {},
closed() {
this.dialog.save = false;
this.dialog.roleSave = false;
this.postId = "";
this.$refs.table2.refresh();
},
postRoleDel(row) {
this.$confirm(`确定删除选中的岗位关系吗?`, "提示", {
type: "warning",
})
.then(() => {
this.$API.system.postrole.delete.req(row.id).then((res) => {
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
const loading = this.$loading(); const loading = this.$loading();
this.$refs.table2.refresh(); this.$refs.table2.refresh();
loading.close(); loading.close();
this.$message.success("操作成功") this.$message.success("操作成功");
} }
});
}) })
.catch(() => {});
}).catch(() => {
})
}, },
} },
} };
</script> </script>
<style> <style>

View File

@ -133,6 +133,7 @@ export default {
}, },
// //
async submit() { async submit() {
var valid = await this.$refs.form.validate().catch(() => {}); var valid = await this.$refs.form.validate().catch(() => {});
if (!valid) { if (!valid) {
return false; return false;
@ -140,11 +141,9 @@ export default {
this.isSaveing = true; this.isSaveing = true;
try { try {
let res; let res;
if (this.mode === "add") {
res = await this.$API.system.postrole.create.req(this.form); res = await this.$API.system.postrole.create.req(this.form);
} else if (this.mode === "edit") {
res = await this.$API.system.postrole.update.req(this.form.id, this.form);
}
this.isSaveing = false; this.isSaveing = false;
this.$emit("success", this.form, this.mode); this.$emit("success", this.form, this.mode);
this.visible = false; this.visible = false;