Browse Source

💥 feat: add pro-descriptions demos (#7200)

* 💥 feat: add pro-descriptions demos

* add version

* better yaml
pull/7207/head v4.2.1
陈帅 6 years ago
committed by GitHub
parent
commit
deb118a407
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .github/workflows/deploy.yml
  2. 16
      package.json
  3. 34
      src/pages/ListTableList/index.tsx

6
.github/workflows/deploy.yml

@ -1,11 +1,13 @@
name: Deploy CI name: Deploy CI
on: [push] on:
push:
branches:
- master
jobs: jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@master uses: actions/checkout@master

16
package.json

@ -1,13 +1,13 @@
{ {
"name": "ant-design-pro", "name": "ant-design-pro",
"version": "4.2.0", "version": "4.2.1",
"private": true, "private": true,
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"scripts": { "scripts": {
"postinstall": "umi g tmp",
"analyze": "cross-env ANALYZE=1 umi build", "analyze": "cross-env ANALYZE=1 umi build",
"build": "umi build", "build": "umi build",
"deploy": "npm run site && npm run gh-pages", "deploy": "npm run site && npm run gh-pages",
"dev": "npm run start:dev",
"docker-hub:build": "docker build -f Dockerfile.hub -t ant-design-pro ./", "docker-hub:build": "docker build -f Dockerfile.hub -t ant-design-pro ./",
"docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build", "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build",
"docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up", "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up",
@ -18,17 +18,17 @@
"fetch:blocks": "pro fetch-blocks && npm run prettier", "fetch:blocks": "pro fetch-blocks && npm run prettier",
"gh-pages": "gh-pages -d dist", "gh-pages": "gh-pages -d dist",
"i18n-remove": "pro i18n-remove --locale=zh-CN --write", "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
"postinstall": "umi g tmp",
"lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier", "lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
"precommit": "lint-staged",
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
"lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
"lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
"precommit": "lint-staged",
"prettier": "prettier -c --write \"**/*\"", "prettier": "prettier -c --write \"**/*\"",
"site": "npm run fetch:blocks && npm run build", "site": "npm run fetch:blocks && npm run build",
"start": "umi dev", "start": "umi dev",
"dev": "npm run start:dev",
"start:dev": "cross-env REACT_APP_ENV=dev MOCK=none umi dev", "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none umi dev",
"start:no-mock": "cross-env MOCK=none umi dev", "start:no-mock": "cross-env MOCK=none umi dev",
"start:no-ui": "cross-env UMI_UI=none umi dev", "start:no-ui": "cross-env UMI_UI=none umi dev",
@ -38,7 +38,7 @@
"test": "umi test", "test": "umi test",
"test:all": "node ./tests/run-tests.js", "test:all": "node ./tests/run-tests.js",
"test:component": "umi test ./src/components", "test:component": "umi test ./src/components",
"tsc": "tsc" "tsc": "tsc --noEmit"
}, },
"lint-staged": { "lint-staged": {
"**/*.less": "stylelint --syntax less", "**/*.less": "stylelint --syntax less",
@ -54,6 +54,7 @@
], ],
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.0.0", "@ant-design/icons": "^4.0.0",
"@ant-design/pro-descriptions": "^1.0.4",
"@ant-design/pro-layout": "^6.4.1", "@ant-design/pro-layout": "^6.4.1",
"@ant-design/pro-table": "^2.5.3", "@ant-design/pro-table": "^2.5.3",
"antd": "^4.5.3", "antd": "^4.5.3",
@ -102,7 +103,8 @@
"prettier": "^2.0.1", "prettier": "^2.0.1",
"pro-download": "1.0.1", "pro-download": "1.0.1",
"puppeteer-core": "^5.0.0", "puppeteer-core": "^5.0.0",
"stylelint": "^13.0.0" "stylelint": "^13.0.0",
"typescript": "^3.9.7"
}, },
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"

34
src/pages/ListTableList/index.tsx

@ -1,9 +1,9 @@
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { Button, Divider, message, Input } from 'antd'; import { Button, Divider, message, Input, Drawer } from 'antd';
import React, { useState, useRef } from 'react'; import React, { useState, useRef } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'; import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
import ProDescriptions from '@ant-design/pro-descriptions';
import CreateForm from './components/CreateForm'; import CreateForm from './components/CreateForm';
import UpdateForm, { FormValueType } from './components/UpdateForm'; import UpdateForm, { FormValueType } from './components/UpdateForm';
import { TableListItem } from './data.d'; import { TableListItem } from './data.d';
@ -76,6 +76,7 @@ const TableList: React.FC<{}> = () => {
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false); const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [stepFormValues, setStepFormValues] = useState({}); const [stepFormValues, setStepFormValues] = useState({});
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const [row, setRow] = useState<TableListItem>();
const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]); const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
const columns: ProColumns<TableListItem>[] = [ const columns: ProColumns<TableListItem>[] = [
{ {
@ -88,6 +89,9 @@ const TableList: React.FC<{}> = () => {
message: '规则名称为必填项', message: '规则名称为必填项',
}, },
], ],
render: (dom, entity) => {
return <a onClick={() => setRow(entity)}>{dom}</a>;
},
}, },
{ {
title: '描述', title: '描述',
@ -182,7 +186,7 @@ const TableList: React.FC<{}> = () => {
onClick={async () => { onClick={async () => {
await handleRemove(selectedRowsState); await handleRemove(selectedRowsState);
setSelectedRows([]); setSelectedRows([]);
actionRef.current?.reloadAndRest(); actionRef.current?.reloadAndRest?.();
}} }}
> >
@ -204,7 +208,6 @@ const TableList: React.FC<{}> = () => {
rowKey="key" rowKey="key"
type="form" type="form"
columns={columns} columns={columns}
rowSelection={{}}
/> />
</CreateForm> </CreateForm>
{stepFormValues && Object.keys(stepFormValues).length ? ( {stepFormValues && Object.keys(stepFormValues).length ? (
@ -227,6 +230,29 @@ const TableList: React.FC<{}> = () => {
values={stepFormValues} values={stepFormValues}
/> />
) : null} ) : null}
<Drawer
width={600}
visible={!!row}
onClose={() => {
setRow(undefined);
}}
closable={false}
>
{row?.name && (
<ProDescriptions<TableListItem>
column={2}
title={row?.name}
request={async () => ({
data: row || {},
})}
params={{
id: row?.name,
}}
columns={columns}
/>
)}
</Drawer>
</PageContainer> </PageContainer>
); );
}; };

Loading…
Cancel
Save