于宏哲PHP 10 months ago
parent
commit
6ceb6d8f03
  1. 13
      admin/src/app/api/sys.ts
  2. 465
      admin/src/app/views/school_approval/config/index.vue
  3. 15
      niucloud/app/adminapi/controller/sys/System.php
  4. 5
      niucloud/app/adminapi/route/sys.php
  5. 12
      niucloud/app/service/admin/auth/AuthService.php
  6. 18
      niucloud/app/service/admin/sys/SystemService.php
  7. 3
      niucloud/app/service/school_approval/SchoolApprovalConfigService.php

13
admin/src/app/api/sys.ts

@ -796,3 +796,16 @@ export function setDocument(params: Record<string, any>) {
export function getScsjtj(params: Record<string, any>) {
return request.post('sys/scsjtj', params)
}
export function person_all() {
return request.get('sys/person_all')
}
export function role_all() {
return request.get('sys/role_all')
}
export function departments_all() {
return request.get('sys/departments_all')
}

465
admin/src/app/views/school_approval/config/index.vue

@ -9,21 +9,10 @@
</el-button>
</div>
<div class="flex items-center">
<el-input
v-model="state.searchParams.config_name"
class="w-200px mr-15px"
placeholder="请输入配置名称"
clearable
@keyup.enter="handleSearch"
@clear="handleSearch"
/>
<el-select
v-model="state.searchParams.status"
class="w-150px mr-15px"
placeholder="请选择状态"
clearable
@change="handleSearch"
>
<el-input v-model="state.searchParams.config_name" class="w-200px mr-15px" placeholder="请输入配置名称"
clearable @keyup.enter="handleSearch" @clear="handleSearch" />
<el-select v-model="state.searchParams.status" class="w-150px mr-15px" placeholder="请选择状态" clearable
@change="handleSearch">
<el-option label="启用" :value="1" />
<el-option label="禁用" :value="0" />
</el-select>
@ -38,23 +27,15 @@
</div>
</div>
<el-table
v-loading="state.loading"
class="mt-15px"
:data="state.configList"
:header-cell-style="{ background: '#fafafa', color: '#606266' }"
>
<el-table v-loading="state.loading" class="mt-15px" :data="state.configList"
:header-cell-style="{ background: '#fafafa', color: '#606266' }">
<el-table-column label="ID" prop="id" width="80" />
<el-table-column label="配置名称" prop="config_name" min-width="180" />
<el-table-column label="配置描述" prop="description" min-width="200" show-overflow-tooltip />
<el-table-column label="状态" prop="status" width="100">
<template #default="{ row }">
<el-switch
v-model="row.status"
:active-value="1"
:inactive-value="0"
@change="handleStatusChange(row)"
/>
<el-switch v-model="row.status" :active-value="1" :inactive-value="0"
@change="handleStatusChange(row)" />
</template>
</el-table-column>
<el-table-column label="创建时间" prop="created_at" width="180" />
@ -74,132 +55,100 @@
</el-table>
<div class="flex justify-end mt-15px">
<el-pagination
v-model:current-page="state.searchParams.page"
v-model:page-size="state.searchParams.limit"
:page-sizes="[10, 20, 50, 100]"
:total="state.total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
<el-pagination v-model:current-page="state.searchParams.page"
v-model:page-size="state.searchParams.limit" :page-sizes="[10, 20, 50, 100]" :total="state.total"
layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
@current-change="handleCurrentChange" />
</div>
</el-card>
<!-- 新增/编辑弹窗 -->
<el-dialog
v-model="state.dialog.visible"
:title="state.dialog.title"
width="800px"
:close-on-click-modal="false"
:destroy-on-close="true"
>
<el-form
ref="formRef"
:model="state.dialog.form"
:rules="state.dialog.rules"
label-width="120px"
>
<el-dialog v-model="state.dialog.visible" :title="state.dialog.title" width="800px"
:close-on-click-modal="false" :destroy-on-close="true">
<el-form ref="formRef" :model="state.dialog.form" :rules="state.dialog.rules" label-width="120px">
<el-form-item label="配置名称" prop="config_name">
<el-input v-model="state.dialog.form.config_name" placeholder="请输入配置名称" />
</el-form-item>
<el-form-item label="配置描述" prop="description">
<el-input
v-model="state.dialog.form.description"
type="textarea"
:rows="3"
placeholder="请输入配置描述"
/>
<el-input v-model="state.dialog.form.description" type="textarea" :rows="3" placeholder="请输入配置描述" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-switch
v-model="state.dialog.form.status"
:active-value="1"
:inactive-value="0"
/>
<el-switch v-model="state.dialog.form.status" :active-value="1" :inactive-value="0" />
</el-form-item>
<el-form-item label="审批节点" prop="nodes">
<div class="mb-10px">
<el-button type="primary" @click="handleAddNode">
<icon name="add" class="mr-5px" />
<!-- 添加节点按钮 -->
<div class="mb-4">
<el-button type="primary" @click="handleAddNode" size="small">
<icon name="add" class="mr-1" />
添加节点
</el-button>
</div>
<div v-if="state.dialog.form.nodes.length === 0" class="text-gray-400 text-center py-20px border border-dashed rounded">
<!-- 无节点提示 -->
<div v-if="state.dialog.form.nodes.length === 0"
class="text-gray-400 text-center py-6 border border-dashed rounded bg-gray-50">
暂无审批节点请点击添加
</div>
<div v-else class="node-list">
<div
v-for="(element, index) in state.dialog.form.nodes"
:key="index"
class="node-item p-15px mb-15px border border-gray-200 rounded"
>
<div class="flex justify-between items-center mb-10px">
<div class="flex items-center">
<icon name="rank" class="drag-handle mr-5px cursor-move" />
<span class="font-bold">节点 {{ index + 1 }}</span>
<!-- 节点列表 -->
<div v-else class="space-y-4">
<div v-for="(element, index) in state.dialog.form.nodes" :key="index"
class="p-4 border border-gray-300 rounded-md bg-white shadow-sm">
<!-- 节点头部 -->
<div class="flex justify-between items-center mb-4">
<div class="flex items-center text-gray-800 font-medium">
<icon name="rank" class="drag-handle mr-2 text-gray-500 cursor-move" />
节点 {{ index + 1 }}
</div>
<el-button type="danger" link @click="handleRemoveNode(index)">
删除
</el-button>
</div>
<div class="flex items-center mb-10px">
<span class="w-100px">节点名称</span>
<el-input
v-model="element.node_name"
placeholder="请输入节点名称"
/>
<!-- 节点名称 -->
<div class="flex items-center mb-3">
<span class="w-28 text-gray-600">节点名称</span>
<el-input v-model="element.node_name" placeholder="请输入节点名称" size="small" style="width: 73%;"/>
</div>
<div class="flex items-center mb-10px">
<span class="w-100px">审批人类型</span>
<el-select
v-model="element.approver_type"
class="flex-1"
placeholder="请选择审批人类型"
>
<!-- 审批人类型 -->
<div class="flex items-center mb-3">
<span class="w-28 text-gray-600">审批人类型</span>
<el-select v-model="element.approver_type" class="flex-1" placeholder="请选择审批人类型"
size="small">
<el-option label="指定用户" value="user" />
<el-option label="指定角色" value="role" />
<el-option label="指定部门" value="department" />
</el-select>
</div>
<div class="flex items-center mb-10px">
<span class="w-100px">审批人</span>
<el-select
v-model="element.approver_ids"
class="flex-1"
multiple
placeholder="请选择审批人"
>
<!-- 这里根据 approver_type 不同显示不同的选项 -->
<!-- 审批 -->
<div class="flex items-center mb-3">
<span class="w-28 text-gray-600">审批</span>
<el-select v-model="element.approver_ids" class="flex-1" multiple placeholder="请选择审批"
size="small">
<!-- 用户 -->
<template v-if="element.approver_type === 'user'">
<el-option
v-for="item in state.userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-option v-for="item in state.userOptions" :key="item.id" :label="item.name"
:value="String(item.id)" />
</template>
<!-- 角色 -->
<template v-else-if="element.approver_type === 'role'">
<el-option
v-for="item in state.roleOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-option v-for="item in state.roleOptions" :key="item.role_id"
:label="item.role_name" :value="String(item.role_id)" />
</template>
<!-- 部门 -->
<template v-else-if="element.approver_type === 'department'">
<el-option
v-for="item in state.departmentOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
<el-option v-for="item in state.departmentOptions" :key="item.id"
:label="item.department_name" :value="String(item.id)" />
</template>
</el-select>
</div>
<!-- 审批类型 -->
<div class="flex items-center">
<span class="w-100px">审批类型</span>
<el-radio-group v-model="element.sign_type">
<span class="w-28 text-gray-600">审批类型</span>
<el-radio-group v-model="element.sign_type" size="small">
<el-radio label="or_sign">或签一人通过即可</el-radio>
<el-radio label="and_sign">会签需全部通过</el-radio>
</el-radio-group>
@ -207,6 +156,7 @@
</div>
</div>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="state.dialog.visible = false">取消</el-button>
@ -217,12 +167,7 @@
</el-dialog>
<!-- 详情弹窗 -->
<el-dialog
v-model="state.detailDialog.visible"
title="审批流配置详情"
width="800px"
:destroy-on-close="true"
>
<el-dialog v-model="state.detailDialog.visible" title="审批流配置详情" width="800px" :destroy-on-close="true">
<el-descriptions :column="1" border>
<el-descriptions-item label="ID">
{{ state.detailDialog.info?.id || '-' }}
@ -246,19 +191,17 @@
<div class="mt-20px">
<div class="font-bold text-16px mb-10px">审批节点列表</div>
<el-timeline>
<el-timeline-item
v-for="(node, index) in state.detailDialog.info?.nodes || []"
:key="index"
:type="getNodeType(node.sign_type)"
:color="getNodeColor(node.sign_type)"
>
<el-timeline-item v-for="(node, index) in state.detailDialog.info?.nodes || []" :key="index"
:type="getNodeType(node.sign_type)" :color="getNodeColor(node.sign_type)">
<div class="font-bold mb-5px">{{ node.node_name }}</div>
<div class="text-gray-500">
审批人类型{{ getApproverTypeText(node.approver_type) }}
</div>
<div class="text-gray-500">
审批人{{ node.approver_ids }}
审批人{{ getApproverNames(node.approver_ids,node.approver_type)}}
</div>
<div class="text-gray-500">
审批类型{{ node.sign_type === 'or_sign' ? '或签' : '会签' }}
</div>
@ -270,45 +213,51 @@
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox, FormInstance } from 'element-plus'
import { getConfigList, getConfigInfo, addConfig, editConfig, deleteConfig, changeConfigStatus } from '@/app/api/school_approval/config'
// draggable使
// import draggable from 'vuedraggable'
// i18n
// import { useI18n } from 'vue-i18n'
// const { t } = useI18n()
//
const formRef = ref<FormInstance>()
//
interface DetailInfo {
id?: number;
config_name?: string;
description?: string;
status?: number;
created_at?: string;
nodes?: Array<{
node_name: string;
approver_type: string;
approver_ids: string;
sign_type: string;
import { reactive, ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox, FormInstance } from 'element-plus'
import { getConfigList, getConfigInfo, addConfig, editConfig, deleteConfig, changeConfigStatus } from '@/app/api/school_approval/config'
import {
person_all,
role_all,
departments_all
} from '@/app/api/sys'
// draggable使
// import draggable from 'vuedraggable'
// i18n
// import { useI18n } from 'vue-i18n'
// const { t } = useI18n()
//
const formRef = ref<FormInstance>()
//
interface DetailInfo {
id ?: number;
config_name ?: string;
description ?: string;
status ?: number;
created_at ?: string;
nodes ?: Array<{
node_name : string;
approver_type : string;
approver_ids : string;
sign_type : string;
}>;
}
//
interface ApprovalNode {
key: string;
node_name: string;
approver_type: string;
approver_ids: string[];
sign_type: string;
}
//
const state = reactive({
}
//
interface ApprovalNode {
key : string;
node_name : string;
approver_type : string;
approver_ids : string[];
sign_type : string;
}
//
const state = reactive({
loading: false,
configList: [],
total: 0,
@ -319,19 +268,9 @@ const state = reactive({
status: ''
},
// API
userOptions: [
{ label: '用户1', value: '1' },
{ label: '用户2', value: '2' },
{ label: '用户3', value: '3' }
],
roleOptions: [
{ label: '角色1', value: '1' },
{ label: '角色2', value: '2' }
],
departmentOptions: [
{ label: '部门1', value: '1' },
{ label: '部门2', value: '2' }
],
userOptions: [],
roleOptions: [],
departmentOptions: [],
dialog: {
visible: false,
title: '',
@ -357,10 +296,48 @@ const state = reactive({
visible: false,
info: {} as DetailInfo
}
})
})
const setPersonIdList = async () => {
state.userOptions = await (await person_all()).data
}
setPersonIdList()
const setRoleIdList = async () => {
state.roleOptions = await (await role_all()).data
}
setRoleIdList()
//
function validateNodes(rule: any, value: any, callback: any) {
const setDepartmentsIdList = async () => {
state.departmentOptions = await (await departments_all()).data
}
setDepartmentsIdList()
const getApproverNames = (ids : string | string[], type : string) => {
if (!ids) return '';
const idArray = typeof ids === 'string' ? ids.split(',') : ids;
let options = [];
if (type === 'user') {
options = state.userOptions;
} else if (type === 'role') {
options = state.roleOptions;
} else if (type === 'department') {
options = state.departmentOptions;
}
console.log(options);
return idArray
.map(id => {
const match = options.find(item => String(item.id || item.role_id) === String(id));
return match ? (match.name || match.role_name || match.department_name) : '';
})
.filter(name => name !== '')
.join(', ');
};
//
function validateNodes(rule : any, value : any, callback : any) {
if (!value || value.length === 0) {
callback(new Error('请至少添加一个审批节点'))
} else {
@ -380,10 +357,10 @@ function validateNodes(rule: any, value: any, callback: any) {
}
callback()
}
}
}
//
async function getList() {
//
async function getList() {
state.loading = true
try {
const res = await getConfigList(state.searchParams)
@ -394,16 +371,16 @@ async function getList() {
} finally {
state.loading = false
}
}
}
//
function handleSearch() {
//
function handleSearch() {
state.searchParams.page = 1
getList()
}
}
//
function handleReset() {
//
function handleReset() {
state.searchParams = {
page: 1,
limit: 10,
@ -411,23 +388,23 @@ function handleReset() {
status: ''
}
getList()
}
}
//
function handleCurrentChange(page: number) {
//
function handleCurrentChange(page : number) {
state.searchParams.page = page
getList()
}
}
//
function handleSizeChange(size: number) {
//
function handleSizeChange(size : number) {
state.searchParams.limit = size
state.searchParams.page = 1
getList()
}
}
//
function handleAdd() {
//
function handleAdd() {
state.dialog.type = 'add'
state.dialog.title = '添加审批流配置'
state.dialog.form = {
@ -438,10 +415,10 @@ function handleAdd() {
nodes: []
}
state.dialog.visible = true
}
}
//
async function handleEdit(row: any) {
//
async function handleEdit(row : any) {
state.dialog.type = 'edit'
state.dialog.title = '编辑审批流配置'
state.dialog.loading = true
@ -450,7 +427,7 @@ async function handleEdit(row: any) {
state.dialog.form = { ...res.data }
// key
if (state.dialog.form.nodes && Array.isArray(state.dialog.form.nodes)) {
state.dialog.form.nodes = state.dialog.form.nodes.map((node: any, index: number) => {
state.dialog.form.nodes = state.dialog.form.nodes.map((node : any, index : number) => {
// approver_idssplit
const approverIds = typeof node.approver_ids === 'string'
? node.approver_ids.split(',')
@ -472,10 +449,10 @@ async function handleEdit(row: any) {
} finally {
state.dialog.loading = false
}
}
}
//
async function handleDetail(row: any) {
//
async function handleDetail(row : any) {
try {
const res = await getConfigInfo({ id: row.id })
state.detailDialog.info = res.data
@ -483,10 +460,10 @@ async function handleDetail(row: any) {
} catch (error) {
console.error(error)
}
}
}
//
function handleDelete(row: any) {
//
function handleDelete(row : any) {
ElMessageBox.confirm('确定要删除此项吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -501,11 +478,11 @@ function handleDelete(row: any) {
console.error(error)
}
})
.catch(() => {})
}
.catch(() => { })
}
//
async function handleStatusChange(row: any) {
//
async function handleStatusChange(row : any) {
try {
await changeConfigStatus({ id: row.id, status: row.status })
ElMessage.success(
@ -517,10 +494,10 @@ async function handleStatusChange(row: any) {
console.error(error)
row.status = row.status ? 0 : 1 //
}
}
}
//
function handleAddNode() {
//
function handleAddNode() {
state.dialog.form.nodes.push({
key: `node_${state.dialog.form.nodes.length}_${Date.now()}`,
node_name: '',
@ -528,15 +505,15 @@ function handleAddNode() {
approver_ids: [],
sign_type: 'or_sign'
})
}
}
//
function handleRemoveNode(index: number) {
//
function handleRemoveNode(index : number) {
state.dialog.form.nodes.splice(index, 1)
}
}
//
async function handleSubmit() {
//
async function handleSubmit() {
if (!formRef.value) return
await formRef.value.validate(async (valid) => {
@ -548,7 +525,7 @@ async function handleSubmit() {
const formData = { ...state.dialog.form }
//
formData.nodes = formData.nodes.map((node: any, index: number) => {
formData.nodes = formData.nodes.map((node : any, index : number) => {
// keyAPI
const { key, ...nodeWithoutKey } = node;
@ -585,54 +562,54 @@ async function handleSubmit() {
state.dialog.loading = false
}
})
}
}
//
function getNodeType(signType: string) {
//
function getNodeType(signType : string) {
return signType === 'or_sign' ? 'primary' : 'success'
}
}
//
function getNodeColor(signType: string) {
//
function getNodeColor(signType : string) {
return signType === 'or_sign' ? '#409EFF' : '#67C23A'
}
}
//
function getApproverTypeText(type: string) {
const map: Record<string, string> = {
//
function getApproverTypeText(type : string) {
const map : Record<string, string> = {
user: '指定用户',
role: '指定角色',
department: '指定部门'
}
return map[type] || type
}
}
onMounted(() => {
onMounted(() => {
getList()
})
})
</script>
<style lang="scss" scoped>
.node-item {
.node-item {
background-color: #f9f9f9;
transition: all 0.3s;
&:hover {
background-color: #f2f2f2;
}
}
}
.ghost {
.ghost {
opacity: 0.5;
background: #c8ebfb;
}
}
.drag-handle {
.drag-handle {
cursor: move;
color: #909399;
&:hover {
color: #409eff;
}
}
}
</style>

15
niucloud/app/adminapi/controller/sys/System.php

@ -169,4 +169,19 @@ class System extends BaseAdminController
}
//全部人员
public function person_all(){
return success(data: (new SystemService())->person_all());
}
public function role_all(){
return success(data: (new SystemService())->role_all());
}
public function departments_all(){
return success(data: (new SystemService())->departments_all());
}
}

5
niucloud/app/adminapi/route/sys.php

@ -351,6 +351,11 @@ Route::group('sys', function() {
//系统环境(不效验登录状态)
Route::group('sys', function() {
Route::get('person_all', 'sys.System/person_all');
Route::get('role_all', 'sys.System/role_all');
Route::get('departments_all', 'sys.System/departments_all');
Route::get('web/website', 'sys.Config/getWebsite');
// 获取版权信息
Route::get('web/copyright', 'sys.Config/getCopyright');

12
niucloud/app/service/admin/auth/AuthService.php

@ -48,7 +48,10 @@ class AuthService extends BaseAdminService
if (!in_array($rule, $method_menu_list))
return true;
$auth_role_list = $this->getAuthApiList();
if (!empty($auth_role_list[ $method ]) && in_array($rule, $auth_role_list[ $method ]))
return true;
@ -72,7 +75,14 @@ class AuthService extends BaseAdminService
//获取站点信息
return ( new MenuService() )->getAllApiList(1);
} else {
$user_role_ids = $user_info[ 'role_ids' ];
$per = new Personnel();
$CampusPersonRole = new CampusPersonRole();
$per_id = $per->where(['sys_user_id' => $this->uid])->column('id');
$user_role_ids = $CampusPersonRole->where(['person_id' => $per_id])->column('role_id');
// $user_role_ids = $user_info[ 'role_ids' ];
$role_service = new RoleService();
$menu_keys = $role_service->getMenuKeysByRoleIds($user_role_ids ?? []);
return $menu_service->getApiListByMenuKeys($menu_keys);

18
niucloud/app/service/admin/sys/SystemService.php

@ -17,10 +17,12 @@ use app\model\campus\Campus;
use app\model\campus_person_role\CampusPersonRole;
use app\model\communication_records\CommunicationRecords;
use app\model\customer_resources\CustomerResources;
use app\model\departments\Departments;
use app\model\market_performance\MarketPerformance;
use app\model\personnel\Personnel;
use app\model\student\Student;
use app\model\sys\SysConfig;
use app\model\sys\SysRole;
use app\service\core\sys\CoreSysConfigService;
use core\base\BaseAdminService;
use think\facade\Db;
@ -342,4 +344,20 @@ class SystemService extends BaseAdminService
}
return $data;
}
public function person_all(){
$Personnel = new Personnel();
return $Personnel->select()->toArray();
}
public function role_all(){
$sysRole = new SysRole();
return $sysRole->select()->toArray();
}
public function departments_all(){
$departments = new Departments();
return $departments->select()->toArray();
}
}

3
niucloud/app/service/school_approval/SchoolApprovalConfigService.php

@ -51,10 +51,11 @@ class SchoolApprovalConfigService
public function getInfo(int $id): array
{
$info = (new SchoolApprovalConfig())->with(['nodes'])->where(['id' => $id])->find();
if (empty($info)) {
return [];
}
return $info->toArray();
}

Loading…
Cancel
Save