1- import intl from 'react-intl-universal' ;
2- import React , {
3- useCallback ,
4- useRef ,
5- useState ,
6- useEffect ,
7- useMemo ,
8- } from 'react' ;
1+ import useTableScrollHeight from '@/hooks/useTableScrollHeight' ;
2+ import { SharedContext } from '@/layouts' ;
3+ import config from '@/utils/config' ;
4+ import { request } from '@/utils/http' ;
5+ import { exportJson } from '@/utils/index' ;
6+ import {
7+ CheckCircleOutlined ,
8+ DeleteOutlined ,
9+ EditOutlined ,
10+ PushpinFilled ,
11+ PushpinOutlined ,
12+ StopOutlined ,
13+ UploadOutlined ,
14+ } from '@ant-design/icons' ;
15+ import { PageContainer } from '@ant-design/pro-layout' ;
16+ import { useOutletContext } from '@umijs/max' ;
917import {
1018 Button ,
11- message ,
19+ Input ,
1220 Modal ,
21+ Space ,
1322 Table ,
1423 Tag ,
15- Space ,
16- Typography ,
1724 Tooltip ,
18- Input ,
19- UploadProps ,
25+ Typography ,
2026 Upload ,
27+ UploadProps ,
28+ message ,
2129} from 'antd' ;
22- import {
23- EditOutlined ,
24- DeleteOutlined ,
25- SyncOutlined ,
26- CheckCircleOutlined ,
27- StopOutlined ,
28- UploadOutlined ,
29- } from '@ant-design/icons' ;
30- import config from '@/utils/config' ;
31- import { PageContainer } from '@ant-design/pro-layout' ;
32- import { request } from '@/utils/http' ;
33- import EnvModal from './modal' ;
34- import EditNameModal from './editNameModal' ;
30+ import dayjs from 'dayjs' ;
31+ import React , { useCallback , useEffect , useRef , useState } from 'react' ;
3532import { DndProvider , useDrag , useDrop } from 'react-dnd' ;
3633import { HTML5Backend } from 'react-dnd-html5-backend' ;
37- import './index.less' ;
38- import { exportJson } from '@/utils/index' ;
39- import { useOutletContext } from '@umijs/max' ;
40- import { SharedContext } from '@/layouts' ;
41- import useTableScrollHeight from '@/hooks/useTableScrollHeight' ;
42- import Copy from '../../components/copy' ;
34+ import intl from 'react-intl-universal' ;
4335import { useVT } from 'virtualizedtableforantd4' ;
44- import dayjs from 'dayjs' ;
36+ import Copy from '../../components/copy' ;
37+ import EditNameModal from './editNameModal' ;
38+ import './index.less' ;
39+ import EnvModal from './modal' ;
4540
4641const { Paragraph } = Typography ;
4742const { Search } = Input ;
@@ -59,11 +54,15 @@ enum StatusColor {
5954enum OperationName {
6055 '启用' ,
6156 '禁用' ,
57+ '置顶' ,
58+ '取消置顶' ,
6259}
6360
6461enum OperationPath {
6562 'enable' ,
6663 'disable' ,
64+ 'pin' ,
65+ 'unpin' ,
6766}
6867
6968const type = 'DragableBodyRow' ;
@@ -181,7 +180,7 @@ const Env = () => {
181180 {
182181 title : intl . get ( '操作' ) ,
183182 key : 'action' ,
184- width : 120 ,
183+ width : 160 ,
185184 render : ( text : string , record : any , index : number ) => {
186185 const isPc = ! isPhone ;
187186 return (
@@ -208,6 +207,23 @@ const Env = () => {
208207 ) }
209208 </ a >
210209 </ Tooltip >
210+ < Tooltip
211+ title = {
212+ isPc
213+ ? record . isPinned === 1
214+ ? intl . get ( '取消置顶' )
215+ : intl . get ( '置顶' )
216+ : ''
217+ }
218+ >
219+ < a onClick = { ( ) => pinOrUnpinEnv ( record , index ) } >
220+ { record . isPinned === 1 ? (
221+ < PushpinFilled />
222+ ) : (
223+ < PushpinOutlined />
224+ ) }
225+ </ a >
226+ </ Tooltip >
211227 < Tooltip title = { isPc ? intl . get ( '删除' ) : '' } >
212228 < a onClick = { ( ) => deleteEnv ( record , index ) } >
213229 < DeleteOutlined />
@@ -305,6 +321,51 @@ const Env = () => {
305321 setIsModalVisible ( true ) ;
306322 } ;
307323
324+ const pinOrUnpinEnv = ( record : any , index : number ) => {
325+ Modal . confirm ( {
326+ title : `确认${
327+ record . isPinned === 1 ? intl . get ( '取消置顶' ) : intl . get ( '置顶' )
328+ } `,
329+ content : (
330+ < >
331+ { intl . get ( '确认' ) }
332+ { record . isPinned === 1 ? intl . get ( '取消置顶' ) : intl . get ( '置顶' ) }
333+ Env{ ' ' }
334+ < Paragraph
335+ style = { { wordBreak : 'break-all' , display : 'inline' } }
336+ ellipsis = { { rows : 6 , expandable : true } }
337+ type = "warning"
338+ copyable
339+ >
340+ { record . name } : { record . value }
341+ </ Paragraph > { ' ' }
342+ { intl . get ( '吗' ) }
343+ </ >
344+ ) ,
345+ onOk ( ) {
346+ request
347+ . put (
348+ `${ config . apiPrefix } envs/${
349+ record . isPinned === 1 ? 'unpin' : 'pin'
350+ } `,
351+ [ record . id ] ,
352+ )
353+ . then ( ( { code, data } ) => {
354+ if ( code === 200 ) {
355+ message . success (
356+ `${
357+ record . isPinned === 1
358+ ? intl . get ( '取消置顶' )
359+ : intl . get ( '置顶' )
360+ } ${ intl . get ( '成功' ) } `,
361+ ) ;
362+ getEnvs ( ) ;
363+ }
364+ } ) ;
365+ } ,
366+ } ) ;
367+ } ;
368+
308369 const deleteEnv = ( record : any , index : number ) => {
309370 Modal . confirm ( {
310371 title : intl . get ( '确认删除' ) ,
@@ -589,6 +650,20 @@ const Env = () => {
589650 >
590651 { intl . get ( '批量禁用' ) }
591652 </ Button >
653+ < Button
654+ type = "primary"
655+ onClick = { ( ) => operateEnvs ( 2 ) }
656+ style = { { marginLeft : 8 , marginBottom : 5 } }
657+ >
658+ { intl . get ( '批量置顶' ) }
659+ </ Button >
660+ < Button
661+ type = "primary"
662+ onClick = { ( ) => operateEnvs ( 3 ) }
663+ style = { { marginLeft : 8 , marginRight : 8 } }
664+ >
665+ { intl . get ( '批量取消置顶' ) }
666+ </ Button >
592667 < span style = { { marginLeft : 8 } } >
593668 { intl . get ( '已选择' ) }
594669 < a > { selectedRowIds ?. length } </ a >
0 commit comments