Commit 9b974642 authored by 前端-许佳敏's avatar 前端-许佳敏

fix: merge丢失的文件

parent ebf66e97
This diff is collapsed.
.field-header_container {
display: flex;
justify-content: space-between;
font-size: 14px;
margin-bottom: 18px;
}
.field-header_title {
display: flex;
align-items: center;
font-weight: 700;
&::before {
content: "";
width: 2px;
height: 14px;
background: #00B37A;
margin-right: 6px;
}
}
import React, { ReactNode } from 'react'
import mixinsClassName from 'classnames'
import './index.less'
export interface FieldHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
renderTitle: ReactNode,
extra?: ReactNode,
}
const FieldHeader:React.FC<FieldHeaderProps> = (props) => {
const { renderTitle, extra, className, ...restDivProps } = props
return (
<div className={mixinsClassName('field-header_container', className)} {...restDivProps}>
<div className='field-header_title'>{renderTitle}</div>
<div>{extra}</div>
</div>
)
}
FieldHeader.defaultProps = {}
export default FieldHeader
import { Modal } from "antd"
import { ReactNode, useCallback, useEffect, useState } from "react"
export interface leaveOptions {
title?: ReactNode,
onSave: any,
onModalOk(resolve: any),
onModalCancel(reject: any),
}
/**
* 对即将离开某个操作时, 发出提示弹窗
*/
export const useLeavePage = (options: leaveOptions): [React.Dispatch<React.SetStateAction<boolean>>, any] => {
const { title, onSave, onModalOk, onModalCancel } = options
const [saveStatus, setSaveStatus] = useState<boolean>(true)
const validateSaveStatus = useCallback(() => {
if (saveStatus) {
return Promise.resolve()
} else {
return new Promise((resolve, reject) => {
Modal.confirm({
content: title || '确认要离开当前页面吗,您提交的数据尚未保存',
onOk() {
onModalOk(resolve)
},
onCancel() {
onModalCancel(reject)
}
})
})
}
}, [saveStatus])
return [setSaveStatus, validateSaveStatus]
}
import { useMap } from '@umijs/hooks'
import React, { useState, useEffect } from 'react'
import { Modal } from 'antd'
import { TabTreeActions } from '@/components/TabTree'
import { ISchemaFormActions } from '@formily/antd'
import { isObject } from '@/utils'
export enum FormState {
FREE, // 空闲状态
EDIT, // 编辑状态
ADD, // 新增状态
}
export interface useTreeTabOptions {
selectCallback?(selectKey?, node?),
fetchMenuData?(),
fetchItemDetailData?(id),
// 重置右侧详情
resetDetail?(),
// 对树形工具栏做render扩展
extendsToolsRender?: any,
// 树形的实例操作方法
treeActions?: TabTreeActions
// 右侧表单的实例操作方法
formActions?: ISchemaFormActions
// 删除菜单时调用的API
deleteMenu?: any
}
export interface treeNodeResponse {
/**
* 该节点是否选中
*/
selected: boolean,
/**
* 节点信息
*/
node: any
}
export const useTreeData = (options: useTreeTabOptions = {}) => {
const { selectCallback, fetchMenuData, treeActions, formActions, extendsToolsRender, deleteMenu } = options
const [treeExtraMaps, { set, get }] = useMap<any, any>()
const [treeData, setTreeData] = useState<any[]>([])
const [treeStatus, setTreeStatus] = useState<FormState>(FormState.FREE)
const [nodeRecord, setNodeRecord] = useState<any>(null)
const [isEditForm, setIsEditForm] = useState<boolean>(false)
useEffect(() => {
resetMenu()
}, [])
const resetMenu = async () => {
if (fetchMenuData) {
const res = await fetchMenuData()
setTreeData(res.data || [])
}
}
const handleSelect = (selectKey?, node?) => {
return new Promise<treeNodeResponse>((resolve, reject) => {
if (selectCallback) {
// 完全自定义点击节点事件
selectCallback(selectKey, node)
return;
}
resolve({
selected: true,
node: node || null
})
})
}
const handleDeleteMenu = (id) => {
deleteMenu({
id: isObject(id) ? nodeRecord.key : id
}).then(() => {
setTreeStatus(FormState.FREE)
setNodeRecord(undefined)
resetMenu()
})
}
// 新增整合树形操作菜单
// 树形工具栏
const toolsRender = {
addNode(node) {
const activeParentId = treeActions && treeActions.getParent(node.key || node.id)?.id
setNodeRecord({
...node,
parentId: activeParentId, // 添加同级的时候 使用上一级的id作为parentId
})
formActions && formActions.reset({ validate: false })
setTreeStatus(FormState.ADD)
},
addChildNode(node) {
setNodeRecord({
...node,
parentId: node.key || node.id
})
formActions && formActions.reset({ validate: false })
set(node.key || node.id, null)
setTreeStatus(FormState.ADD)
},
deleteNode(node) {
const id = node.key || node.id
handleDeleteMenu(id)
},
...extendsToolsRender
}
return {
handleSelect,
treeStatus,
setTreeStatus,
treeData,
setTreeData,
nodeRecord,
setNodeRecord,
isEditForm,
setIsEditForm,
treeExtraMaps,
setTreeMaps: set,
getTreeMaps: get,
resetMenu,
toolsRender,
handleDeleteMenu
}
}
.org-tag-container {
margin-bottom: 8px;
.ant-tag-has-color, .ant-tag-has-color a, .ant-tag-has-color a:hover, .ant-tag-has-color .anticon-close, .ant-tag-has-color .anticon-close:hover {
color: #606266;
}
}
.org-tag {
color: #606266;
}
import TabTree, { createTreeActions } from '@/components/TabTree'
import { useTreeTabs } from '@/hooks/useTreeTabs'
import { PublicApi } from '@/services/api'
import { Button, Drawer, Row } from 'antd'
import React, { useEffect, useState } from 'react'
import './orgModal.less'
export interface OrgModalProps {
visible: boolean,
handleSyncSelect: any,
plateformTreeData: any,
fetchOrgsTreeData: any,
selectKeys: any[],
onSuccess(selectKeys: any[]),
onCancel(),
}
const syncTreeActions = createTreeActions()
const OrgModal:React.FC<OrgModalProps> = (props) => {
const { visible, onSuccess, onCancel, plateformTreeData, handleSyncSelect, fetchOrgsTreeData, selectKeys } = props
const [resetSearch, setResetSearch] = useState(false)
const [customPlateformExpandkeys, setCustomPlateformExpandkeys] = useState<any>()
const handleSuccess = () => {
onSuccess(syncTreeActions.getSelectKeys())
}
useEffect(() => {
syncTreeActions.setSelectKeys(selectKeys)
}, [selectKeys])
return (
<Drawer
visible={visible}
closable={false}
placement='right'
width={600}
>
<TabTree
fetchData = {params => fetchOrgsTreeData()}
treeData={plateformTreeData}
handleSelect={handleSyncSelect}
actions={syncTreeActions}
customKey="id"
enableSearch
searchPlaceholder="组织机构名称"
checkStrictly
resetSearch={resetSearch}
customExpandkeys={customPlateformExpandkeys}
checkable={true}
/>
<Row justify='end'>
<Button onClick={onCancel} style={{marginRight: 8}}>关闭</Button>
<Button onClick={handleSuccess} type='primary'>确认</Button>
</Row>
</Drawer>
)
}
OrgModal.defaultProps = {}
export default OrgModal
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment