Merge pull request 'uesr' (#37) from uesr into master
Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/37
This commit is contained in:
@@ -16,6 +16,22 @@ export const getSubCompOpt = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询角色信息
|
||||||
|
export const getRolesOpt = () => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/role/option',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取岗位下拉
|
||||||
|
export const getJobOpt = () => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/job/option',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const getUserList = (params) => {
|
export const getUserList = (params) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/user',
|
url: '/admin/user',
|
||||||
@@ -23,18 +39,17 @@ export const getUserList = (params) => {
|
|||||||
params
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取用户详情
|
//获取用户详情
|
||||||
export const getUserDetail = (userId) => {
|
export const getUserDetail = (userId) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/admin/user/info/${userId}`,
|
url: `/admin/mosr/user/info/${userId}`,
|
||||||
method: "get"
|
method: "get"
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 新增用户
|
// 新增用户
|
||||||
export const addUser = (data) => {
|
export const addUser = (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/user',
|
url: '/admin/mosr/user',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
@@ -42,7 +57,7 @@ export const addUser = (data) => {
|
|||||||
// 修改用户
|
// 修改用户
|
||||||
export const editUser = (data) => {
|
export const editUser = (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/admin/user',
|
url: '/admin/mosr/user',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -524,3 +524,10 @@ html, body, #app, .el-container, .el-aside, .el-main {
|
|||||||
.el-pagination {
|
.el-pagination {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 操作页面底部按钮
|
||||||
|
.oper-page-btn {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 15px;
|
||||||
|
right: 15px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.el-menu-item.is-active {
|
.el-menu-item.is-active {
|
||||||
background: #BEA266;
|
background: rgba(190,162,102,0.5);
|
||||||
//background-color: #373350 !important;
|
//background-color: #373350 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/components/baseTitle/index.vue
Normal file
33
src/components/baseTitle/index.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<div class="base-title">
|
||||||
|
<span></span>
|
||||||
|
<span>{{ title }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
const props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.base-title {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
margin: 15px 0;
|
||||||
|
font-weight: bold;
|
||||||
|
>span:first-child {
|
||||||
|
display: inline-block;
|
||||||
|
width: 10px;
|
||||||
|
height: 20px;
|
||||||
|
background: #BEA266;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -10,7 +10,6 @@ export const hasPerm = (el, binding, vnode) => {
|
|||||||
const hasPermission = permisstions.some(permission => {
|
const hasPermission = permisstions.some(permission => {
|
||||||
return allPermission === permission || permissiosFlag.includes(permission)
|
return allPermission === permission || permissiosFlag.includes(permission)
|
||||||
})
|
})
|
||||||
console.log(hasPermission);
|
|
||||||
if (!hasPermission) {
|
if (!hasPermission) {
|
||||||
el.parentNode && el.parentNode.removeChild(el)
|
el.parentNode && el.parentNode.removeChild(el)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
label-width="auto"
|
label-width="auto"
|
||||||
ref="formInstance"
|
ref="formInstance"
|
||||||
>
|
>
|
||||||
<el-row>
|
<el-row :gutter="20">
|
||||||
<el-col
|
<el-col
|
||||||
v-for="item in filterSchma"
|
v-for="item in filterSchma"
|
||||||
v-bind="item.colProps || { span: 12}"
|
v-bind="item.colProps || { span: 12}"
|
||||||
@@ -62,7 +62,6 @@ const filterSchma = computed(()=>{
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(filterSchma.value, 'filterSchma');
|
|
||||||
|
|
||||||
const validate = async () => {
|
const validate = async () => {
|
||||||
let validObj = {}
|
let validObj = {}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
v-for="btn in tableConfig.btns"
|
v-for="btn in tableConfig.btns"
|
||||||
:key="btn.key"
|
:key="btn.key"
|
||||||
:type="btn.type || ''"
|
:type="btn.type || ''"
|
||||||
:v-perm="btn.auth || '[*:*:*]'"
|
v-perm="btn.auth || ['*:*:*']"
|
||||||
@click="handleClickBtns(btn.key)"
|
@click="handleClickBtns(btn.key)"
|
||||||
>
|
>
|
||||||
{{ btn.name }}
|
{{ btn.name }}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<router-link
|
<router-link
|
||||||
v-for="item in tagsViewStore.visitedViews"
|
v-for="item in tagsViewStore.visitedViews"
|
||||||
:key="item.path" :to="{ path: item.path }" class="tag"
|
:key="item.path" :to="{ path: item.path, query: item.query }" class="tag"
|
||||||
:class="isActive(item) ? 'active' : ''"
|
:class="isActive(item) ? 'active' : ''"
|
||||||
@click.prevent
|
@click.prevent
|
||||||
@contextmenu.prevent.native="openMenu(item, $event)">
|
@contextmenu.prevent.native="openMenu(item, $event)">
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
|
|
||||||
export const useTagsView = defineStore('tagsView',()=>{
|
export const useTagsView = defineStore('tagsView',()=>{
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
//已显示的标签页list
|
//已显示的标签页list
|
||||||
const visitedViews = ref([])
|
const visitedViews = ref([])
|
||||||
|
|
||||||
//添加标签页面
|
//添加标签页面
|
||||||
const addVisitedViews = ({path,meta}) => {
|
const addVisitedViews = ({path,meta,query}) => {
|
||||||
if(visitedViews.value.length == 0) {
|
if(visitedViews.value.length == 0) {
|
||||||
visitedViews.value.push({path,meta})
|
visitedViews.value.push({path,meta,query})
|
||||||
}else {
|
}else {
|
||||||
const paths = visitedViews.value.map(item => item.path)
|
const paths = visitedViews.value.map(item => item.path)
|
||||||
if(paths.includes(path) == false) {
|
if(paths.includes(path) == false) {
|
||||||
visitedViews.value.push({path,meta})
|
visitedViews.value.push({path,meta,query})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +33,16 @@ export const useTagsView = defineStore('tagsView',()=>{
|
|||||||
toLastTagView(visitedViews)
|
toLastTagView(visitedViews)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除当前标签页并跳转到指定路由
|
||||||
|
const delViewAndGoView = (path) => {
|
||||||
|
visitedViews.value.forEach((item,index)=>{
|
||||||
|
if(item.path == route.path) {
|
||||||
|
visitedViews.value.splice(index,1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
router.push(path)
|
||||||
|
}
|
||||||
|
|
||||||
//删除其他标签页
|
//删除其他标签页
|
||||||
const delOtherVisitedViews = ({path,meta}) => {
|
const delOtherVisitedViews = ({path,meta}) => {
|
||||||
visitedViews.value = []
|
visitedViews.value = []
|
||||||
@@ -50,5 +61,6 @@ export const useTagsView = defineStore('tagsView',()=>{
|
|||||||
addVisitedViews,
|
addVisitedViews,
|
||||||
delVisitedViews,
|
delVisitedViews,
|
||||||
delOtherVisitedViews,
|
delOtherVisitedViews,
|
||||||
|
delViewAndGoView
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
235
src/views/system/user/add.vue
Normal file
235
src/views/system/user/add.vue
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
<template>
|
||||||
|
<baseTitle :title="'用户信息录入'"></baseTitle>
|
||||||
|
<fvForm :schema="schame" @getInstance="getInstance" :rules="rules"></fvForm>
|
||||||
|
<div class="oper-page-btn">
|
||||||
|
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||||
|
<el-button type="primary" @click="handleBack">返回</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="jsx">
|
||||||
|
import { addUser, editUser } from '@/api/user/user.js'
|
||||||
|
import { ElLoading, ElNotification } from 'element-plus';
|
||||||
|
import { useTagsView } from '@/stores/tagsview.js'
|
||||||
|
import { useAuthStore } from '@/stores/userstore.js'
|
||||||
|
import { useCacheStore } from "@/stores/cache.js";
|
||||||
|
import { getDeptOpt, getSubCompOpt, getRolesOpt, getJobOpt, getUserDetail } from '@/api/user/user.js'
|
||||||
|
|
||||||
|
const tagsViewStore = useTagsView()
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const cacheStore = useCacheStore();
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const form = ref(null)
|
||||||
|
|
||||||
|
const localData = reactive({
|
||||||
|
subCompanyIdOpt: [],
|
||||||
|
departmentIdOpt: [],
|
||||||
|
roleOpt: [],
|
||||||
|
jobOpt: []
|
||||||
|
})
|
||||||
|
|
||||||
|
const schame = computed(()=>{
|
||||||
|
let arr = [
|
||||||
|
{
|
||||||
|
label: '子公司',
|
||||||
|
prop: 'subCompanyId',
|
||||||
|
component: 'el-tree-select',
|
||||||
|
props: {
|
||||||
|
placeholder: '请输入',
|
||||||
|
clearable: true,
|
||||||
|
filterable: true,
|
||||||
|
checkStrictly: true,
|
||||||
|
data: localData.subCompanyIdOpt
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
change: async (val) => {
|
||||||
|
const { data } = await getDeptOpt({subCompanyId: val})
|
||||||
|
localData.departmentIdOpt = data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '归属部门',
|
||||||
|
prop: 'departmentId',
|
||||||
|
component: 'el-tree-select',
|
||||||
|
props: {
|
||||||
|
placeholder: '请选择',
|
||||||
|
clearable: true,
|
||||||
|
data: localData.departmentIdOpt,
|
||||||
|
filterable: true,
|
||||||
|
checkStrictly: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户账号',
|
||||||
|
prop: 'userName',
|
||||||
|
component: 'el-input',
|
||||||
|
props: {
|
||||||
|
placeholder: '请输入'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户昵称',
|
||||||
|
prop: 'nickName',
|
||||||
|
component: 'el-input',
|
||||||
|
props: {
|
||||||
|
placeholder: '请输入'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户密码',
|
||||||
|
prop: 'password',
|
||||||
|
component: 'el-input',
|
||||||
|
props: {
|
||||||
|
placeholder: '请输入',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '岗位',
|
||||||
|
prop: 'jobId',
|
||||||
|
component: 'el-tree-select',
|
||||||
|
props: {
|
||||||
|
placeholder: '请选择',
|
||||||
|
filterable: true,
|
||||||
|
checkStrictly: true,
|
||||||
|
data: localData.jobOpt
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '角色',
|
||||||
|
prop: 'roleIds',
|
||||||
|
component: 'el-tree-select',
|
||||||
|
props: {
|
||||||
|
placeholder: '请选择',
|
||||||
|
multiple: true,
|
||||||
|
data: localData.roleOpt
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '性别',
|
||||||
|
prop: 'sex',
|
||||||
|
component: 'el-tree-select',
|
||||||
|
props: {
|
||||||
|
placeholder: '请选择',
|
||||||
|
data: cacheStore.getDict('user_sex')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '帐号状态',
|
||||||
|
prop: 'state',
|
||||||
|
component: 'el-tree-select',
|
||||||
|
props: {
|
||||||
|
placeholder: '请选择',
|
||||||
|
data: cacheStore.getDict('normal_disable')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '手机号码',
|
||||||
|
prop: 'mobile',
|
||||||
|
component: 'el-input',
|
||||||
|
props: {
|
||||||
|
placeholder: '请输入'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '邮箱',
|
||||||
|
prop: 'email',
|
||||||
|
component: 'el-input',
|
||||||
|
props: {
|
||||||
|
placeholder: '请输入'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
let editArr = []
|
||||||
|
if(!route.query.isAdd) {
|
||||||
|
arr.forEach(item=>{
|
||||||
|
if(item.prop != 'password') {
|
||||||
|
editArr.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return !authStore.roles.includes('superAdmin') ? editArr.slice(1) : editArr
|
||||||
|
}
|
||||||
|
return !authStore.roles.includes('superAdmin') ? arr.slice(1) : arr
|
||||||
|
})
|
||||||
|
|
||||||
|
const rules = reactive({
|
||||||
|
userName: [{required: true, message: '请输入', trigger: 'change'}],
|
||||||
|
nickName: [{required: true, message: '请输入', trigger: 'change'}],
|
||||||
|
password: [{required: true, message: '请输入', trigger: 'change'}],
|
||||||
|
departmentId: [{required: true, message: '请选择', trigger: 'change'}],
|
||||||
|
subCompanyId: [{required: true, message: '请选择', trigger: 'change'}],
|
||||||
|
jobId: [{required: true, message: '请选择', trigger: 'change'}],
|
||||||
|
roleIds: [{required: true, message: '请选择', trigger: 'change'}],
|
||||||
|
sex: [{required: true, message: '请选择', trigger: 'change'}],
|
||||||
|
state: [{required: true, message: '请选择', trigger: 'change'}],
|
||||||
|
})
|
||||||
|
|
||||||
|
const getInstance = (e) => {
|
||||||
|
form.value = e
|
||||||
|
}
|
||||||
|
|
||||||
|
const init = async () => {
|
||||||
|
const { data } = await getDeptOpt()
|
||||||
|
localData.departmentIdOpt = data
|
||||||
|
const res = await getSubCompOpt()
|
||||||
|
localData.subCompanyIdOpt = res.data
|
||||||
|
const roleRes = await getRolesOpt()
|
||||||
|
localData.roleOpt = roleRes.data
|
||||||
|
const jobRes = await getJobOpt()
|
||||||
|
localData.jobOpt = jobRes.data
|
||||||
|
}
|
||||||
|
|
||||||
|
const getInfo = async () => {
|
||||||
|
if(!route.query.id) return
|
||||||
|
// 获取详情数据
|
||||||
|
const { data } = await getUserDetail(route.query.id)
|
||||||
|
form.value.setValues(data)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
const loading = ElLoading.service({fullscreen: true})
|
||||||
|
try {
|
||||||
|
const { isValidate } = await form.value.validate()
|
||||||
|
if(!isValidate) return Promise.reject()
|
||||||
|
const values = form.value.getValues()
|
||||||
|
let message
|
||||||
|
if(route.query.isAdd) {
|
||||||
|
const { code, msg } = await addUser(values)
|
||||||
|
code === 1000 ? message = msg : null
|
||||||
|
} else {
|
||||||
|
const { code, msg } = await editUser(values)
|
||||||
|
code === 1000 ? message = msg : null
|
||||||
|
}
|
||||||
|
ElNotification({
|
||||||
|
title: route.query.isAdd ? '新增' : '编辑',
|
||||||
|
message: message,
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
|
loading.close()
|
||||||
|
tagsViewStore.delViewAndGoView('/system/user')
|
||||||
|
} catch {
|
||||||
|
loading.close()
|
||||||
|
return Promise.reject()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
history.back()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
if(!route.query.isAdd) {
|
||||||
|
getInfo()
|
||||||
|
}
|
||||||
|
init()
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -7,9 +7,11 @@
|
|||||||
import Tag from '@/components/Tag.vue'
|
import Tag from '@/components/Tag.vue'
|
||||||
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
|
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
|
||||||
import { useAuthStore } from '@/stores/userstore.js'
|
import { useAuthStore } from '@/stores/userstore.js'
|
||||||
import { getDeptOpt, getSubCompOpt } from '../../../api/user/user';
|
import { getDeptOpt, getSubCompOpt } from '../../../api/user/user.js';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const searchConfig = ref([
|
const searchConfig = ref([
|
||||||
{
|
{
|
||||||
@@ -117,15 +119,18 @@ const tableConfig = reactive({
|
|||||||
currentRender: ({row, index}) => {
|
currentRender: ({row, index}) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<el-button type="primary" link>编辑</el-button>
|
<el-button type="primary" link onClick={()=>handleEdit(row)}>编辑</el-button>
|
||||||
<el-button type="danger" link>删除</el-button>
|
<el-button type="danger" link onClick={()=>handleDel(row)}>删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
api: '/admin/mosr/user',
|
api: '/admin/mosr/user',
|
||||||
params: {}
|
params: {},
|
||||||
|
btns: [
|
||||||
|
{name: '新增', type: 'primary', auth: ['admin:user:add'], key: 'add'}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
@@ -147,7 +152,40 @@ const search = (val) => {
|
|||||||
tableIns.value.refresh()
|
tableIns.value.refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
const headBtnClick = (key) => {}
|
const handleAdd = () => {
|
||||||
|
router.push({
|
||||||
|
path: '/system/useradd',
|
||||||
|
query: {
|
||||||
|
isAdd: 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEdit = (row) => {
|
||||||
|
router.push({
|
||||||
|
path: '/system/useredit',
|
||||||
|
query: {
|
||||||
|
id: row.userId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDel = (row) => {
|
||||||
|
ElMessageBox.confirm('确定删除该条数据吗?', '确定删除', {
|
||||||
|
type: 'warning',
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消'
|
||||||
|
}).then(async res => {
|
||||||
|
// const { code } = await
|
||||||
|
}).catch(()=>{})
|
||||||
|
}
|
||||||
|
|
||||||
|
const headBtnClick = (key) => {
|
||||||
|
switch(key) {
|
||||||
|
case 'add': handleAdd()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user