账户管理增加type编辑

This commit is contained in:
曹前明 2022-09-07 18:34:08 +08:00
parent b29f3cc295
commit cd07f46cb9
2 changed files with 274 additions and 225 deletions

View File

@ -34,19 +34,20 @@
v-auth="'user.create'" v-auth="'user.create'"
@click="add" @click="add"
></el-button> ></el-button>
<!-- <el-button <el-select
type="danger" v-model="query.type"
plain placeholder="账号类型"
icon="el-icon-delete" @change="handleQuery"
:disabled="selection.length == 0" clearable
@click="batch_del" style="margin-left: 2px"
></el-button> --> >
<!-- <el-button <el-option
type="primary" v-for="item in userTypeOptions2"
plain :key="item.value"
:disabled="selection.length == 0" :label="item.label"
>密码重置 :value="item.value"
</el-button> --> ></el-option>
</el-select>
</div> </div>
<div class="right-panel"> <div class="right-panel">
<div class="right-panel-search"> <div class="right-panel-search">
@ -172,6 +173,16 @@
label-width="100px" label-width="100px"
label-position="left" label-position="left"
> >
<el-form-item label="账户类型:" prop="type">
<el-select v-model="addForm.type" placeholder="账号类型">
<el-option
v-for="item in userTypeOptions2"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="登录账号" prop="username"> <el-form-item label="登录账号" prop="username">
<el-input <el-input
v-model="addForm.username" v-model="addForm.username"
@ -244,19 +255,19 @@ export default {
}, },
// //
addForm: { addForm: {
id: "",
username: "", username: "",
name: "", name: "",
// email: "", // email: "",
phone: "", phone: null,
// belong_dept: [], // belong_dept: [],
is_active: true, is_active: true,
type: "employee"
}, },
// //
rules: { rules: {
username: [{ required: true, message: "请输入登录账号" }], username: [{ required: true, message: "请输入登录账号" }],
name: [{ required: true, message: "请输入真实姓名" }], name: [{ required: true, message: "请输入真实姓名" }],
group: [{ required: true, message: "请选择所属角色" }], type: [{ required: true, message: "请选择所属账号类型" }],
}, },
// //
groups: [], groups: [],
@ -287,6 +298,12 @@ export default {
'visitor': '访客', 'visitor': '访客',
'driver':'司机' 'driver':'司机'
}, },
userTypeOptions2: [
{label:"正式员工", value:"employee"},
{label:"相关方", value:"remployee"},
{label:"访客", value:"visitor"},
{label:"货车司机", value:"driver"}
],
idArr: [] idArr: []
}; };
}, },
@ -330,6 +347,7 @@ export default {
this.addForm.username = row.username; this.addForm.username = row.username;
this.addForm.phone = row.phone; this.addForm.phone = row.phone;
this.addForm.is_active = row.is_active; this.addForm.is_active = row.is_active;
this.addForm.type = row.type;
}, },
formSetting(row) { formSetting(row) {
this.dialog.save = true; this.dialog.save = true;

View File

@ -18,28 +18,32 @@
<el-row> <el-row>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="姓名:" prop="name"> <el-form-item label="姓名:" prop="name">
<span>{{form.name}}</span> <span>{{ form.name }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="登录账号:" prop="name"> <el-form-item label="登录账号:" prop="name">
<span>{{form.username}}</span> <span>{{ form.username }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="手机号:" prop="phone"> <el-form-item label="手机号:" prop="phone">
<span>{{form.phone}}</span> <span>{{ form.phone }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="是否启用:"> <el-form-item label="是否启用:">
<span>{{job_states[form.is_active]}}</span> <span>{{ job_states[form.is_active] }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<!--drag-sort --> <!--drag-sort -->
<sc-form-table v-model="userPostForm.list" :addTemplate="addTemplate" placeholder="暂无数据"> <sc-form-table
v-model="userPostForm.list"
:addTemplate="addTemplate"
placeholder="暂无数据"
>
<!-- <el-table-column prop="val" label="名称" min-width="150"> <!-- <el-table-column prop="val" label="名称" min-width="150">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.id">{{scope.row.name}}</span> <span v-if="scope.row.id">{{scope.row.name}}</span>
@ -48,13 +52,19 @@
</el-table-column> --> </el-table-column> -->
<el-table-column prop="val" label="排序" min-width="80"> <el-table-column prop="val" label="排序" min-width="80">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.id">{{scope.row.sort}}</span> <span v-if="scope.row.id">{{ scope.row.sort }}</span>
<el-input v-else v-model="scope.row.sort" placeholder="请输入内容"></el-input> <el-input
v-else
v-model="scope.row.sort"
placeholder="请输入内容"
></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="time" label="部门" min-width="150"> <el-table-column prop="time" label="部门" min-width="150">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.id&&scope.row.dept_">{{scope.row.dept_.name}}</span> <span v-if="scope.row.id && scope.row.dept_">{{
scope.row.dept_.name
}}</span>
<el-cascader <el-cascader
v-else v-else
v-model="scope.row.dept" v-model="scope.row.dept"
@ -69,16 +79,40 @@
</el-table-column> </el-table-column>
<el-table-column prop="type" label="岗位" min-width="150"> <el-table-column prop="type" label="岗位" min-width="150">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.id">{{scope.row.post_.name}}</span> <span v-if="scope.row.id">{{ scope.row.post_.name }}</span>
<el-select v-else v-model="scope.row.post" filterable placeholder="请选择所在岗位"> <el-select
<el-option v-for="item in postOptions" :key="item.id" :label="item.name" :value="item.id"></el-option> v-else
v-model="scope.row.post"
filterable
placeholder="请选择所在岗位"
>
<el-option
v-for="item in postOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="open" label="操作" width="80" align="center"> <el-table-column prop="open" label="操作" width="80" align="center">
<template #default="scope"> <template #default="scope">
<el-button v-if="scope.row.id" text type="danger" size="small" @click="userPostDel(scope.row.id)">删除</el-button> <el-button
<el-button v-else text type="primary" size="small" @click="createUserPost(scope.row)">添加</el-button> v-if="scope.row.id"
text
type="danger"
size="small"
@click="userPostDel(scope.row.id)"
>删除</el-button
>
<el-button
v-else
text
type="primary"
size="small"
@click="createUserPost(scope.row)"
>添加</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</sc-form-table> </sc-form-table>
@ -88,24 +122,24 @@
</template> </template>
<script> <script>
import {genTree} from "@/utils/verificate"; import { genTree } from "@/utils/verificate";
export default { export default {
emits: ["success", "closed"], emits: ["success", "closed"],
data() { data() {
return { return {
addTemplate: { addTemplate: {
name: '', name: "",
sort: '', sort: "",
user: '', user: "",
post: "", post: "",
dept: "", dept: "",
}, },
userPostForm: { userPostForm: {
title: "用户/岗位关系", title: "用户/岗位关系",
list: [] list: [],
}, },
loading: false, loading: false,
job_states: { true: "启用",false: "禁用"}, job_states: { true: "启用", false: "禁用" },
visible: false, visible: false,
isSaveing: false, isSaveing: false,
form: {}, form: {},
@ -135,22 +169,21 @@
mounted() { mounted() {
this.getPosts(); this.getPosts();
this.getGroup(); this.getGroup();
}, },
methods: { methods: {
getPosts(){ getPosts() {
this.$API.system.post.list.req({page:0}).then(res=>{ this.$API.system.post.list.req({ page: 0 }).then((res) => {
if(res.err_msg){ if (res.err_msg) {
this.$message.error(res.err_msg) this.$message.error(res.err_msg);
}else{ } else {
this.postOptions = res; this.postOptions = res;
} }
}) });
}, },
// //
async getGroup() { async getGroup() {
let res = await this.$API.system.dept.list.req({page: 0}); let res = await this.$API.system.dept.list.req({ page: 0 });
this.group =genTree(res); this.group = genTree(res);
}, },
// //
open(mode) { open(mode) {
@ -166,7 +199,7 @@
}, },
closeDrawer() { closeDrawer() {
this.visible = false; this.visible = false;
this.$emit('closed'); this.$emit("closed");
}, },
handleChange(value) { handleChange(value) {
debugger; debugger;
@ -181,42 +214,40 @@
}, },
///// /////
// //
getUserPostList(){ getUserPostList() {
debugger; debugger;
console.log(this.form.id); console.log(this.form.id);
let obj = {user:this.form.id, page:0}; let obj = { user: this.form.id, page: 0 };
this.$API.system.userPost.list.req(obj).then(res=>{ this.$API.system.userPost.list.req(obj).then((res) => {
this.userPostForm.list=res; this.userPostForm.list = res;
}) });
}, },
// //
createUserPost(row){ createUserPost(row) {
debugger; debugger;
console.log(row); console.log(row);
this.isSaveing = true; this.isSaveing = true;
row.user = this.form.id; row.user = this.form.id;
this.$API.system.userPost.create.req(row).then(res=>{ this.$API.system.userPost.create.req(row).then((res) => {
this.getUserPostList(); this.getUserPostList();
this.$message.success("操作成功"); this.$message.success("操作成功");
}) });
}, },
// //
userPostDel(id){ userPostDel(id) {
this.$confirm(`确定删除该岗位关系吗?`, '提示', { this.$confirm(`确定删除该岗位关系吗?`, "提示", {
type: 'warning', type: "warning",
confirmButtonText: '删除', confirmButtonText: "删除",
confirmButtonClass: 'el-button--danger' confirmButtonClass: "el-button--danger",
}).then(() => { }).then(() => {
this.$API.system.userPost.delete.req(id).then(res=>{ this.$API.system.userPost.delete.req(id).then((res) => {
this.getUserPostList(); this.getUserPostList();
this.$message.success("操作成功"); this.$message.success("操作成功");
});
}) });
})
}, },
}, },
}; };
</script> </script>
<style> <style>