|
@ -10,6 +10,7 @@ const AppManagement = () => { |
|
|
const [editing, setEditing] = useState(false); |
|
|
const [editing, setEditing] = useState(false); |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]); |
|
|
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]); |
|
|
|
|
|
const [filteredAppArr, setFilteredAppArr] = useState<API.MatrixApp[]>([]); |
|
|
const { initialState } = useModel('@@initialState'); |
|
|
const { initialState } = useModel('@@initialState'); |
|
|
const currentUser = initialState?.currentUser; |
|
|
const currentUser = initialState?.currentUser; |
|
|
const canUpdate = currentUser && currentUser.role && currentUser.role < 2; |
|
|
const canUpdate = currentUser && currentUser.role && currentUser.role < 2; |
|
@ -24,15 +25,20 @@ const AppManagement = () => { |
|
|
{ |
|
|
{ |
|
|
title: '应用名', |
|
|
title: '应用名', |
|
|
dataIndex: 'name', |
|
|
dataIndex: 'name', |
|
|
|
|
|
copyable: true, |
|
|
|
|
|
hideInSearch: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: 'code', |
|
|
title: 'code', |
|
|
dataIndex: 'code', |
|
|
dataIndex: 'code', |
|
|
|
|
|
copyable: true, |
|
|
|
|
|
hideInSearch: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '下载地址', |
|
|
title: '下载地址', |
|
|
dataIndex: 'url', |
|
|
dataIndex: 'url', |
|
|
width: 200, |
|
|
width: 200, |
|
|
|
|
|
hideInSearch: true, |
|
|
renderText: (url: string) => ( |
|
|
renderText: (url: string) => ( |
|
|
<Popover |
|
|
<Popover |
|
|
overlayInnerStyle={{ padding: 0 }} |
|
|
overlayInnerStyle={{ padding: 0 }} |
|
@ -51,10 +57,12 @@ const AppManagement = () => { |
|
|
dataIndex: 'secret', |
|
|
dataIndex: 'secret', |
|
|
ellipsis: true, |
|
|
ellipsis: true, |
|
|
copyable: true, |
|
|
copyable: true, |
|
|
|
|
|
hideInSearch: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '菜单栏中', |
|
|
title: '菜单栏中', |
|
|
dataIndex: 'hide', |
|
|
dataIndex: 'hide', |
|
|
|
|
|
hideInSearch: true, |
|
|
renderText: (r: number) => { |
|
|
renderText: (r: number) => { |
|
|
if (r === 0) { |
|
|
if (r === 0) { |
|
|
return <Tag color="blue">展示</Tag>; |
|
|
return <Tag color="blue">展示</Tag>; |
|
@ -66,6 +74,7 @@ const AppManagement = () => { |
|
|
{ |
|
|
{ |
|
|
title: '渠道', |
|
|
title: '渠道', |
|
|
dataIndex: 'channel', |
|
|
dataIndex: 'channel', |
|
|
|
|
|
hideInSearch: true, |
|
|
renderText: (r: string) => { |
|
|
renderText: (r: string) => { |
|
|
switch (r) { |
|
|
switch (r) { |
|
|
case 'fanmiyou': |
|
|
case 'fanmiyou': |
|
@ -79,6 +88,7 @@ const AppManagement = () => { |
|
|
{ |
|
|
{ |
|
|
title: '操作', |
|
|
title: '操作', |
|
|
width: 80, |
|
|
width: 80, |
|
|
|
|
|
hideInSearch: true, |
|
|
renderText: (record: API.MatrixApp) => ( |
|
|
renderText: (record: API.MatrixApp) => ( |
|
|
<a key="edit" onClick={() => handleEdit(record)}> |
|
|
<a key="edit" onClick={() => handleEdit(record)}> |
|
|
编辑 |
|
|
编辑 |
|
@ -99,6 +109,7 @@ const AppManagement = () => { |
|
|
const res = await appList(); |
|
|
const res = await appList(); |
|
|
if (res.data) { |
|
|
if (res.data) { |
|
|
setAppArr(res.data); |
|
|
setAppArr(res.data); |
|
|
|
|
|
setFilteredAppArr(res.data); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -121,6 +132,10 @@ const AppManagement = () => { |
|
|
setVisible(false); |
|
|
setVisible(false); |
|
|
fetchApp(); |
|
|
fetchApp(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
const handleSearch = (value: string) => { |
|
|
|
|
|
const filtered = appArr.filter((item) => item?.name?.includes(value)); |
|
|
|
|
|
setFilteredAppArr(filtered); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<PageContainer> |
|
|
<PageContainer> |
|
@ -130,9 +145,22 @@ const AppManagement = () => { |
|
|
</Button> |
|
|
</Button> |
|
|
)} |
|
|
)} |
|
|
<ProTable |
|
|
<ProTable |
|
|
search={false} |
|
|
search={{ |
|
|
|
|
|
defaultCollapsed: false, // 默认展开搜索框
|
|
|
|
|
|
optionRender: () => [ |
|
|
|
|
|
// 自定义搜索框
|
|
|
|
|
|
<Input |
|
|
|
|
|
key="name" |
|
|
|
|
|
placeholder="请输入应用名" |
|
|
|
|
|
onChange={(e) => handleSearch(e.target.value)} |
|
|
|
|
|
/>, |
|
|
|
|
|
], |
|
|
|
|
|
}} |
|
|
|
|
|
onReset={() => { |
|
|
|
|
|
setFilteredAppArr(appArr); |
|
|
|
|
|
}} |
|
|
columns={canUpdate ? columnsWithOperation : columns} |
|
|
columns={canUpdate ? columnsWithOperation : columns} |
|
|
dataSource={appArr} |
|
|
dataSource={filteredAppArr} |
|
|
/> |
|
|
/> |
|
|
|
|
|
|
|
|
<Modal title="编辑" visible={visible} onOk={handleOk} onCancel={handleCancel}> |
|
|
<Modal title="编辑" visible={visible} onOk={handleOk} onCancel={handleCancel}> |
|
|