|
|
@@ -1,46 +1,37 @@
|
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
|
-import BaseService from '@/utils/BaseService';
|
|
|
-import type { CertificateItem } from '@/pages/link/Certificate/typings';
|
|
|
-import { useRef } from 'react';
|
|
|
+import { useRef, useState } from 'react';
|
|
|
import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
|
-import { message, Popconfirm, Tooltip } from 'antd';
|
|
|
-import { EditOutlined, MinusOutlined } from '@ant-design/icons';
|
|
|
-import BaseCrud from '@/components/BaseCrud';
|
|
|
+import { message } from 'antd';
|
|
|
+import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
|
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
-import type { ISchema } from '@formily/json-schema';
|
|
|
-import { CurdModel } from '@/components/BaseCrud/model';
|
|
|
+import SearchComponent from '@/components/SearchComponent';
|
|
|
+import ProTable from '@jetlinks/pro-table';
|
|
|
+import PermissionButton from '@/components/PermissionButton';
|
|
|
+import usePermissions from '@/hooks/permission';
|
|
|
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
|
|
|
+import { history } from 'umi';
|
|
|
+import Service from '../service';
|
|
|
+
|
|
|
+export const service = new Service('network/certificate');
|
|
|
|
|
|
-export const service = new BaseService<CertificateItem>('network/certificate');
|
|
|
const Certificate = () => {
|
|
|
const intl = useIntl();
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
+ const [param, setParam] = useState({});
|
|
|
+ const { permission } = usePermissions('link/Certificate');
|
|
|
|
|
|
const columns: ProColumns<CertificateItem>[] = [
|
|
|
{
|
|
|
- dataIndex: 'index',
|
|
|
- valueType: 'indexBorder',
|
|
|
- width: 48,
|
|
|
+ dataIndex: 'type',
|
|
|
+ title: '证书标准',
|
|
|
},
|
|
|
{
|
|
|
dataIndex: 'name',
|
|
|
- title: intl.formatMessage({
|
|
|
- id: 'pages.table.name',
|
|
|
- defaultMessage: '名称',
|
|
|
- }),
|
|
|
- },
|
|
|
- {
|
|
|
- dataIndex: 'instance',
|
|
|
- title: intl.formatMessage({
|
|
|
- id: 'pages.link.type',
|
|
|
- defaultMessage: '类型',
|
|
|
- }),
|
|
|
+ title: '证书名称',
|
|
|
},
|
|
|
{
|
|
|
dataIndex: 'description',
|
|
|
- title: intl.formatMessage({
|
|
|
- id: 'pages.table.describe',
|
|
|
- defaultMessage: '描述',
|
|
|
- }),
|
|
|
+ title: '说明',
|
|
|
},
|
|
|
{
|
|
|
title: intl.formatMessage({
|
|
|
@@ -51,29 +42,29 @@ const Certificate = () => {
|
|
|
align: 'center',
|
|
|
width: 200,
|
|
|
render: (text, record) => [
|
|
|
- <a
|
|
|
- key="edit"
|
|
|
+ <PermissionButton
|
|
|
+ key={'update'}
|
|
|
+ type={'link'}
|
|
|
+ style={{ padding: 0 }}
|
|
|
+ isPermission={permission.update}
|
|
|
+ tooltip={{
|
|
|
+ title: '编辑',
|
|
|
+ }}
|
|
|
onClick={() => {
|
|
|
- CurdModel.update(record);
|
|
|
- CurdModel.model = 'edit';
|
|
|
+ const url = `${getMenuPathByParams(MENUS_CODE['link/Certificate/Detail'], record.id)}`;
|
|
|
+ history.push(url);
|
|
|
}}
|
|
|
>
|
|
|
- <Tooltip
|
|
|
- title={intl.formatMessage({
|
|
|
- id: 'pages.data.option.edit',
|
|
|
- defaultMessage: '编辑',
|
|
|
- })}
|
|
|
- >
|
|
|
- <EditOutlined />
|
|
|
- </Tooltip>
|
|
|
- </a>,
|
|
|
- <a key="delete">
|
|
|
- <Popconfirm
|
|
|
- title={intl.formatMessage({
|
|
|
- id: 'pages.data.option.remove.tips',
|
|
|
- defaultMessage: '确认删除?',
|
|
|
- })}
|
|
|
- onConfirm={async () => {
|
|
|
+ <EditOutlined />
|
|
|
+ </PermissionButton>,
|
|
|
+ <PermissionButton
|
|
|
+ key={'delete'}
|
|
|
+ type={'link'}
|
|
|
+ style={{ padding: 0 }}
|
|
|
+ isPermission={permission.delete}
|
|
|
+ popConfirm={{
|
|
|
+ title: '确认删除?',
|
|
|
+ onConfirm: async () => {
|
|
|
await service.remove(record.id);
|
|
|
message.success(
|
|
|
intl.formatMessage({
|
|
|
@@ -82,117 +73,54 @@ const Certificate = () => {
|
|
|
}),
|
|
|
);
|
|
|
actionRef.current?.reload();
|
|
|
- }}
|
|
|
- >
|
|
|
- <Tooltip
|
|
|
- title={intl.formatMessage({
|
|
|
- id: 'pages.data.option.remove',
|
|
|
- defaultMessage: '删除',
|
|
|
- })}
|
|
|
- >
|
|
|
- <MinusOutlined />
|
|
|
- </Tooltip>
|
|
|
- </Popconfirm>
|
|
|
- </a>,
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ tooltip={{
|
|
|
+ title: '删除',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <DeleteOutlined />
|
|
|
+ </PermissionButton>,
|
|
|
],
|
|
|
},
|
|
|
];
|
|
|
|
|
|
- const schema: ISchema = {
|
|
|
- type: 'object',
|
|
|
- properties: {
|
|
|
- name: {
|
|
|
- title: '名称',
|
|
|
- 'x-component': 'Input',
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- },
|
|
|
- instance: {
|
|
|
- title: '类型',
|
|
|
- 'x-component': 'Select',
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- default: 'PEM',
|
|
|
- enum: [
|
|
|
- { label: 'PFX', value: 'PFX' },
|
|
|
- { label: 'JKS', value: 'JKS' },
|
|
|
- { label: 'PEM', value: 'PEM' },
|
|
|
- ],
|
|
|
- },
|
|
|
- configs: {
|
|
|
- type: 'object',
|
|
|
- properties: {
|
|
|
- '{url:keystoreBase64}': {
|
|
|
- title: '密钥库',
|
|
|
- 'x-component': 'FUpload',
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- 'x-component-props': {
|
|
|
- type: 'file',
|
|
|
- },
|
|
|
- },
|
|
|
- keystorePwd: {
|
|
|
- title: '密钥库密码',
|
|
|
- 'x-component': 'Password',
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- 'x-visible': false,
|
|
|
- 'x-component-props': {
|
|
|
- style: {
|
|
|
- width: '100%',
|
|
|
- },
|
|
|
- },
|
|
|
- 'x-reactions': {
|
|
|
- dependencies: ['..instance'],
|
|
|
- fulfill: {
|
|
|
- state: {
|
|
|
- visible: '{{["JKS","PFX"].includes($deps[0])}}',
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- '{url:trustKeyStoreBase64}': {
|
|
|
- title: '信任库',
|
|
|
- 'x-component': 'FUpload',
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- 'x-component-props': {
|
|
|
- style: {
|
|
|
- width: '100px',
|
|
|
- },
|
|
|
- type: 'file',
|
|
|
- },
|
|
|
- },
|
|
|
- trustKeyStorePwd: {
|
|
|
- title: '信任库密码',
|
|
|
- 'x-visible': false,
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- 'x-component': 'Password',
|
|
|
- 'x-reactions': {
|
|
|
- dependencies: ['..instance'],
|
|
|
- fulfill: {
|
|
|
- state: {
|
|
|
- visible: '{{["JKS","PFX"].includes($deps[0])}}',
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- description: {
|
|
|
- title: '说明',
|
|
|
- 'x-component': 'Input.TextArea',
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
-
|
|
|
return (
|
|
|
<PageContainer>
|
|
|
- <BaseCrud
|
|
|
- columns={columns}
|
|
|
- service={service}
|
|
|
- title={intl.formatMessage({
|
|
|
- id: 'pages.link.certificate',
|
|
|
- defaultMessage: '证书管理',
|
|
|
- })}
|
|
|
- schema={schema}
|
|
|
+ <SearchComponent<CertificateItem>
|
|
|
+ field={columns}
|
|
|
+ target="certificate"
|
|
|
+ onSearch={(data) => {
|
|
|
+ // 重置分页数据
|
|
|
+ actionRef.current?.reset?.();
|
|
|
+ setParam(data);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <ProTable<CertificateItem>
|
|
|
actionRef={actionRef}
|
|
|
+ params={param}
|
|
|
+ columns={columns}
|
|
|
+ search={false}
|
|
|
+ headerTitle={
|
|
|
+ <PermissionButton
|
|
|
+ onClick={() => {
|
|
|
+ const url = `${getMenuPathByParams(MENUS_CODE['link/Certificate/Detail'])}`;
|
|
|
+ history.push(url);
|
|
|
+ }}
|
|
|
+ isPermission={permission.add}
|
|
|
+ key="button"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
+ {intl.formatMessage({
|
|
|
+ id: 'pages.data.option.add',
|
|
|
+ defaultMessage: '新增',
|
|
|
+ })}
|
|
|
+ </PermissionButton>
|
|
|
+ }
|
|
|
+ request={async (params) =>
|
|
|
+ service.query({ ...params, sorts: [{ name: 'createTime', order: 'desc' }] })
|
|
|
+ }
|
|
|
/>
|
|
|
</PageContainer>
|
|
|
);
|