villianjs-pro 1.0.34 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProTable/components/form-content-container.d.ts +10 -0
- package/dist/ProTable/components/form-content-container.js +1 -0
- package/dist/ProTable/components/grid-card.d.ts +1 -1
- package/dist/ProTable/components/grid-card.js +1 -1
- package/dist/ProTable/components/grid-view.d.ts +1 -1
- package/dist/ProTable/components/grid-view.js +1 -1
- package/dist/ProTable/components/headerTitle.d.ts +4 -0
- package/dist/ProTable/components/headerTitle.js +1 -0
- package/dist/ProTable/components/list-container.d.ts +3 -0
- package/dist/ProTable/components/list-container.js +1 -0
- package/dist/ProTable/components/list.d.ts +3 -0
- package/dist/ProTable/components/list.js +1 -0
- package/dist/ProTable/components/operation-form-wrapper.d.ts +7 -0
- package/dist/ProTable/components/operation-form-wrapper.js +1 -0
- package/dist/ProTable/components/row-actions.d.ts +1 -1
- package/dist/ProTable/components/row-actions.js +1 -1
- package/dist/ProTable/components/search.d.ts +2 -2
- package/dist/ProTable/components/search.js +1 -1
- package/dist/ProTable/{utils.d.ts → components/utils.d.ts} +2 -2
- package/dist/ProTable/container.d.ts +3 -0
- package/dist/ProTable/container.js +1 -0
- package/dist/ProTable/context.d.ts +1 -20
- package/dist/ProTable/context.js +1 -1
- package/dist/ProTable/hooks/usePagination.js +1 -1
- package/dist/ProTable/index.d.ts +2 -3
- package/dist/ProTable/index.js +1 -1
- package/dist/ProTable/styles.js +1 -1
- package/dist/ProTable/table.d.ts +3 -3
- package/dist/ProTable/table.js +1 -1
- package/dist/ProTable/types.d.ts +333 -160
- package/dist/imports/components/import-detail-dialog.js +1 -1
- package/dist/imports/components/import-history-dialog.js +1 -1
- package/package.json +1 -1
- package/dist/ProTable/components/Container.d.ts +0 -27
- package/dist/ProTable/components/Container.js +0 -1
- package/dist/ProTable/components/form-content.d.ts +0 -34
- package/dist/ProTable/components/form-content.js +0 -1
- package/dist/ProTable/components/form-footer.d.ts +0 -32
- package/dist/ProTable/components/form-footer.js +0 -1
- package/dist/ProTable/components/header-buttons-wrapper.d.ts +0 -10
- package/dist/ProTable/components/header-buttons-wrapper.js +0 -1
- package/dist/ProTable/components/list/index.d.ts +0 -19
- package/dist/ProTable/components/list/index.js +0 -1
- package/dist/ProTable/components/operation-container.d.ts +0 -39
- package/dist/ProTable/components/operation-container.js +0 -1
- package/dist/ProTable/components/operation-content-router.d.ts +0 -37
- package/dist/ProTable/components/operation-content-router.js +0 -1
- package/dist/ProTable/components/operation-content.d.ts +0 -35
- package/dist/ProTable/components/operation-content.js +0 -1
- package/dist/ProTable/components/row-actions-router.d.ts +0 -8
- package/dist/ProTable/components/row-actions-router.js +0 -1
- package/dist/ProTable/hooks/useRouterNavigation.d.ts +0 -10
- package/dist/ProTable/hooks/useRouterNavigation.js +0 -1
- /package/dist/ProTable/{utils.js → components/utils.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import{useMemo,useEffect,useState,useRef,useCallback}from"react";import React from"react";import{Tag,Row,Col,Card,Alert,theme,Descriptions,Progress,Spin}from"antd";import{ProTable}from"../../ProTable";import{Modal}from"../../Modal";import{CheckCircleOutlined,CloseCircleOutlined,ExclamationCircleOutlined,LoadingOutlined}from"@ant-design/icons";import{formatDate}from"../utils/date";import{getContainerStyle,getStatCardStyle,getStatNumberStyle,getStatLabelStyle,getRowNumberStyle}from"../utils/styles";import{useLocale}from"../../locale";import{useImportContextOptional}from"../context/import-context";var useToken=theme.useToken;export var ImportDetailDialog=function(param){var open=param.open,onOpenChange=param.onOpenChange,record=param.record,errorColumns=param.errorColumns,queryImportErrors=param.queryImportErrors,errorTableProps=param.errorTableProps,contentRender=param.contentRender,propsQueryProgress=param.queryProgress,propsPollInterval=param.pollInterval;var _messages_imports_detail_processingDescription;var token=useToken().token;var messages=useLocale().messages;var context=useImportContextOptional();var queryProgress=propsQueryProgress!==null&&propsQueryProgress!==void 0?propsQueryProgress:context===null||context===void 0?void 0:context.queryProgress;var _ref;var pollInterval=(_ref=propsPollInterval!==null&&propsPollInterval!==void 0?propsPollInterval:context===null||context===void 0?void 0:context.pollInterval)!==null&&_ref!==void 0?_ref:2e3;var _useState=_sliced_to_array(useState(null),2),currentProgress=_useState[0],setCurrentProgress=_useState[1];var _useState1=_sliced_to_array(useState(record.status),2),currentStatus=_useState1[0],setCurrentStatus=_useState1[1];var _useState2=_sliced_to_array(useState(record),2),currentRecord=_useState2[0],setCurrentRecord=_useState2[1];var pollingRef=useRef(null);var isUnmountedRef=useRef(false);useEffect(function(){setCurrentRecord(record);setCurrentStatus(record.status)},[record]);var queryProgressRef=useRef(queryProgress);var recordIdRef=useRef(record.id);var currentStatusRef=useRef(currentStatus);useEffect(function(){queryProgressRef.current=queryProgress;recordIdRef.current=record.id;currentStatusRef.current=currentStatus},[queryProgress,record.id,currentStatus]);var fetchProgress=useCallback(function(){return _async_to_generator(function(){var progress,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(isUnmountedRef.current||!queryProgressRef.current||currentStatusRef.current!=="processing"){return[2]}_state.label=1;case 1:_state.trys.push([1,3,,4]);return[4,queryProgressRef.current(recordIdRef.current)];case 2:progress=_state.sent();if(isUnmountedRef.current)return[2];setCurrentProgress(progress);if(progress.status!==currentStatusRef.current){setCurrentStatus(progress.status);setCurrentRecord(function(prev){var _progress_success,_progress_failed,_progress_total;return _object_spread_props(_object_spread({},prev),{status:progress.status,success:(_progress_success=progress.success)!==null&&_progress_success!==void 0?_progress_success:prev.success,failed:(_progress_failed=progress.failed)!==null&&_progress_failed!==void 0?_progress_failed:prev.failed,total:(_progress_total=progress.total)!==null&&_progress_total!==void 0?_progress_total:prev.total})})}else{setCurrentRecord(function(prev){var _progress_success,_progress_failed,_progress_total;return _object_spread_props(_object_spread({},prev),{success:(_progress_success=progress.success)!==null&&_progress_success!==void 0?_progress_success:prev.success,failed:(_progress_failed=progress.failed)!==null&&_progress_failed!==void 0?_progress_failed:prev.failed,total:(_progress_total=progress.total)!==null&&_progress_total!==void 0?_progress_total:prev.total})})}if(progress.status==="completed"||progress.status==="failed"){if(pollingRef.current){clearInterval(pollingRef.current);pollingRef.current=null}}return[3,4];case 3:error=_state.sent();console.error("查询导入进度失败:",error);return[3,4];case 4:return[2]}})})()},[]);useEffect(function(){if(!open){if(pollingRef.current){clearInterval(pollingRef.current);pollingRef.current=null}isUnmountedRef.current=true;return}isUnmountedRef.current=false;if(currentStatus==="processing"&&queryProgress){fetchProgress();pollingRef.current=setInterval(function(){fetchProgress()},pollInterval)}return function(){if(pollingRef.current){clearInterval(pollingRef.current);pollingRef.current=null}isUnmountedRef.current=true}},[open,currentStatus,queryProgress,pollInterval,fetchProgress]);var formattedCreatedAt=useMemo(function(){if(!record.createdAt)return"";try{var date=new Date(record.createdAt);if(isNaN(date.getTime())){return record.createdAt}return formatDate(date,"YYYY-MM-DD HH:mm:ss")}catch(e){return record.createdAt}},[record.createdAt]);var containerStyle=useMemo(function(){return getContainerStyle(token)},[token]);var statCardStyle=useMemo(function(){return getStatCardStyle(token)},[token]);var statNumberStyle=useMemo(function(){return getStatNumberStyle(token)},[token]);var statLabelStyle=useMemo(function(){return getStatLabelStyle(token)},[token]);var successRate=useMemo(function(){if(currentRecord.total===0)return"0.0";return(currentRecord.success/currentRecord.total*100).toFixed(1)},[currentRecord.success,currentRecord.total]);var defaultErrorColumns=useMemo(function(){return[{title:messages.imports.detail.errorColumns.rowNumber,dataIndex:"row_number",key:"row_number",width:120,valueType:"digit",render:function(_,recordItem){return React.createElement("span",{style:getRowNumberStyle(token)},messages.imports.detail.rowNumberText.replace("{rowNumber}",String(recordItem.row_number)))}},{title:messages.imports.detail.errorColumns.errorType,dataIndex:"error_type",key:"error_type",width:160,valueType:"text"},{title:messages.imports.detail.errorColumns.errorMessage,dataIndex:"error_message",key:"error_message",valueType:"text",ellipsis:true},{title:messages.imports.detail.errorColumns.errorId,dataIndex:"id",key:"id",width:220,valueType:"text",copyable:true}]},[messages]);var finalErrorColumns=useMemo(function(){if(errorColumns&&errorColumns.length>0){return errorColumns}return defaultErrorColumns},[errorColumns,defaultErrorColumns]);var errorRequest=useMemo(function(){if(!queryImportErrors){return function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){return[2,{data:[],success:true,total:0}]})})()}}return function(params){return _async_to_generator(function(){var result,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:_state.trys.push([0,2,,3]);return[4,queryImportErrors(_object_spread({importId:currentRecord.id},params))];case 1:result=_state.sent();return[2,{data:result.list||[],success:true,total:result.total||0}];case 2:error=_state.sent();console.error(messages.imports.detail.queryFailed,error);return[2,{data:[],success:false,total:0}];case 3:return[2]}})})()}},[queryImportErrors,currentRecord.id,messages]);var progressPercent=useMemo(function(){if(currentProgress){return Math.round(currentProgress.progress||0)}if(currentRecord.total>0){return Math.round((currentRecord.success+currentRecord.failed)/currentRecord.total*100)}return 0},[currentProgress,currentRecord]);var headerNode=React.createElement(React.Fragment,null,React.createElement(Descriptions,{column:3,size:"small",labelStyle:{fontSize:token.fontSizeSM,color:token.colorTextSecondary},contentStyle:{fontSize:token.fontSizeSM,color:token.colorText}},React.createElement(Descriptions.Item,{label:messages.imports.detail.labels.importId,span:3},React.createElement("span",{style:{fontFamily:"monospace",fontWeight:token.fontWeightStrong}},currentRecord.id)),React.createElement(Descriptions.Item,{label:messages.imports.detail.labels.currentStatus,span:1},React.createElement("div",null,currentStatus==="completed"&&React.createElement(Tag,{color:"success"},messages.imports.detail.status.completed),currentStatus==="failed"&&React.createElement(Tag,{color:"error"},messages.imports.detail.status.failed),currentStatus==="processing"&&React.createElement(Tag,{color:"processing"},messages.imports.detail.status.processing),currentStatus==="cancelled"&&React.createElement(Tag,{color:"default"},messages.imports.detail.status.cancelled))),React.createElement(Descriptions.Item,{label:messages.imports.detail.labels.importTime,span:2},React.createElement("span",{style:{fontWeight:token.fontWeightStrong}},formattedCreatedAt))),currentStatus==="processing"&&React.createElement("div",{style:{padding:token.padding,background:token.colorInfoBg,borderRadius:token.borderRadius,marginBottom:token.margin,border:"1px solid ".concat(token.colorInfoBorder)}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:token.marginSM,marginBottom:token.marginSM}},React.createElement(Spin,{indicator:React.createElement(LoadingOutlined,{style:{fontSize:token.fontSizeLG,color:token.colorInfo},spin:true})}),React.createElement("div",{style:{flex:1}},React.createElement("div",{style:{fontSize:token.fontSize,fontWeight:token.fontWeightStrong,color:token.colorText,marginBottom:token.marginXXS}},messages.imports.detail.processingTitle||"正在处理导入任务..."),React.createElement("div",{style:{fontSize:token.fontSizeSM,color:token.colorTextSecondary}},((_messages_imports_detail_processingDescription=messages.imports.detail.processingDescription)===null||_messages_imports_detail_processingDescription===void 0?void 0:_messages_imports_detail_processingDescription.replace("{current}",String(currentRecord.success+currentRecord.failed)).replace("{total}",String(currentRecord.total)))||"已处理 ".concat(currentRecord.success+currentRecord.failed," / ").concat(currentRecord.total," 条数据")))),React.createElement(Progress,{percent:progressPercent,strokeColor:token.colorInfo,showInfo:true})),React.createElement(Row,{gutter:token.margin,style:{marginInline:0}},React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorBgContainer})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorText})},currentRecord.total),React.createElement("p",{style:statLabelStyle},messages.imports.detail.stats.total))),React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorSuccessBg,borderColor:token.colorSuccessBorder})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorSuccess})},currentRecord.success),React.createElement("p",{style:_object_spread_props(_object_spread({},statLabelStyle),{color:token.colorSuccessText})},messages.imports.detail.stats.success))),React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorErrorBg,borderColor:token.colorErrorBorder})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorError})},currentRecord.failed),React.createElement("p",{style:_object_spread_props(_object_spread({},statLabelStyle),{color:token.colorErrorText})},messages.imports.detail.stats.failed))),React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorInfoBg,borderColor:token.colorInfoBorder})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorInfo})},successRate,"%"),React.createElement("p",{style:_object_spread_props(_object_spread({},statLabelStyle),{color:token.colorInfoText})},messages.imports.importResult.successRate||"成功率")))));var failedTableNode=currentRecord.failed>0&&queryImportErrors&¤tStatus!=="processing"?React.createElement("div",null,React.createElement(ProTable,_object_spread({rowKey:"id",columns:finalErrorColumns,request:errorRequest,search:false,pagination:{defaultPageSize:10,showSizeChanger:true,showQuickJumper:true},size:"small",showCreateBtn:false,showBatchRemoveBtn:false,showViewBtn:false,showUpdateBtn:false,showRemoveBtn:false,rowButtonItems:[],headerButtonItems:[{key:"title",label:messages.imports.detail.failedDataTitle,icon:React.createElement(ExclamationCircleOutlined,{style:{color:token.colorError}}),isCustom:true,component:React.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},React.createElement(ExclamationCircleOutlined,{style:{color:token.colorError}}),React.createElement("h3",{style:{fontSize:14,fontWeight:600,color:token.colorText,margin:0}},messages.imports.detail.failedDataTitle))}],scroll:{x:800}},errorTableProps))):null;var bodyContent=contentRender?contentRender({record:currentRecord,defaultHeader:headerNode,defaultFailedTable:failedTableNode}):React.createElement(React.Fragment,null,headerNode,failedTableNode,currentStatus==="completed"&¤tRecord.failed===0&&React.createElement(Alert,{message:messages.imports.detail.successAlert,type:"success",icon:React.createElement(CheckCircleOutlined,null)}),currentStatus==="failed"&&React.createElement(Alert,{message:messages.imports.detail.failedAlert.message,description:messages.imports.detail.failedAlert.description,type:"error",icon:React.createElement(CloseCircleOutlined,null)}));return React.createElement(Modal,{title:messages.imports.detail.title,open:open,onCancel:function(){return onOpenChange(false)},footer:null,width:1e3,centered:false,destroyOnHidden:true,styles:{body:{maxHeight:"90vh",overflowY:"auto"}}},React.createElement("div",{style:containerStyle},bodyContent))};
|
|
1
|
+
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import{useMemo,useEffect,useState,useRef,useCallback}from"react";import React from"react";import{Tag,Row,Col,Card,Alert,theme,Descriptions,Progress,Spin}from"antd";import{ProTable}from"../../ProTable";import{Modal}from"../../Modal";import{CheckCircleOutlined,CloseCircleOutlined,ExclamationCircleOutlined,LoadingOutlined}from"@ant-design/icons";import{formatDate}from"../utils/date";import{getContainerStyle,getStatCardStyle,getStatNumberStyle,getStatLabelStyle,getRowNumberStyle}from"../utils/styles";import{useLocale}from"../../locale";import{useImportContextOptional}from"../context/import-context";var useToken=theme.useToken;export var ImportDetailDialog=function(param){var open=param.open,onOpenChange=param.onOpenChange,record=param.record,errorColumns=param.errorColumns,queryImportErrors=param.queryImportErrors,errorTableProps=param.errorTableProps,contentRender=param.contentRender,propsQueryProgress=param.queryProgress,propsPollInterval=param.pollInterval;var _messages_imports_detail_processingDescription;var token=useToken().token;var messages=useLocale().messages;var context=useImportContextOptional();var queryProgress=propsQueryProgress!==null&&propsQueryProgress!==void 0?propsQueryProgress:context===null||context===void 0?void 0:context.queryProgress;var _ref;var pollInterval=(_ref=propsPollInterval!==null&&propsPollInterval!==void 0?propsPollInterval:context===null||context===void 0?void 0:context.pollInterval)!==null&&_ref!==void 0?_ref:2e3;var _useState=_sliced_to_array(useState(null),2),currentProgress=_useState[0],setCurrentProgress=_useState[1];var _useState1=_sliced_to_array(useState(record.status),2),currentStatus=_useState1[0],setCurrentStatus=_useState1[1];var _useState2=_sliced_to_array(useState(record),2),currentRecord=_useState2[0],setCurrentRecord=_useState2[1];var pollingRef=useRef(null);var isUnmountedRef=useRef(false);useEffect(function(){setCurrentRecord(record);setCurrentStatus(record.status)},[record]);var queryProgressRef=useRef(queryProgress);var recordIdRef=useRef(record.id);var currentStatusRef=useRef(currentStatus);useEffect(function(){queryProgressRef.current=queryProgress;recordIdRef.current=record.id;currentStatusRef.current=currentStatus},[queryProgress,record.id,currentStatus]);var fetchProgress=useCallback(function(){return _async_to_generator(function(){var progress,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(isUnmountedRef.current||!queryProgressRef.current||currentStatusRef.current!=="processing"){return[2]}_state.label=1;case 1:_state.trys.push([1,3,,4]);return[4,queryProgressRef.current(recordIdRef.current)];case 2:progress=_state.sent();if(isUnmountedRef.current)return[2];setCurrentProgress(progress);if(progress.status!==currentStatusRef.current){setCurrentStatus(progress.status);setCurrentRecord(function(prev){var _progress_success,_progress_failed,_progress_total;return _object_spread_props(_object_spread({},prev),{status:progress.status,success:(_progress_success=progress.success)!==null&&_progress_success!==void 0?_progress_success:prev.success,failed:(_progress_failed=progress.failed)!==null&&_progress_failed!==void 0?_progress_failed:prev.failed,total:(_progress_total=progress.total)!==null&&_progress_total!==void 0?_progress_total:prev.total})})}else{setCurrentRecord(function(prev){var _progress_success,_progress_failed,_progress_total;return _object_spread_props(_object_spread({},prev),{success:(_progress_success=progress.success)!==null&&_progress_success!==void 0?_progress_success:prev.success,failed:(_progress_failed=progress.failed)!==null&&_progress_failed!==void 0?_progress_failed:prev.failed,total:(_progress_total=progress.total)!==null&&_progress_total!==void 0?_progress_total:prev.total})})}if(progress.status==="completed"||progress.status==="failed"){if(pollingRef.current){clearInterval(pollingRef.current);pollingRef.current=null}}return[3,4];case 3:error=_state.sent();console.error("查询导入进度失败:",error);return[3,4];case 4:return[2]}})})()},[]);useEffect(function(){if(!open){if(pollingRef.current){clearInterval(pollingRef.current);pollingRef.current=null}isUnmountedRef.current=true;return}isUnmountedRef.current=false;if(currentStatus==="processing"&&queryProgress){fetchProgress();pollingRef.current=setInterval(function(){fetchProgress()},pollInterval)}return function(){if(pollingRef.current){clearInterval(pollingRef.current);pollingRef.current=null}isUnmountedRef.current=true}},[open,currentStatus,queryProgress,pollInterval,fetchProgress]);var formattedCreatedAt=useMemo(function(){if(!record.createdAt)return"";try{var date=new Date(record.createdAt);if(isNaN(date.getTime())){return record.createdAt}return formatDate(date,"YYYY-MM-DD HH:mm:ss")}catch(e){return record.createdAt}},[record.createdAt]);var containerStyle=useMemo(function(){return getContainerStyle(token)},[token]);var statCardStyle=useMemo(function(){return getStatCardStyle(token)},[token]);var statNumberStyle=useMemo(function(){return getStatNumberStyle(token)},[token]);var statLabelStyle=useMemo(function(){return getStatLabelStyle(token)},[token]);var successRate=useMemo(function(){if(currentRecord.total===0)return"0.0";return(currentRecord.success/currentRecord.total*100).toFixed(1)},[currentRecord.success,currentRecord.total]);var defaultErrorColumns=useMemo(function(){return[{title:messages.imports.detail.errorColumns.rowNumber,dataIndex:"row_number",key:"row_number",width:120,valueType:"digit",render:function(_,recordItem){return React.createElement("span",{style:getRowNumberStyle(token)},messages.imports.detail.rowNumberText.replace("{rowNumber}",String(recordItem.row_number)))}},{title:messages.imports.detail.errorColumns.errorType,dataIndex:"error_type",key:"error_type",width:160,valueType:"text"},{title:messages.imports.detail.errorColumns.errorMessage,dataIndex:"error_message",key:"error_message",valueType:"text",ellipsis:true},{title:messages.imports.detail.errorColumns.errorId,dataIndex:"id",key:"id",width:220,valueType:"text",copyable:true}]},[messages]);var finalErrorColumns=useMemo(function(){if(errorColumns&&errorColumns.length>0){return errorColumns}return defaultErrorColumns},[errorColumns,defaultErrorColumns]);var errorRequest=useMemo(function(){if(!queryImportErrors){return function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){return[2,{data:[],success:true,total:0}]})})()}}return function(params){return _async_to_generator(function(){var result,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:_state.trys.push([0,2,,3]);return[4,queryImportErrors(_object_spread({importId:currentRecord.id},params))];case 1:result=_state.sent();return[2,{data:result.list||[],success:true,total:result.total||0}];case 2:error=_state.sent();console.error(messages.imports.detail.queryFailed,error);return[2,{data:[],success:false,total:0}];case 3:return[2]}})})()}},[queryImportErrors,currentRecord.id,messages]);var progressPercent=useMemo(function(){if(currentProgress){return Math.round(currentProgress.progress||0)}if(currentRecord.total>0){return Math.round((currentRecord.success+currentRecord.failed)/currentRecord.total*100)}return 0},[currentProgress,currentRecord]);var headerNode=React.createElement(React.Fragment,null,React.createElement(Descriptions,{column:3,size:"small",labelStyle:{fontSize:token.fontSizeSM,color:token.colorTextSecondary},contentStyle:{fontSize:token.fontSizeSM,color:token.colorText}},React.createElement(Descriptions.Item,{label:messages.imports.detail.labels.importId,span:3},React.createElement("span",{style:{fontFamily:"monospace",fontWeight:token.fontWeightStrong}},currentRecord.id)),React.createElement(Descriptions.Item,{label:messages.imports.detail.labels.currentStatus,span:1},React.createElement("div",null,currentStatus==="completed"&&React.createElement(Tag,{color:"success"},messages.imports.detail.status.completed),currentStatus==="failed"&&React.createElement(Tag,{color:"error"},messages.imports.detail.status.failed),currentStatus==="processing"&&React.createElement(Tag,{color:"processing"},messages.imports.detail.status.processing),currentStatus==="cancelled"&&React.createElement(Tag,{color:"default"},messages.imports.detail.status.cancelled))),React.createElement(Descriptions.Item,{label:messages.imports.detail.labels.importTime,span:2},React.createElement("span",{style:{fontWeight:token.fontWeightStrong}},formattedCreatedAt))),currentStatus==="processing"&&React.createElement("div",{style:{padding:token.padding,background:token.colorInfoBg,borderRadius:token.borderRadius,marginBottom:token.margin,border:"1px solid ".concat(token.colorInfoBorder)}},React.createElement("div",{style:{display:"flex",alignItems:"center",gap:token.marginSM,marginBottom:token.marginSM}},React.createElement(Spin,{indicator:React.createElement(LoadingOutlined,{style:{fontSize:token.fontSizeLG,color:token.colorInfo},spin:true})}),React.createElement("div",{style:{flex:1}},React.createElement("div",{style:{fontSize:token.fontSize,fontWeight:token.fontWeightStrong,color:token.colorText,marginBottom:token.marginXXS}},messages.imports.detail.processingTitle||"正在处理导入任务..."),React.createElement("div",{style:{fontSize:token.fontSizeSM,color:token.colorTextSecondary}},((_messages_imports_detail_processingDescription=messages.imports.detail.processingDescription)===null||_messages_imports_detail_processingDescription===void 0?void 0:_messages_imports_detail_processingDescription.replace("{current}",String(currentRecord.success+currentRecord.failed)).replace("{total}",String(currentRecord.total)))||"已处理 ".concat(currentRecord.success+currentRecord.failed," / ").concat(currentRecord.total," 条数据")))),React.createElement(Progress,{percent:progressPercent,strokeColor:token.colorInfo,showInfo:true})),React.createElement(Row,{gutter:token.margin,style:{marginInline:0}},React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorBgContainer})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorText})},currentRecord.total),React.createElement("p",{style:statLabelStyle},messages.imports.detail.stats.total))),React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorSuccessBg,borderColor:token.colorSuccessBorder})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorSuccess})},currentRecord.success),React.createElement("p",{style:_object_spread_props(_object_spread({},statLabelStyle),{color:token.colorSuccessText})},messages.imports.detail.stats.success))),React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorErrorBg,borderColor:token.colorErrorBorder})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorError})},currentRecord.failed),React.createElement("p",{style:_object_spread_props(_object_spread({},statLabelStyle),{color:token.colorErrorText})},messages.imports.detail.stats.failed))),React.createElement(Col,{span:6},React.createElement(Card,{variant:"outlined",styles:{body:_object_spread_props(_object_spread({},statCardStyle),{background:token.colorInfoBg,borderColor:token.colorInfoBorder})}},React.createElement("p",{style:_object_spread_props(_object_spread({},statNumberStyle),{color:token.colorInfo})},successRate,"%"),React.createElement("p",{style:_object_spread_props(_object_spread({},statLabelStyle),{color:token.colorInfoText})},messages.imports.importResult.successRate||"成功率")))));var failedTableNode=currentRecord.failed>0&&queryImportErrors&¤tStatus!=="processing"?React.createElement("div",null,React.createElement(ProTable,_object_spread({columns:finalErrorColumns,search:false,tableProps:{rowKey:"id",request:errorRequest,pagination:{defaultPageSize:10,showSizeChanger:true,showQuickJumper:true},size:"small",scroll:{x:800}},showCreateBtn:false,showBatchRemoveBtn:false,showViewBtn:false,showUpdateBtn:false,showRemoveBtn:false,rowButtonItems:[],headerButtonItems:[{key:"title",label:messages.imports.detail.failedDataTitle,icon:React.createElement(ExclamationCircleOutlined,{style:{color:token.colorError}}),isCustom:true,component:React.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},React.createElement(ExclamationCircleOutlined,{style:{color:token.colorError}}),React.createElement("h3",{style:{fontSize:14,fontWeight:600,color:token.colorText,margin:0}},messages.imports.detail.failedDataTitle))}]},errorTableProps))):null;var bodyContent=contentRender?contentRender({record:currentRecord,defaultHeader:headerNode,defaultFailedTable:failedTableNode}):React.createElement(React.Fragment,null,headerNode,failedTableNode,currentStatus==="completed"&¤tRecord.failed===0&&React.createElement(Alert,{message:messages.imports.detail.successAlert,type:"success",icon:React.createElement(CheckCircleOutlined,null)}),currentStatus==="failed"&&React.createElement(Alert,{message:messages.imports.detail.failedAlert.message,description:messages.imports.detail.failedAlert.description,type:"error",icon:React.createElement(CloseCircleOutlined,null)}));return React.createElement(Modal,{title:messages.imports.detail.title,open:open,onCancel:function(){return onOpenChange(false)},footer:null,width:1e3,centered:false,destroyOnHidden:true,styles:{body:{maxHeight:"90vh",overflowY:"auto"}}},React.createElement("div",{style:containerStyle},bodyContent))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import{useState,useMemo,useCallback}from"react";import{Button,theme}from"antd";import{ProTable}from"../../ProTable";import{Modal}from"../../Modal";import React from"react";import{EyeOutlined}from"@ant-design/icons";import{ImportDetailDialog}from"./import-detail-dialog";import{useImportContextOptional}from"../context/import-context";import{useRef}from"react";import{useLocale}from"../../locale";import{tagRender}from"../../library";var useToken=theme.useToken;export var ImportHistoryDialog=function(param){var open=param.open,onOpenChange=param.onOpenChange,customColumns=param.columns,customQueryImportRecords=param.queryImportRecords,tableProps=param.tableProps;var token=useToken().token;var messages=useLocale().messages;var context=useImportContextOptional();var _useState=_sliced_to_array(useState(null),2),selectedRecord=_useState[0],setSelectedRecord=_useState[1];var _useState1=_sliced_to_array(useState(false),2),detailDialogOpen=_useState1[0],setDetailDialogOpen=_useState1[1];var tableRef=useRef(null);var handleViewDetail=useCallback(function(record){setSelectedRecord(record);setDetailDialogOpen(true)},[]);var finalQueryImportRecords=customQueryImportRecords!==null&&customQueryImportRecords!==void 0?customQueryImportRecords:context===null||context===void 0?void 0:context.queryImportRecords;var finalQueryImportErrors=context===null||context===void 0?void 0:context.queryImportErrors;var finalImportErrorColumns=context===null||context===void 0?void 0:context.importErrorColumns;var finalImportErrorTableProps=context===null||context===void 0?void 0:context.importErrorTableProps;var finalImportDetailContentRender=context===null||context===void 0?void 0:context.importDetailContentRender;var defaultColumns=useMemo(function(){return[{title:messages.imports.history.columns.importId,dataIndex:"id",key:"id",hideInSearch:true},{title:messages.imports.history.columns.status,dataIndex:"status",key:"status",hideInSearch:false,valueType:"select",width:150,valueEnum:{completed:{text:messages.imports.history.statusEnum.completed,color:"success",status:"Success"},failed:{text:messages.imports.history.statusEnum.failed,color:"error",status:"Error"},processing:{text:messages.imports.history.statusEnum.processing,color:"processing",status:"Processing"},cancelled:{text:messages.imports.history.statusEnum.cancelled,color:"default",status:"Cancelled"}},render:tagRender},{title:messages.imports.history.columns.total,dataIndex:"total",key:"total",hideInSearch:true,valueType:"digit",width:150},{title:messages.imports.history.columns.success,dataIndex:"success",key:"success",hideInSearch:true,valueType:"digit",width:150},{title:messages.imports.history.columns.failed,dataIndex:"failed",key:"failed",hideInSearch:true,valueType:"digit",width:150},{title:messages.imports.history.columns.importTime,dataIndex:"createdAt",key:"createdAt",hideInSearch:false,valueType:"dateTime",width:200},{title:messages.imports.history.columns.operation,key:"action",hideInSearch:true,width:100,fixed:"right",render:function(_,record){return React.createElement(Button,{variant:"link",color:"primary",size:"small",icon:React.createElement(EyeOutlined,null),onClick:function(){return handleViewDetail(record)}},messages.imports.history.view)}}]},[handleViewDetail,messages]);var finalColumns=useMemo(function(){if(customColumns){return customColumns}return defaultColumns},[customColumns,defaultColumns]);var handleRequest=useMemo(function(){if(!finalQueryImportRecords){return function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){return[2,{data:[],success:true,total:0}]})})()}}return function(params){return _async_to_generator(function(){var result,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:_state.trys.push([0,2,,3]);return[4,finalQueryImportRecords(params)];case 1:result=_state.sent();return[2,{data:result.list||[],success:true,total:result.total||0}];case 2:error=_state.sent();console.error(messages.imports.history.queryFailed,error);return[2,{data:[],success:false,total:0}];case 3:return[2]}})})()}},[finalQueryImportRecords]);return React.createElement(React.Fragment,null,React.createElement(Modal,{title:messages.imports.history.title,open:open,onCancel:function(){return onOpenChange(false)},footer:null,width:1e3,centered:false,destroyOnHidden:true,styles:{body:{padding:"0"}},maskClosable:false},React.createElement(ProTable,_object_spread_props(_object_spread({columns:finalColumns,
|
|
1
|
+
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import{useState,useMemo,useCallback}from"react";import{Button,theme}from"antd";import{ProTable}from"../../ProTable";import{Modal}from"../../Modal";import React from"react";import{EyeOutlined}from"@ant-design/icons";import{ImportDetailDialog}from"./import-detail-dialog";import{useImportContextOptional}from"../context/import-context";import{useRef}from"react";import{useLocale}from"../../locale";import{tagRender}from"../../library";var useToken=theme.useToken;export var ImportHistoryDialog=function(param){var open=param.open,onOpenChange=param.onOpenChange,customColumns=param.columns,customQueryImportRecords=param.queryImportRecords,tableProps=param.tableProps;var token=useToken().token;var messages=useLocale().messages;var context=useImportContextOptional();var _useState=_sliced_to_array(useState(null),2),selectedRecord=_useState[0],setSelectedRecord=_useState[1];var _useState1=_sliced_to_array(useState(false),2),detailDialogOpen=_useState1[0],setDetailDialogOpen=_useState1[1];var tableRef=useRef(null);var handleViewDetail=useCallback(function(record){setSelectedRecord(record);setDetailDialogOpen(true)},[]);var finalQueryImportRecords=customQueryImportRecords!==null&&customQueryImportRecords!==void 0?customQueryImportRecords:context===null||context===void 0?void 0:context.queryImportRecords;var finalQueryImportErrors=context===null||context===void 0?void 0:context.queryImportErrors;var finalImportErrorColumns=context===null||context===void 0?void 0:context.importErrorColumns;var finalImportErrorTableProps=context===null||context===void 0?void 0:context.importErrorTableProps;var finalImportDetailContentRender=context===null||context===void 0?void 0:context.importDetailContentRender;var defaultColumns=useMemo(function(){return[{title:messages.imports.history.columns.importId,dataIndex:"id",key:"id",hideInSearch:true},{title:messages.imports.history.columns.status,dataIndex:"status",key:"status",hideInSearch:false,valueType:"select",width:150,valueEnum:{completed:{text:messages.imports.history.statusEnum.completed,color:"success",status:"Success"},failed:{text:messages.imports.history.statusEnum.failed,color:"error",status:"Error"},processing:{text:messages.imports.history.statusEnum.processing,color:"processing",status:"Processing"},cancelled:{text:messages.imports.history.statusEnum.cancelled,color:"default",status:"Cancelled"}},render:tagRender},{title:messages.imports.history.columns.total,dataIndex:"total",key:"total",hideInSearch:true,valueType:"digit",width:150},{title:messages.imports.history.columns.success,dataIndex:"success",key:"success",hideInSearch:true,valueType:"digit",width:150},{title:messages.imports.history.columns.failed,dataIndex:"failed",key:"failed",hideInSearch:true,valueType:"digit",width:150},{title:messages.imports.history.columns.importTime,dataIndex:"createdAt",key:"createdAt",hideInSearch:false,valueType:"dateTime",width:200},{title:messages.imports.history.columns.operation,key:"action",hideInSearch:true,width:100,fixed:"right",render:function(_,record){return React.createElement(Button,{variant:"link",color:"primary",size:"small",icon:React.createElement(EyeOutlined,null),onClick:function(){return handleViewDetail(record)}},messages.imports.history.view)}}]},[handleViewDetail,messages]);var finalColumns=useMemo(function(){if(customColumns){return customColumns}return defaultColumns},[customColumns,defaultColumns]);var handleRequest=useMemo(function(){if(!finalQueryImportRecords){return function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){return[2,{data:[],success:true,total:0}]})})()}}return function(params){return _async_to_generator(function(){var result,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:_state.trys.push([0,2,,3]);return[4,finalQueryImportRecords(params)];case 1:result=_state.sent();return[2,{data:result.list||[],success:true,total:result.total||0}];case 2:error=_state.sent();console.error(messages.imports.history.queryFailed,error);return[2,{data:[],success:false,total:0}];case 3:return[2]}})})()}},[finalQueryImportRecords]);return React.createElement(React.Fragment,null,React.createElement(Modal,{title:messages.imports.history.title,open:open,onCancel:function(){return onOpenChange(false)},footer:null,width:1e3,centered:false,destroyOnHidden:true,styles:{body:{padding:"0"}},maskClosable:false},React.createElement(ProTable,_object_spread_props(_object_spread({columns:finalColumns,tableRef:tableRef,search:{searchProps:{labelWidth:"auto"}},tableProps:{rowKey:"id",request:handleRequest,pagination:{defaultPageSize:10,showSizeChanger:true,showQuickJumper:true},size:"small",scroll:{x:1e3}},showCreateBtn:false,showBatchRemoveBtn:false,showViewBtn:false,showUpdateBtn:false,showRemoveBtn:false,rowButtonItems:[]},tableProps),{style:{padding:"".concat(token.paddingSM,"px 0")}}))),selectedRecord&&React.createElement(ImportDetailDialog,{open:detailDialogOpen,onOpenChange:setDetailDialogOpen,record:selectedRecord,errorColumns:finalImportErrorColumns,queryImportErrors:finalQueryImportErrors,errorTableProps:finalImportErrorTableProps,contentRender:finalImportDetailContentRender,queryProgress:context===null||context===void 0?void 0:context.queryProgress,pollInterval:context===null||context===void 0?void 0:context.pollInterval}))};
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ProTableProps, ProTableSearchProps, GridCardRender } from "../types";
|
|
3
|
-
export declare const Container: <DataSource extends Record<string, any> = Record<string, any>, ParamsType extends Record<string, any> = Record<string, any>, ValueType = "text">(props: {
|
|
4
|
-
prefixCls: string;
|
|
5
|
-
cssVarCls: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: React.CSSProperties;
|
|
8
|
-
searchConfig: Omit<ProTableSearchProps<DataSource, ValueType extends string ? ValueType : "text">, "columns"> | null;
|
|
9
|
-
searchColumns: any[];
|
|
10
|
-
columns: any[];
|
|
11
|
-
headerTitle: React.ReactNode;
|
|
12
|
-
rowSelection: any;
|
|
13
|
-
pagination: any;
|
|
14
|
-
tableProps: Omit<ProTableProps<DataSource, ParamsType, ValueType>, "columns" | "search" | "searchType" | "showCreateBtn" | "createBtnProps" | "onCreate" | "showBatchRemoveBtn" | "batchRemoveBtnProps" | "onBatchRemove" | "headerButtonItems" | "headerButtonMaxCount" | "openPageSizeCache" | "defaultPageSize">;
|
|
15
|
-
actionRef?: any;
|
|
16
|
-
wrapCSS: (element: React.ReactElement) => React.ReactElement;
|
|
17
|
-
gridCardRender?: GridCardRender<DataSource>;
|
|
18
|
-
gridColumns?: {
|
|
19
|
-
xs?: number;
|
|
20
|
-
sm?: number;
|
|
21
|
-
md?: number;
|
|
22
|
-
lg?: number;
|
|
23
|
-
xl?: number;
|
|
24
|
-
xxl?: number;
|
|
25
|
-
};
|
|
26
|
-
gridCardFieldsPerRow?: number;
|
|
27
|
-
}) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import React from"react";import{Flex}from"antd";import classNames from"classnames";import ProTableSearch from"./search";import{ProTableList}from"./list/index";export var Container=function(props){var prefixCls=props.prefixCls,cssVarCls=props.cssVarCls,className=props.className,style=props.style,searchConfig=props.searchConfig,searchColumns=props.searchColumns,columns=props.columns,headerTitle=props.headerTitle,rowSelection=props.rowSelection,pagination=props.pagination,tableProps=props.tableProps,actionRef=props.actionRef,wrapCSS=props.wrapCSS,gridCardRender=props.gridCardRender,gridColumns=props.gridColumns,gridCardFieldsPerRow=props.gridCardFieldsPerRow;var _React_useState=_sliced_to_array(React.useState(function(){return(searchConfig===null||searchConfig===void 0?void 0:searchConfig.initialValues)||{}}),2),searchFormValues=_React_useState[0],setSearchFormValues=_React_useState[1];var handleSearchFinish=React.useCallback(function(values){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}return _async_to_generator(function(){var _actionRef_current_setPageInfo,_actionRef_current,_searchConfig;return _ts_generator(this,function(_state){switch(_state.label){case 0:setSearchFormValues(values||{});actionRef===null||actionRef===void 0?void 0:(_actionRef_current=actionRef.current)===null||_actionRef_current===void 0?void 0:(_actionRef_current_setPageInfo=_actionRef_current.setPageInfo)===null||_actionRef_current_setPageInfo===void 0?void 0:_actionRef_current_setPageInfo.call(_actionRef_current,{current:1});if(!(searchConfig===null||searchConfig===void 0?void 0:searchConfig.onFinish))return[3,2];return[4,(_searchConfig=searchConfig).onFinish.apply(_searchConfig,[values].concat(_to_consumable_array(args)))];case 1:_state.sent();_state.label=2;case 2:return[2]}})})()},[searchConfig,actionRef]);var handleSearchReset=React.useCallback(function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}return _async_to_generator(function(){var _actionRef_current_reset,_actionRef_current,_searchConfig;return _ts_generator(this,function(_state){switch(_state.label){case 0:setSearchFormValues({});if(!(searchConfig===null||searchConfig===void 0?void 0:searchConfig.onReset))return[3,2];return[4,(_searchConfig=searchConfig).onReset.apply(_searchConfig,_to_consumable_array(args))];case 1:_state.sent();_state.label=2;case 2:actionRef===null||actionRef===void 0?void 0:(_actionRef_current=actionRef.current)===null||_actionRef_current===void 0?void 0:(_actionRef_current_reset=_actionRef_current.reset)===null||_actionRef_current_reset===void 0?void 0:_actionRef_current_reset.call(_actionRef_current);return[2]}})})()},[searchConfig,actionRef]);var mergedSearchConfig=React.useMemo(function(){if(!searchConfig){return null}return _object_spread_props(_object_spread({},searchConfig),{onFinish:handleSearchFinish,onReset:handleSearchReset})},[searchConfig,handleSearchFinish,handleSearchReset]);var mergedTableProps=React.useMemo(function(){return _object_spread_props(_object_spread({},tableProps),{params:_object_spread({},tableProps.params||{},searchFormValues),gridCardFieldsPerRow:gridCardFieldsPerRow})},[tableProps,searchFormValues,gridCardFieldsPerRow]);return wrapCSS(React.createElement(Flex,{vertical:true,gap:8,className:classNames(prefixCls,cssVarCls,className),style:style},mergedSearchConfig&&React.createElement(ProTableSearch,_object_spread({columns:searchColumns},mergedSearchConfig)),React.createElement(ProTableList,{columns:columns,headerTitle:headerTitle,rowSelection:rowSelection,pagination:pagination,tableProps:mergedTableProps,actionRef:actionRef,gridCardRender:gridCardRender,gridColumns:gridColumns})))};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ProColumns } from "@ant-design/pro-components";
|
|
3
|
-
import type { OperationType, FormConfig } from "../types";
|
|
4
|
-
export interface FormContentProps<T = any, ValueType extends string = 'text'> {
|
|
5
|
-
/**
|
|
6
|
-
* 操作类型
|
|
7
|
-
*/
|
|
8
|
-
type: OperationType;
|
|
9
|
-
/**
|
|
10
|
-
* 当前记录(编辑和查看时使用)
|
|
11
|
-
*/
|
|
12
|
-
record?: T;
|
|
13
|
-
/**
|
|
14
|
-
* 表格列配置(用于自动生成表单)
|
|
15
|
-
*/
|
|
16
|
-
tableColumns?: ProColumns<T, ValueType>[];
|
|
17
|
-
/**
|
|
18
|
-
* 表单配置
|
|
19
|
-
*/
|
|
20
|
-
formConfig?: FormConfig<T, ValueType>;
|
|
21
|
-
/**
|
|
22
|
-
* 表单提交回调
|
|
23
|
-
*/
|
|
24
|
-
onSubmit?: (values: T) => Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* 表单实例引用
|
|
27
|
-
*/
|
|
28
|
-
formRef?: React.MutableRefObject<any>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 表单内容组件
|
|
32
|
-
* 用于显示具体的表单内容(新增/编辑/查看)
|
|
33
|
-
*/
|
|
34
|
-
export declare const FormContent: <T extends Record<string, any> = Record<string, any>, ValueType extends string = "text">(props: FormContentProps<T, ValueType>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _object_without_properties(source,excluded){if(source==null)return{};var target=_object_without_properties_loose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _object_without_properties_loose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import React from"react";import{ProForm}from"../../Form";export var FormContent=function(props){var type=props.type,record=props.record,_props_tableColumns=props.tableColumns,tableColumns=_props_tableColumns===void 0?[]:_props_tableColumns,_props_formConfig=props.formConfig,formConfig=_props_formConfig===void 0?{}:_props_formConfig,onSubmit=props.onSubmit,externalFormRef=props.formRef;var customColumns=formConfig.columns,_formConfig_formProps=formConfig.formProps,formProps=_formConfig_formProps===void 0?{}:_formConfig_formProps,_formConfig_layout=formConfig.layout,layout=_formConfig_layout===void 0?"horizontal":_formConfig_layout,labelCol=formConfig.labelCol,wrapperCol=formConfig.wrapperCol;var internalFormRef=React.useRef(null);var formRef=externalFormRef||internalFormRef;var generateFormColumns=React.useMemo(function(){if(customColumns&&customColumns.length>0){return customColumns}return tableColumns.filter(function(col){var _col_hideInForm=col.hideInForm,hideInForm=_col_hideInForm===void 0?false:_col_hideInForm,valueType=col.valueType;if(valueType==="option"){return false}return!hideInForm}).map(function(col){var title=col.title,dataIndex=col.dataIndex,_col_valueType=col.valueType,valueType=_col_valueType===void 0?"text":_col_valueType,valueEnum=col.valueEnum,fieldProps=col.fieldProps,formItemProps=col.formItemProps,restCol=_object_without_properties(col,["title","dataIndex","valueType","valueEnum","fieldProps","formItemProps"]);var formColumn=_object_spread({title:title,dataIndex:dataIndex,valueType:valueType,valueEnum:valueEnum,fieldProps:_object_spread({},fieldProps),formItemProps:_object_spread({},formItemProps)},restCol);if(type==="view"){formColumn.readonly=true;formColumn.fieldProps=_object_spread_props(_object_spread({},formColumn.fieldProps),{disabled:true})}return formColumn})},[tableColumns,customColumns,type]);var initialValues=React.useMemo(function(){if(type==="create"){return formProps.initialValues||{}}return record||formProps.initialValues||{}},[type,record,formProps.initialValues]);var handleFinish=function(values){return _async_to_generator(function(){return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onSubmit)return[3,2];return[4,onSubmit(values)];case 1:_state.sent();_state.label=2;case 2:return[2]}})})()};return React.createElement(ProForm,_object_spread({formRef:formRef,columns:generateFormColumns,layout:layout,layoutType:"Form",labelCol:_object_spread({flex:"0 0 auto"},labelCol),wrapperCol:wrapperCol,initialValues:initialValues,onFinish:handleFinish,submitter:false},formProps))};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { OperationType } from "../types";
|
|
3
|
-
export interface FormFooterProps {
|
|
4
|
-
/**
|
|
5
|
-
* 操作类型
|
|
6
|
-
*/
|
|
7
|
-
type: OperationType;
|
|
8
|
-
/**
|
|
9
|
-
* 提交按钮文本
|
|
10
|
-
*/
|
|
11
|
-
submitText?: string;
|
|
12
|
-
/**
|
|
13
|
-
* 取消按钮文本
|
|
14
|
-
*/
|
|
15
|
-
cancelText?: string;
|
|
16
|
-
/**
|
|
17
|
-
* 提交中状态
|
|
18
|
-
*/
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* 提交回调
|
|
22
|
-
*/
|
|
23
|
-
onSubmit: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* 取消回调
|
|
26
|
-
*/
|
|
27
|
-
onCancel: () => void;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 表单底部按钮组件
|
|
31
|
-
*/
|
|
32
|
-
export declare const FormFooter: React.FC<FormFooterProps>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}import React from"react";import{Space}from"antd";import{Button}from"../../Button";import{useLocale}from"../../locale";import useStyle from"../styles";export var FormFooter=function(props){var type=props.type,submitText=props.submitText,cancelText=props.cancelText,_props_loading=props.loading,loading=_props_loading===void 0?false:_props_loading,onSubmit=props.onSubmit,onCancel=props.onCancel;var messages=useLocale().messages;var _useStyle=_sliced_to_array(useStyle("VlianTable"),2),wrapSSR=_useStyle[0],hashId=_useStyle[1];var getSubmitText=function(){if(submitText){return submitText}switch(type){case"create":return messages.table.createSubmitText||"创建";case"update":return messages.table.updateSubmitText||"保存";case"view":return messages.table.closeText||"关闭";default:return messages.table.submitText||"提交"}};if(type==="view"){return wrapSSR(React.createElement("div",{className:"VlianTable-form-footer ".concat(hashId)},React.createElement(Button,{onClick:onCancel},cancelText||messages.table.closeText||"关闭")))}return wrapSSR(React.createElement("div",{className:"VlianTable-form-footer ".concat(hashId)},React.createElement(Space,null,React.createElement(Button,{onClick:onCancel},cancelText||messages.table.cancelText||"取消"),React.createElement(Button,{type:"primary",loading:loading,onClick:onSubmit},getSubmitText()))))};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React from"react";import{useNavigate,useLocation}from"react-router-dom";import{ProTableContext}from"../context";export var HeaderButtonsWrapper=function(param){var children=param.children,mode=param.mode,operationType=param.operationType;var navigate=useNavigate();var location=useLocation();var setOperationType=React.useContext(ProTableContext).setOperationType;var prevPathnameRef=React.useRef(location.pathname);var isNavigatingRef=React.useRef(false);React.useEffect(function(){if(mode==="router"){if(operationType==="create"&&location.pathname!=="/create"){isNavigatingRef.current=true;navigate("/create");setTimeout(function(){isNavigatingRef.current=false},0)}else if(operationType==="list"&&location.pathname!=="/"){isNavigatingRef.current=true;navigate("/");setTimeout(function(){isNavigatingRef.current=false},0)}}},[mode,operationType,navigate,location.pathname]);React.useEffect(function(){if(mode==="router"){var pathname=location.pathname;if(pathname===prevPathnameRef.current){return}if(isNavigatingRef.current){prevPathnameRef.current=pathname;return}prevPathnameRef.current=pathname;var newOperationType="list";if(pathname==="/"||pathname===""){newOperationType="list"}else if(pathname==="/create"){newOperationType="create"}else if(pathname.includes("/update/")||pathname.includes("/edit/")){newOperationType="update"}else if(pathname.includes("/view/")||pathname.includes("/detail/")){newOperationType="view"}if(operationType!==newOperationType){setOperationType(newOperationType)}}},[mode,location.pathname,setOperationType,operationType]);return React.createElement(React.Fragment,null,children)};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ProTableProps, GridCardRender } from "../../types";
|
|
3
|
-
export declare const ProTableList: <DataSource extends Record<string, any> = Record<string, any>, ParamsType extends Record<string, any> = Record<string, any>, ValueType = "text">(props: {
|
|
4
|
-
columns: any[];
|
|
5
|
-
headerTitle?: React.ReactNode;
|
|
6
|
-
rowSelection?: any;
|
|
7
|
-
pagination?: any;
|
|
8
|
-
tableProps: Omit<ProTableProps<DataSource, ParamsType, ValueType>, "columns" | "search" | "searchType" | "showCreateBtn" | "createBtnProps" | "onCreate" | "showBatchRemoveBtn" | "batchRemoveBtnProps" | "onBatchRemove" | "headerButtonItems" | "headerButtonMaxCount" | "openPageSizeCache" | "defaultPageSize">;
|
|
9
|
-
actionRef?: any;
|
|
10
|
-
gridCardRender?: GridCardRender<DataSource>;
|
|
11
|
-
gridColumns?: {
|
|
12
|
-
xs?: number;
|
|
13
|
-
sm?: number;
|
|
14
|
-
md?: number;
|
|
15
|
-
lg?: number;
|
|
16
|
-
xl?: number;
|
|
17
|
-
xxl?: number;
|
|
18
|
-
};
|
|
19
|
-
}) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}import React from"react";import{ProTable as AntdProTable}from"@ant-design/pro-components";import{ProTableContext}from"../../context";import{useContext}from"react";import{AppstoreOutlined,TableOutlined}from"@ant-design/icons";import{GridView}from"../grid-view";import{Spin,Tooltip}from"antd";import useStyle from"../../styles";import{GridCard}from"../grid-card";export var ProTableList=function(props){var columns=props.columns,headerTitle=props.headerTitle,rowSelection=props.rowSelection,pagination=props.pagination,tableProps=props.tableProps,actionRef=props.actionRef,gridCardRender=props.gridCardRender,gridColumns=props.gridColumns;var _useContext=useContext(ProTableContext),selectedRowKeys=_useContext.selectedRowKeys,setSelectedRowKeys=_useContext.setSelectedRowKeys,setSelectedRows=_useContext.setSelectedRows,viewMode=_useContext.viewMode,setViewMode=_useContext.setViewMode,dataSource=_useContext.dataSource,setDataSource=_useContext.setDataSource,loading=_useContext.loading;var _useStyle=_sliced_to_array(useStyle("VlianTable"),2),wrapSSR=_useStyle[0],hashId=_useStyle[1];var _React_useState=_sliced_to_array(React.useState(columns),2),sortedColumns=_React_useState[0],setSortedColumns=_React_useState[1];var fieldsPerRow=tableProps.gridCardFieldsPerRow||3;var handleColumnsStateChange=React.useCallback(function(map){var newSortedColumns=_to_consumable_array(columns).sort(function(a,b){var _map_aKey,_map_bKey;var aKey=a.key||a.dataIndex;var bKey=b.key||b.dataIndex;var _map_aKey_order;var aOrder=(_map_aKey_order=(_map_aKey=map[aKey])===null||_map_aKey===void 0?void 0:_map_aKey.order)!==null&&_map_aKey_order!==void 0?_map_aKey_order:0;var _map_bKey_order;var bOrder=(_map_bKey_order=(_map_bKey=map[bKey])===null||_map_bKey===void 0?void 0:_map_bKey.order)!==null&&_map_bKey_order!==void 0?_map_bKey_order:0;return aOrder-bOrder});setSortedColumns(newSortedColumns)},[columns]);var defaultGridCardRender=React.useCallback(function(params){return React.createElement(GridCard,_object_spread_props(_object_spread({},params),{sortedColumns:sortedColumns,rowKey:tableProps.rowKey,fieldsPerRow:fieldsPerRow}))},[sortedColumns,tableProps.rowKey,fieldsPerRow]);var finalGridCardRender=gridCardRender||defaultGridCardRender;var handleGridSelectChange=React.useCallback(function(keys,rows){setSelectedRowKeys(keys);setSelectedRows(rows);if(rowSelection&&(typeof rowSelection==="undefined"?"undefined":_type_of(rowSelection))==="object"&&rowSelection.onChange){rowSelection.onChange(keys,rows)}},[rowSelection,setSelectedRowKeys,setSelectedRows]);var mergedRowSelection=React.useMemo(function(){if(rowSelection===false){return false}if(!rowSelection){return undefined}return _object_spread_props(_object_spread({},rowSelection),{selectedRowKeys:selectedRowKeys,onChange:function(keys,selectedRowsData,info){setSelectedRowKeys(keys);if(selectedRowsData){setSelectedRows(selectedRowsData)}if(rowSelection&&(typeof rowSelection==="undefined"?"undefined":_type_of(rowSelection))==="object"&&rowSelection.onChange){if(rowSelection.onChange.length===3){rowSelection.onChange(keys,selectedRowsData||[],info||{})}else{rowSelection.onChange(keys,selectedRowsData||[])}}}})},[rowSelection,selectedRowKeys,setSelectedRowKeys,setSelectedRows]);var mergedScroll=React.useMemo(function(){var defaultScroll={x:true};if(tableProps.scroll){return _object_spread({},defaultScroll,tableProps.scroll)}return defaultScroll},[tableProps.scroll]);var mergedOptions=React.useMemo(function(){var defaultOptions=tableProps.options||{};var _defaultOptions_fullScreen,_defaultOptions_reload,_defaultOptions_setting,_defaultOptions_density;return _object_spread_props(_object_spread({},defaultOptions),{fullScreen:(_defaultOptions_fullScreen=defaultOptions.fullScreen)!==null&&_defaultOptions_fullScreen!==void 0?_defaultOptions_fullScreen:true,reload:(_defaultOptions_reload=defaultOptions.reload)!==null&&_defaultOptions_reload!==void 0?_defaultOptions_reload:true,setting:(_defaultOptions_setting=defaultOptions.setting)!==null&&_defaultOptions_setting!==void 0?_defaultOptions_setting:true,density:(_defaultOptions_density=defaultOptions.density)!==null&&_defaultOptions_density!==void 0?_defaultOptions_density:true})},[tableProps.options]);var toolbar=React.useMemo(function(){var _tableProps_toolbar;var toggleViewMode=function(){setViewMode(viewMode==="table"?"grid":"table")};return _object_spread_props(_object_spread({},tableProps.toolbar),{actions:_to_consumable_array(((_tableProps_toolbar=tableProps.toolbar)===null||_tableProps_toolbar===void 0?void 0:_tableProps_toolbar.actions)||[]).concat([React.createElement(Tooltip,{key:"view-mode-switch",title:viewMode==="table"?"切换到网格视图":"切换到列表视图"},React.createElement("div",{onClick:toggleViewMode,className:"VlianTable-view-switch ".concat(hashId)},viewMode==="table"?React.createElement(AppstoreOutlined,null):React.createElement(TableOutlined,null)))])})},[tableProps.toolbar,viewMode,setViewMode]);return wrapSSR(React.createElement("div",{className:"VlianTable-list ".concat(hashId)},React.createElement(AntdProTable,_object_spread_props(_object_spread({},tableProps),{className:viewMode==="grid"?"VlianTable-grid-mode ".concat(hashId):undefined,columns:columns,search:false,cardProps:false,headerTitle:headerTitle,rowSelection:mergedRowSelection,pagination:pagination,actionRef:actionRef,scroll:mergedScroll,options:mergedOptions,toolbar:toolbar,onDataSourceChange:function(datas){setDataSource(datas)},onColumnsStateChange:function(map){var _tableProps_onColumnsStateChange;handleColumnsStateChange(map);(_tableProps_onColumnsStateChange=tableProps.onColumnsStateChange)===null||_tableProps_onColumnsStateChange===void 0?void 0:_tableProps_onColumnsStateChange.call(tableProps,map)},tableRender:function(_,dom){if(viewMode==="grid"){return React.createElement(React.Fragment,null,dom,React.createElement("div",null,React.createElement(Spin,{spinning:loading},React.createElement(GridView,{dataSource:dataSource,cardRender:finalGridCardRender,gridColumns:gridColumns,pagination:pagination,actionRef:actionRef,rowSelection:rowSelection,selectedRowKeys:selectedRowKeys,onSelectChange:handleGridSelectChange,rowKey:tableProps.rowKey}))))}return dom}}))))};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { VlianTableMode, OperationType } from "../types";
|
|
3
|
-
import type { DrawerProps } from "antd";
|
|
4
|
-
import type { ModalProps } from "../../Modal/components/antd";
|
|
5
|
-
export interface OperationContainerProps {
|
|
6
|
-
/**
|
|
7
|
-
* 操作模式
|
|
8
|
-
*/
|
|
9
|
-
mode: VlianTableMode;
|
|
10
|
-
/**
|
|
11
|
-
* 操作类型
|
|
12
|
-
*/
|
|
13
|
-
operationType: OperationType;
|
|
14
|
-
/**
|
|
15
|
-
* 是否显示
|
|
16
|
-
*/
|
|
17
|
-
visible: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* 关闭回调
|
|
20
|
-
*/
|
|
21
|
-
onClose: () => void;
|
|
22
|
-
/**
|
|
23
|
-
* 子组件
|
|
24
|
-
*/
|
|
25
|
-
children: React.ReactNode;
|
|
26
|
-
/**
|
|
27
|
-
* Modal 配置
|
|
28
|
-
*/
|
|
29
|
-
modalProps?: Omit<ModalProps, 'open' | 'onCancel' | 'children'>;
|
|
30
|
-
/**
|
|
31
|
-
* Drawer 配置
|
|
32
|
-
*/
|
|
33
|
-
drawerProps?: Omit<DrawerProps, 'open' | 'onClose' | 'children'>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 操作容器组件
|
|
37
|
-
* 根据 mode 渲染不同的容器(Modal/Drawer)
|
|
38
|
-
*/
|
|
39
|
-
export declare const OperationContainer: React.FC<OperationContainerProps>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}import React from"react";import{Drawer}from"antd";import{Modal}from"../../Modal/components/antd";import{useLocale}from"../../locale";export var OperationContainer=function(props){var mode=props.mode,operationType=props.operationType,visible=props.visible,onClose=props.onClose,children=props.children,modalProps=props.modalProps,drawerProps=props.drawerProps;var messages=useLocale().messages;var getTitle=function(){switch(operationType){case"create":return messages.table.createTitle||"新增";case"update":return messages.table.updateTitle||"编辑";case"view":return messages.table.viewTitle||"查看";default:return""}};if(mode==="modal"){return React.createElement(Modal,_object_spread({title:getTitle(),open:visible,onCancel:onClose,footer:null,width:800,maxHeight:"80vh"},modalProps),children)}if(mode==="drawer"){return React.createElement(Drawer,_object_spread({title:getTitle(),open:visible,onClose:onClose,width:720},drawerProps),children)}return React.createElement(React.Fragment,null,children)};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { OperationType, OperationContentRender, FormConfig } from '../types';
|
|
2
|
-
import type { ProColumns } from "@ant-design/pro-components";
|
|
3
|
-
export interface OperationContentRouterProps<T = any, ValueType extends string = 'text'> {
|
|
4
|
-
/**
|
|
5
|
-
* 操作类型
|
|
6
|
-
*/
|
|
7
|
-
type: OperationType;
|
|
8
|
-
/**
|
|
9
|
-
* 当前记录
|
|
10
|
-
*/
|
|
11
|
-
currentRecord: T | null;
|
|
12
|
-
/**
|
|
13
|
-
* 操作内容渲染函数
|
|
14
|
-
*/
|
|
15
|
-
operationContent?: OperationContentRender<T>;
|
|
16
|
-
/**
|
|
17
|
-
* 关闭回调
|
|
18
|
-
*/
|
|
19
|
-
onClose: () => void;
|
|
20
|
-
/**
|
|
21
|
-
* 成功回调
|
|
22
|
-
*/
|
|
23
|
-
onSuccess: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* 表格列配置(用于自动生成表单)
|
|
26
|
-
*/
|
|
27
|
-
tableColumns?: ProColumns<T, ValueType>[];
|
|
28
|
-
/**
|
|
29
|
-
* 表单配置
|
|
30
|
-
*/
|
|
31
|
-
formConfig?: FormConfig<T, ValueType>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Router 模式下的操作内容包装器
|
|
35
|
-
* 在关闭或成功时自动导航回列表页
|
|
36
|
-
*/
|
|
37
|
-
export declare const OperationContentRouter: <T extends Record<string, any> = Record<string, any>, ValueType extends string = "text">(props: OperationContentRouterProps<T, ValueType>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React from"react";import{useNavigate}from"react-router-dom";import{OperationContent}from"./operation-content";export var OperationContentRouter=function(props){var type=props.type,currentRecord=props.currentRecord,operationContent=props.operationContent,onClose=props.onClose,onSuccess=props.onSuccess,tableColumns=props.tableColumns,formConfig=props.formConfig;var navigate=useNavigate();var handleClose=React.useCallback(function(){onClose();navigate("/")},[onClose,navigate]);var handleSuccess=React.useCallback(function(){onSuccess();navigate("/")},[onSuccess,navigate]);if(operationContent){return React.createElement(React.Fragment,null,operationContent({type:type,record:currentRecord||undefined,onClose:handleClose,onSuccess:handleSuccess}))}return React.createElement(OperationContent,{type:type,record:currentRecord||undefined,onClose:handleClose,onSuccess:handleSuccess,tableColumns:tableColumns,formConfig:formConfig})};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { OperationType, FormConfig } from "../types";
|
|
2
|
-
import type { ProColumns } from "@ant-design/pro-components";
|
|
3
|
-
export interface OperationContentProps<T = any, ValueType extends string = 'text'> {
|
|
4
|
-
/**
|
|
5
|
-
* 操作类型
|
|
6
|
-
*/
|
|
7
|
-
type: OperationType;
|
|
8
|
-
/**
|
|
9
|
-
* 当前记录(编辑和查看时使用)
|
|
10
|
-
*/
|
|
11
|
-
record?: T;
|
|
12
|
-
/**
|
|
13
|
-
* 关闭回调
|
|
14
|
-
*/
|
|
15
|
-
onClose: () => void;
|
|
16
|
-
/**
|
|
17
|
-
* 成功回调(用于刷新列表)
|
|
18
|
-
*/
|
|
19
|
-
onSuccess?: (result: any) => void;
|
|
20
|
-
/**
|
|
21
|
-
* 表格列配置(用于自动生成表单)
|
|
22
|
-
*/
|
|
23
|
-
tableColumns?: ProColumns<T, ValueType>[];
|
|
24
|
-
/**
|
|
25
|
-
* 表单配置
|
|
26
|
-
*/
|
|
27
|
-
formConfig?: FormConfig<T, ValueType>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 操作内容组件
|
|
31
|
-
* 用于显示具体的操作内容(新增/编辑/查看)
|
|
32
|
-
*
|
|
33
|
-
* 支持内置表单和自定义内容
|
|
34
|
-
*/
|
|
35
|
-
export declare const OperationContent: <T extends Record<string, any> = Record<string, any>, ValueType extends string = "text">(props: OperationContentProps<T, ValueType>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import React from"react";import{FormContent}from"./form-content";import{FormFooter}from"./form-footer";import{message}from"antd";import useStyle from"../styles";export var OperationContent=function(props){var type=props.type,record=props.record,onClose=props.onClose,onSuccess=props.onSuccess,_props_tableColumns=props.tableColumns,tableColumns=_props_tableColumns===void 0?[]:_props_tableColumns,formConfig=props.formConfig;var formRef=React.useRef(null);var _React_useState=_sliced_to_array(React.useState(false),2),loading=_React_useState[0],setLoading=_React_useState[1];var _useStyle=_sliced_to_array(useStyle("VlianTable"),2),wrapSSR=_useStyle[0],hashId=_useStyle[1];if(!formConfig||formConfig.enabled===false){return wrapSSR(React.createElement("div",{className:"VlianTable-operation-placeholder ".concat(hashId)},React.createElement("div",null,"当前操作类型: ",type),React.createElement("div",null,"请通过 operationContent 属性自定义渲染内容,或配置 formConfig 使用内置表单")))}var handleSubmit=function(){return _async_to_generator(function(){var form,values,result,successMsg,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:form=formRef.current;if(!form)return[2];setLoading(true);_state.label=1;case 1:_state.trys.push([1,5,6,7]);return[4,form.validateFields()];case 2:values=_state.sent();if(!formConfig.onSubmit)return[3,4];return[4,formConfig.onSubmit(values,type,record)];case 3:result=_state.sent();if(result===false){return[2]}_state.label=4;case 4:if(formConfig.showMessage){successMsg=type==="create"?"创建成功":type==="update"?"更新成功":"提交成功";message.success(successMsg)}onSuccess===null||onSuccess===void 0?void 0:onSuccess(result);onClose();return[3,7];case 5:error=_state.sent();console.error("表单提交失败:",error);if(formConfig.showMessage){if(error===null||error===void 0?void 0:error.errorFields){message.error("请检查表单字段")}else{message.error((error===null||error===void 0?void 0:error.message)||"提交失败")}}return[3,7];case 6:setLoading(false);return[7];case 7:return[2]}})})()};var renderFooter=function(){if(formConfig.footerRender!==undefined){if(formConfig.footerRender===false){return null}return formConfig.footerRender({type:type,record:record,form:formRef.current,onSubmit:handleSubmit,onCancel:onClose,loading:loading})}return React.createElement(FormFooter,{type:type,submitText:type==="create"?formConfig.createSubmitText:formConfig.updateSubmitText,cancelText:formConfig.cancelText,loading:loading,onSubmit:handleSubmit,onCancel:onClose})};return React.createElement(React.Fragment,null,React.createElement(FormContent,{type:type,record:record,tableColumns:tableColumns,formConfig:formConfig,formRef:formRef}),renderFooter())};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type RowActionsProps } from './row-actions';
|
|
2
|
-
/**
|
|
3
|
-
* Router 模式下的行操作按钮组件
|
|
4
|
-
* 在 Router 模式下,点击操作按钮会导航到对应的路由
|
|
5
|
-
*/
|
|
6
|
-
export declare const RowActionsRouter: <T extends Record<string, any> = Record<string, any>>(props: RowActionsProps<T> & {
|
|
7
|
-
rowKey?: string | ((record: T) => string | number);
|
|
8
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _object_without_properties(source,excluded){if(source==null)return{};var target=_object_without_properties_loose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _object_without_properties_loose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import React from"react";import{useNavigate}from"react-router-dom";import{RowActions}from"./row-actions";export var RowActionsRouter=function(props){var navigate=useNavigate();var record=props.record,onView=props.onView,onUpdate=props.onUpdate,_props_rowKey=props.rowKey,rowKey=_props_rowKey===void 0?"id":_props_rowKey,restProps=_object_without_properties(props,["record","onView","onUpdate","rowKey"]);var getRecordId=function(){if(typeof rowKey==="function"){return rowKey(record)}return record[rowKey]};var handleView=function(record,index){return _async_to_generator(function(){var id;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onView)return[3,2];return[4,onView(record,index)];case 1:_state.sent();_state.label=2;case 2:id=getRecordId();navigate("/view/".concat(id));return[2]}})})()};var handleUpdate=function(record,index){return _async_to_generator(function(){var id;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onUpdate)return[3,2];return[4,onUpdate(record,index)];case 1:_state.sent();_state.label=2;case 2:id=getRecordId();navigate("/update/".concat(id));return[2]}})})()};return React.createElement(RowActions,_object_spread_props(_object_spread({},restProps),{record:record,onView:handleView,onUpdate:handleUpdate}))};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Router 模式下的导航 Hook
|
|
3
|
-
*/
|
|
4
|
-
export declare const useRouterNavigation: () => {
|
|
5
|
-
operationType: import("..").OperationType;
|
|
6
|
-
navigateToCreate: () => void;
|
|
7
|
-
navigateToUpdate: (id: string | number) => void;
|
|
8
|
-
navigateToView: (id: string | number) => void;
|
|
9
|
-
navigateToList: () => void;
|
|
10
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useNavigate,useLocation}from"react-router-dom";import{useContext,useEffect}from"react";import{ProTableContext}from"../context";export var useRouterNavigation=function(){var navigate=useNavigate();var location=useLocation();var _useContext=useContext(ProTableContext),operationType=_useContext.operationType,setOperationType=_useContext.setOperationType;useEffect(function(){var path=location.pathname;if(path==="/"||path===""){setOperationType("list")}else if(path==="/create"){setOperationType("create")}else if(path.includes("/update/")||path.includes("/edit/")){setOperationType("update")}else if(path.includes("/view/")||path.includes("/detail/")){setOperationType("view")}},[location.pathname,setOperationType]);var navigateToCreate=function(){navigate("/create")};var navigateToUpdate=function(id){navigate("/update/".concat(id))};var navigateToView=function(id){navigate("/view/".concat(id))};var navigateToList=function(){navigate("/")};return{operationType:operationType,navigateToCreate:navigateToCreate,navigateToUpdate:navigateToUpdate,navigateToView:navigateToView,navigateToList:navigateToList}};
|
|
File without changes
|