@pisell/materials 1.0.660 → 1.0.662
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +6 -6
- package/build/lowcode/preview.js +5 -5
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +15 -15
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +15 -15
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +4 -2
- package/es/components/dataSourceComponents/fields/Input/WithMode.js +520 -7
- package/es/components/dataSourceComponents/fields/Input/index.js +19 -6
- package/es/components/pisellScan/index.js +17 -3
- package/es/locales/en-US.js +1 -1
- package/es/locales/zh-CN.js +2 -2
- package/es/locales/zh-TW.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +3 -1
- package/lib/components/dataSourceComponents/fields/Input/WithMode.js +349 -3
- package/lib/components/dataSourceComponents/fields/Input/index.js +13 -3
- package/lib/components/pisellScan/index.js +9 -3
- package/lib/locales/en-US.js +9 -1
- package/lib/locales/zh-CN.js +10 -2
- package/lib/locales/zh-TW.js +9 -1
- package/lowcode/data-source-table/meta.ts +4 -0
- package/lowcode/form-item-input/meta.ts +99 -0
- package/package.json +1 -1
- package/es/components/TimeResourceSelector/index.d.ts +0 -21
- package/es/components/appVersionControl/index.d.ts +0 -4
- package/es/components/badge/index.d.ts +0 -7
- package/es/components/buttonGroupEdit/index.d.ts +0 -8
- package/es/components/buttonGroupPreview/index.d.ts +0 -19
- package/es/components/cardMetricItem/index.d.ts +0 -12
- package/es/components/cardPro/index.d.ts +0 -3
- package/es/components/collapse/index.d.ts +0 -15
- package/es/components/cropPhoto/index.d.ts +0 -3
- package/es/components/dataSourceComponents/dataSourceForm/group/index.d.ts +0 -20
- package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +0 -15
- package/es/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.d.ts +0 -7
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.d.ts +0 -39
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +0 -56
- package/es/components/dataSourceComponents/dataSourceMenu/Basic.d.ts +0 -2
- package/es/components/dataSourceComponents/dataSourceMenu/index.d.ts +0 -2
- package/es/components/dataSourceComponents/dataSourceTable/BaseTable.d.ts +0 -8
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useColumns.d.ts +0 -11
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +0 -48
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +0 -97
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -78
- package/es/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts +0 -5
- package/es/components/dataSourceComponents/fields/DatePicker/WithMode.d.ts +0 -4
- package/es/components/dataSourceComponents/fields/DatePicker/type.d.ts +0 -6
- package/es/components/dataSourceComponents/fields/Input/WithMode.d.ts +0 -4
- package/es/components/dataSourceComponents/fields/Input/index.d.ts +0 -22
- package/es/components/dataSourceComponents/fields/Input/type.d.ts +0 -7
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +0 -24
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +0 -24
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.d.ts +0 -5
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +0 -4
- package/es/components/dataSourceComponents/fields/Upload/WithMode.d.ts +0 -4
- package/es/components/dataSourceComponents/fields/Upload/index.d.ts +0 -3
- package/es/components/dataSourceComponents/fields/Upload/serve.d.ts +0 -20
- package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +0 -56
- package/es/components/dataSourceComponents/fields/Upload/type.d.ts +0 -37
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +0 -18
- package/es/components/dataSourceComponents/hooks/useActions.d.ts +0 -18
- package/es/components/dataSourceComponents/hooks/usePlatform.d.ts +0 -3
- package/es/components/dataSourceComponents/hooks/useValueMap.d.ts +0 -8
- package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +0 -119
- package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.d.ts +0 -8
- package/es/components/date-picker/datePickerCpt.d.ts +0 -8
- package/es/components/drag-sort-tree/index.d.ts +0 -3
- package/es/components/iconfont/index.d.ts +0 -7
- package/es/components/picker-view/index.d.ts +0 -2
- package/es/components/pisell-config-provider/index.d.ts +0 -12
- package/es/components/pisellAlert/index.d.ts +0 -24
- package/es/components/pisellAnchor/index.d.ts +0 -18
- package/es/components/pisellAvatar/index.d.ts +0 -19
- package/es/components/pisellCard/index.d.ts +0 -19
- package/es/components/pisellCustomCheckboxGroup/index.d.ts +0 -16
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +0 -24
- package/es/components/pisellDraggable/index.d.ts +0 -32
- package/es/components/pisellDraggable/types.d.ts +0 -19
- package/es/components/pisellDropSort/PisellDropSort.d.ts +0 -5
- package/es/components/pisellDropSort/components/SortableItem/index.d.ts +0 -25
- package/es/components/pisellDropSort/types.d.ts +0 -52
- package/es/components/pisellDropdown/index.d.ts +0 -20
- package/es/components/pisellEmpty/index.d.ts +0 -19
- package/es/components/pisellHeaderProgressBar/index.d.ts +0 -29
- package/es/components/pisellImageCarousels/index.d.ts +0 -18
- package/es/components/pisellInformationEntry/index.d.ts +0 -33
- package/es/components/pisellLayout/content.d.ts +0 -10
- package/es/components/pisellLayout/sider.d.ts +0 -8
- package/es/components/pisellList01/index.d.ts +0 -17
- package/es/components/pisellMenu/PisellMenu.d.ts +0 -9
- package/es/components/pisellMenu/types.d.ts +0 -26
- package/es/components/pisellNavigationMenu/PisellNavigationMenu.d.ts +0 -5
- package/es/components/pisellNavigationMenu/types.d.ts +0 -64
- package/es/components/pisellNavigationMenu/utils.d.ts +0 -15
- package/es/components/pisellQrcode/index.d.ts +0 -10
- package/es/components/pisellScan/index.d.ts +0 -23
- package/es/components/pisellSectionHeaders/index.d.ts +0 -21
- package/es/components/pisellStatisticList/index.d.ts +0 -21
- package/es/components/pisellText/components/Amount/index.d.ts +0 -20
- package/es/components/pisellWalletPassCard/index.d.ts +0 -55
- package/es/components/productCard/components/Action/index.d.ts +0 -3
- package/es/components/productCard/components/AmountFooter/index.d.ts +0 -3
- package/es/components/productCard/components/Divider/index.d.ts +0 -3
- package/es/components/productCard/components/Header/DeleteButton/index.d.ts +0 -3
- package/es/components/productCard/components/Header/index.d.ts +0 -3
- package/es/components/productCard/components/MultiDay/index.d.ts +0 -3
- package/es/components/productCard/components/MultiDay/utils.d.ts +0 -14
- package/es/components/productCard/components/Note/index.d.ts +0 -3
- package/es/components/productCard/components/Packages/components/collapsibleList/index.d.ts +0 -10
- package/es/components/productCard/components/Packages/components/collapsibleList/utils.d.ts +0 -1
- package/es/components/productCard/components/Packages/components/options/index.d.ts +0 -3
- package/es/components/productCard/components/Packages/index.d.ts +0 -3
- package/es/components/productCard/components/Packages/utils.d.ts +0 -20
- package/es/components/productCard/components/Sales/index.d.ts +0 -3
- package/es/components/productCard/components/Time/components/Like/index.d.ts +0 -8
- package/es/components/productCard/components/Time/index.d.ts +0 -3
- package/es/components/productCard/hooks/useOpenNote.d.ts +0 -3
- package/es/components/productCard/index.d.ts +0 -5
- package/es/components/productCard/locales.d.ts +0 -45
- package/es/components/productCard/status.d.ts +0 -32
- package/es/components/productCard/types.d.ts +0 -78
- package/es/components/productCard/utils.d.ts +0 -31
- package/es/components/record-view/index.d.ts +0 -37
- package/es/components/section-footers/index.d.ts +0 -9
- package/es/components/table/Actions/component/ExportImport/index.d.ts +0 -7
- package/es/components/table/Actions/component/ExportImport/utils/index.d.ts +0 -9
- package/es/components/table/Gallery/components/GalleryItem/index.d.ts +0 -14
- package/es/components/table/Gallery/index.d.ts +0 -5
- package/es/components/table/Table/index.d.ts +0 -4
- package/es/components/table/Table/utils.d.ts +0 -173
- package/es/components/table/hooks/useTableSetting.d.ts +0 -22
- package/es/components/table/hooks/useTransDataSource.d.ts +0 -12
- package/es/components/table/types.d.ts +0 -253
- package/es/components/tabs/index.d.ts +0 -16
- package/es/components/versionSelect/index.d.ts +0 -17
- package/es/components/walletCard/index.d.ts +0 -71
- package/es/hooks/useEngineContext.d.ts +0 -9
- package/es/index.d.ts +0 -139
- package/es/locales/en-US.d.ts +0 -225
- package/es/locales/index.d.ts +0 -1
- package/es/locales/zh-CN.d.ts +0 -224
- package/es/locales/zh-TW.d.ts +0 -224
- package/es/utils/index.d.ts +0 -4
- package/lib/components/TimeResourceSelector/index.d.ts +0 -21
- package/lib/components/appVersionControl/index.d.ts +0 -4
- package/lib/components/badge/index.d.ts +0 -7
- package/lib/components/buttonGroupEdit/index.d.ts +0 -8
- package/lib/components/buttonGroupPreview/index.d.ts +0 -19
- package/lib/components/cardMetricItem/index.d.ts +0 -12
- package/lib/components/cardPro/index.d.ts +0 -3
- package/lib/components/collapse/index.d.ts +0 -15
- package/lib/components/cropPhoto/index.d.ts +0 -3
- package/lib/components/dataSourceComponents/dataSourceForm/group/index.d.ts +0 -20
- package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +0 -15
- package/lib/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.d.ts +0 -7
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.d.ts +0 -39
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +0 -56
- package/lib/components/dataSourceComponents/dataSourceMenu/Basic.d.ts +0 -2
- package/lib/components/dataSourceComponents/dataSourceMenu/index.d.ts +0 -2
- package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.d.ts +0 -8
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useColumns.d.ts +0 -11
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +0 -48
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +0 -97
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -78
- package/lib/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts +0 -5
- package/lib/components/dataSourceComponents/fields/DatePicker/WithMode.d.ts +0 -4
- package/lib/components/dataSourceComponents/fields/DatePicker/type.d.ts +0 -6
- package/lib/components/dataSourceComponents/fields/Input/WithMode.d.ts +0 -4
- package/lib/components/dataSourceComponents/fields/Input/index.d.ts +0 -22
- package/lib/components/dataSourceComponents/fields/Input/type.d.ts +0 -7
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +0 -24
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +0 -24
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.d.ts +0 -5
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +0 -4
- package/lib/components/dataSourceComponents/fields/Upload/WithMode.d.ts +0 -4
- package/lib/components/dataSourceComponents/fields/Upload/index.d.ts +0 -3
- package/lib/components/dataSourceComponents/fields/Upload/serve.d.ts +0 -20
- package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +0 -56
- package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +0 -37
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +0 -18
- package/lib/components/dataSourceComponents/hooks/useActions.d.ts +0 -18
- package/lib/components/dataSourceComponents/hooks/usePlatform.d.ts +0 -3
- package/lib/components/dataSourceComponents/hooks/useValueMap.d.ts +0 -8
- package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +0 -119
- package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.d.ts +0 -8
- package/lib/components/date-picker/datePickerCpt.d.ts +0 -8
- package/lib/components/drag-sort-tree/index.d.ts +0 -3
- package/lib/components/iconfont/index.d.ts +0 -7
- package/lib/components/picker-view/index.d.ts +0 -2
- package/lib/components/pisell-config-provider/index.d.ts +0 -12
- package/lib/components/pisellAlert/index.d.ts +0 -24
- package/lib/components/pisellAnchor/index.d.ts +0 -18
- package/lib/components/pisellAvatar/index.d.ts +0 -19
- package/lib/components/pisellCard/index.d.ts +0 -19
- package/lib/components/pisellCustomCheckboxGroup/index.d.ts +0 -16
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +0 -24
- package/lib/components/pisellDraggable/index.d.ts +0 -32
- package/lib/components/pisellDraggable/types.d.ts +0 -19
- package/lib/components/pisellDropSort/PisellDropSort.d.ts +0 -5
- package/lib/components/pisellDropSort/components/SortableItem/index.d.ts +0 -25
- package/lib/components/pisellDropSort/types.d.ts +0 -52
- package/lib/components/pisellDropdown/index.d.ts +0 -20
- package/lib/components/pisellEmpty/index.d.ts +0 -19
- package/lib/components/pisellHeaderProgressBar/index.d.ts +0 -29
- package/lib/components/pisellImageCarousels/index.d.ts +0 -18
- package/lib/components/pisellInformationEntry/index.d.ts +0 -33
- package/lib/components/pisellLayout/content.d.ts +0 -10
- package/lib/components/pisellLayout/sider.d.ts +0 -8
- package/lib/components/pisellList01/index.d.ts +0 -17
- package/lib/components/pisellMenu/PisellMenu.d.ts +0 -9
- package/lib/components/pisellMenu/types.d.ts +0 -26
- package/lib/components/pisellNavigationMenu/PisellNavigationMenu.d.ts +0 -5
- package/lib/components/pisellNavigationMenu/types.d.ts +0 -64
- package/lib/components/pisellNavigationMenu/utils.d.ts +0 -15
- package/lib/components/pisellQrcode/index.d.ts +0 -10
- package/lib/components/pisellScan/index.d.ts +0 -23
- package/lib/components/pisellSectionHeaders/index.d.ts +0 -21
- package/lib/components/pisellStatisticList/index.d.ts +0 -21
- package/lib/components/pisellText/components/Amount/index.d.ts +0 -20
- package/lib/components/pisellWalletPassCard/index.d.ts +0 -55
- package/lib/components/productCard/components/Action/index.d.ts +0 -3
- package/lib/components/productCard/components/AmountFooter/index.d.ts +0 -3
- package/lib/components/productCard/components/Divider/index.d.ts +0 -3
- package/lib/components/productCard/components/Header/DeleteButton/index.d.ts +0 -3
- package/lib/components/productCard/components/Header/index.d.ts +0 -3
- package/lib/components/productCard/components/MultiDay/index.d.ts +0 -3
- package/lib/components/productCard/components/MultiDay/utils.d.ts +0 -14
- package/lib/components/productCard/components/Note/index.d.ts +0 -3
- package/lib/components/productCard/components/Packages/components/collapsibleList/index.d.ts +0 -10
- package/lib/components/productCard/components/Packages/components/collapsibleList/utils.d.ts +0 -1
- package/lib/components/productCard/components/Packages/components/options/index.d.ts +0 -3
- package/lib/components/productCard/components/Packages/index.d.ts +0 -3
- package/lib/components/productCard/components/Packages/utils.d.ts +0 -20
- package/lib/components/productCard/components/Sales/index.d.ts +0 -3
- package/lib/components/productCard/components/Time/components/Like/index.d.ts +0 -8
- package/lib/components/productCard/components/Time/index.d.ts +0 -3
- package/lib/components/productCard/hooks/useOpenNote.d.ts +0 -3
- package/lib/components/productCard/index.d.ts +0 -5
- package/lib/components/productCard/locales.d.ts +0 -45
- package/lib/components/productCard/status.d.ts +0 -32
- package/lib/components/productCard/types.d.ts +0 -78
- package/lib/components/productCard/utils.d.ts +0 -31
- package/lib/components/record-view/index.d.ts +0 -37
- package/lib/components/section-footers/index.d.ts +0 -9
- package/lib/components/table/Actions/component/ExportImport/index.d.ts +0 -7
- package/lib/components/table/Actions/component/ExportImport/utils/index.d.ts +0 -9
- package/lib/components/table/Gallery/components/GalleryItem/index.d.ts +0 -14
- package/lib/components/table/Gallery/index.d.ts +0 -5
- package/lib/components/table/Table/index.d.ts +0 -4
- package/lib/components/table/Table/utils.d.ts +0 -173
- package/lib/components/table/hooks/useTableSetting.d.ts +0 -22
- package/lib/components/table/hooks/useTransDataSource.d.ts +0 -12
- package/lib/components/table/types.d.ts +0 -253
- package/lib/components/tabs/index.d.ts +0 -16
- package/lib/components/versionSelect/index.d.ts +0 -17
- package/lib/components/walletCard/index.d.ts +0 -71
- package/lib/hooks/useEngineContext.d.ts +0 -9
- package/lib/index.d.ts +0 -139
- package/lib/locales/en-US.d.ts +0 -225
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/zh-CN.d.ts +0 -224
- package/lib/locales/zh-TW.d.ts +0 -224
- package/lib/utils/index.d.ts +0 -4
|
@@ -45,7 +45,8 @@ var useTableProps = function useTableProps(props) {
|
|
|
45
45
|
search = originProps.search,
|
|
46
46
|
clickToDetail = originProps.clickToDetail,
|
|
47
47
|
propsOnRow = originProps.onRow,
|
|
48
|
-
filterBy = originProps.filterBy
|
|
48
|
+
filterBy = originProps.filterBy,
|
|
49
|
+
onDeleteFinish = originProps.onDeleteFinish;
|
|
49
50
|
var _ref = operation || {},
|
|
50
51
|
items = _ref.items,
|
|
51
52
|
show = _ref.show,
|
|
@@ -138,11 +139,12 @@ var useTableProps = function useTableProps(props) {
|
|
|
138
139
|
_context.next = 8;
|
|
139
140
|
return destroy === null || destroy === void 0 ? void 0 : destroy.runAsync(record.id);
|
|
140
141
|
case 8:
|
|
142
|
+
onDeleteFinish === null || onDeleteFinish === void 0 || onDeleteFinish(record);
|
|
141
143
|
refreshData();
|
|
142
144
|
PisellToast({
|
|
143
145
|
content: getText('pisell-action-delete-success')
|
|
144
146
|
});
|
|
145
|
-
case
|
|
147
|
+
case 11:
|
|
146
148
|
case "end":
|
|
147
149
|
return _context.stop();
|
|
148
150
|
}
|
|
@@ -1,12 +1,525 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["allowScan", "scanCodeType", "language"];
|
|
1
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
13
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
// @ts-nocheck
|
|
21
|
+
import { Input as AntInput, Button, Upload, message } from 'antd';
|
|
22
|
+
import React, { useState, useMemo, useEffect, useRef } from 'react';
|
|
23
|
+
import { ScanOutlined, PictureOutlined, ArrowLeftOutlined } from '@ant-design/icons';
|
|
24
|
+
import { BrowserMultiFormatReader, BarcodeFormat } from '@zxing/library';
|
|
4
25
|
import ReadPretty from "./ReadPretty";
|
|
5
26
|
import { withMode } from "../../dataSourceForm/utils";
|
|
27
|
+
import PisellScan from "../../../pisellScan";
|
|
28
|
+
import { getText } from "../../../../locales";
|
|
29
|
+
import { getCurrentLocale } from "../../../../utils/locale";
|
|
30
|
+
import usePisellConfig from "../../../pisell-config-provider/hooks/usePisellConfig";
|
|
31
|
+
|
|
32
|
+
// 为原生桥接声明全局类型
|
|
33
|
+
|
|
34
|
+
// 用于判断是否处于开发环境
|
|
35
|
+
var isDevelopEnv = process.env.NODE_ENV === 'development';
|
|
6
36
|
var Input = function Input(props) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
37
|
+
var _useState = useState(false),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
scanVisible = _useState2[0],
|
|
40
|
+
setScanVisible = _useState2[1];
|
|
41
|
+
var _usePisellConfig = usePisellConfig(),
|
|
42
|
+
_usePisellConfig$plat = _usePisellConfig.platform,
|
|
43
|
+
platform = _usePisellConfig$plat === void 0 ? 'pc' : _usePisellConfig$plat;
|
|
44
|
+
var isH5 = platform === 'h5';
|
|
45
|
+
var scanRef = useRef(null);
|
|
46
|
+
var _useState3 = useState(''),
|
|
47
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
48
|
+
debugValue = _useState4[0],
|
|
49
|
+
setDebugValue = _useState4[1];
|
|
50
|
+
var _useState5 = useState(false),
|
|
51
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
52
|
+
fullScreenMode = _useState6[0],
|
|
53
|
+
setFullScreenMode = _useState6[1];
|
|
54
|
+
var scanContainerRef = useRef(null);
|
|
55
|
+
|
|
56
|
+
// 监控props.value的变化
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
if (props.value !== undefined) {
|
|
59
|
+
if (isDevelopEnv) {
|
|
60
|
+
console.log('[Input.WithMode] props.value变化:', props.value);
|
|
61
|
+
}
|
|
62
|
+
setDebugValue(props.value);
|
|
63
|
+
}
|
|
64
|
+
}, [props.value]);
|
|
65
|
+
|
|
66
|
+
// 包装onChange处理函数
|
|
67
|
+
var handleChange = function handleChange(e) {
|
|
68
|
+
if (e && e.target) {
|
|
69
|
+
setDebugValue(e.target.value);
|
|
70
|
+
} else if (e === '' || e === null || e === undefined) {
|
|
71
|
+
setDebugValue('');
|
|
72
|
+
}
|
|
73
|
+
if (props.onChange) {
|
|
74
|
+
props.onChange(e);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// 从props中获取属性
|
|
79
|
+
var _props$allowScan = props.allowScan,
|
|
80
|
+
allowScan = _props$allowScan === void 0 ? false : _props$allowScan,
|
|
81
|
+
_props$scanCodeType = props.scanCodeType,
|
|
82
|
+
scanCodeType = _props$scanCodeType === void 0 ? 'all' : _props$scanCodeType,
|
|
83
|
+
_props$language = props.language,
|
|
84
|
+
language = _props$language === void 0 ? getCurrentLocale() : _props$language,
|
|
85
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
86
|
+
|
|
87
|
+
// 根据scanCodeType确定扫描的格式
|
|
88
|
+
var formatMap = {
|
|
89
|
+
all: [BarcodeFormat.QR_CODE, BarcodeFormat.EAN_8, BarcodeFormat.EAN_13, BarcodeFormat.CODE_128, BarcodeFormat.CODE_39, BarcodeFormat.CODE_93],
|
|
90
|
+
qrcode: [BarcodeFormat.QR_CODE],
|
|
91
|
+
barcode: [BarcodeFormat.EAN_8, BarcodeFormat.EAN_13, BarcodeFormat.CODE_128, BarcodeFormat.CODE_39, BarcodeFormat.CODE_93]
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// 获取当前扫码类型对应的格式数组
|
|
95
|
+
var formats = useMemo(function () {
|
|
96
|
+
if (scanCodeType === 'qrcode') {
|
|
97
|
+
return formatMap.qrcode;
|
|
98
|
+
} else if (scanCodeType === 'barcode') {
|
|
99
|
+
return formatMap.barcode;
|
|
100
|
+
} else {
|
|
101
|
+
return formatMap.all;
|
|
102
|
+
}
|
|
103
|
+
}, [scanCodeType]);
|
|
104
|
+
|
|
105
|
+
// 获取扫码类型文本
|
|
106
|
+
var getScanTypeText = useMemo(function () {
|
|
107
|
+
if (isDevelopEnv) {
|
|
108
|
+
console.log('[Input.WithMode] 当前扫码类型:', scanCodeType);
|
|
109
|
+
}
|
|
110
|
+
if (scanCodeType === 'qrcode') {
|
|
111
|
+
return getText('scan.qrcode');
|
|
112
|
+
} else if (scanCodeType === 'barcode') {
|
|
113
|
+
return getText('scan.barcode');
|
|
114
|
+
} else {
|
|
115
|
+
return getText('scan.all');
|
|
116
|
+
}
|
|
117
|
+
}, [scanCodeType]);
|
|
118
|
+
var getBackText = getText('scan.back');
|
|
119
|
+
var getFromAlbumText = getText('scan.fromAlbum');
|
|
120
|
+
|
|
121
|
+
// 处理扫码结果
|
|
122
|
+
var handleScan = function handleScan(value, barcodeFormat, isValidType) {
|
|
123
|
+
var _scanRef$current2;
|
|
124
|
+
if (isDevelopEnv) {
|
|
125
|
+
console.log('[Input.WithMode] 扫码结果:', value, '码类型:', barcodeFormat, '是否有效类型:', isValidType);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 确保值有效
|
|
129
|
+
if (!value) {
|
|
130
|
+
console.warn('[Input.WithMode] 扫码结果为空');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 验证扫码类型是否符合要求
|
|
135
|
+
if (isValidType === false) {
|
|
136
|
+
var _scanRef$current;
|
|
137
|
+
// 关闭扫码界面
|
|
138
|
+
setScanVisible(false);
|
|
139
|
+
setFullScreenMode(false);
|
|
140
|
+
(_scanRef$current = scanRef.current) === null || _scanRef$current === void 0 || (_scanRef$current = _scanRef$current.codeReader) === null || _scanRef$current === void 0 || _scanRef$current.reset();
|
|
141
|
+
|
|
142
|
+
// 显示错误提示
|
|
143
|
+
var errorMsg = scanCodeType === 'qrcode' ? getText('scan.qrcodeOnlyError') : getText('scan.barcodeOnlyError');
|
|
144
|
+
message.error(errorMsg || "\u4E0D\u7B26\u5408\u5F53\u524D\u626B\u7801\u7C7B\u578B\u8981\u6C42\uFF0C\u8BF7\u626B\u63CF".concat(getScanTypeText));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 关闭扫码界面
|
|
149
|
+
setScanVisible(false);
|
|
150
|
+
setFullScreenMode(false);
|
|
151
|
+
(_scanRef$current2 = scanRef.current) === null || _scanRef$current2 === void 0 || (_scanRef$current2 = _scanRef$current2.codeReader) === null || _scanRef$current2 === void 0 || _scanRef$current2.reset();
|
|
152
|
+
|
|
153
|
+
// 设置扫码结果
|
|
154
|
+
handleChange({
|
|
155
|
+
target: {
|
|
156
|
+
value: value
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// 退出全屏扫码
|
|
162
|
+
var exitFullScreenScan = function exitFullScreenScan() {
|
|
163
|
+
var _scanRef$current3;
|
|
164
|
+
if (document.exitFullscreen) {
|
|
165
|
+
document.exitFullscreen().catch(function (err) {
|
|
166
|
+
console.error('退出全屏失败:', err);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
setFullScreenMode(false);
|
|
170
|
+
setScanVisible(false);
|
|
171
|
+
(_scanRef$current3 = scanRef.current) === null || _scanRef$current3 === void 0 || (_scanRef$current3 = _scanRef$current3.codeReader) === null || _scanRef$current3 === void 0 || _scanRef$current3.reset();
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// 处理扫码按钮点击事件
|
|
175
|
+
var handleScanClick = function handleScanClick() {
|
|
176
|
+
if (isDevelopEnv) {
|
|
177
|
+
console.log('[Input.WithMode] 点击扫码按钮,当前扫码类型:', scanCodeType, '标题:', getScanTypeText);
|
|
178
|
+
}
|
|
179
|
+
if (isH5) {
|
|
180
|
+
var _window$webkit, _window$nativeBridge;
|
|
181
|
+
// 移动设备扫码逻辑 - 直接唤起原生扫码
|
|
182
|
+
if ((_window$webkit = window.webkit) !== null && _window$webkit !== void 0 && (_window$webkit = _window$webkit.messageHandlers) !== null && _window$webkit !== void 0 && _window$webkit.nativeScan) {
|
|
183
|
+
// iOS 扫码
|
|
184
|
+
window.webkit.messageHandlers.nativeScan.postMessage({
|
|
185
|
+
scanType: scanCodeType || 'all'
|
|
186
|
+
});
|
|
187
|
+
} else if ((_window$nativeBridge = window.nativeBridge) !== null && _window$nativeBridge !== void 0 && _window$nativeBridge.scan) {
|
|
188
|
+
// Android 扫码
|
|
189
|
+
window.nativeBridge.scan(scanCodeType || 'all');
|
|
190
|
+
} else {
|
|
191
|
+
// H5环境,但没有原生扫码能力,使用全屏H5扫码
|
|
192
|
+
setScanVisible(true);
|
|
193
|
+
setFullScreenMode(true);
|
|
194
|
+
|
|
195
|
+
// 请求全屏
|
|
196
|
+
setTimeout(function () {
|
|
197
|
+
if (scanContainerRef.current && scanContainerRef.current.requestFullscreen) {
|
|
198
|
+
scanContainerRef.current.requestFullscreen().catch(function (err) {
|
|
199
|
+
console.error('进入全屏失败:', err);
|
|
200
|
+
// 即使全屏失败,也显示扫码界面
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}, 100);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// 处理从相册选择图片
|
|
209
|
+
var handleImageSelect = /*#__PURE__*/function () {
|
|
210
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
|
|
211
|
+
var url, img;
|
|
212
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
213
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
214
|
+
case 0:
|
|
215
|
+
if (isDevelopEnv) {
|
|
216
|
+
console.log('[handleImageSelect] 选择图片:', file);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 检查文件类型
|
|
220
|
+
if (file.type.includes('image/')) {
|
|
221
|
+
_context2.next = 4;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
message.error('请选择图片文件');
|
|
225
|
+
return _context2.abrupt("return", false);
|
|
226
|
+
case 4:
|
|
227
|
+
try {
|
|
228
|
+
message.loading({
|
|
229
|
+
content: '正在处理图片...',
|
|
230
|
+
key: 'scanLoading',
|
|
231
|
+
duration: 0
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// 创建图片URL
|
|
235
|
+
url = URL.createObjectURL(file); // 创建图片元素
|
|
236
|
+
img = new Image(); // 处理图片加载完成
|
|
237
|
+
img.onload = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
238
|
+
var canvas, ctx, imageData, hints, reader, _result, barcodeFormat, isValidType, errorMsg;
|
|
239
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
240
|
+
while (1) switch (_context.prev = _context.next) {
|
|
241
|
+
case 0:
|
|
242
|
+
_context.prev = 0;
|
|
243
|
+
// 创建临时canvas
|
|
244
|
+
canvas = document.createElement('canvas');
|
|
245
|
+
ctx = canvas.getContext('2d'); // 设置canvas尺寸
|
|
246
|
+
canvas.width = img.width;
|
|
247
|
+
canvas.height = img.height;
|
|
248
|
+
|
|
249
|
+
// 在canvas上绘制图片
|
|
250
|
+
ctx === null || ctx === void 0 || ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
251
|
+
|
|
252
|
+
// 获取图片数据
|
|
253
|
+
imageData = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
254
|
+
if (!imageData) {
|
|
255
|
+
_context.next = 24;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
// 创建解码器
|
|
259
|
+
hints = new Map();
|
|
260
|
+
if (formats && formats.length > 0) {
|
|
261
|
+
hints.set(2, formats); // 2 对应 DecodeHintType.POSSIBLE_FORMATS
|
|
262
|
+
}
|
|
263
|
+
reader = new BrowserMultiFormatReader(hints);
|
|
264
|
+
_context.prev = 11;
|
|
265
|
+
_context.next = 14;
|
|
266
|
+
return reader.decodeFromImageData(imageData);
|
|
267
|
+
case 14:
|
|
268
|
+
_result = _context.sent;
|
|
269
|
+
// 获取扫码类型
|
|
270
|
+
barcodeFormat = _result.getBarcodeFormat(); // 验证是否符合扫码类型要求
|
|
271
|
+
isValidType = !formats || formats.length === 0 || formats.includes(barcodeFormat);
|
|
272
|
+
if (!isValidType) {
|
|
273
|
+
// 显示错误提示
|
|
274
|
+
errorMsg = scanCodeType === 'qrcode' ? getText('scan.qrcodeOnlyError') : getText('scan.barcodeOnlyError');
|
|
275
|
+
message.error({
|
|
276
|
+
content: errorMsg || "\u4E0D\u7B26\u5408\u5F53\u524D\u626B\u7801\u7C7B\u578B\u8981\u6C42\uFF0C\u8BF7\u626B\u63CF".concat(getScanTypeText),
|
|
277
|
+
key: 'scanLoading'
|
|
278
|
+
});
|
|
279
|
+
} else {
|
|
280
|
+
// 关闭loading
|
|
281
|
+
message.success({
|
|
282
|
+
content: '识别成功',
|
|
283
|
+
key: 'scanLoading'
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// 处理扫码结果
|
|
287
|
+
setScanVisible(false);
|
|
288
|
+
setFullScreenMode(false);
|
|
289
|
+
|
|
290
|
+
// 设置扫码结果
|
|
291
|
+
handleChange({
|
|
292
|
+
target: {
|
|
293
|
+
value: _result.getText()
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
_context.next = 24;
|
|
298
|
+
break;
|
|
299
|
+
case 20:
|
|
300
|
+
_context.prev = 20;
|
|
301
|
+
_context.t0 = _context["catch"](11);
|
|
302
|
+
console.error('[handleImageSelect] 扫描图片失败:', _context.t0);
|
|
303
|
+
message.error({
|
|
304
|
+
content: '未能识别二维码/条形码',
|
|
305
|
+
key: 'scanLoading'
|
|
306
|
+
});
|
|
307
|
+
case 24:
|
|
308
|
+
_context.next = 30;
|
|
309
|
+
break;
|
|
310
|
+
case 26:
|
|
311
|
+
_context.prev = 26;
|
|
312
|
+
_context.t1 = _context["catch"](0);
|
|
313
|
+
console.error('[handleImageSelect] 扫描图片失败:', _context.t1);
|
|
314
|
+
message.error({
|
|
315
|
+
content: '未能识别二维码/条形码',
|
|
316
|
+
key: 'scanLoading'
|
|
317
|
+
});
|
|
318
|
+
case 30:
|
|
319
|
+
// 释放URL资源
|
|
320
|
+
URL.revokeObjectURL(url);
|
|
321
|
+
case 31:
|
|
322
|
+
case "end":
|
|
323
|
+
return _context.stop();
|
|
324
|
+
}
|
|
325
|
+
}, _callee, null, [[0, 26], [11, 20]]);
|
|
326
|
+
}));
|
|
327
|
+
|
|
328
|
+
// 处理图片加载失败
|
|
329
|
+
img.onerror = function () {
|
|
330
|
+
URL.revokeObjectURL(url);
|
|
331
|
+
message.error({
|
|
332
|
+
content: '图片加载失败',
|
|
333
|
+
key: 'scanLoading'
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// 设置图片源
|
|
338
|
+
img.src = url;
|
|
339
|
+
} catch (error) {
|
|
340
|
+
console.error('[handleImageSelect] 处理图片失败:', error);
|
|
341
|
+
message.error({
|
|
342
|
+
content: '处理图片失败',
|
|
343
|
+
key: 'scanLoading'
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return _context2.abrupt("return", false);
|
|
347
|
+
case 6:
|
|
348
|
+
case "end":
|
|
349
|
+
return _context2.stop();
|
|
350
|
+
}
|
|
351
|
+
}, _callee2);
|
|
352
|
+
}));
|
|
353
|
+
return function handleImageSelect(_x) {
|
|
354
|
+
return _ref.apply(this, arguments);
|
|
355
|
+
};
|
|
356
|
+
}();
|
|
357
|
+
|
|
358
|
+
// 自定义输入框组件,完全控制清空和扫描操作
|
|
359
|
+
var CustomInput = function CustomInput() {
|
|
360
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
361
|
+
style: {
|
|
362
|
+
display: 'flex',
|
|
363
|
+
width: '100%',
|
|
364
|
+
position: 'relative'
|
|
365
|
+
}
|
|
366
|
+
}, /*#__PURE__*/React.createElement(AntInput, _extends({}, restProps, {
|
|
367
|
+
ref: props.innerRef || undefined,
|
|
368
|
+
style: _objectSpread(_objectSpread({}, props.style), {}, {
|
|
369
|
+
flex: 1
|
|
370
|
+
}, allowScan && isH5 ? {
|
|
371
|
+
borderTopRightRadius: 0,
|
|
372
|
+
borderBottomRightRadius: 0,
|
|
373
|
+
borderRight: 0
|
|
374
|
+
} : {}),
|
|
375
|
+
onChange: handleChange,
|
|
376
|
+
value: debugValue,
|
|
377
|
+
allowClear: props.allowClear !== false
|
|
378
|
+
})), allowScan && isH5 && /*#__PURE__*/React.createElement(Button, {
|
|
379
|
+
icon: /*#__PURE__*/React.createElement(ScanOutlined, null),
|
|
380
|
+
onClick: handleScanClick,
|
|
381
|
+
style: {
|
|
382
|
+
borderTopLeftRadius: 0,
|
|
383
|
+
borderBottomLeftRadius: 0,
|
|
384
|
+
height: 'auto'
|
|
385
|
+
}
|
|
386
|
+
}));
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// 组件挂载时初始化
|
|
390
|
+
useEffect(function () {
|
|
391
|
+
// 检查当前设备类型,使用 platform 判断
|
|
392
|
+
if (isH5) {
|
|
393
|
+
// 移动设备初始化逻辑
|
|
394
|
+
if (isDevelopEnv) {
|
|
395
|
+
console.log('[Input.WithMode] 当前平台: H5');
|
|
396
|
+
window.__DEBUG_INPUT_PROPS__ = props;
|
|
397
|
+
|
|
398
|
+
// 添加全局测试函数
|
|
399
|
+
window.testPisellScan = function () {
|
|
400
|
+
console.log('测试扫码功能');
|
|
401
|
+
setScanVisible(true);
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// 输出所有重要的状态和配置
|
|
405
|
+
console.log('组件初始化配置:', {
|
|
406
|
+
allowScan: allowScan,
|
|
407
|
+
scanCodeType: scanCodeType,
|
|
408
|
+
formats: formats
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// 设置原生扫码回调
|
|
413
|
+
window.handleScanCallback = function (result) {
|
|
414
|
+
if (isDevelopEnv) {
|
|
415
|
+
console.log('接收到原生扫码结果:', result);
|
|
416
|
+
}
|
|
417
|
+
handleScan(result);
|
|
418
|
+
};
|
|
419
|
+
} else {
|
|
420
|
+
if (isDevelopEnv) {
|
|
421
|
+
console.log('[Input.WithMode] 当前平台: PC');
|
|
422
|
+
window.__DEBUG_INPUT_PROPS__ = props;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return function () {
|
|
426
|
+
// 清理全局函数
|
|
427
|
+
window.handleScanCallback = undefined;
|
|
428
|
+
window.testPisellScan = undefined;
|
|
429
|
+
};
|
|
430
|
+
}, [platform, allowScan, scanCodeType, formats]);
|
|
431
|
+
|
|
432
|
+
// 监听全屏事件
|
|
433
|
+
useEffect(function () {
|
|
434
|
+
var handleFullscreenChange = function handleFullscreenChange() {
|
|
435
|
+
if (!document.fullscreenElement && fullScreenMode) {
|
|
436
|
+
var _scanRef$current4;
|
|
437
|
+
// 用户通过其他方式退出了全屏
|
|
438
|
+
setFullScreenMode(false);
|
|
439
|
+
setScanVisible(false);
|
|
440
|
+
(_scanRef$current4 = scanRef.current) === null || _scanRef$current4 === void 0 || (_scanRef$current4 = _scanRef$current4.codeReader) === null || _scanRef$current4 === void 0 || _scanRef$current4.reset();
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
|
444
|
+
return function () {
|
|
445
|
+
return document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
|
446
|
+
};
|
|
447
|
+
}, [fullScreenMode]);
|
|
448
|
+
|
|
449
|
+
// 扫码类型变化时,更新标题
|
|
450
|
+
useEffect(function () {
|
|
451
|
+
if (isDevelopEnv) {
|
|
452
|
+
console.log('[Input.WithMode] 扫码类型变化:', scanCodeType, '标题文本:', getScanTypeText);
|
|
453
|
+
}
|
|
454
|
+
}, [scanCodeType, getScanTypeText]);
|
|
455
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CustomInput, null), allowScan && isH5 && scanVisible && /*#__PURE__*/React.createElement("div", {
|
|
456
|
+
ref: scanContainerRef,
|
|
457
|
+
style: {
|
|
458
|
+
position: fullScreenMode ? 'fixed' : 'absolute',
|
|
459
|
+
top: 0,
|
|
460
|
+
left: 0,
|
|
461
|
+
right: 0,
|
|
462
|
+
bottom: 0,
|
|
463
|
+
backgroundColor: '#000',
|
|
464
|
+
zIndex: 9999,
|
|
465
|
+
display: 'flex',
|
|
466
|
+
flexDirection: 'column'
|
|
467
|
+
}
|
|
468
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
469
|
+
style: {
|
|
470
|
+
padding: '10px 15px',
|
|
471
|
+
backgroundColor: '#fff',
|
|
472
|
+
display: 'flex',
|
|
473
|
+
justifyContent: 'space-between',
|
|
474
|
+
alignItems: 'center'
|
|
475
|
+
}
|
|
476
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
477
|
+
style: {
|
|
478
|
+
fontSize: '16px',
|
|
479
|
+
fontWeight: 'bold'
|
|
480
|
+
}
|
|
481
|
+
}, getScanTypeText || 'Scan QR Code/Barcode'), /*#__PURE__*/React.createElement("span", {
|
|
482
|
+
onClick: exitFullScreenScan,
|
|
483
|
+
style: {
|
|
484
|
+
cursor: 'pointer',
|
|
485
|
+
fontSize: '24px'
|
|
486
|
+
}
|
|
487
|
+
}, "\xD7")), /*#__PURE__*/React.createElement("div", {
|
|
488
|
+
style: {
|
|
489
|
+
flex: 1,
|
|
490
|
+
position: 'relative'
|
|
491
|
+
}
|
|
492
|
+
}, /*#__PURE__*/React.createElement(PisellScan, {
|
|
493
|
+
width: "100%",
|
|
494
|
+
height: "100%",
|
|
495
|
+
onChange: handleScan,
|
|
496
|
+
timeBetweenScansMillis: 1000,
|
|
497
|
+
ref: scanRef,
|
|
498
|
+
formats: formats,
|
|
499
|
+
preferFrontCamera: false // 使用后置摄像头
|
|
500
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
501
|
+
style: {
|
|
502
|
+
padding: '15px',
|
|
503
|
+
backgroundColor: '#fff',
|
|
504
|
+
display: 'flex',
|
|
505
|
+
justifyContent: 'center',
|
|
506
|
+
borderTop: '1px solid #f0f0f0'
|
|
507
|
+
}
|
|
508
|
+
}, /*#__PURE__*/React.createElement(Upload, {
|
|
509
|
+
accept: "image/*",
|
|
510
|
+
showUploadList: false,
|
|
511
|
+
beforeUpload: handleImageSelect,
|
|
512
|
+
style: {
|
|
513
|
+
marginRight: '15px'
|
|
514
|
+
}
|
|
515
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
516
|
+
icon: /*#__PURE__*/React.createElement(PictureOutlined, null),
|
|
517
|
+
style: {
|
|
518
|
+
marginRight: '15px'
|
|
519
|
+
}
|
|
520
|
+
}, getFromAlbumText || 'From Album')), /*#__PURE__*/React.createElement(Button, {
|
|
521
|
+
icon: /*#__PURE__*/React.createElement(ArrowLeftOutlined, null),
|
|
522
|
+
onClick: exitFullScreenScan
|
|
523
|
+
}, getBackText || 'Back'))));
|
|
10
524
|
};
|
|
11
|
-
|
|
12
|
-
export default InputWithMode;
|
|
525
|
+
export default withMode(Input, ReadPretty);
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withFormItem } from "../../dataSourceForm/utils";
|
|
3
|
+
import InputWithMode from "./WithMode";
|
|
1
4
|
import JSON from "../Input.Json";
|
|
2
5
|
import Password from "../Input.Password";
|
|
3
6
|
import TextArea from "../Input.TextArea";
|
|
4
7
|
import Url from "../Input.Url";
|
|
5
8
|
import Email from "../Input.Email";
|
|
6
|
-
import Phone from "../Input.Phone";
|
|
7
|
-
import Mobile from "../Input.Mobile";
|
|
8
|
-
import Subdomain from "../Input.Subdomain";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import Phone from "../Input.Phone";
|
|
10
|
+
import Mobile from "../Input.Mobile";
|
|
11
|
+
import Subdomain from "../Input.Subdomain";
|
|
12
|
+
// 修改 withFormItem 调用,确保属性传递
|
|
13
|
+
var InputWithForm = withFormItem(InputWithMode, {
|
|
14
|
+
innerProps: {
|
|
15
|
+
// 要传递的属性,移除allowScan
|
|
16
|
+
scanCodeType: undefined,
|
|
17
|
+
language: undefined
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// 简化组件,直接传递属性
|
|
22
|
+
var Input = function Input(props) {
|
|
23
|
+
return /*#__PURE__*/React.createElement(InputWithForm, props);
|
|
24
|
+
};
|
|
12
25
|
Input.JSON = JSON;
|
|
13
26
|
Input.Password = Password;
|
|
14
27
|
Input.TextArea = TextArea;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["width", "height", "borderRadius", "style", "children", "onChange", "timeBetweenScansMillis"];
|
|
2
|
+
var _excluded = ["width", "height", "borderRadius", "style", "children", "onChange", "timeBetweenScansMillis", "formats"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -11,6 +11,9 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
11
11
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
12
12
|
import { BrowserMultiFormatReader, NotFoundException } from '@zxing/library';
|
|
13
13
|
import "./index.less";
|
|
14
|
+
|
|
15
|
+
// 添加导入JSX命名空间解决JSX类型问题
|
|
16
|
+
|
|
14
17
|
/**
|
|
15
18
|
* 二维码条形码扫描组件
|
|
16
19
|
*/
|
|
@@ -23,6 +26,7 @@ var PisellScan = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
23
26
|
onChange = props.onChange,
|
|
24
27
|
_props$timeBetweenSca = props.timeBetweenScansMillis,
|
|
25
28
|
timeBetweenScansMillis = _props$timeBetweenSca === void 0 ? 500 : _props$timeBetweenSca,
|
|
29
|
+
formats = props.formats,
|
|
26
30
|
others = _objectWithoutProperties(props, _excluded);
|
|
27
31
|
var videoRef = useRef(null);
|
|
28
32
|
var codeReaderRef = useRef(null);
|
|
@@ -32,7 +36,12 @@ var PisellScan = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
32
36
|
};
|
|
33
37
|
});
|
|
34
38
|
useEffect(function () {
|
|
35
|
-
|
|
39
|
+
// 使用传入的formats参数初始化扫码器
|
|
40
|
+
var hints = new Map();
|
|
41
|
+
if (formats && formats.length > 0) {
|
|
42
|
+
hints.set(2, formats); // 2 对应 DecodeHintType.POSSIBLE_FORMATS
|
|
43
|
+
}
|
|
44
|
+
var codeReader = new BrowserMultiFormatReader(hints, timeBetweenScansMillis);
|
|
36
45
|
// 将 codeReader 实例保存到 ref 对象中
|
|
37
46
|
codeReaderRef.current = codeReader;
|
|
38
47
|
var selectedDeviceId;
|
|
@@ -44,7 +53,12 @@ var PisellScan = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
44
53
|
codeReader.decodeFromVideoDevice(null, videoRef.current, function (result, err) {
|
|
45
54
|
// 如果解码成功,调用 onChange 回调并传递解码结果的文本
|
|
46
55
|
if (result) {
|
|
47
|
-
|
|
56
|
+
var _barcodeFormat = result.getBarcodeFormat();
|
|
57
|
+
// 判断识别出的码类型是否在允许的格式列表中
|
|
58
|
+
var _isValidType = !formats || formats.length === 0 || formats.includes(_barcodeFormat);
|
|
59
|
+
|
|
60
|
+
// 回调中返回更多信息
|
|
61
|
+
onChange === null || onChange === void 0 || onChange(result.getText(), _barcodeFormat, _isValidType);
|
|
48
62
|
}
|
|
49
63
|
// 如果解码出错且错误不是 NotFoundException,则输出错误到控制台
|
|
50
64
|
if (err && !(err instanceof NotFoundException)) {
|