@@ -226,6 +226,23 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
226226 ) ;
227227 } ,
228228 } ,
229+ {
230+ title : i18n ( 'editTable.label.primaryKey' ) ,
231+ dataIndex : 'primaryKey' ,
232+ width : '50px' ,
233+ render : ( primaryKey : boolean , record : IColumnItemNew ) => {
234+ return (
235+ < div >
236+ < div className = { styles . keyBox } onClick = { ( ) => { handelPrimaryKey ( record ) } } >
237+ {
238+ primaryKey &&
239+ < Iconfont code = "" />
240+ }
241+ </ div >
242+ </ div >
243+ ) ;
244+ } ,
245+ } ,
229246 {
230247 title : i18n ( 'editTable.label.comment' ) ,
231248 dataIndex : 'comment' ,
@@ -263,6 +280,26 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
263280 } ,
264281 ] ;
265282
283+ const handelPrimaryKey = ( _data : IColumnItemNew ) => {
284+ const newData = dataSource . map ( ( item ) => {
285+ if ( item . key === _data ?. key ) {
286+ // 判断当前数据是新增的数据还是编辑后的数据
287+ let editStatus = item . editStatus ;
288+ if ( editStatus !== EditColumnOperationType . Add ) {
289+ editStatus = EditColumnOperationType . Modify ;
290+ }
291+ const editingDataItem = {
292+ ...item ,
293+ primaryKey : ! item . primaryKey ,
294+ editStatus,
295+ } ;
296+ return editingDataItem ;
297+ }
298+ return item ;
299+ } ) ;
300+ setDataSource ( newData ) ;
301+ }
302+
266303 const onDragEnd = ( { active, over } : DragEndEvent ) => {
267304 if ( active . id !== over ?. id ) {
268305 setDataSource ( ( previous ) => {
0 commit comments