@kmkf-fe-packages/kmkf-utils 2.2.31-beta.53 → 2.2.31-beta.59

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/README.md CHANGED
@@ -1 +1 @@
1
- 112311133111
1
+ 1123111331111
@@ -5,5 +5,5 @@ export default abstract class BaseAddressData {
5
5
  protected abstract addressOptions: TreeOption[];
6
6
  getProCodeByName(proName: string): number | undefined;
7
7
  getNameByCode(code: string | number): string;
8
- getCodesByNames(names: Array<string>): (string | undefined)[];
8
+ getCodesByNames(names: Array<string>, isIncludesDistrict?: boolean): (string | undefined)[];
9
9
  }
@@ -1,7 +1,4 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
- 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); }
4
- 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; }
5
2
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
3
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
4
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -27,32 +24,32 @@ var BaseAddressData = /*#__PURE__*/function () {
27
24
  var _ref;
28
25
  return (_ref = (this.addrData || {})[code] || []) === null || _ref === void 0 ? void 0 : _ref[0];
29
26
  }
27
+
28
+ // isIncludesDistrict 为true时区县如果未找到全等的就查找包含的<暂时仅jst识别地址需要>
30
29
  }, {
31
30
  key: "getCodesByNames",
32
31
  value: function getCodesByNames(names) {
32
+ var isIncludesDistrict = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
33
33
  var codes = [];
34
34
  var currentData = this.addressOptions;
35
- var _iterator = _createForOfIteratorHelper(names),
36
- _step;
37
- try {
38
- var _loop = function _loop() {
39
- var name = _step.value;
40
- var foundChild = currentData.find(function (item) {
41
- return item.label === name;
35
+ names.forEach(function (name, index) {
36
+ var _foundChild, _foundChild2;
37
+ var foundChild = currentData.find(function (item) {
38
+ return item.label === name;
39
+ });
40
+
41
+ // 区县如果未找到全等的就查找包含的
42
+ if (!foundChild && isIncludesDistrict && index === 2) {
43
+ foundChild = currentData.find(function (item) {
44
+ return item.label.includes(name);
42
45
  });
43
- codes.push(foundChild === null || foundChild === void 0 ? void 0 : foundChild.value);
44
- if (!isEmpty(foundChild === null || foundChild === void 0 ? void 0 : foundChild.children)) {
45
- currentData = (foundChild === null || foundChild === void 0 ? void 0 : foundChild.children) || [];
46
- }
47
- };
48
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
49
- _loop();
50
46
  }
51
- } catch (err) {
52
- _iterator.e(err);
53
- } finally {
54
- _iterator.f();
55
- }
47
+ codes.push((_foundChild = foundChild) === null || _foundChild === void 0 ? void 0 : _foundChild.value);
48
+ if (!isEmpty((_foundChild2 = foundChild) === null || _foundChild2 === void 0 ? void 0 : _foundChild2.children)) {
49
+ var _foundChild3;
50
+ currentData = ((_foundChild3 = foundChild) === null || _foundChild3 === void 0 ? void 0 : _foundChild3.children) || [];
51
+ }
52
+ });
56
53
  return codes.filter(Boolean);
57
54
  }
58
55
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/kmkf-utils",
3
- "version": "2.2.31-beta.53",
3
+ "version": "2.2.31-beta.59",
4
4
  "module": "dist/esm/index.js",
5
5
  "typings": "dist/esm/index.d.ts",
6
6
  "files": [
@@ -41,7 +41,7 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "da633abe80f99d28e5ab6d93e38822a002674de0",
44
+ "gitHead": "667f2e77063db5c02eb02af929adefd29c399c4c",
45
45
  "gitHooks": {
46
46
  "pre-commit": "lint-staged"
47
47
  }