11const ExportJsonExcel = require ( "js-export-excel" ) ;
22import React , { useEffect , useState } from "react" ;
3+ import moment from "moment" ;
34import { Link } from "react-router-dom" ;
4- import { Row , Table , Button , message , Form , Input } from "antd" ;
5+ import {
6+ Row , Table , Button , message ,
7+ Form , Input , Space , Breadcrumb ,
8+ DatePicker
9+ } from "antd" ;
510import { EllipsisOutlined } from "@ant-design/icons" ;
611
7- export { default as Affix } from ' antd/es/affix' ;
8- export { default as Anchor } from ' antd/es/anchor' ;
9- export { default as AutoComplete } from ' antd/es/auto-complete' ;
10- export { default as Alert } from ' antd/es/alert' ;
11- export { default as Avatar } from ' antd/es/avatar' ;
12- export { default as BackTop } from ' antd/es/back-top' ;
13- export { default as Badge } from ' antd/es/badge' ;
14- export { default as Breadcrumb } from ' antd/es/breadcrumb' ;
15- export { default as Button } from ' antd/es/button' ;
16- export { default as Calendar } from ' antd/es/calendar' ;
17- export { default as Card } from ' antd/es/card' ;
18- export { default as Collapse } from ' antd/es/collapse' ;
19- export { default as Carousel } from ' antd/es/carousel' ;
20- export { default as Cascader } from ' antd/es/cascader' ;
21- export { default as Checkbox } from ' antd/es/checkbox' ;
22- export { default as Col } from ' antd/es/col' ;
23- export { default as Comment } from ' antd/es/comment' ;
24- export { default as ConfigProvider } from ' antd/es/config-provider' ;
25- export { default as DatePicker } from ' antd/es/date-picker' ;
26- export { default as Descriptions } from ' antd/es/descriptions' ;
27- export { default as Divider } from ' antd/es/divider' ;
28- export { default as Dropdown } from ' antd/es/dropdown' ;
29- export { default as Drawer } from ' antd/es/drawer' ;
30- export { default as Empty } from ' antd/es/empty' ;
31- export { default as Form } from ' antd/es/form' ;
32- export { default as Grid } from ' antd/es/grid' ;
33- export { default as Input } from ' antd/es/input' ;
34- export { default as InputNumber } from ' antd/es/input-number' ;
35- export { default as Layout } from ' antd/es/layout' ;
36- export { default as List } from ' antd/es/list' ;
37- export { default as message } from ' antd/es/message' ;
38- export { default as Menu } from ' antd/es/menu' ;
39- export { default as Mentions } from ' antd/es/mentions' ;
40- export { default as Modal } from ' antd/es/modal' ;
41- export { default as Statistic } from ' antd/es/statistic' ;
42- export { default as notification } from ' antd/es/notification' ;
43- export { default as PageHeader } from ' antd/es/page-header' ;
44- export { default as Pagination } from ' antd/es/pagination' ;
45- export { default as Popconfirm } from ' antd/es/popconfirm' ;
46- export { default as Popover } from ' antd/es/popover' ;
47- export { default as Progress } from ' antd/es/progress' ;
48- export { default as Radio } from ' antd/es/radio' ;
49- export { default as Rate } from ' antd/es/rate' ;
50- export { default as Result } from ' antd/es/result' ;
51- export { default as Row } from ' antd/es/row' ;
52- export { default as Select } from ' antd/es/select' ;
53- export { default as Skeleton } from ' antd/es/skeleton' ;
54- export { default as Slider } from ' antd/es/slider' ;
55- export { default as Space } from ' antd/es/space' ;
56- export { default as Spin } from ' antd/es/spin' ;
57- export { default as Steps } from ' antd/es/steps' ;
58- export { default as Switch } from ' antd/es/switch' ;
59- export { default as Table } from ' antd/es/table' ;
60- export { default as Transfer } from ' antd/es/transfer' ;
61- export { default as Tree } from ' antd/es/tree' ;
62- export { default as TreeSelect } from ' antd/es/tree-select' ;
63- export { default as Tabs } from ' antd/es/tabs' ;
64- export { default as Tag } from ' antd/es/tag' ;
65- export { default as TimePicker } from ' antd/es/time-picker' ;
66- export { default as Timeline } from ' antd/es/timeline' ;
67- export { default as Tooltip } from ' antd/es/tooltip' ;
68- export { default as Typography } from ' antd/es/typography' ;
69- export { default as Upload } from ' antd/es/upload' ;
70- export { default as version } from ' antd/es/version' ;
12+ export { default as Affix } from " antd/es/affix" ;
13+ export { default as Anchor } from " antd/es/anchor" ;
14+ export { default as AutoComplete } from " antd/es/auto-complete" ;
15+ export { default as Alert } from " antd/es/alert" ;
16+ export { default as Avatar } from " antd/es/avatar" ;
17+ export { default as BackTop } from " antd/es/back-top" ;
18+ export { default as Badge } from " antd/es/badge" ;
19+ export { default as Breadcrumb } from " antd/es/breadcrumb" ;
20+ export { default as Button } from " antd/es/button" ;
21+ export { default as Calendar } from " antd/es/calendar" ;
22+ export { default as Card } from " antd/es/card" ;
23+ export { default as Collapse } from " antd/es/collapse" ;
24+ export { default as Carousel } from " antd/es/carousel" ;
25+ export { default as Cascader } from " antd/es/cascader" ;
26+ export { default as Checkbox } from " antd/es/checkbox" ;
27+ export { default as Col } from " antd/es/col" ;
28+ export { default as Comment } from " antd/es/comment" ;
29+ export { default as ConfigProvider } from " antd/es/config-provider" ;
30+ export { default as DatePicker } from " antd/es/date-picker" ;
31+ export { default as Descriptions } from " antd/es/descriptions" ;
32+ export { default as Divider } from " antd/es/divider" ;
33+ export { default as Dropdown } from " antd/es/dropdown" ;
34+ export { default as Drawer } from " antd/es/drawer" ;
35+ export { default as Empty } from " antd/es/empty" ;
36+ export { default as Form } from " antd/es/form" ;
37+ export { default as Grid } from " antd/es/grid" ;
38+ export { default as Input } from " antd/es/input" ;
39+ export { default as InputNumber } from " antd/es/input-number" ;
40+ export { default as Layout } from " antd/es/layout" ;
41+ export { default as List } from " antd/es/list" ;
42+ export { default as message } from " antd/es/message" ;
43+ export { default as Menu } from " antd/es/menu" ;
44+ export { default as Mentions } from " antd/es/mentions" ;
45+ export { default as Modal } from " antd/es/modal" ;
46+ export { default as Statistic } from " antd/es/statistic" ;
47+ export { default as notification } from " antd/es/notification" ;
48+ export { default as PageHeader } from " antd/es/page-header" ;
49+ export { default as Pagination } from " antd/es/pagination" ;
50+ export { default as Popconfirm } from " antd/es/popconfirm" ;
51+ export { default as Popover } from " antd/es/popover" ;
52+ export { default as Progress } from " antd/es/progress" ;
53+ export { default as Radio } from " antd/es/radio" ;
54+ export { default as Rate } from " antd/es/rate" ;
55+ export { default as Result } from " antd/es/result" ;
56+ export { default as Row } from " antd/es/row" ;
57+ export { default as Select } from " antd/es/select" ;
58+ export { default as Skeleton } from " antd/es/skeleton" ;
59+ export { default as Slider } from " antd/es/slider" ;
60+ export { default as Space } from " antd/es/space" ;
61+ export { default as Spin } from " antd/es/spin" ;
62+ export { default as Steps } from " antd/es/steps" ;
63+ export { default as Switch } from " antd/es/switch" ;
64+ export { default as Table } from " antd/es/table" ;
65+ export { default as Transfer } from " antd/es/transfer" ;
66+ export { default as Tree } from " antd/es/tree" ;
67+ export { default as TreeSelect } from " antd/es/tree-select" ;
68+ export { default as Tabs } from " antd/es/tabs" ;
69+ export { default as Tag } from " antd/es/tag" ;
70+ export { default as TimePicker } from " antd/es/time-picker" ;
71+ export { default as Timeline } from " antd/es/timeline" ;
72+ export { default as Tooltip } from " antd/es/tooltip" ;
73+ export { default as Typography } from " antd/es/typography" ;
74+ export { default as Upload } from " antd/es/upload" ;
75+ export { default as version } from " antd/es/version" ;
7176
7277import { ImageBoxStyle } from "@/styles" ;
7378
@@ -82,7 +87,7 @@ import {ImageBoxStyle} from "@/styles";
8287 可编辑表格
8388 */
8489export function EditTable ( props ) {
85- let { columns, data, editURL, tableTitle, loading} = props ;
90+ let { columns, data, editURL, tableTitle, loading, onAdd } = props ;
8691
8792 const [ selectedRowKeys , setSelectedRowKeys ] = useState ( [ ] ) ;
8893
@@ -94,13 +99,13 @@ export function EditTable(props) {
9499 if ( index % 2 !== 0 ) {
95100 return "odd" ;
96101 } else {
97- return "" ;
102+ return "even " ;
98103 }
99104 } ;
100105
101106 const exportExcel = ( ) => {
102107 if ( ! data || data . length === 0 ) {
103- message . info ( ' 没有可导出的数据' ) ;
108+ message . info ( " 没有可导出的数据" ) ;
104109 return ;
105110 }
106111
@@ -119,7 +124,7 @@ export function EditTable(props) {
119124 let finalData = [ ] ;
120125
121126 columns . forEach ( c => {
122- header [ c [ "dataIndex" ] ] = c [ "title" ]
127+ header [ c [ "dataIndex" ] ] = c [ "title" ] ;
123128 keys . push ( c [ "dataIndex" ] ) ;
124129 } ) ;
125130
@@ -149,9 +154,10 @@ export function EditTable(props) {
149154 return (
150155 < div className = { "clearfix export-table-title" } >
151156 < p > { tableTitle || "" } </ p >
152- < p >
157+ < Space direction = { "horizontal" } >
158+ < Button type = { "primary" } onClick = { ( ) => ( onAdd && onAdd ( ) ) } > 新增</ Button >
153159 < Button type = { "primary" } onClick = { exportExcel } > 导出</ Button >
154- </ p >
160+ </ Space >
155161 </ div >
156162 ) ;
157163 } ;
@@ -176,13 +182,18 @@ export function EditTable(props) {
176182 } ,
177183 ...columns ,
178184 {
179- key : ' edit' ,
185+ key : " edit" ,
180186 dataIndex : "edit" ,
181- title : '编辑' ,
187+ title : "编辑" ,
182188 render : ( text , record ) => (
183- < Link to = { `${ editURL } ${ record [ "key" ] } ` } target = { "_blank" } >
184- < Button type = { "primary" } > 编辑</ Button >
185- </ Link >
189+ < Space >
190+ < Link to = { `${ editURL } edit/${ record [ "key" ] } ` } target = { "_blank" } >
191+ < Button type = { "link" } size = { "small" } > 编辑</ Button >
192+ </ Link >
193+ < Link to = { `${ editURL } view/${ record [ "key" ] } ` } target = { "_blank" } >
194+ < Button type = { "link" } size = { "small" } > 查看</ Button >
195+ </ Link >
196+ </ Space >
186197 ) ,
187198 }
188199 ] . map ( v => {
@@ -191,10 +202,10 @@ export function EditTable(props) {
191202 }
192203 return {
193204 ...v ,
194- sortDirections : [ ' descend' , ' ascend' ] ,
205+ sortDirections : [ " descend" , " ascend" ] ,
195206 sorter : ( a , b ) => {
196- let stringA = a [ v . dataIndex ] . toUpperCase ( ) ;
197- let stringB = b [ v . dataIndex ] . toUpperCase ( ) ;
207+ let stringA = a [ v . dataIndex ] ;
208+ let stringB = b [ v . dataIndex ] ;
198209 if ( stringA < stringB ) {
199210 return - 1 ;
200211 }
@@ -203,7 +214,7 @@ export function EditTable(props) {
203214 }
204215 return 0 ;
205216 } ,
206- }
217+ } ;
207218 } ) ;
208219 // endregion
209220
@@ -225,11 +236,11 @@ export function EditTable(props) {
225236 < Table . Summary . Cell key = { c [ "key" ] } > {
226237 getTotal ( currentData , c [ "dataIndex" ] )
227238 } </ Table . Summary . Cell >
228- )
239+ ) ;
229240 } else {
230241 return (
231242 < Table . Summary . Cell key = { c [ "key" ] } />
232- )
243+ ) ;
233244 }
234245 } )
235246 ) }
@@ -241,7 +252,7 @@ export function EditTable(props) {
241252 < div style = { { width : "100%" , overflow : "hidden" , marginTop : 15 } } >
242253 < Table className = { "advanced-table" } dataSource = { data } columns = { mergedColumns }
243254 rowClassName = { rowClassName } title = { title } pagination = { false }
244- rowSelection = { rowSelection } scroll = { { x : ' max-content' } } bordered = { true }
255+ rowSelection = { rowSelection } scroll = { { x : " max-content" } } bordered = { true }
245256 tableLayout = { "auto" } loading = { loading } summary = { summary }
246257 />
247258 </ div >
@@ -256,13 +267,13 @@ export function ImageWrap(props) {
256267
257268 const onClick = ( ) => {
258269 trigger && trigger ( href ) ;
259- }
270+ } ;
260271
261272 return (
262273 < ImageBoxStyle onClick = { onClick } >
263274 < img src = { src } alt = "图片" />
264275 </ ImageBoxStyle >
265- )
276+ ) ;
266277}
267278
268279/*
@@ -281,7 +292,7 @@ export function InputButton(props) {
281292 value = { value }
282293 onChange = { ( { target : { value} } ) => ( onChange ( field , value ) ) }
283294 />
284- )
295+ ) ;
285296}
286297
287298/*
@@ -291,10 +302,57 @@ export function Container(props) {
291302 let { children} = props ;
292303
293304 return (
294- < Form colon = { false } labelCol = { { span : 5 } } >
305+ < Form colon = { false } className = { "g-from" } >
295306 < Row gutter = { [ 15 , 0 ] } className = { "container-panel" } >
296307 { children }
297308 </ Row >
298309 </ Form >
299310 ) ;
300311}
312+
313+ /*
314+ 面包屑导航标题
315+ */
316+ export function NavPath ( props ) {
317+ let { paths} = props ;
318+ paths = paths || [ ] ;
319+
320+ return (
321+ < Breadcrumb separator = ">" style = { { padding : "15px 0" } } >
322+ { paths . map ( v => {
323+ return (
324+ < Breadcrumb . Item key = { v } > { v } </ Breadcrumb . Item >
325+ ) ;
326+ } ) }
327+ </ Breadcrumb >
328+ ) ;
329+ }
330+
331+ export function DateStrPicker ( props ) {
332+ let { onChange, value, name} = props ;
333+
334+ const changeVal = ( val , strVal ) => {
335+ onChange ( name , strVal ) ;
336+ } ;
337+
338+ return (
339+ < DatePicker style = { { width : "100%" } } value = { moment ( value ) } onChange = { changeVal } />
340+ ) ;
341+ }
342+
343+ export function DateStrRange ( props ) {
344+ let { onChange, value, name} = props ;
345+
346+ let [ n1 , n2 ] = name . split ( "," ) ;
347+ let [ d1 , d2 ] = value ;
348+
349+ const changeVal = ( momentVal , strVal ) => {
350+ onChange ( n1 , strVal [ 0 ] ) ;
351+ onChange ( n2 , strVal [ 1 ] ) ;
352+ } ;
353+
354+ return (
355+ < DatePicker . RangePicker value = { [ moment ( d1 ) , moment ( d2 ) ] } style = { { width : "100%" } }
356+ onChange = { changeVal } />
357+ ) ;
358+ }
0 commit comments