|
@@ -1,14 +1,16 @@
|
|
|
import useModal from '@/components/Modal'
|
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
-import { Button } from 'antd'
|
|
|
+import { Button, message, Tag } from 'antd'
|
|
|
import { ColumnsType } from 'antd/lib/table'
|
|
|
-import { useRef, useState } from 'react'
|
|
|
+import { useState } from 'react'
|
|
|
import useDrawer from '@/components/Drawer'
|
|
|
import LeftMenu from '../RuleCode/components/LeftMenu'
|
|
|
-import AssemblyDetail from './components/AssemblyDetail'
|
|
|
+import AssemblyDetail, { assemblyName } from './components/AssemblyDetail'
|
|
|
import { MatterType, useRowScript } from './hooks/useRowScript'
|
|
|
import AddAssemblyModal from './components/AddAssemblyModal'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import { updateAssembly } from '@/services/api/business'
|
|
|
|
|
|
interface IState {
|
|
|
subjectParams: {
|
|
@@ -16,10 +18,10 @@ interface IState {
|
|
|
businessType?: Nullable<string>
|
|
|
}
|
|
|
expandTreeIds: []
|
|
|
+ assembly: []
|
|
|
}
|
|
|
|
|
|
const Matter: React.FC = () => {
|
|
|
- const tRef = useRef<ActionType>(null)
|
|
|
const [drawer, DrawerDom] = useDrawer()
|
|
|
const [state, setState] = useState<IState>({
|
|
|
subjectParams: {
|
|
@@ -28,11 +30,28 @@ const Matter: React.FC = () => {
|
|
|
},
|
|
|
expandTreeIds: []
|
|
|
})
|
|
|
+
|
|
|
+ const [assemblyArr, setAssemblyArr] = useState([])
|
|
|
+ console.log(assemblyArr)
|
|
|
+
|
|
|
const contentHeight = document.body.clientHeight - 122
|
|
|
const [modal, ModalDOM] = useModal()
|
|
|
- const { query, loading, add, edit, deleteMatter, treeList = [], expandTreeIds = [] } = useRowScript(modal)
|
|
|
+ const {
|
|
|
+ query,
|
|
|
+ loading,
|
|
|
+ refresh,
|
|
|
+ add,
|
|
|
+ edit,
|
|
|
+ deleteMatter,
|
|
|
+ treeList = [],
|
|
|
+ expandTreeIds = []
|
|
|
+ } = useRowScript(modal)
|
|
|
+
|
|
|
+ const handleChange = (checkName: string) => {
|
|
|
+ setAssemblyArr([...assemblyArr, checkName])
|
|
|
+ }
|
|
|
|
|
|
- const openDrawer = () => {
|
|
|
+ const openDrawer = record => {
|
|
|
drawer.open({
|
|
|
title: '组件配置',
|
|
|
closeIcon: null,
|
|
@@ -43,13 +62,22 @@ const Matter: React.FC = () => {
|
|
|
title: '添加组件',
|
|
|
okText: '确认',
|
|
|
cancelText: '取消',
|
|
|
- children: <AddAssemblyModal />
|
|
|
+ width: 1000,
|
|
|
+ children: <AddAssemblyModal record={record} onChange={checkName => handleChange(checkName)} />,
|
|
|
+ onOk: async () => {
|
|
|
+ const { code = -1 } = await updateAssembly({ ID: record.ID, assembly: assemblyArr })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ message.success('添加成功')
|
|
|
+ modal.close()
|
|
|
+ refresh()
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
}}>
|
|
|
添加组件
|
|
|
</Button>
|
|
|
),
|
|
|
- children: <AssemblyDetail reload={() => tRef.current?.reload()} />
|
|
|
+ children: <AssemblyDetail record={record} />
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -74,7 +102,10 @@ const Matter: React.FC = () => {
|
|
|
},
|
|
|
{
|
|
|
title: '包含组件',
|
|
|
- dataIndex: ''
|
|
|
+ dataIndex: 'assemblyName',
|
|
|
+ align: 'center',
|
|
|
+ render: (assembly, record) =>
|
|
|
+ record?.assembly?.map(item => <Tag key={record.ID}>{assemblyName[item]}</Tag>)
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
@@ -88,7 +119,9 @@ const Matter: React.FC = () => {
|
|
|
编辑
|
|
|
</span>
|
|
|
{record.matterType === MatterType.MATTER ? (
|
|
|
- <span className="px-2 text-primary cursor-pointer hover:text-hex-967bbd" onClick={openDrawer}>
|
|
|
+ <span
|
|
|
+ className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
|
|
|
+ onClick={() => openDrawer(record)}>
|
|
|
组件配置
|
|
|
</span>
|
|
|
) : null}
|
|
@@ -116,7 +149,6 @@ const Matter: React.FC = () => {
|
|
|
<ProTable
|
|
|
search={false}
|
|
|
rowKey="ID"
|
|
|
- actionRef={tRef}
|
|
|
headerTitle={
|
|
|
<div className="flex flex-nowrap justify-start items-center">
|
|
|
<div className="children:mx-1 px-1 py-2 ">
|