mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 08:07:06 +08:00
完善审批用户
This commit is contained in:
@@ -29,3 +29,8 @@ export function adminDelete(params: any) {
|
|||||||
export function adminStatus(params: any) {
|
export function adminStatus(params: any) {
|
||||||
return request.post({ url: '/system/admin/disable', params })
|
return request.post({ url: '/system/admin/disable', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 部门下的管理员
|
||||||
|
export function adminListByDeptId(params: any) {
|
||||||
|
return request.get({ url: '/system/admin/ListByDeptId', params })
|
||||||
|
}
|
||||||
|
@@ -219,6 +219,8 @@ export default {
|
|||||||
label: node?.text?.value,
|
label: node?.text?.value,
|
||||||
type: node.type,
|
type: node.type,
|
||||||
fieldAuth: node?.properties?.fieldAuth,
|
fieldAuth: node?.properties?.fieldAuth,
|
||||||
|
|
||||||
|
userType: node?.properties?.userType || 0,
|
||||||
userId: node?.properties?.userId || 0,
|
userId: node?.properties?.userId || 0,
|
||||||
deptId: node?.properties?.deptId || 0,
|
deptId: node?.properties?.deptId || 0,
|
||||||
postId: node?.properties?.postId || 0
|
postId: node?.properties?.postId || 0
|
||||||
|
@@ -133,9 +133,11 @@ export default {
|
|||||||
open(node, fieldList) {
|
open(node, fieldList) {
|
||||||
this.node = node
|
this.node = node
|
||||||
|
|
||||||
|
this.properties.userType = node?.properties?.userType || ''
|
||||||
this.properties.userId = node?.properties?.userId || ''
|
this.properties.userId = node?.properties?.userId || ''
|
||||||
this.properties.deptId = node?.properties?.deptId || ''
|
this.properties.deptId = node?.properties?.deptId || ''
|
||||||
this.properties.postId = node?.properties?.postId || ''
|
this.properties.postId = node?.properties?.postId || ''
|
||||||
|
|
||||||
this.properties.fieldAuth = node?.properties?.fieldAuth
|
this.properties.fieldAuth = node?.properties?.fieldAuth
|
||||||
? { ...node?.properties?.fieldAuth }
|
? { ...node?.properties?.fieldAuth }
|
||||||
: {}
|
: {}
|
||||||
@@ -163,6 +165,7 @@ export default {
|
|||||||
this.setProperties('fieldAuth', {
|
this.setProperties('fieldAuth', {
|
||||||
...fieldAuth
|
...fieldAuth
|
||||||
})
|
})
|
||||||
|
this.setProperties('userType', this.properties.userType)
|
||||||
this.setProperties('userId', this.properties.userId)
|
this.setProperties('userId', this.properties.userId)
|
||||||
this.setProperties('deptId', this.properties.deptId)
|
this.setProperties('deptId', this.properties.deptId)
|
||||||
this.setProperties('postId', this.properties.postId)
|
this.setProperties('postId', this.properties.postId)
|
||||||
|
@@ -48,25 +48,18 @@ export const treeToArray = (data: any[], props = { children: 'children' }) => {
|
|||||||
* @param {Object} props `{ parent: 'pid', children: 'children' }`
|
* @param {Object} props `{ parent: 'pid', children: 'children' }`
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const arrayToTree = (
|
export function arrayToTree(arr, parentId = '') {
|
||||||
data: any[],
|
const tree = []
|
||||||
props = { id: 'id', parentId: 'pid', children: 'children' }
|
for (const item of arr) {
|
||||||
) => {
|
if (item.pid == parentId) {
|
||||||
data = cloneDeep(data)
|
const children = arrayToTree(arr, item.id)
|
||||||
const { id, parentId, children } = props
|
if (children.length > 0) {
|
||||||
const result: any[] = []
|
item.children = children
|
||||||
const map = new Map()
|
}
|
||||||
data.forEach((item) => {
|
tree.push(item)
|
||||||
map.set(item[id], item)
|
|
||||||
const parent = map.get(item[parentId])
|
|
||||||
if (parent) {
|
|
||||||
parent[children] = parent[children] ?? []
|
|
||||||
parent[children].push(item)
|
|
||||||
} else {
|
|
||||||
result.push(item)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
return result
|
return tree
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -103,14 +103,14 @@ function open(applyId) {
|
|||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
next_nodes.value = res
|
next_nodes.value = res
|
||||||
|
|
||||||
res.map((item) => {
|
// res.map((item) => {
|
||||||
if (item.type == 'bpmn:userTask') {
|
// if (item.type == 'bpmn:userTask') {
|
||||||
flow_history_get_approver(item).then((user) => {
|
// }
|
||||||
console.log('user', user)
|
// })
|
||||||
approverUserList.value = user
|
})
|
||||||
})
|
flow_history_get_approver({ applyId: applyId }).then((user) => {
|
||||||
}
|
console.log('user', user)
|
||||||
})
|
approverUserList.value = user
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function BeforeClose() {
|
function BeforeClose() {
|
||||||
|
@@ -33,15 +33,25 @@
|
|||||||
:maxlength="100"
|
:maxlength="100"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="负责人" prop="duty">
|
<el-form-item label="负责人" prop="duty_id" v-if="formData.id">
|
||||||
<el-input
|
<el-select
|
||||||
v-model="formData.duty"
|
class="flex-1"
|
||||||
placeholder="请输入负责人姓名"
|
v-model="formData.dutyId"
|
||||||
clearable
|
clearable
|
||||||
:maxlength="30"
|
placeholder="请选择上级部门"
|
||||||
/>
|
@change="dutyChange"
|
||||||
|
>
|
||||||
|
<el-option label="请先给管理员绑定部门" :value="0" />
|
||||||
|
|
||||||
|
<el-option
|
||||||
|
v-for="item in DeptUsers"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.nickname"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="联系电话" prop="mobile">
|
<el-form-item label="部门电话" prop="mobile">
|
||||||
<el-input v-model="formData.mobile" placeholder="请输入联系电话" clearable />
|
<el-input v-model="formData.mobile" placeholder="请输入联系电话" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
@@ -60,6 +70,8 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
import { deptLists, deptEdit, deptAdd, deptDetail } from '@/api/org/department'
|
import { deptLists, deptEdit, deptAdd, deptDetail } from '@/api/org/department'
|
||||||
|
import { adminListByDeptId } from '@/api/perms/admin'
|
||||||
|
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { useDictOptions } from '@/hooks/useDictOptions'
|
import { useDictOptions } from '@/hooks/useDictOptions'
|
||||||
import feedback from '@/utils/feedback'
|
import feedback from '@/utils/feedback'
|
||||||
@@ -74,11 +86,29 @@ const formData = reactive({
|
|||||||
id: '',
|
id: '',
|
||||||
pid: '' as string | number,
|
pid: '' as string | number,
|
||||||
name: '',
|
name: '',
|
||||||
|
dutyId: 0,
|
||||||
duty: '',
|
duty: '',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
sort: 0,
|
sort: 0,
|
||||||
isStop: 0
|
isStop: 0
|
||||||
})
|
})
|
||||||
|
const DeptUsers = ref([])
|
||||||
|
// 部门下的管理员
|
||||||
|
async function getDeptUsers(deptId: number) {
|
||||||
|
const users = await adminListByDeptId({ deptId: deptId })
|
||||||
|
DeptUsers.value = users
|
||||||
|
}
|
||||||
|
function dutyChange(id: number) {
|
||||||
|
console.log('params', id)
|
||||||
|
if (id) {
|
||||||
|
const duty = DeptUsers.value.find((item) => item.id == id)
|
||||||
|
formData.duty = duty.nickname
|
||||||
|
// formData.duty_id = duty.id
|
||||||
|
} else {
|
||||||
|
formData.duty = ''
|
||||||
|
}
|
||||||
|
// formData
|
||||||
|
}
|
||||||
const checkMobile = (rule: any, value: any, callback: any) => {
|
const checkMobile = (rule: any, value: any, callback: any) => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return callback()
|
return callback()
|
||||||
@@ -115,11 +145,11 @@ const formRules = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
mobile: [
|
mobile: [
|
||||||
{
|
// {
|
||||||
required: true,
|
// required: true,
|
||||||
message: '请输入联系电话',
|
// message: '请输入联系电话',
|
||||||
trigger: ['blur']
|
// trigger: ['blur']
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
validator: checkMobile,
|
validator: checkMobile,
|
||||||
trigger: ['blur']
|
trigger: ['blur']
|
||||||
@@ -146,6 +176,8 @@ const handleSubmit = async () => {
|
|||||||
const open = (type = 'add') => {
|
const open = (type = 'add') => {
|
||||||
mode.value = type
|
mode.value = type
|
||||||
popupRef.value?.open()
|
popupRef.value?.open()
|
||||||
|
// if (type == 'edit') {
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
const setFormData = (data: Record<any, any>) => {
|
const setFormData = (data: Record<any, any>) => {
|
||||||
@@ -155,18 +187,18 @@ const setFormData = (data: Record<any, any>) => {
|
|||||||
formData[key] = data[key]
|
formData[key] = data[key]
|
||||||
}
|
}
|
||||||
//TODO:因为后端返回字段为is_stop
|
//TODO:因为后端返回字段为is_stop
|
||||||
else{
|
else {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
formData[key] = data['is_stop']
|
formData[key] = data['is_stop']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDetail = async (row: Record<string, any>) => {
|
const getDetail = async (row: Record<string, any>) => {
|
||||||
const data = await deptDetail({
|
const data = await deptDetail({
|
||||||
id: row.id
|
id: row.id
|
||||||
})
|
})
|
||||||
|
getDeptUsers(data.id)
|
||||||
setFormData(data)
|
setFormData(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,6 +48,8 @@
|
|||||||
min-width="150"
|
min-width="150"
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
/>
|
/>
|
||||||
|
<el-table-column label="负责人" prop="duty" show-overflow-tooltip />
|
||||||
|
|
||||||
<el-table-column label="部门状态" prop="isStop" min-width="100">
|
<el-table-column label="部门状态" prop="isStop" min-width="100">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag class="ml-2" :type="row.isStop ? 'danger' : ''">
|
<el-tag class="ml-2" :type="row.isStop ? 'danger' : ''">
|
||||||
@@ -114,6 +116,8 @@ const getLists = async () => {
|
|||||||
// 根据id和pid处理层级关系
|
// 根据id和pid处理层级关系
|
||||||
|
|
||||||
lists.value = arrayToTree(list)
|
lists.value = arrayToTree(list)
|
||||||
|
console.log('lists', lists)
|
||||||
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type FlowHistoryHandler struct {
|
type FlowHistoryHandler struct {
|
||||||
Service IFlowHistoryService
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary 流程历史列表
|
// @Summary 流程历史列表
|
||||||
@@ -180,14 +179,19 @@ func (hd FlowHistoryHandler) NextNode(c *gin.Context) {
|
|||||||
|
|
||||||
// 获取节点的可审批用户
|
// 获取节点的可审批用户
|
||||||
func (hd FlowHistoryHandler) GetApprover(c *gin.Context) {
|
func (hd FlowHistoryHandler) GetApprover(c *gin.Context) {
|
||||||
var node FlowTree
|
var nextNode NextNodeReq
|
||||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &node)) {
|
// var node FlowTree
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &nextNode)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// response.CheckAndResp(c, Service.GetNextNode(node))
|
// response.CheckAndResp(c, Service.GetNextNode(node))
|
||||||
res, err := Service.GetApprover(node)
|
res, err := Service.GetApprover(nextNode.ApplyId)
|
||||||
response.CheckAndRespWithData(c, res, err)
|
if err != nil {
|
||||||
|
response.FailWithMsg(c, response.Failed, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OkWithData(c, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同意审批(当前nodeId)
|
// 同意审批(当前nodeId)
|
||||||
|
@@ -78,9 +78,10 @@ type FlowTree struct {
|
|||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
||||||
UserId int `json:"userId"`
|
UserType int `json:"userType"` // 用户类型,1指定部门、岗位,2用户部门负责人,3指定审批人
|
||||||
DeptId int `json:"deptId"`
|
UserId int `json:"userId"`
|
||||||
PostId int `json:"postId"`
|
DeptId int `json:"deptId"`
|
||||||
|
PostId int `json:"postId"`
|
||||||
|
|
||||||
FieldAuth map[string]int `json:"fieldAuth"`
|
FieldAuth map[string]int `json:"fieldAuth"`
|
||||||
|
|
||||||
|
@@ -2,8 +2,10 @@ package flow_history
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"x_admin/admin/flow/flow_apply"
|
"x_admin/admin/flow/flow_apply"
|
||||||
"x_admin/admin/system/admin"
|
"x_admin/admin/system/admin"
|
||||||
|
"x_admin/admin/system/dept"
|
||||||
"x_admin/core"
|
"x_admin/core"
|
||||||
"x_admin/core/request"
|
"x_admin/core/request"
|
||||||
"x_admin/core/response"
|
"x_admin/core/response"
|
||||||
@@ -14,17 +16,17 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IFlowHistoryService interface {
|
// type IFlowHistoryService interface {
|
||||||
List(page request.PageReq, listReq FlowHistoryListReq) (res response.PageResp, e error)
|
// List(page request.PageReq, listReq FlowHistoryListReq) (res response.PageResp, e error)
|
||||||
ListAll() (res []FlowHistoryResp, e error)
|
// ListAll() (res []FlowHistoryResp, e error)
|
||||||
|
|
||||||
Detail(id int) (res FlowHistoryResp, e error)
|
// Detail(id int) (res FlowHistoryResp, e error)
|
||||||
Add(addReq FlowHistoryAddReq) (e error)
|
// Add(addReq FlowHistoryAddReq) (e error)
|
||||||
Edit(editReq FlowHistoryEditReq) (e error)
|
// Edit(editReq FlowHistoryEditReq) (e error)
|
||||||
Del(id int) (e error)
|
// Del(id int) (e error)
|
||||||
|
|
||||||
GetNextNode(nextNode NextNodeReq) (e error)
|
// GetNextNode(nextNode NextNodeReq) (e error)
|
||||||
}
|
// }
|
||||||
|
|
||||||
var Service = NewFlowHistoryService()
|
var Service = NewFlowHistoryService()
|
||||||
|
|
||||||
@@ -177,32 +179,70 @@ func (Service flowHistoryService) Del(id int) (e error) {
|
|||||||
/**
|
/**
|
||||||
* 获取节点的审批用户
|
* 获取节点的审批用户
|
||||||
*/
|
*/
|
||||||
func (Service flowHistoryService) GetApprover(node FlowTree) (res []admin.SystemAuthAdminResp, e error) {
|
func (Service flowHistoryService) GetApprover(ApplyId int) (res []admin.SystemAuthAdminResp, e error) {
|
||||||
var userId = node.UserId
|
nextNodes, applyDetail, _, err := Service.GetNextNode(ApplyId)
|
||||||
var deptId = node.DeptId
|
if err != nil {
|
||||||
var postId = node.PostId
|
return nil, err
|
||||||
|
}
|
||||||
|
var userTask FlowTree
|
||||||
|
for n := 0; n < len(nextNodes); n++ {
|
||||||
|
if nextNodes[n].Type == "bpmn:userTask" {
|
||||||
|
userTask = nextNodes[n]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 没有审批节点不用获取审批人
|
||||||
|
if userTask.Id == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var userType = userTask.UserType //用户类型,1指定部门、岗位,2用户部门负责人,3指定审批人
|
||||||
|
var userId = userTask.UserId
|
||||||
|
var deptId = userTask.DeptId
|
||||||
|
var postId = userTask.PostId
|
||||||
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
||||||
|
|
||||||
adminModel := Service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
adminModel := Service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
||||||
|
|
||||||
dept := map[string]interface{}{}
|
where := map[string]interface{}{}
|
||||||
if deptId > 0 {
|
if userType == 1 {
|
||||||
dept["admin.dept_id"] = deptId
|
if deptId > 0 {
|
||||||
// adminModel.Or("admin.dept_id =?", deptId)
|
where["admin.dept_id"] = deptId
|
||||||
}
|
// adminModel.Or("admin.dept_id =?", deptId)
|
||||||
if postId > 0 {
|
}
|
||||||
dept["admin.post_id"] = postId
|
if postId > 0 {
|
||||||
// adminModel.Or("admin.post_id =?", postId)
|
where["admin.post_id"] = postId
|
||||||
}
|
// adminModel.Or("admin.post_id =?", postId)
|
||||||
|
}
|
||||||
|
} else if userType == 2 {
|
||||||
|
// 申请人所在的部门负责人
|
||||||
|
|
||||||
var where = Service.db.Where(dept)
|
applyUser, err := admin.Service.Detail(uint(applyDetail.ApplyUserId))
|
||||||
if userId > 0 {
|
if err != nil {
|
||||||
where.Or("admin.id =?", userId)
|
return nil, err
|
||||||
|
}
|
||||||
|
if applyUser.DeptId == 0 {
|
||||||
|
return nil, errors.New("申请人没有绑定部门")
|
||||||
|
}
|
||||||
|
deptDetails, err := dept.Service.Detail(applyUser.DeptId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if deptDetails.DutyId == 0 {
|
||||||
|
return nil, errors.New(deptDetails.Name + "部门没有绑定负责人")
|
||||||
|
}
|
||||||
|
where["admin.id"] = deptDetails.DutyId
|
||||||
|
|
||||||
|
} else if userType == 3 {
|
||||||
|
if userId > 0 {
|
||||||
|
where["admin.id"] = userId
|
||||||
|
// adminModel.Or("admin.id =?", userId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据
|
// 数据
|
||||||
var adminResp []admin.SystemAuthAdminResp
|
var adminResp []admin.SystemAuthAdminResp
|
||||||
err := adminModel.Where(where).Find(&adminResp).Error
|
err = adminModel.Where(where).Find(&adminResp).Error
|
||||||
if e = response.CheckErr(err, "获取审批用户失败"); e != nil {
|
if e = response.CheckErr(err, "获取审批用户失败"); e != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -215,6 +255,7 @@ func (Service flowHistoryService) GetApprover(node FlowTree) (res []admin.System
|
|||||||
return adminResp, nil
|
return adminResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通过审批
|
||||||
func (Service flowHistoryService) Pass(pass PassReq) (e error) {
|
func (Service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||||
nextNodes, applyDetail, LastHistory, err := Service.GetNextNode(pass.ApplyId)
|
nextNodes, applyDetail, LastHistory, err := Service.GetNextNode(pass.ApplyId)
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"x_admin/config"
|
"x_admin/config"
|
||||||
"x_admin/core/request"
|
"x_admin/core/request"
|
||||||
"x_admin/core/response"
|
"x_admin/core/response"
|
||||||
@@ -112,3 +113,27 @@ func (ah AdminHandler) Disable(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
response.CheckAndResp(c, Service.Disable(c, disableReq.ID))
|
response.CheckAndResp(c, Service.Disable(c, disableReq.ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary 获取部门的用户
|
||||||
|
// @Description 获取部门的用户
|
||||||
|
// @Tags 管理员
|
||||||
|
// @Param deptId path int true "部门id"
|
||||||
|
// @Success 200 {object} response.Response "{"code": 200, "data": []}"
|
||||||
|
// @Router /system/admin/ListByDeptId/{deptId} [get]
|
||||||
|
func (ah AdminHandler) ListByDeptId(c *gin.Context) {
|
||||||
|
deptIdStr, bool := c.GetQuery("deptId")
|
||||||
|
if bool == false {
|
||||||
|
response.FailWithMsg(c, response.Failed, "deptId不能为空")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
deptId, err := strconv.Atoi(deptIdStr)
|
||||||
|
if err != nil {
|
||||||
|
response.FailWithMsg(c, response.Failed, "deptId参数错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &deptId)) {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
res, err := Service.ListByUserIdOrDeptIdPostId(0, deptId, 0)
|
||||||
|
response.CheckAndRespWithData(c, res, err)
|
||||||
|
}
|
||||||
|
@@ -94,19 +94,19 @@ func (adminSrv systemAuthAdminService) Self(adminId uint) (res SystemAuthAdminSe
|
|||||||
return SystemAuthAdminSelfResp{User: admin, Permissions: auths}, nil
|
return SystemAuthAdminSelfResp{User: admin, Permissions: auths}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取管理员列表-用户id加部门岗位
|
// 获取管理员列表-
|
||||||
func (adminSrv systemAuthAdminService) ListByUserIdOrDeptIdPostId(userId, deptId, postId int) (res []SystemAuthAdminResp, e error) {
|
func (adminSrv systemAuthAdminService) ListByUserIdOrDeptIdPostId(userId, deptId, postId int) (res []SystemAuthAdminResp, e error) {
|
||||||
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
||||||
|
|
||||||
adminModel := adminSrv.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
adminModel := adminSrv.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
||||||
if userId > 0 {
|
if userId > 0 {
|
||||||
adminModel.Or("admin.id =?", userId)
|
adminModel.Where("admin.id =?", userId)
|
||||||
}
|
}
|
||||||
if deptId > 0 {
|
if deptId > 0 {
|
||||||
adminModel.Or("admin.dept_id =?", deptId)
|
adminModel.Where("admin.dept_id =?", deptId)
|
||||||
}
|
}
|
||||||
if postId > 0 {
|
if postId > 0 {
|
||||||
adminModel.Or("admin.post_id =?", postId)
|
adminModel.Where("admin.post_id =?", postId)
|
||||||
}
|
}
|
||||||
// 数据
|
// 数据
|
||||||
var adminResp []SystemAuthAdminResp
|
var adminResp []SystemAuthAdminResp
|
||||||
|
@@ -17,6 +17,7 @@ type SystemAuthDeptDetailReq struct {
|
|||||||
type SystemAuthDeptAddReq struct {
|
type SystemAuthDeptAddReq struct {
|
||||||
Pid uint `form:"pid" binding:"gte=0"` // 部门父级
|
Pid uint `form:"pid" binding:"gte=0"` // 部门父级
|
||||||
Name string `form:"name" binding:"required,min=1,max=100"` // 部门名称
|
Name string `form:"name" binding:"required,min=1,max=100"` // 部门名称
|
||||||
|
DutyId int `form:"dutyId" binding:"omitempty"` // 负责人id
|
||||||
Duty string `form:"duty" binding:"omitempty,min=1,max=30"` // 负责人
|
Duty string `form:"duty" binding:"omitempty,min=1,max=30"` // 负责人
|
||||||
Mobile string `form:"mobile" binding:"omitempty,len=11"` // 联系电话
|
Mobile string `form:"mobile" binding:"omitempty,len=11"` // 联系电话
|
||||||
IsStop uint8 `form:"isStop" binding:"oneof=0 1"` // 是否停用: [0=否, 1=是]
|
IsStop uint8 `form:"isStop" binding:"oneof=0 1"` // 是否停用: [0=否, 1=是]
|
||||||
@@ -28,6 +29,7 @@ type SystemAuthDeptEditReq struct {
|
|||||||
ID uint `form:"id" binding:"required,gt=0"` // 主键
|
ID uint `form:"id" binding:"required,gt=0"` // 主键
|
||||||
Pid uint `form:"pid" binding:"gte=0"` // 部门父级
|
Pid uint `form:"pid" binding:"gte=0"` // 部门父级
|
||||||
Name string `form:"name" binding:"required,min=1,max=100"` // 部门名称
|
Name string `form:"name" binding:"required,min=1,max=100"` // 部门名称
|
||||||
|
DutyId int `form:"dutyId" binding:"omitempty"` // 负责人id
|
||||||
Duty string `form:"duty" binding:"omitempty,min=1,max=30"` // 负责人
|
Duty string `form:"duty" binding:"omitempty,min=1,max=30"` // 负责人
|
||||||
Mobile string `form:"mobile" binding:"omitempty,len=11"` // 联系电话
|
Mobile string `form:"mobile" binding:"omitempty,len=11"` // 联系电话
|
||||||
IsStop uint8 `form:"isStop" binding:"oneof=0 1"` // 是否停用: [0=否, 1=是]
|
IsStop uint8 `form:"isStop" binding:"oneof=0 1"` // 是否停用: [0=否, 1=是]
|
||||||
@@ -44,6 +46,7 @@ type SystemAuthDeptResp struct {
|
|||||||
ID uint `json:"id" structs:"id"` // 主键
|
ID uint `json:"id" structs:"id"` // 主键
|
||||||
Pid uint `json:"pid" structs:"pid"` // 部门父级
|
Pid uint `json:"pid" structs:"pid"` // 部门父级
|
||||||
Name string `json:"name" structs:"name"` // 部门名称
|
Name string `json:"name" structs:"name"` // 部门名称
|
||||||
|
DutyId int `json:"dutyId" structs:"dutyId"` // 负责人id
|
||||||
Duty string `json:"duty" structs:"duty"` // 负责人
|
Duty string `json:"duty" structs:"duty"` // 负责人
|
||||||
Mobile string `json:"mobile" structs:"mobile"` // 联系电话
|
Mobile string `json:"mobile" structs:"mobile"` // 联系电话
|
||||||
Sort uint16 `json:"sort" structs:"sort"` // 排序编号
|
Sort uint16 `json:"sort" structs:"sort"` // 排序编号
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"x_admin/core"
|
"x_admin/core"
|
||||||
"x_admin/core/response"
|
"x_admin/core/response"
|
||||||
"x_admin/model/system_model"
|
"x_admin/model/system_model"
|
||||||
"x_admin/util"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@@ -44,7 +43,7 @@ func (deptSrv systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List 部门列表
|
// List 部门列表
|
||||||
func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (mapList []interface{}, e error) {
|
func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptResps []SystemAuthDeptResp, e error) {
|
||||||
deptModel := deptSrv.db.Where("is_delete = ?", 0)
|
deptModel := deptSrv.db.Where("is_delete = ?", 0)
|
||||||
if listReq.Name != "" {
|
if listReq.Name != "" {
|
||||||
deptModel = deptModel.Where("name like ?", "%"+listReq.Name+"%")
|
deptModel = deptModel.Where("name like ?", "%"+listReq.Name+"%")
|
||||||
@@ -57,10 +56,10 @@ func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (mapLis
|
|||||||
if e = response.CheckErr(err, "List Find err"); e != nil {
|
if e = response.CheckErr(err, "List Find err"); e != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
deptResps := []SystemAuthDeptResp{}
|
// deptResps = []SystemAuthDeptResp{}
|
||||||
response.Copy(&deptResps, depts)
|
response.Copy(&deptResps, depts)
|
||||||
mapList = util.ArrayUtil.ListToTree(
|
// mapList = util.ArrayUtil.ListToTree(
|
||||||
util.ConvertUtil.StructsToMaps(deptResps), "id", "pid", "children")
|
// util.ConvertUtil.StructsToMaps(deptResps), "id", "pid", "children")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,12 +22,14 @@ func AdminRoute(rg *gin.RouterGroup) {
|
|||||||
|
|
||||||
rg.GET("/admin/self", handle.Self)
|
rg.GET("/admin/self", handle.Self)
|
||||||
rg.GET("/admin/list", handle.List)
|
rg.GET("/admin/list", handle.List)
|
||||||
|
rg.GET("/admin/ListByDeptId", handle.ListByDeptId)
|
||||||
rg.GET("/admin/detail", handle.Detail)
|
rg.GET("/admin/detail", handle.Detail)
|
||||||
rg.POST("/admin/add", middleware.RecordLog("管理员新增"), handle.Add)
|
rg.POST("/admin/add", middleware.RecordLog("管理员新增"), handle.Add)
|
||||||
rg.POST("/admin/edit", middleware.RecordLog("管理员编辑"), handle.Edit)
|
rg.POST("/admin/edit", middleware.RecordLog("管理员编辑"), handle.Edit)
|
||||||
rg.POST("/admin/upInfo", middleware.RecordLog("管理员更新"), handle.UpInfo)
|
rg.POST("/admin/upInfo", middleware.RecordLog("管理员更新"), handle.UpInfo)
|
||||||
rg.POST("/admin/del", middleware.RecordLog("管理员删除"), handle.Del)
|
rg.POST("/admin/del", middleware.RecordLog("管理员删除"), handle.Del)
|
||||||
rg.POST("/admin/disable", middleware.RecordLog("管理员状态切换"), handle.Disable)
|
rg.POST("/admin/disable", middleware.RecordLog("管理员状态切换"), handle.Disable)
|
||||||
|
|
||||||
}
|
}
|
||||||
func RoleRoute(rg *gin.RouterGroup) {
|
func RoleRoute(rg *gin.RouterGroup) {
|
||||||
// db := core.GetDB()
|
// db := core.GetDB()
|
||||||
|
@@ -75,8 +75,9 @@ type SystemAuthDept struct {
|
|||||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||||
Pid uint `gorm:"not null;default:0;comment:'上级主键'"`
|
Pid uint `gorm:"not null;default:0;comment:'上级主键'"`
|
||||||
Name string `gorm:"not null;default:'';comment:'部门名称''"`
|
Name string `gorm:"not null;default:'';comment:'部门名称''"`
|
||||||
Duty string `gorm:"not null;default:'';comment:'负责人名'"`
|
DutyId int `gorm:"null;comment:'负责人id'"`
|
||||||
Mobile string `gorm:"not null;default:'';comment:'联系电话'"`
|
Duty string `gorm:"null;default:'';comment:'负责人名'"`
|
||||||
|
Mobile string `gorm:"null;default:'';comment:'联系电话'"`
|
||||||
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
|
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
|
||||||
IsStop uint8 `gorm:"not null;default:0;comment:'是否停用: 0=否, 1=是'"`
|
IsStop uint8 `gorm:"not null;default:0;comment:'是否停用: 0=否, 1=是'"`
|
||||||
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
|
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
|
||||||
|
Reference in New Issue
Block a user