@nocobase/plugin-action-import 2.1.0-beta.9 → 2.1.0
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/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/ImportActionInitializer.d.ts +2 -6
- package/dist/client/buildImportFieldOptions.d.ts +9 -0
- package/dist/client/constants.d.ts +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +1 -1
- package/dist/client/locale/index.d.ts +2 -1
- package/dist/client/useFields.d.ts +1 -1
- package/dist/{client/models → client-v2}/ImportActionModel.d.ts +2 -2
- package/dist/client-v2/buildImportFieldOptions.d.ts +9 -0
- package/dist/{client/models → client-v2}/getOptionFields.d.ts +1 -1
- package/dist/client-v2/importSupport.d.ts +15 -0
- package/dist/client-v2/index.d.ts +15 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +9 -0
- package/dist/externalVersion.js +11 -11
- package/dist/node_modules/exceljs/excel.js +15 -15
- package/dist/node_modules/exceljs/package.json +1 -1
- package/dist/node_modules/xlsx/dist/xlsx.core.min.js +17 -16
- package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +378 -80
- package/dist/node_modules/xlsx/dist/xlsx.full.min.js +17 -17
- package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +9 -9
- package/dist/node_modules/xlsx/package.json +1 -1
- package/dist/node_modules/xlsx/types/index.d.ts +40 -8
- package/dist/node_modules/xlsx/xlsx.js +4 -4
- package/dist/server/actions/import-xlsx.d.ts +3 -0
- package/dist/server/actions/import-xlsx.js +16 -8
- package/dist/server/services/xlsx-importer.d.ts +12 -4
- package/dist/server/services/xlsx-importer.js +82 -45
- package/package.json +4 -3
package/client-v2.d.ts
ADDED
package/client-v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client-v2/index.js');
|
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
|
-
|
|
11
|
-
importColumns: any;
|
|
12
|
-
explain: string;
|
|
13
|
-
};
|
|
10
|
+
import { DownloadTips, ImportWarning, initImportSettings } from '../client-v2/importSupport';
|
|
14
11
|
export declare const ImportActionInitializer: () => React.JSX.Element;
|
|
15
|
-
export
|
|
16
|
-
export declare const DownloadTips: () => React.JSX.Element;
|
|
12
|
+
export { DownloadTips, ImportWarning, initImportSettings };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { buildImportFieldOptions } from '../client-v2/buildImportFieldOptions';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ export * from './ImportDesigner';
|
|
|
11
11
|
export * from './ImportPluginProvider';
|
|
12
12
|
export * from './useImportAction';
|
|
13
13
|
import { Plugin } from '@nocobase/client';
|
|
14
|
+
export { buildImportFieldOptions } from '../client-v2/buildImportFieldOptions';
|
|
14
15
|
export declare class PluginActionImportClient extends Plugin {
|
|
15
16
|
load(): Promise<void>;
|
|
16
17
|
}
|
|
18
|
+
export { ImportActionModel } from '../client-v2/ImportActionModel';
|
|
17
19
|
export default PluginActionImportClient;
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("react-dom"),require("react"),require("@formily/antd-v5"),require("@emotion/css"),require("@nocobase/flow-engine"),require("lodash"),require("file-saver"),require("@formily/shared"),require("@nocobase/client"),require("@formily/reactive"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import",["@formily/core","react-dom","react","@formily/antd-v5","@emotion/css","@nocobase/flow-engine","lodash","file-saver","@formily/shared","@nocobase/client","@formily/reactive","@formily/react","@nocobase/utils/client","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import"]=t(require("@formily/core"),require("react-dom"),require("react"),require("@formily/antd-v5"),require("@emotion/css"),require("@nocobase/flow-engine"),require("lodash"),require("file-saver"),require("@formily/shared"),require("@nocobase/client"),require("@formily/reactive"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-action-import"]=t(e["@formily/core"],e["react-dom"],e.react,e["@formily/antd-v5"],e["@emotion/css"],e["@nocobase/flow-engine"],e.lodash,e["file-saver"],e["@formily/shared"],e["@nocobase/client"],e["@formily/reactive"],e["@formily/react"],e["@nocobase/utils/client"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,f,m,d,y){return function(){"use strict";var v={482:function(e){e.exports=m},964:function(e){e.exports=o},632:function(e){e.exports=r},563:function(t){t.exports=e},505:function(e){e.exports=p},229:function(e){e.exports=s},875:function(e){e.exports=c},772:function(e){e.exports=u},667:function(e){e.exports=i},584:function(e){e.exports=f},721:function(e){e.exports=d},346:function(e){e.exports=l},467:function(e){e.exports=a},156:function(e){e.exports=n},111:function(e){e.exports=t},238:function(e){e.exports=y}},b={};function h(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return v[e](n,n.exports,h),n.exports}h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var g={};return!function(){h.r(g),h.d(g,{PluginActionImportClient:function(){return eU},ImportActionInitializer:function(){return m},useImportStartAction:function(){return H},DownloadTips:function(){return y},initImportSettings:function(){return f},ImportContextProvider:function(){return eo},ImportWarning:function(){return d},ImportDesigner:function(){return T},default:function(){return e_},useDownloadXlsxTemplateAction:function(){return $},ImportPluginProvider:function(){return er}});var e,t=h(875),n=h(772),r=h(156),o=h.n(r),i=h(238);function a(){return(0,i.useTranslation)(["action-import","client"],{nsMode:"fallback"})}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var c=["createdAt","createdBy","updatedAt","updatedBy"],u=function(e){var t=(0,n.useCollectionManager_deprecated)().getCollectionFields,r=t(e),o=(0,n.useCompile)(),i=function(e,n){if(!(!e.interface||c.includes(e.interface))){var r={name:e.name,title:o(null==e||null==(i=e.uiSchema)?void 0:i.title)||e.name,schema:null==e?void 0:e.uiSchema};if(!e.target||n>=2)return r;if(e.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(e.type)){var i,u,s=a(t(e.target),n+1).filter(Boolean);r.children=r.children||[],(u=r.children).push.apply(u,function(e){if(Array.isArray(e))return l(e)}(s)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(s)||function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}}(s)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}return r}},a=function(e,t){var n=[];return e.forEach(function(e){var r=i(e,t);r&&n.push(r)}),n};return a(r,1)},s=h(721),p=h(584),f=function(e){return{importColumns:null==e?void 0:e.filter(function(e){return!e.children}).map(function(e){return{dataIndex:[e.name]}}),explain:""}},m=function(){var e=(0,n.useSchemaInitializerItem)(),r=(0,n.useSchemaInitializer)().insert,i=u((0,n.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Import") }}',"x-component":"ImportAction","x-action":"importXlsx","x-settings":"actionSettings:import","x-toolbar":"ActionSchemaToolbar"};return o().createElement(n.SchemaInitializerItem,{title:e.title,onClick:function(){p.lodash.set(a,"x-action-settings.importSettings",f(i));var n,o=(0,t.merge)(a||{},e.schema||{});null==e||null==(n=e.schemaInitialize)||n.call(e,o),r(o)}})},d=function(){var e=a().t;return o().createElement(s.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},y=function(){var e=a().t;return o().createElement(s.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},v=h(632),b=h(505),x="action-import";function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function I(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function O(){var e=I(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return O=function(){return e},e}function w(){var e=I(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return w=function(){return e},e}var A=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],j=function(){var e=(0,i.useTranslation)(x).t,t=u((0,n.useCollection_deprecated)().name),r=(0,n.useCompile)();return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(x,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,n.css)(O())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":n.Cascader,required:!0,"x-use-component-props":function(){return{options:r(t)}},"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(x,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(x,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(w())}}}}}},beforeUploadHandler:function(){return!1},uploadValidator:function(t,n){if(t.length>1)return{type:"error",message:e("Only one file is allowed to be uploaded")};var r,o=null!=(r=t[0])?r:{};return A.includes(o.type)?"":{type:"error",message:e("Please upload the file of Excel")}},validateUpload:function(e,t,n){var r,o,i,a=(function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(n,1)||function(e,t){if(e){if("string"==typeof e)return S(e,1);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}}(n,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];t.disabled=(null==a?void 0:a.length)===0,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t.componentProps),o=o={disabled:(null==a?void 0:a.length)===0||(null==(i=e.errors)?void 0:i.length)>0},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),t.componentProps=r}}};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){C(e,t,n[t])})}return e}var T=function(){var e,t,a,l,c,u,s,p=(0,b.useField)(),f=(0,b.useFieldSchema)(),m=(0,i.useTranslation)().t,d=(0,n.useDesignable)().dn,y=(e=(0,r.useState)(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,2)||function(e,t){if(e){if("string"==typeof e)return P(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return P(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),h=y[0],g=y[1],x=j().importSettingsSchema;return(0,r.useEffect)(function(){g(x)},[p.address,null==f||null==(t=f["x-action-settings"])?void 0:t.importSettings]),o().createElement(n.GeneralSchemaDesigner,{disableInitializer:!0},o().createElement(n.SchemaSettingsModalItem,{title:m("Edit button"),schema:{type:"object",title:m("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:m("Button title"),default:f.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:m("Button icon"),default:null==f||null==(a=f["x-component-props"])?void 0:a.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:m("Button background color"),default:(null==f||null==(l=f["x-component-props"])?void 0:l.danger)?"danger":(null==f||null==(c=f["x-component-props"])?void 0:c.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:function(e){var t,n=e.title,r=e.icon,o=e.type;f.title=n,p.title=n,p.componentProps.icon=r,p.componentProps.danger="danger"===o,p.componentProps.type=o,f["x-component-props"]=f["x-component-props"]||{},f["x-component-props"].icon=r,f["x-component-props"].danger="danger"===o,f["x-component-props"].type=o,d.emit("patch",{schema:(C(t={},"x-uid",f["x-uid"]),C(t,"title",n),C(t,"x-component-props",E({},f["x-component-props"])),t)}),d.refresh()}}),o().createElement(n.SchemaSettingsActionModalItem,{title:m("Importable fields"),schema:h,initialValues:E({},null!=(s=null==f||null==(u=f["x-action-settings"])?void 0:u.importSettings)?s:{}),components:{ArrayItems:v.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title}});f["x-action-settings"].importSettings={importColumns:o,explain:r},d.emit("patch",{schema:(C(t={},"x-uid",f["x-uid"]),C(t,"x-action-settings",f["x-action-settings"]),t)}),d.refresh()}}),o().createElement(n.SchemaSettingsDivider,null),o().createElement(n.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:m("Delete action")}}))},F=h(111),k=(0,r.createContext)(null);k.displayName="ImportContext";var D=function(){return(0,r.useContext)(k)},M=h(482),B=h(346);function q(){var e,t,n=(e=["\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return q=function(){return n},n}var R={IMPORTING:1,IMPORTED:2},U=function(e){var t=(0,i.useTranslation)(x).t,r=D(),a=r.importModalVisible,l=r.importStatus,c=r.importResult,u=r.setImportModalVisible,p=null!=c?c:{},f=p.data,m=p.meta,d=function(){u(!1)};return o().createElement(s.Modal,{title:t("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:a,footer:null,closable:l===R.IMPORTED,onCancel:d},o().createElement("div",{className:(0,n.css)(q())},l===R.IMPORTING&&o().createElement(s.Spin,{indicator:o().createElement(M.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:t("Excel data importing")}),l===R.IMPORTED&&o().createElement(s.Space,{direction:"vertical",align:"center"},o().createElement(M.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),o().createElement("p",null,function(e){if(!e)return null;var n=e.data,r=e.meta;if(r)return t("{{successCount}} records have been successfully imported",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},null!=r?r:{}));var o=["".concat(t("Total records"),": ").concat(n.total||0),"".concat(t("Successfully imported"),": ").concat(n.success||0)];return n.skipped>0&&o.push("".concat(t("Skipped"),": ").concat(n.skipped)),n.updated>0&&o.push("".concat(t("Updated"),": ").concat(n.updated)),o.join(", ")}(c)),o().createElement(s.Space,null,(null==m?void 0:m.failureCount)>0&&o().createElement(s.Button,{onClick:function(){var e=new Blob([new Int8Array(null==f?void 0:f.data)],{type:"application/x-xls"});(0,B.saveAs)(e,"fail.xlsx")}},t("To download the failure data")),o().createElement(s.Button,{type:"primary",onClick:d},t("Done"))))))},_=h(467),z=h.n(_);function N(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function V(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){N(i,r,o,a,l,"next",e)}function l(e){N(i,r,o,a,l,"throw",e)}a(void 0)})}}function X(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var G=function(){for(var e=(0,n.useActionContext)().fieldSchema,t=(0,b.useFieldSchema)(),r=e||t;r&&"importXlsx"!==r["x-action"];)console.log("schema",r=r.parent);return{schema:r}},L=function(e){return e&&Array.isArray(e)?e:[]},$=function(){var e=(0,n.useBlockRequestContext)().resource,t=(0,n.useCompile)(),r=(0,n.useCollectionManager_deprecated)(),o=r.getCollectionJoinField,i=r.getCollectionField,a=(0,n.useCollection_deprecated)(),l=a.name,c=a.title,u=G().schema;return{run:function(){return V(function(){var n,r,a,s,p,f,m;return X(this,function(d){switch(d.label){case 0:return s=(a=z().cloneDeep(null!=(r=null==u||null==(n=u["x-action-settings"])?void 0:n.importSettings)?r:{})).importColumns,p=a.explain,f=L(s).map(function(e){var n=i("".concat(l,".").concat(e.dataIndex[0]));if(n){if(e.defaultTitle=t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,e.dataIndex.length>1){var r,a,c=o("".concat(l,".").concat(e.dataIndex.join(".")));if(!c)return;e.defaultTitle=e.defaultTitle+"/"+t(null==c||null==(a=c.uiSchema)?void 0:a.title)||c.name}return"chinaRegion"===n.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),[4,e.downloadXlsxTemplate({values:{title:t(c),explain:p,columns:t(f)}},{method:"post",responseType:"blob"})];case 1:return m=new Blob([d.sent().data],{type:"application/x-xls"}),(0,B.saveAs)(m,"".concat(t(c),".xlsx")),[2]}})})()}}},H=function(){var e,t=(0,n.useBlockRequestContext)().service,o=(0,n.useCompile)(),i=(0,n.useCollectionManager_deprecated)(),a=i.getCollectionJoinField,l=i.getCollectionField,c=(0,n.useCollection_deprecated)().name,u=G().schema,s=(0,b.useForm)(),p=(0,n.useActionContext)().setVisible,f=D(),m=f.setImportModalVisible,d=f.setImportStatus,y=f.setImportResult,v=s.values.upload,h=(0,n.useDataBlockResource)();return(0,r.useEffect)(function(){s.reset()},[]),{run:function(){return V(function(){var e,n,r,i,f,v,b,g,x,S,I,O,w,A;return X(this,function(j){switch(j.label){case 0:v=(f=z().cloneDeep(null!=(i=null==u||null==(e=u["x-action-settings"])?void 0:e.importSettings)?i:{})).importColumns,b=f.explain,g=L(v).map(function(e){var t=l("".concat(c,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=o(null==t||null==(n=t.uiSchema)?void 0:n.title)||t.name,e.dataIndex.length>1){var n,r,i=a("".concat(c,".").concat(e.dataIndex.join(".")));if(!i)return;e.defaultTitle=e.defaultTitle+"/"+o(null==i||null==(r=i.uiSchema)?void 0:r.title)||i.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),x=new FormData,S=s.values.upload.map(function(e){return e.originFileObj}),x.append("file",S[0]),x.append("columns",JSON.stringify(g)),x.append("explain",b),I=(null==u||null==(n=u["x-action-settings"])?void 0:n.importMode)||"auto",O=(null==u||null==(r=u["x-action-settings"])?void 0:r.timeout)||6e5,p(!1),m(!0),d(R.IMPORTING),j.label=1;case 1:return j.trys.push([1,6,,7]),[4,h.importXlsx({values:x,mode:I,timeout:O})];case 2:if(w=j.sent().data,s.reset(),w.data.taskId)return[3,4];return y(w),[4,null==t||null==(A=t.refresh)?void 0:A.call(t)];case 3:return j.sent(),d(R.IMPORTED),[3,5];case 4:m(!1),p(!1),j.label=5;case 5:return[3,7];case 6:return j.sent(),m(!1),p(!0),[3,7];case 7:return[2]}})})()},disabled:(null==v?void 0:v.length)===0||(null==(e=s.errors)?void 0:e.length)>0}},W=h(964);function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function K(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Q(){var e=K(["\n .ant-formily-item-label {\n height: var(--controlHeightLG);\n }\n "]);return Q=function(){return e},e}function Y(){var e=K(["\n margin-top: 5px;\n "]);return Y=function(){return e},e}var Z={type:"void",name:"import-modal",title:'{{ t("Import Data", {ns: "'.concat(x,'" }) }}'),"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:(0,W.css)(Q())},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:'{{ t("Step 1: Download template", {ns: "'.concat(x,'" }) }}'),"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:'{{ t("Download template", {ns: "'.concat(x,'" }) }}'),"x-component":"Action","x-component-props":{className:(0,W.css)(Y()),useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:'{{ t("Step 2: Upload Excel", {ns: "'.concat(x,'" }) }}'),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:'{{ t("Upload placeholder", {ns: "'.concat(x,'" }) }}'),beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:'{{ t("Start import", {ns: "'.concat(x,'" }) }}'),"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}},ee=function(e){var t,i,a,l=(t=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return J(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return J(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=l[0],u=l[1],s=(0,n.useCompile)(),p=(0,b.useFieldSchema)();return o().createElement(n.ActionContextProvider,{value:{visible:c,setVisible:u,fieldSchema:p}},o().createElement(n.Action,(i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({icon:e.icon||"uploadoutlined",title:s((null==p?void 0:p.title)||"t('Import')")},e),a=a={onClick:function(){return u(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i)),o().createElement(n.SchemaComponent,{schema:Z}))};function et(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function en(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return et(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return et(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var er=function(e){var t=j(),r=t.uploadValidator,i=t.beforeUploadHandler,a=t.validateUpload;return o().createElement(n.SchemaComponentOptions,{components:{ImportActionInitializer:m,ImportDesigner:T,ImportWarning:d,DownloadTips:y,ImportAction:ee},scope:{uploadValidator:r,validateUpload:a,beforeUploadHandler:i,useDownloadXlsxTemplateAction:$,useImportStartAction:H}},o().createElement(eo,null,e.children))},eo=function(e){var t=en((0,r.useState)(!1),2),n=t[0],i=t[1],a=en((0,r.useState)(R.IMPORTING),2),l=a[0],c=a[1],u=en((0,r.useState)(null),2),s=u[0],p=u[1];return o().createElement(k.Provider,{value:{importModalVisible:n,setImportModalVisible:i,importStatus:l,setImportStatus:c,importResult:s,setImportResult:p}},(0,F.createPortal)(o().createElement(U,null),document.body),e.children)};function ei(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ea(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function el(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ea(e,t,n[t])})}return e}var ec=new n.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:n.ButtonEditor,useComponentProps:function(){return(0,n.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:n.SchemaSettingsLinkageRules,useComponentProps:function(){return el({},(0,n.useSchemaToolbar)().linkageRulesProps)}},{name:"importableFields",type:"actionModal",useComponentProps:function(){var e,t,o,a,l=(0,b.useField)(),c=(0,b.useFieldSchema)(),u=(0,i.useTranslation)().t,s=(0,n.useDesignable)().dn,p=(e=(0,r.useState)(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,2)||function(e,t){if(e){if("string"==typeof e)return ei(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ei(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=p[0],m=p[1],d=j().importSettingsSchema;return(0,r.useEffect)(function(){m(d)},[l.address,null==c||null==(t=c["x-action-settings"])?void 0:t.importSettings]),{title:u("Importable fields"),schema:el({},f),initialValues:el({},null!=(a=null==c||null==(o=c["x-action-settings"])?void 0:o.importSettings)?a:{}),components:{ArrayItems:v.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});c["x-action-settings"].importSettings={importColumns:o,explain:r},s.emit("patch",{schema:(ea(t={},"x-uid",c["x-uid"]),ea(t,"x-action-settings",c["x-action-settings"]),t)}),s.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps:function(){return{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:(0,(0,i.useTranslation)().t)("Delete action")}}}}]}),eu=h(563),es=h(229),ep=h(667);function ef(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var em=["createdAt","createdBy","updatedAt","updatedBy"],ed=function(e,t){var n=function(e,n){if(!(!e.interface||em.includes(e.interface))){var o={name:e.name,title:t(null==e||null==(i=e.uiSchema)?void 0:i.title)||e.name,schema:null==e?void 0:e.uiSchema};if(!e.target||n>=2)return o;if(e.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(e.type)){var i,a,l=r(e.targetCollection&&e.targetCollection.getFields()||[],n+1).filter(Boolean);o.children=o.children||[],(a=o.children).push.apply(a,function(e){if(Array.isArray(e))return ef(e)}(l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||function(e,t){if(e){if("string"==typeof e)return ef(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ef(e,t)}}(l)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}return o}},r=function(e,t){var r=[];return e.forEach(function(e){var o=n(e,t);o&&r.push(o)}),r};return r(e,1)};function ey(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ev(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eb(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ev(i,r,o,a,l,"next",e)}function l(e){ev(i,r,o,a,l,"throw",e)}a(void 0)})}}function eh(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eg(e){return(eg=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ex(e,t){return(ex=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eS(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eI(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eI=function(){return!!e})()}function eO(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function ew(){var e=eS(["\n margin-top: 5px;\n "]);return ew=function(){return e},e}function eA(){var e=eS(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return eA=function(){return e},e}function ej(){var e=eS(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return ej=function(){return e},e}var eP=["id","createdAt","createdBy","updatedAt","updatedBy"],eC=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],eE={type:"object",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:(0,ep.escapeT)("Step 1: Download template",{ns:"".concat(x)}),"x-component":"FormItem",properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:(0,ep.escapeT)("Download template",{ns:"".concat(x)}),"x-component":"Button","x-component-props":{className:(0,W.css)(ew()),children:(0,ep.escapeT)("Download template",{ns:"".concat(x)}),onClick:"{{ handelDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:(0,ep.escapeT)("Step 2: Upload Excel",{ns:"".concat(x)}),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":function(e,t){var n,r=e.fileList;if(r.length>1)return{type:"error",message:(0,ep.escapeT)("Only one file is allowed to be uploaded")};var o=null!=(n=r[0])?n:{};return eC.includes(o.type)?"":{type:"error",message:(0,ep.escapeT)("Please upload the file of Excel")}},"x-component-props":{action:"",height:"150px",maxCount:1,children:(0,ep.escapeT)("Upload placeholder",{ns:"".concat(x)}),beforeUpload:function(){return!1}}}}},eT=(0,b.createSchemaField)({components:{ImportWarning:d,DownloadTips:y,Upload:s.Upload,FormItem:v.FormItem,Button:s.Button}}),eF=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=eg(t),eh(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eI()?Reflect.construct(t,r||[],eg(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,ep.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ex(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(n.ActionModel);function ek(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eD(e,t,n){return(eD=eR()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&eB(o,n.prototype),o}).apply(null,arguments)}eh(eF,"scene",n.ActionSceneEnum.collection),eF.define({label:(0,ep.escapeT)("Import")}),eF.registerFlow({key:"importSettings",title:(0,ep.escapeT)("Import settings"),on:"click",steps:{import:{handler:(e=eb(function(e,t){var n,r,i,a,l,c,u,p,f,m,d,y;return eO(this,function(t){switch(t.label){case 0:var h,g,S;return n=(0,es.observable)({status:"",result:null}),r=(0,eu.createForm)(),a=(i=e.model.context.blockModel).resource,c=(l=i.collection).title,u=l.name,f=(p=e.model.getProps().importSettings).explain,m=(!(h=p.importColumns)||!Array.isArray(h)?[]:h).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(i.collection.dataSourceKey,".").concat(u,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,o,a=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(u,".").concat(t.dataIndex.join(".")));if(!a)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==a||null==(o=a.uiSchema)?void 0:o.title)||a.name}return t}}).filter(Boolean),g=eb(function(){var t;return eO(this,function(n){switch(n.label){case 0:return[4,a.runAction("downloadXlsxTemplate",{data:{title:e.t(c),explain:f,columns:function(e){if(Array.isArray(e))return ey(e)}(m)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(m)||function(e,t){if(e){if("string"==typeof e)return ey(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ey(e,t)}}(m)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,B.saveAs)(t,"".concat(e.t(c),".xlsx")),[2]}})}),d=function(){return g.apply(this,arguments)},S=eb(function(t){var o,i,l,c,u,s,p,d;return eO(this,function(y){switch(y.label){case 0:o=r.values.upload.fileList,i=new FormData,l=o.map(function(e){return e.originFileObj}),i.append("file",l[0]),i.append("columns",JSON.stringify(m)),i.append("explain",f),c=e.model.getProps().importMode,n.status="importing",y.label=1;case 1:return y.trys.push([1,6,,7]),[4,a.runAction("importXlsx",{data:i,mode:c,timeout:6e5})];case 2:if(null==(s=y.sent().data)||null==(u=s.data)?void 0:u.taskId)return[3,4];return n.result=s,n.status="imported",[4,null==a||null==(p=a.refresh)?void 0:p.call(a)];case 3:return y.sent(),r.reset(),[3,5];case 4:t.close(),r.reset(),y.label=5;case 5:return[3,7];case 6:return d=y.sent(),n.status="",console.error(d),[3,7];case 7:return[2]}})}),y=(0,ep.observer)(function(t){var i=t.popover,a=e.t;if("importing"===n.status)return o().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},o().createElement(s.Spin,{tip:a("Excel data importing"),indicator:o().createElement(M.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===n.status){var l,c,u,p=null==(u=n.result)?void 0:u.meta;return o().createElement(s.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},o().createElement(M.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),o().createElement("p",null,function(e){if(!e)return null;var t=e.successCount;if(e.meta,t)return a("{{successCount}} records have been successfully imported",{successCount:t},{ns:x})}(n.result)),o().createElement(s.Space,null,(null==p?void 0:p.failureCount)>0&&o().createElement(s.Button,{onClick:function(){var e,t,r=new Blob([new Int8Array(null==(t=n.result)||null==(e=t.data)?void 0:e.data)],{type:"application/x-xls"});(0,B.saveAs)(r,"fail.xlsx")}},a("To download the failure data")),o().createElement(s.Button,{type:"primary",onClick:function(){i.close(),n.status="",n.result=null}},a("Done"))))}return o().createElement(b.FormProvider,{form:r},o().createElement(v.FormLayout,{layout:"vertical"},o().createElement(eT,{schema:eE,scope:{t:e.t,handelDownloadXlsxTemplateAction:d}})),o().createElement(v.FormButtonGroup,{align:"right"},o().createElement(s.Button,{onClick:function(){return i.close()}},a("Cancel")),o().createElement(s.Button,{type:"primary",onClick:function(){return function(e){return S.apply(this,arguments)}(i)},disabled:!(null==(c=r.values.upload)||null==(l=c.fileList)?void 0:l.length)},a("Start import",{ns:"".concat(x)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(x)}),content:function(e){return o().createElement(y,{popover:e})}})];case 1:return t.sent(),[2]}})}),function(t,n){return e.apply(this,arguments)})}}}),eF.registerFlow({key:"importActionSetting",title:(0,ep.escapeT)("Import action settings",{ns:x}),steps:{importSetting:{title:(0,ep.escapeT)("Importable fields"),uiSchema:function(e){var t=ed(e.model.context.blockModel.collection.getFields(),e.t);return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(x,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,W.css)(eA())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":n.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:t}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(x,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(x,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,W.css)(ej())}}}}}},defaultParams:function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eh(e,t,n[t])})}return e}({},{importColumns:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.isAssociationField()&&!(eP.includes(e.interface)||!e.options.interface)}).map(function(e){return{dataIndex:[e.name]}}),explain:""})},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});function eM(e){return(eM=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eB(e,t){return(eB=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eq(e){var t="function"==typeof Map?new Map:void 0;return(eq=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eD(e,arguments,eM(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eB(n,e)})(e)}function eR(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eR=function(){return!!e})()}var eU=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=eM(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eR()?Reflect.construct(e,t||[],eM(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&eB(r,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){var e,r;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(o){return t.app.use(er),e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,n.useActionAvailable)("importXlsx")}},null==(r=t.app.schemaInitializerManager.get("table:configureActions"))||r.add("enableActions.import",e),t.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),t.app.schemaSettingsManager.add(ec),t.app.flowEngine.registerModels({ImportActionModel:eF}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ek(i,r,o,a,l,"next",e)}function l(e){ek(i,r,o,a,l,"throw",e)}a(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,t),r}(eq(n.Plugin)),e_=eU}(),g}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import",["react-i18next","@emotion/css","react-dom","@formily/antd-v5","@formily/reactive","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/client-v2","@formily/shared","@formily/core","react","antd","@nocobase/client","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import"]=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-action-import"]=t(e["react-i18next"],e["@emotion/css"],e["react-dom"],e["@formily/antd-v5"],e["@formily/reactive"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@formily/shared"],e["@formily/core"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,f,m,d,y){return function(){var b={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},452:function(e){"use strict";e.exports=s},230:function(e){"use strict";e.exports=i},992:function(e){"use strict";e.exports=o},166:function(e){"use strict";e.exports=u},342:function(e){"use strict";e.exports=m},485:function(e){"use strict";e.exports=c},694:function(e){"use strict";e.exports=l},768:function(e){"use strict";e.exports=d},59:function(e){"use strict";e.exports=f},773:function(e){"use strict";e.exports=y},155:function(e){"use strict";e.exports=p},514:function(e){"use strict";e.exports=n},953:function(t){"use strict";t.exports=e}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e].call(n.exports,n,n.exports,h),n.exports}h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},h.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.g.importScripts&&(g=h.g.location+"");var g,x=h.g.document;if(!g&&x&&(x.currentScript&&"SCRIPT"===x.currentScript.tagName.toUpperCase()&&(g=x.currentScript.src),!g)){var w=x.getElementsByTagName("script");if(w.length)for(var S=w.length-1;S>-1&&(!g||!/^http(s?):/.test(g));)g=w[S--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");h.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var O={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client/"}h.p=e}(),!function(){"use strict";h.r(O),h.d(O,{useImportStartAction:function(){return J},default:function(){return eq},ImportActionInitializer:function(){return x},ImportContextProvider:function(){return ea},DownloadTips:function(){return g},ImportPluginProvider:function(){return ei},ImportDesigner:function(){return D},ImportWarning:function(){return v},ImportActionModel:function(){return eA},PluginActionImportClient:function(){return eR},buildImportFieldOptions:function(){return s},initImportSettings:function(){return b},useDownloadXlsxTemplateAction:function(){return W}});var e=h(166),t=h(342),n=h(155),r=h.n(n),o=["createdAt","createdBy","updatedAt","updatedBy"],i=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],a=function(e){return(null==e?void 0:e.target)&&i.includes(e.type)},l=function(e){return!(null==e?void 0:e.interface)||o.includes(e.interface)},c=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:null==e?void 0:e.uiSchema,disabled:n}},u=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(l(e))return null;if(!a(e))return c(e,t);var s=(n(e)||[]).map(function(e){return l(e)?null:a(e)?i>=1?c(e,t,!0):u(e,t,n,i+1):u(e,t,n)}).filter(Boolean);return s.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},c(e,t)),o=o={children:s},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):c(e,t,!0)},s=function(e,t,n){return(e||[]).map(function(e){return u(e,t,n,+!!a(e))}).filter(Boolean)},p=function(e){var n=(0,t.useCollectionManager_deprecated)().getCollectionFields,r=n(e),o=(0,t.useCompile)();return s(r,function(e){var t;return o(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return n(e.target)})},f=h(768),m=h(59),d=h(953),y="action-import",b=function(e){return{importColumns:null==e?void 0:e.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""}},v=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(m.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},g=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(m.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},x=function(){var n=(0,t.useSchemaInitializerItem)(),o=(0,t.useSchemaInitializer)().insert,i=p((0,t.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Import") }}',"x-component":"ImportAction","x-action":"importXlsx","x-settings":"actionSettings:import","x-toolbar":"ActionSchemaToolbar"};return r().createElement(t.SchemaInitializerItem,{title:n.title,onClick:function(){f.lodash.set(a,"x-action-settings.importSettings",b(i));var t,r=(0,e.merge)(a||{},n.schema||{});null==n||null==(t=n.schemaInitialize)||t.call(n,r),o(r)}})},w=h(418),S=h(230);function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(){var e=j(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return A=function(){return e},e}function P(){var e=j(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return P=function(){return e},e}var E=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],C=function(){var e=(0,d.useTranslation)(y).t,n=p((0,t.useCollection_deprecated)().name),r=(0,t.useCompile)();return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,t.css)(A())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":t.Cascader,required:!0,"x-use-component-props":function(){return{options:r(n)}},"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,t.css)(P())}}}}}},beforeUploadHandler:function(){return!1},uploadValidator:function(t,n){if(t.length>1)return{type:"error",message:e("Only one file is allowed to be uploaded")};var r,o=null!=(r=t[0])?r:{};return E.includes(o.type)?"":{type:"error",message:e("Please upload the file of Excel")}},validateUpload:function(e,t,n){var r,o,i,a=(function(e){if(Array.isArray(e))return e}(n)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||function(e){if(e){if("string"==typeof e)return I(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,1)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];t.disabled=(null==a?void 0:a.length)===0,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t.componentProps),o=o={disabled:(null==a?void 0:a.length)===0||(null==(i=e.errors)?void 0:i.length)>0},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),t.componentProps=r}}};function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){k(e,t,n[t])})}return e}var D=function(){var e,o,i,a,l,c,u,s=(0,S.useField)(),p=(0,S.useFieldSchema)(),f=(0,d.useTranslation)().t,m=(0,t.useDesignable)().dn,y=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return T(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return T(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),b=y[0],v=y[1],h=C().importSettingsSchema;return(0,n.useEffect)(function(){v(h)},[s.address,null==p||null==(i=p["x-action-settings"])?void 0:i.importSettings]),r().createElement(t.GeneralSchemaDesigner,{disableInitializer:!0},r().createElement(t.SchemaSettingsModalItem,{title:f("Edit button"),schema:{type:"object",title:f("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:f("Button title"),default:p.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:f("Button icon"),default:null==p||null==(a=p["x-component-props"])?void 0:a.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:f("Button background color"),default:(null==p||null==(l=p["x-component-props"])?void 0:l.danger)?"danger":(null==p||null==(c=p["x-component-props"])?void 0:c.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:function(e){var t,n=e.title,r=e.icon,o=e.type;p.title=n,s.title=n,s.componentProps.icon=r,s.componentProps.danger="danger"===o,s.componentProps.type=o,p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].icon=r,p["x-component-props"].danger="danger"===o,p["x-component-props"].type=o,m.emit("patch",{schema:(k(t={},"x-uid",p["x-uid"]),k(t,"title",n),k(t,"x-component-props",F({},p["x-component-props"])),t)}),m.refresh()}}),r().createElement(t.SchemaSettingsActionModalItem,{title:f("Importable fields"),schema:b,initialValues:F({},null!=(o=null==p||null==(u=p["x-action-settings"])?void 0:u.importSettings)?o:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title}});p["x-action-settings"].importSettings={importColumns:o,explain:r},m.emit("patch",{schema:(k(t={},"x-uid",p["x-uid"]),k(t,"x-action-settings",p["x-action-settings"]),t)}),m.refresh()}}),r().createElement(t.SchemaSettingsDivider,null),r().createElement(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:f("Delete action")}}))},M=h(514),_=(0,n.createContext)(null);_.displayName="ImportContext";var B=function(){return(0,n.useContext)(_)},R=h(375),q=h(574);function U(){var e,t,n=(e=["\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return U=function(){return n},n}var L=function(e){var n=(0,d.useTranslation)(y).t,o=B(),i=o.importModalVisible,a=o.importStatus,l=o.importResult,c=o.setImportModalVisible,u=null!=l?l:{},s=u.data,p=u.meta,f=function(){c(!1)};return r().createElement(m.Modal,{title:n("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:i,footer:null,closable:2===a,onCancel:f},r().createElement("div",{className:(0,t.css)(U())},1===a&&r().createElement(m.Spin,{indicator:r().createElement(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:n("Excel data importing")}),2===a&&r().createElement(m.Space,{direction:"vertical",align:"center"},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.data,r=e.meta;if(r)return n("{{successCount}} records have been successfully imported",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},null!=r?r:{}));var o=["".concat(n("Total records"),": ").concat(t.total||0),"".concat(n("Successfully imported"),": ").concat(t.success||0)];return t.skipped>0&&o.push("".concat(n("Skipped"),": ").concat(t.skipped)),t.updated>0&&o.push("".concat(n("Updated"),": ").concat(t.updated)),o.join(", ")}(l)),r().createElement(m.Space,null,(null==p?void 0:p.failureCount)>0&&r().createElement(m.Button,{onClick:function(){var e=new Blob([new Int8Array(null==s?void 0:s.data)],{type:"application/x-xls"});(0,q.saveAs)(e,"fail.xlsx")}},n("To download the failure data")),r().createElement(m.Button,{type:"primary",onClick:f},n("Done"))))))},z=h(773),N=h.n(z);function $(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function X(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){$(i,r,o,a,l,"next",e)}function l(e){$(i,r,o,a,l,"throw",e)}a(void 0)})}}function V(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var H=function(){for(var e=(0,t.useActionContext)().fieldSchema,n=(0,S.useFieldSchema)(),r=e||n;r&&"importXlsx"!==r["x-action"];)console.log("schema",r=r.parent);return{schema:r}},G=function(e){return e&&Array.isArray(e)?e:[]},W=function(){var e=(0,t.useBlockRequestContext)().resource,n=(0,t.useCompile)(),r=(0,t.useCollectionManager_deprecated)(),o=r.getCollectionJoinField,i=r.getCollectionField,a=(0,t.useCollection_deprecated)(),l=a.name,c=a.title,u=H().schema;return{run:function(){return X(function(){var t,r,a,s,p,f,m;return V(this,function(d){switch(d.label){case 0:return s=(a=N().cloneDeep(null!=(t=null==u||null==(r=u["x-action-settings"])?void 0:r.importSettings)?t:{})).importColumns,p=a.explain,f=G(s).map(function(e){var t=i("".concat(l,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=n(null==t||null==(r=t.uiSchema)?void 0:r.title)||t.name,e.dataIndex.length>1){var r,a,c=o("".concat(l,".").concat(e.dataIndex.join(".")));if(!c)return;e.defaultTitle=e.defaultTitle+"/"+n(null==c||null==(a=c.uiSchema)?void 0:a.title)||c.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),[4,e.downloadXlsxTemplate({values:{title:n(c),explain:p,columns:n(f)}},{method:"post",responseType:"blob"})];case 1:return m=new Blob([d.sent().data],{type:"application/x-xls"}),(0,q.saveAs)(m,"".concat(n(c),".xlsx")),[2]}})})()}}},J=function(){var e,r=(0,t.useBlockRequestContext)().service,o=(0,t.useCompile)(),i=(0,t.useCollectionManager_deprecated)(),a=i.getCollectionJoinField,l=i.getCollectionField,c=(0,t.useCollection_deprecated)().name,u=H().schema,s=(0,S.useForm)(),p=(0,t.useActionContext)().setVisible,f=B(),m=f.setImportModalVisible,d=f.setImportStatus,y=f.setImportResult,b=s.values.upload,v=(0,t.useDataBlockResource)();return(0,n.useEffect)(function(){s.reset()},[]),{run:function(){return X(function(){var e,t,n,i,f,b,h,g,x,w,S,O,I,j;return V(this,function(A){switch(A.label){case 0:b=(f=N().cloneDeep(null!=(e=null==u||null==(t=u["x-action-settings"])?void 0:t.importSettings)?e:{})).importColumns,h=f.explain,g=G(b).map(function(e){var t=l("".concat(c,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=o(null==t||null==(n=t.uiSchema)?void 0:n.title)||t.name,e.dataIndex.length>1){var n,r,i=a("".concat(c,".").concat(e.dataIndex.join(".")));if(!i)return;e.defaultTitle=e.defaultTitle+"/"+o(null==i||null==(r=i.uiSchema)?void 0:r.title)||i.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),x=new FormData,w=s.values.upload.map(function(e){return e.originFileObj}),x.append("file",w[0]),x.append("columns",JSON.stringify(g)),x.append("explain",h),S=(null==u||null==(n=u["x-action-settings"])?void 0:n.importMode)||"auto",O=(null==u||null==(i=u["x-action-settings"])?void 0:i.timeout)||6e5,p(!1),m(!0),d(1),A.label=1;case 1:return A.trys.push([1,6,,7]),[4,v.importXlsx({values:x,mode:S,timeout:O})];case 2:if(I=A.sent().data,s.reset(),I.data.taskId)return[3,4];return y(I),[4,null==r||null==(j=r.refresh)?void 0:j.call(r)];case 3:return A.sent(),d(2),[3,5];case 4:m(!1),p(!1),A.label=5;case 5:return[3,7];case 6:return A.sent(),m(!1),p(!0),[3,7];case 7:return[2]}})})()},disabled:(null==b?void 0:b.length)===0||(null==(e=s.errors)?void 0:e.length)>0}},K=h(477);function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Y(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Z(){var e=Y(["\n .ant-formily-item-label {\n height: var(--controlHeightLG);\n }\n "]);return Z=function(){return e},e}function ee(){var e=Y(["\n margin-top: 5px;\n "]);return ee=function(){return e},e}var et={type:"void",name:"import-modal",title:'{{ t("Import Data", {ns: "'.concat(y,'" }) }}'),"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:(0,K.css)(Z())},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:'{{ t("Step 1: Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:'{{ t("Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{className:(0,K.css)(ee()),useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:'{{ t("Step 2: Upload Excel", {ns: "'.concat(y,'" }) }}'),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:'{{ t("Upload placeholder", {ns: "'.concat(y,'" }) }}'),beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:'{{ t("Start import", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}},en=function(e){var o,i,a,l=function(e){if(Array.isArray(e))return e}(o=(0,n.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(o)||function(e){if(e){if("string"==typeof e)return Q(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Q(e,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=l[0],u=l[1],s=(0,t.useCompile)(),p=(0,S.useFieldSchema)();return r().createElement(t.ActionContextProvider,{value:{visible:c,setVisible:u,fieldSchema:p}},r().createElement(t.Action,(i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({icon:e.icon||"uploadoutlined",title:s((null==p?void 0:p.title)||"t('Import')")},e),a=a={onClick:function(){return u(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i)),r().createElement(t.SchemaComponent,{schema:et}))};function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ei=function(e){var n=C(),o=n.uploadValidator,i=n.beforeUploadHandler,a=n.validateUpload;return r().createElement(t.SchemaComponentOptions,{components:{ImportActionInitializer:x,ImportDesigner:D,ImportWarning:v,DownloadTips:g,ImportAction:en},scope:{uploadValidator:o,validateUpload:a,beforeUploadHandler:i,useDownloadXlsxTemplateAction:W,useImportStartAction:J}},r().createElement(ea,null,e.children))},ea=function(e){var t=eo((0,n.useState)(!1),2),o=t[0],i=t[1],a=eo((0,n.useState)(1),2),l=a[0],c=a[1],u=eo((0,n.useState)(null),2),s=u[0],p=u[1];return r().createElement(_.Provider,{value:{importModalVisible:o,setImportModalVisible:i,importStatus:l,setImportStatus:c,importResult:s,setImportResult:p}},(0,M.createPortal)(r().createElement(L,null),document.body),e.children)},el=h(452),ec=h(992),eu=h(485),es=h(694);function ep(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ef(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function em(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ef(i,r,o,a,l,"next",e)}function l(e){ef(i,r,o,a,l,"throw",e)}a(void 0)})}}function ed(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ey(e){return(ey=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eb(e,t){return(eb=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ev(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eh(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eh=function(){return!!e})()}function eg(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function ex(){var e=ev(["\n margin-top: 5px;\n "]);return ex=function(){return e},e}function ew(){var e=ev(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return ew=function(){return e},e}function eS(){var e=ev(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return eS=function(){return e},e}var eO=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],eI={type:"object",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:(0,es.escapeT)("Step 1: Download template",{ns:"".concat(y)}),"x-component":"FormItem",properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:(0,es.escapeT)("Download template",{ns:"".concat(y)}),"x-component":"Button","x-component-props":{className:(0,K.css)(ex()),children:(0,es.escapeT)("Download template",{ns:"".concat(y)}),onClick:"{{ handelDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:(0,es.escapeT)("Step 2: Upload Excel",{ns:"".concat(y)}),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":function(e){var t,n=e.fileList;if(n.length>1)return{type:"error",message:(0,es.escapeT)("Only one file is allowed to be uploaded")};var r=null!=(t=n[0])?t:{};return eO.includes(r.type)?"":{type:"error",message:(0,es.escapeT)("Please upload the file of Excel")}},"x-component-props":{action:"",height:"150px",maxCount:1,children:(0,es.escapeT)("Upload placeholder",{ns:"".concat(y)}),beforeUpload:function(){return!1}}}}},ej=(0,S.createSchemaField)({components:{ImportWarning:v,DownloadTips:g,Upload:m.Upload,FormItem:w.FormItem,Button:m.Button}}),eA=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=ey(t),ed(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eh()?Reflect.construct(t,r||[],ey(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,es.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eb(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(eu.ActionModel);function eP(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eE(e,t,n[t])})}return e}ed(eA,"scene",eu.ActionSceneEnum.collection),eA.define({label:(0,es.escapeT)("Import")}),eA.registerFlow({key:"importSettings",title:(0,es.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return em(function(){var t,n,o,i,a,l,c,u,s,p,f,d;return eg(this,function(b){switch(b.label){case 0:var v;return t=(0,ec.observable)({status:"",result:null}),n=(0,el.createForm)(),i=(o=e.model.context.blockModel).resource,l=(a=o.collection).title,c=a.name,s=(u=e.model.getProps().importSettings).explain,p=(!(v=u.importColumns)||!Array.isArray(v)?[]:v).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(o.collection.dataSourceKey,".").concat(c,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,i,a=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(c,".").concat(t.dataIndex.join(".")));if(!a)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==a||null==(i=a.uiSchema)?void 0:i.title)||a.name}return t}}).filter(Boolean),f=function(){return em(function(){var t;return eg(this,function(n){switch(n.label){case 0:return[4,i.runAction("downloadXlsxTemplate",{data:{title:e.t(l),explain:s,columns:function(e){if(Array.isArray(e))return ep(e)}(p)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(p)||function(e){if(e){if("string"==typeof e)return ep(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ep(e,void 0)}}(p)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,q.saveAs)(t,"".concat(e.t(l),".xlsx")),[2]}})})()},d=(0,es.observer)(function(o){var a=o.popover,l=e.t;if("importing"===t.status)return r().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},r().createElement(m.Spin,{tip:l("Excel data importing"),indicator:r().createElement(R.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===t.status){var c,u,d,b=null==(d=t.result)?void 0:d.meta;return r().createElement(m.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.successCount;if(t)return l("{{successCount}} records have been successfully imported",{successCount:t,ns:y})}(t.result)),r().createElement(m.Space,null,(null==b?void 0:b.failureCount)>0&&r().createElement(m.Button,{onClick:function(){var e,n,r=new Blob([new Int8Array(null==(n=t.result)||null==(e=n.data)?void 0:e.data)],{type:"application/x-xls"});(0,q.saveAs)(r,"fail.xlsx")}},l("To download the failure data")),r().createElement(m.Button,{type:"primary",onClick:function(){a.close(),t.status="",t.result=null}},l("Done"))))}return r().createElement(S.FormProvider,{form:n},r().createElement(w.FormLayout,{layout:"vertical"},r().createElement(ej,{schema:eI,scope:{t:e.t,handelDownloadXlsxTemplateAction:f}})),r().createElement(w.FormButtonGroup,{align:"right"},r().createElement(m.Button,{onClick:function(){return a.close()}},l("Cancel")),r().createElement(m.Button,{type:"primary",onClick:function(){return em(function(){var r,o,l,c,u,f,m,d;return eg(this,function(y){switch(y.label){case 0:r=n.values.upload.fileList,o=new FormData,l=r.map(function(e){return e.originFileObj}),o.append("file",l[0]),o.append("columns",JSON.stringify(p)),o.append("explain",s),c=e.model.getProps().importMode,t.status="importing",y.label=1;case 1:return y.trys.push([1,6,,7]),[4,i.runAction("importXlsx",{data:o,mode:c,timeout:6e5})];case 2:if(null==(f=y.sent().data)||null==(u=f.data)?void 0:u.taskId)return[3,4];return t.result=f,t.status="imported",[4,null==i||null==(m=i.refresh)?void 0:m.call(i)];case 3:return y.sent(),n.reset(),[3,5];case 4:a.close(),n.reset(),y.label=5;case 5:return[3,7];case 6:return d=y.sent(),t.status="",console.error(d),[3,7];case 7:return[2]}})})()},disabled:!(null==(u=n.values.upload)||null==(c=u.fileList)?void 0:c.length)},l("Start import",{ns:"".concat(y)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(y)}),content:function(e){return r().createElement(d,{popover:e})}})];case 1:return b.sent(),[2]}})})()}}}}),eA.registerFlow({key:"importActionSetting",title:(0,es.escapeT)("Import action settings",{ns:y}),steps:{importSetting:{title:(0,es.escapeT)("Importable fields"),uiSchema:function(e){var t,n,r=(t=e.model.context.blockModel.collection.getFields(),n=e.t,s(t,function(e){var t;return n(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,K.css)(ew())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":m.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:r}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,K.css)(eS())}}}}}},defaultParams:function(e){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ed(e,t,n[t])})}return e}({},b(e.model.context.blockModel.collection.getFields()))},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});var eT=new t.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps:function(){return(0,t.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:t.SchemaSettingsLinkageRules,useComponentProps:function(){return eC({},(0,t.useSchemaToolbar)().linkageRulesProps)}},{name:"importableFields",type:"actionModal",useComponentProps:function(){var e,r,o,i,a=(0,S.useField)(),l=(0,S.useFieldSchema)(),c=(0,d.useTranslation)().t,u=(0,t.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return eP(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eP(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=s[0],f=s[1],m=C().importSettingsSchema;return(0,n.useEffect)(function(){f(m)},[a.address,null==l||null==(o=l["x-action-settings"])?void 0:o.importSettings]),{title:c("Importable fields"),schema:eC({},p),initialValues:eC({},null!=(r=null==l||null==(i=l["x-action-settings"])?void 0:i.importSettings)?r:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});l["x-action-settings"].importSettings={importColumns:o,explain:r},u.emit("patch",{schema:(eE(t={},"x-uid",l["x-uid"]),eE(t,"x-action-settings",l["x-action-settings"]),t)}),u.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps:function(){return{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:(0,(0,d.useTranslation)().t)("Delete action")}}}}]});function ek(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eF(e,t,n){return(eF=eB()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&eM(o,n.prototype),o}).apply(null,arguments)}function eD(e){return(eD=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eM(e,t){return(eM=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function e_(e){var t="function"==typeof Map?new Map:void 0;return(e_=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eF(e,arguments,eD(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eM(n,e)})(e)}function eB(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eB=function(){return!!e})()}var eR=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=eD(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eB()?Reflect.construct(e,t||[],eD(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&eM(r,e),n=[{key:"load",value:function(){var e;return(e=function(){var e,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return this.app.use(ei),e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,t.useActionAvailable)("importXlsx")}},null==(n=this.app.schemaInitializerManager.get("table:configureActions"))||n.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(eT),this.app.flowEngine.registerModels({ImportActionModel:eA}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ek(i,r,o,a,l,"next",e)}function l(e){ek(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(e_(t.Plugin)),eq=eR}(),O}()});
|
|
@@ -6,5 +6,6 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
import { NAMESPACE } from '../../client-v2/locale';
|
|
10
|
+
export { NAMESPACE };
|
|
10
11
|
export declare function useImportTranslation(): import("react-i18next").UseTranslationResponse<("action-import" | "client")[], undefined>;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export declare const useFields: (collectionName: string) => any
|
|
9
|
+
export declare const useFields: (collectionName: string) => any;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import { ActionModel } from '@nocobase/client';
|
|
9
|
+
import { ActionModel } from '@nocobase/client-v2';
|
|
10
10
|
import type { ButtonProps } from 'antd/es/button';
|
|
11
11
|
export declare class ImportActionModel extends ActionModel {
|
|
12
|
-
static scene: import("@nocobase/client").ActionSceneType;
|
|
12
|
+
static scene: import("@nocobase/client-v2").ActionSceneType;
|
|
13
13
|
defaultProps: ButtonProps;
|
|
14
14
|
getAclActionName(): string;
|
|
15
15
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildImportFieldOptions: (fields: any, getTitle: any, getTargetFields: any) => any;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export declare const getOptionFields: (fields: any, t: any) => any
|
|
9
|
+
export declare const getOptionFields: (fields: any, t: any) => any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const initImportSettings: (fields: any) => {
|
|
11
|
+
importColumns: any;
|
|
12
|
+
explain: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const ImportWarning: () => React.JSX.Element;
|
|
15
|
+
export declare const DownloadTips: () => React.JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from '@nocobase/client-v2';
|
|
10
|
+
export declare class PluginActionImportClient extends Plugin {
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export { buildImportFieldOptions } from './buildImportFieldOptions';
|
|
14
|
+
export { ImportActionModel } from './ImportActionModel';
|
|
15
|
+
export default PluginActionImportClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import/client-v2",["react-i18next","@emotion/css","@nocobase/client-v2","@formily/antd-v5","@formily/core","@formily/reactive","react","antd","@formily/react","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import/client-v2"]=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-import/client-v2"]=t(e["react-i18next"],e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/antd-v5"],e["@formily/core"],e["@formily/reactive"],e.react,e.antd,e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,a,c,l,u,s){return function(){var p={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){c(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var c=i.URL||i.webkitURL,l=document.createElement("a");l.download=n=n||e.name||"download",l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?o(l):r(l.href)?t(e,n,a):o(l,l.target="_blank")):(l.href=c.createObjectURL(e),setTimeout(function(){c.revokeObjectURL(l.href)},4e4),setTimeout(function(){o(l)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var c=document.createElement("a");c.href=e,c.target="_blank",setTimeout(function(){o(c)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var c="application/octet-stream"===e.type,l=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||c&&l||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=c.saveAs=c,e.exports=c})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=u},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},452:function(e){"use strict";e.exports=o},230:function(e){"use strict";e.exports=l},992:function(e){"use strict";e.exports=i},485:function(e){"use strict";e.exports=n},694:function(e){"use strict";e.exports=s},59:function(e){"use strict";e.exports=c},155:function(e){"use strict";e.exports=a},953:function(t){"use strict";t.exports=e}},f={};function d(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e].call(n.exports,n,n.exports,d),n.exports}d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.g.importScripts&&(m=d.g.location+"");var m,y=d.g.document;if(!m&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(m=y.currentScript.src),!m)){var v=y.getElementsByTagName("script");if(v.length)for(var b=v.length-1;b>-1&&(!m||!/^http(s?):/.test(m));)m=v[b--].src}if(!m)throw Error("Automatic publicPath is not supported in this browser");d.p=m.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var g={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client-v2/"}d.p=e}(),!function(){"use strict";d.r(g),d.d(g,{PluginActionImportClient:function(){return z},default:function(){return G},buildImportFieldOptions:function(){return O},ImportActionModel:function(){return D}});var e=d(485),t=d(375),n=d(477),r=d(418),o=d(452),i=d(230),a=d(992),c=d(694),l=d(59),u=d(574),s=d(155),p=d.n(s),f=d(953),m="action-import",y=["createdAt","createdBy","updatedAt","updatedBy"],v=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],b=function(e){return(null==e?void 0:e.target)&&v.includes(e.type)},h=function(e){return!(null==e?void 0:e.interface)||y.includes(e.interface)},w=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:null==e?void 0:e.uiSchema,disabled:n}},x=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(h(e))return null;if(!b(e))return w(e,t);var a=(n(e)||[]).map(function(e){return h(e)?null:b(e)?i>=1?w(e,t,!0):x(e,t,n,i+1):x(e,t,n)}).filter(Boolean);return a.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},w(e,t)),o=o={children:a},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):w(e,t,!0)},O=function(e,t,n){return(e||[]).map(function(e){return x(e,t,n,+!!b(e))}).filter(Boolean)};function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function E(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){j(i,r,o,a,c,"next",e)}function c(e){j(i,r,o,a,c,"throw",e)}a(void 0)})}}function A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function k(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function F(){var e=P(["\n margin-top: 5px;\n "]);return F=function(){return e},e}function C(){var e=P(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return C=function(){return e},e}function B(){var e=P(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return B=function(){return e},e}var M=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],q={type:"object",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:(0,c.escapeT)("Step 1: Download template",{ns:"".concat(m)}),"x-component":"FormItem",properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:(0,c.escapeT)("Download template",{ns:"".concat(m)}),"x-component":"Button","x-component-props":{className:(0,n.css)(F()),children:(0,c.escapeT)("Download template",{ns:"".concat(m)}),onClick:"{{ handelDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:(0,c.escapeT)("Step 2: Upload Excel",{ns:"".concat(m)}),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":function(e){var t,n=e.fileList;if(n.length>1)return{type:"error",message:(0,c.escapeT)("Only one file is allowed to be uploaded")};var r=null!=(t=n[0])?t:{};return M.includes(r.type)?"":{type:"error",message:(0,c.escapeT)("Please upload the file of Excel")}},"x-component-props":{action:"",height:"150px",maxCount:1,children:(0,c.escapeT)("Upload placeholder",{ns:"".concat(m)}),beforeUpload:function(){return!1}}}}},R=(0,i.createSchemaField)({components:{ImportWarning:function(){var e=(0,f.useTranslation)([m,"client"],{nsMode:"fallback"}).t;return p().createElement(l.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},DownloadTips:function(){var e=(0,f.useTranslation)([m,"client"],{nsMode:"fallback"}).t;return p().createElement(l.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},Upload:l.Upload,FormItem:r.FormItem,Button:l.Button}}),D=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=T(t),A(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,_()?Reflect.construct(t,r||[],T(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,c.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&I(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(e.ActionModel);function L(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function U(e,t,n){return(U=H()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&N(o,n.prototype),o}).apply(null,arguments)}A(D,"scene",e.ActionSceneEnum.collection),D.define({label:(0,c.escapeT)("Import")}),D.registerFlow({key:"importSettings",title:(0,c.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return E(function(){var n,s,f,d,y,v,b,g,h,w,x,O;return k(this,function(j){switch(j.label){case 0:var A;return n=(0,a.observable)({status:"",result:null}),s=(0,o.createForm)(),d=(f=e.model.context.blockModel).resource,v=(y=f.collection).title,b=y.name,h=(g=e.model.getProps().importSettings).explain,w=(!(A=g.importColumns)||!Array.isArray(A)?[]:A).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(f.collection.dataSourceKey,".").concat(b,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,o,i=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(b,".").concat(t.dataIndex.join(".")));if(!i)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==i||null==(o=i.uiSchema)?void 0:o.title)||i.name}return t}}).filter(Boolean),x=function(){return E(function(){var t;return k(this,function(n){switch(n.label){case 0:return[4,d.runAction("downloadXlsxTemplate",{data:{title:e.t(v),explain:h,columns:function(e){if(Array.isArray(e))return S(e)}(w)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(w)||function(e){if(e){if("string"==typeof e)return S(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return S(e,void 0)}}(w)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,u.saveAs)(t,"".concat(e.t(v),".xlsx")),[2]}})})()},O=(0,c.observer)(function(o){var a=o.popover,c=e.t;if("importing"===n.status)return p().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},p().createElement(l.Spin,{tip:c("Excel data importing"),indicator:p().createElement(t.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===n.status){var f,y,v,b=null==(v=n.result)?void 0:v.meta;return p().createElement(l.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},p().createElement(t.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),p().createElement("p",null,function(e){if(!e)return null;var t=e.successCount;if(t)return c("{{successCount}} records have been successfully imported",{successCount:t,ns:m})}(n.result)),p().createElement(l.Space,null,(null==b?void 0:b.failureCount)>0&&p().createElement(l.Button,{onClick:function(){var e,t,r=new Blob([new Int8Array(null==(t=n.result)||null==(e=t.data)?void 0:e.data)],{type:"application/x-xls"});(0,u.saveAs)(r,"fail.xlsx")}},c("To download the failure data")),p().createElement(l.Button,{type:"primary",onClick:function(){a.close(),n.status="",n.result=null}},c("Done"))))}return p().createElement(i.FormProvider,{form:s},p().createElement(r.FormLayout,{layout:"vertical"},p().createElement(R,{schema:q,scope:{t:e.t,handelDownloadXlsxTemplateAction:x}})),p().createElement(r.FormButtonGroup,{align:"right"},p().createElement(l.Button,{onClick:function(){return a.close()}},c("Cancel")),p().createElement(l.Button,{type:"primary",onClick:function(){return E(function(){var t,r,o,i,c,l,u,p;return k(this,function(f){switch(f.label){case 0:t=s.values.upload.fileList,r=new FormData,o=t.map(function(e){return e.originFileObj}),r.append("file",o[0]),r.append("columns",JSON.stringify(w)),r.append("explain",h),i=e.model.getProps().importMode,n.status="importing",f.label=1;case 1:return f.trys.push([1,6,,7]),[4,d.runAction("importXlsx",{data:r,mode:i,timeout:6e5})];case 2:if(null==(l=f.sent().data)||null==(c=l.data)?void 0:c.taskId)return[3,4];return n.result=l,n.status="imported",[4,null==d||null==(u=d.refresh)?void 0:u.call(d)];case 3:return f.sent(),s.reset(),[3,5];case 4:a.close(),s.reset(),f.label=5;case 5:return[3,7];case 6:return p=f.sent(),n.status="",console.error(p),[3,7];case 7:return[2]}})})()},disabled:!(null==(y=s.values.upload)||null==(f=y.fileList)?void 0:f.length)},c("Start import",{ns:"".concat(m)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(m)}),content:function(e){return p().createElement(O,{popover:e})}})];case 1:return j.sent(),[2]}})})()}}}}),D.registerFlow({key:"importActionSetting",title:(0,c.escapeT)("Import action settings",{ns:m}),steps:{importSetting:{title:(0,c.escapeT)("Importable fields"),uiSchema:function(e){var t,r,o=(t=e.model.context.blockModel.collection.getFields(),r=e.t,O(t,function(e){var t;return r(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(m,'"}) }}'),"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,n.css)(C())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":l.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:o}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(m,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(m,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(B())}}}}}},defaultParams:function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){A(e,t,n[t])})}return e}({},{importColumns:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""})},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function N(e,t){return(N=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e){var t="function"==typeof Map?new Map:void 0;return(X=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return U(e,arguments,$(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),N(n,e)})(e)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(H=function(){return!!e})()}var z=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=$(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,H()?Reflect.construct(e,t||[],$(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&N(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.flowEngine.registerModels({ImportActionModel:D}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){L(i,r,o,a,c,"next",e)}function c(e){L(i,r,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(X(e.Plugin)),G=z}(),g}()});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NAMESPACE = "action-import";
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,26 +10,26 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@emotion/css": "11.13.0",
|
|
12
12
|
"@formily/react": "2.3.7",
|
|
13
|
-
"@nocobase/client": "2.1.0
|
|
13
|
+
"@nocobase/client": "2.1.0",
|
|
14
14
|
"react": "18.2.0",
|
|
15
15
|
"react-i18next": "11.18.6",
|
|
16
16
|
"@ant-design/icons": "5.6.1",
|
|
17
17
|
"@formily/shared": "2.3.7",
|
|
18
|
-
"
|
|
19
|
-
"@nocobase/utils": "2.1.0-beta.9",
|
|
18
|
+
"@nocobase/utils": "2.1.0",
|
|
20
19
|
"@formily/antd-v5": "1.2.3",
|
|
21
|
-
"
|
|
20
|
+
"antd": "5.24.2",
|
|
22
21
|
"react-dom": "18.2.0",
|
|
23
|
-
"lodash": "4.
|
|
22
|
+
"lodash": "4.18.1",
|
|
24
23
|
"@formily/core": "2.3.7",
|
|
25
|
-
"@nocobase/server": "2.1.0-beta.9",
|
|
26
24
|
"@formily/reactive": "2.3.7",
|
|
27
|
-
"@nocobase/
|
|
28
|
-
"@nocobase/
|
|
29
|
-
"@nocobase/
|
|
25
|
+
"@nocobase/client-v2": "2.1.0",
|
|
26
|
+
"@nocobase/flow-engine": "2.1.0",
|
|
27
|
+
"@nocobase/server": "2.1.0",
|
|
28
|
+
"@nocobase/actions": "2.1.0",
|
|
29
|
+
"@nocobase/database": "2.1.0",
|
|
30
30
|
"async-mutex": "0.5.0",
|
|
31
|
-
"@nocobase/data-source-manager": "2.1.0
|
|
31
|
+
"@nocobase/data-source-manager": "2.1.0",
|
|
32
32
|
"sequelize": "6.35.2",
|
|
33
|
-
"@nocobase/logger": "2.1.0
|
|
33
|
+
"@nocobase/logger": "2.1.0",
|
|
34
34
|
"mathjs": "15.1.0"
|
|
35
35
|
};
|