@kmkf-fe-packages/kmkf-utils 1.0.3 → 1.0.4-rc.2

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.
@@ -8,12 +8,16 @@ interface OptionsItem {
8
8
  logisticsStatusList?: any[];
9
9
  }
10
10
  export default class ExpressData {
11
- private static instance;
12
- expressData: OptionsItem[];
11
+ private static instanceMap;
12
+ expressDataMap: Record<string, OptionsItem[]>;
13
+ type: string;
14
+ constructor(type: string);
15
+ get expressData(): OptionsItem[];
16
+ set expressData(value: OptionsItem[]);
13
17
  getExpressData: () => OptionsItem[];
14
- setExpressData: (val: OptionsItem[]) => OptionsItem[];
18
+ setExpressData: (val: OptionsItem[], type: string) => OptionsItem[];
15
19
  getExpressNameByCode: (code: string | number, returnCurrentValue?: boolean) => string | number;
16
20
  getExpressCodeByName: (name: string | number, returnCurrentValue?: boolean) => string | number;
17
- static getInstance(): ExpressData;
21
+ static getInstance(type?: string): ExpressData;
18
22
  }
19
23
  export {};
@@ -6,15 +6,20 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
6
6
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
7
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
8
  var ExpressData = /*#__PURE__*/function () {
9
- function ExpressData() {
9
+ // private static instance: ExpressData;
10
+
11
+ // expressData: OptionsItem[] = [];
12
+
13
+ function ExpressData(_type) {
10
14
  var _this = this;
11
15
  _classCallCheck(this, ExpressData);
12
- _defineProperty(this, "expressData", []);
16
+ _defineProperty(this, "expressDataMap", {});
17
+ _defineProperty(this, "type", void 0);
13
18
  _defineProperty(this, "getExpressData", function () {
14
19
  return _this.expressData;
15
20
  });
16
- _defineProperty(this, "setExpressData", function (val) {
17
- return _this.expressData = val;
21
+ _defineProperty(this, "setExpressData", function (val, type) {
22
+ return _this.expressDataMap[type] = val;
18
23
  });
19
24
  _defineProperty(this, "getExpressNameByCode", function (code) {
20
25
  var returnCurrentValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
@@ -30,17 +35,27 @@ var ExpressData = /*#__PURE__*/function () {
30
35
  });
31
36
  return item.length ? item[0].value : returnCurrentValue ? name : "";
32
37
  });
38
+ this.type = _type;
33
39
  }
34
- _createClass(ExpressData, null, [{
40
+ _createClass(ExpressData, [{
41
+ key: "expressData",
42
+ get: function get() {
43
+ return this.expressDataMap[this.type] || [];
44
+ },
45
+ set: function set(value) {
46
+ this.expressDataMap[this.type] = value;
47
+ }
48
+ }], [{
35
49
  key: "getInstance",
36
50
  value: function getInstance() {
37
- if (!ExpressData.instance) {
38
- ExpressData.instance = new ExpressData();
51
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
52
+ if (!ExpressData.instanceMap[type]) {
53
+ ExpressData.instanceMap[type] = new ExpressData(type);
39
54
  }
40
- return ExpressData.instance;
55
+ return ExpressData.instanceMap[type];
41
56
  }
42
57
  }]);
43
58
  return ExpressData;
44
59
  }();
45
- _defineProperty(ExpressData, "instance", void 0);
60
+ _defineProperty(ExpressData, "instanceMap", {});
46
61
  export { ExpressData as default };
@@ -5,5 +5,8 @@ export { default as BsAddressData } from "./bsAddressData";
5
5
  export { default as WdtAddressData } from "./wdtAddressData";
6
6
  export { default as PlatData } from "./platData";
7
7
  export { default as LogisticsAddressData } from "./logisticsAddressData";
8
+ export { default as WdtSendData } from "./wdtSendData";
8
9
  export { default as request } from "./request";
10
+ export * as WDT from "./wdt";
11
+ export * as servers from "./servers";
9
12
  export * from "./utils";
package/dist/esm/index.js CHANGED
@@ -5,5 +5,10 @@ export { default as BsAddressData } from "./bsAddressData";
5
5
  export { default as WdtAddressData } from "./wdtAddressData";
6
6
  export { default as PlatData } from "./platData";
7
7
  export { default as LogisticsAddressData } from "./logisticsAddressData";
8
+ export { default as WdtSendData } from "./wdtSendData";
8
9
  export { default as request } from "./request";
10
+ import * as _WDT from "./wdt";
11
+ export { _WDT as WDT };
12
+ import * as _servers from "./servers";
13
+ export { _servers as servers };
9
14
  export * from "./utils";
@@ -12,5 +12,5 @@ export interface serverProps<T = any> {
12
12
  traceId: string;
13
13
  [key: string]: any;
14
14
  }
15
- declare const requestApi: ({ url, method, data, headers, handleError }: RequestProps) => Promise<serverProps>;
15
+ declare const requestApi: <T = any>({ url, method, data, headers, handleError, }: RequestProps) => Promise<serverProps<T>>;
16
16
  export default requestApi;
@@ -5,7 +5,7 @@
5
5
  * @LastEditors: litian
6
6
  * @LastEditTime: 2022-11-24 09:11:45
7
7
  */
8
- import { extend } from 'umi-request';
8
+ import { extend } from "umi-request";
9
9
  var request = extend({});
10
10
  var requestApi = function requestApi(_ref) {
11
11
  var url = _ref.url,
@@ -19,7 +19,7 @@ var requestApi = function requestApi(_ref) {
19
19
  method: method,
20
20
  headers: headers
21
21
  };
22
- if (method.toLocaleLowerCase() === 'get') {
22
+ if (method.toLocaleLowerCase() === "get") {
23
23
  params.params = data;
24
24
  } else {
25
25
  params.data = data;
@@ -0,0 +1,18 @@
1
+ import WdtAddressData from "../wdtAddressData";
2
+ import AddressData from "../addressData";
3
+ import BsAddressData from "../bsAddressData";
4
+ export declare const queryWdtAddressData: (instance?: WdtAddressData) => Promise<void>;
5
+ export declare const queryAddressData: (instance?: AddressData) => Promise<void>;
6
+ export declare const queryBsAddressData: (instance?: BsAddressData) => Promise<void>;
7
+ export declare const queryWdtWarehouseList: (pageNo: number, pageSize: number) => Promise<import("../request/index").serverProps<{
8
+ warehouses: {
9
+ warehouseNo: string;
10
+ name: string;
11
+ }[];
12
+ totalCount?: number | undefined;
13
+ }>>;
14
+ export declare const getWdtSellerLogisticsCompanyRelation: () => Promise<{
15
+ label: string;
16
+ value: string;
17
+ disabled: boolean;
18
+ }[]>;
@@ -0,0 +1,100 @@
1
+ import get from "lodash/get";
2
+ import WdtAddressData from "../wdtAddressData";
3
+ import AddressData from "../addressData";
4
+ import BsAddressData from "../bsAddressData";
5
+ import toTree from "../utils/toTree";
6
+ import request from "../request/index";
7
+ var transformData = function transformData(list) {
8
+ var map = {};
9
+ var res = {};
10
+ for (var i = 0; i < list.length; i++) {
11
+ res[list[i]["id"]] = [list[i]["name"], list[i]["parentId"]];
12
+ map[list[i]["name"]] = list[i]["id"];
13
+ }
14
+ return {
15
+ map: map,
16
+ res: res
17
+ };
18
+ };
19
+ export var queryWdtAddressData = function queryWdtAddressData() {
20
+ var instance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : WdtAddressData.getInstance();
21
+ return request({
22
+ url: "/qy/gdfw/template/queryWdtAreas/noLogin",
23
+ method: "get",
24
+ data: {}
25
+ }).then(function (resp) {
26
+ var list = resp.data || [];
27
+ var _transformData = transformData(list),
28
+ res = _transformData.res,
29
+ map = _transformData.map;
30
+ instance.addrData = res;
31
+ instance.addrNameMap = map;
32
+ instance.addressOptions = toTree(list, 1);
33
+ });
34
+ };
35
+ export var queryAddressData = function queryAddressData() {
36
+ var instance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : AddressData.getInstance();
37
+ return request({
38
+ url: "/qy/gdfw/template/queryAreas/noLogin",
39
+ method: "get",
40
+ data: {}
41
+ }).then(function (resp) {
42
+ var list = resp.data || [];
43
+ var _transformData2 = transformData(list),
44
+ res = _transformData2.res,
45
+ map = _transformData2.map;
46
+ instance.addrData = res;
47
+ instance.addrNameMap = map;
48
+ instance.addressOptions = get(toTree(list, 0), "0.children", []);
49
+ });
50
+ };
51
+ export var queryBsAddressData = function queryBsAddressData() {
52
+ var instance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : BsAddressData.getInstance();
53
+ return request({
54
+ url: "/qy/gdfw/template/queryBsAreas/noLogin",
55
+ method: "get",
56
+ data: {}
57
+ }).then(function (resp) {
58
+ var list = resp.data || [];
59
+ var _transformData3 = transformData(list),
60
+ res = _transformData3.res,
61
+ map = _transformData3.map;
62
+ instance.addrData = res;
63
+ instance.addrNameMap = map;
64
+ instance.addressOptions = toTree(list, 1);
65
+ });
66
+ };
67
+ export var queryWdtWarehouseList = function queryWdtWarehouseList(pageNo, pageSize) {
68
+ return request({
69
+ url: "/qy/gdfw/wdt/erp/warehouse/list",
70
+ method: "post",
71
+ data: {
72
+ pageNo: pageNo,
73
+ pageSize: pageSize
74
+ }
75
+ });
76
+ };
77
+ export var getWdtSellerLogisticsCompanyRelation = function getWdtSellerLogisticsCompanyRelation() {
78
+ return request({
79
+ url: "/qy/gdfw/wdt/erp/logistics/list",
80
+ method: "post",
81
+ data: {}
82
+ }).then(function (res) {
83
+ if (res !== null && res !== void 0 && res.success) {
84
+ var _res$data;
85
+ var list = ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.map(function (item) {
86
+ return {
87
+ label: item.logisticsName,
88
+ value: item.logisticsNo,
89
+ disabled: item.isDelete
90
+ };
91
+ }).filter(function (item) {
92
+ return item.value;
93
+ }).sort(function (a, b) {
94
+ return (a.disabled ? 1 : 0) - (b.disabled ? 1 : 0);
95
+ })) || [];
96
+ return list;
97
+ }
98
+ return [];
99
+ });
100
+ };
@@ -1,5 +1,5 @@
1
1
  export default (function (key) {
2
- return ["itemList", "itemId", "supplierName", "numIid", "aloneItemId", "aloneItemEncode", "jstItemList", "logisticsCompany", "logisticsCode", "supplyId", "supplyName", "sendId", "sendName", "dateTime", "basicMultSelect", "checkbox", "multSelect", "rate", "picture", "file", "wdtGoods", "wdtReissueType", "wdtReissueGoods", "wdtSendGood", "wdtSendId", "wdtSendName", "wdtLogisticsCode", "wdtSystemShowOrder", "wdtSystemSelectIds", "wdtLogisticsCompany", "wdtLogisticsList", "bsSendGood", "bsSendId", "bsSendName", "bsGoods", "bsExchangeType", "bsExchangeReturnGoods", "bsExchangeSwapOutGoods", "bsExchangeGiftGoods", "bsReissueType", "bsReissueGoods", "bsReturnGoods", "bsReturnType", "bsLogisticsList", "bsLogisticsCompany", "bsLogisticsCode", "bsSystemShowOrder", "bsSystemSelectIds", "reissueLogisticsList", "reissueLogisticsCompany", "reissueLogisticsCode", "deliveryNoList", "deliveryNoIds", "returnGoodsStatusList", "returnGoodsTradeIdList", "returnGoodsTradeItemList", "tradeIdList", "tradeItemList", "wlnLogisticsList", "wlnLogisticsCompany", "wlnLogisticsCode", "wlnSystemShowOrder", "wlnSystemSelectIds", "wlnGoods", "wlnSendGood", "wlnSendId", "wlnSendName", "exchangeReason", "flowTag", "returnGoodsStatusList", "returnGoodsStatusValue", "exchangeReason", "exchangeStatusValue", "inStockStatusItemList", "inStockStatusList", "reissueStatusValue", "reissueReason", "adjustWorkOrderStatusValue", "adjustWorkOrderReason", "msgStatusValues", "msgStatus4Search", "createStatusValue", "createReason", "invoiceStatusValue", "invoiceReason", "invoicingStatusValue", "invoicingReason", "trajectoryList", "trajectoryMoreCompany", "trajectoryMoreCode", "trajectoryMoreSnapshot", "logisticsInterceptList", "logisticsInterceptCompanyList", "logisticsInterceptCodeList", "logisticsInterceptTypeList", "logisticsInterceptStatusList", "logisticsInterceptSnapshotList"].reduce(function (cur, nxt) {
2
+ return ["itemList", "itemId", "supplierName", "numIid", "aloneItemId", "aloneItemEncode", "jstItemList", "logisticsCompany", "logisticsCode", "supplyId", "supplyName", "sendId", "sendName", "dateTime", "basicMultSelect", "checkbox", "multSelect", "rate", "picture", "file", "wdtGoods", "wdtReissueType", "wdtSystemOrderNo", "wdtReissueGoods", "wdtSendGood", "wdtSendId", "wdtSendName", "wdtLogisticsCode", "wdtSystemShowOrder", "wdtSystemSelectIds", "wdtLogisticsCompany", "wdtLogisticsList", "bsSendGood", "bsSendId", "bsSendName", "bsGoods", "bsExchangeType", "bsExchangeReturnGoods", "bsExchangeSwapOutGoods", "bsExchangeGiftGoods", "bsReissueType", "bsReissueGoods", "bsReturnGoods", "bsReturnType", "bsLogisticsList", "bsLogisticsCompany", "bsLogisticsCode", "bsSystemShowOrder", "bsSystemSelectIds", "reissueLogisticsList", "reissueLogisticsCompany", "reissueLogisticsCode", "deliveryNoList", "deliveryNoIds", "returnGoodsStatusList", "returnGoodsTradeIdList", "returnGoodsTradeItemList", "tradeIdList", "tradeItemList", "wlnLogisticsList", "wlnLogisticsCompany", "wlnLogisticsCode", "wlnSystemShowOrder", "wlnSystemSelectIds", "wlnGoods", "wlnSendGood", "wlnSendId", "wlnSendName", "exchangeReason", "flowTag", "returnGoodsStatusList", "returnGoodsStatusValue", "exchangeReason", "exchangeStatusValue", "inStockStatusItemList", "inStockStatusList", "reissueStatusValue", "reissueReason", "adjustWorkOrderStatusValue", "adjustWorkOrderReason", "msgStatusValues", "msgStatus4Search", "createStatusValue", "createReason", "invoiceStatusValue", "invoiceReason", "invoicingStatusValue", "invoicingReason", "trajectoryList", "trajectoryMoreCompany", "trajectoryMoreCode", "trajectoryMoreSnapshot", "logisticsInterceptList", "logisticsInterceptCompanyList", "logisticsInterceptCodeList", "logisticsInterceptTypeList", "logisticsInterceptStatusList", "logisticsInterceptSnapshotList"].reduce(function (cur, nxt) {
3
3
  return cur || (key === null || key === void 0 ? void 0 : key.includes(nxt));
4
4
  }, false);
5
5
  });
@@ -115,21 +115,43 @@ var updateWdtSystemItemListHandle = function updateWdtSystemItemListHandle(list,
115
115
  };
116
116
  var updateWdtItemListByConfigHandle = function updateWdtItemListByConfigHandle(list, type) {
117
117
  var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
118
- var showField = config.showField;
118
+ var showField = config.showField,
119
+ _config$notOrderBack = config.notOrderBack,
120
+ notOrderBack = _config$notOrderBack === void 0 ? false : _config$notOrderBack;
119
121
  return list === null || list === void 0 ? void 0 : list.reduce(function (prv, next) {
120
122
  if (type === "logistics") {
121
123
  if (!["logisticsCompany", ""].includes(showField || "")) {
122
124
  next.logisticsCompany = undefined;
125
+ if (notOrderBack) {
126
+ next.logisticsCode = undefined;
127
+ }
123
128
  }
124
129
  if (!["logisticsCode", ""].includes(showField || "")) {
125
130
  next.logisticsCode = undefined;
131
+ if (notOrderBack) {
132
+ next.logisticsCompany = undefined;
133
+ }
134
+ }
135
+ if (showField === '' && notOrderBack) {
136
+ next.logisticsCompany = undefined;
137
+ next.logisticsCode = undefined;
126
138
  }
127
139
  } else if (type === "send") {
128
140
  if (!["sendId", "all"].includes(showField || "")) {
129
141
  next.sendId = undefined;
142
+ if (notOrderBack) {
143
+ next.sendName = undefined;
144
+ }
130
145
  }
131
146
  if (!["sendName", "all"].includes(showField || "")) {
132
147
  next.sendName = undefined;
148
+ if (notOrderBack) {
149
+ next.sendId = undefined;
150
+ }
151
+ }
152
+ if (showField === 'all' && notOrderBack) {
153
+ next.sendName = undefined;
154
+ next.sendId = undefined;
133
155
  }
134
156
  }
135
157
  prv.push(next);
@@ -150,7 +172,10 @@ export var wdtOrderBackFormValues = function wdtOrderBackFormValues() {
150
172
  prv[uniqueKey] = detail === null || detail === void 0 ? void 0 : detail.wdtGoods;
151
173
  break;
152
174
  case "WDT_REISSUE_GOODS":
153
- prv[uniqueKey] = detail === null || detail === void 0 ? void 0 : detail.wdtReissueGoods;
175
+ prv[uniqueKey] = {
176
+ wdtSystemOrder: detail === null || detail === void 0 ? void 0 : detail.wdtSystemOrder,
177
+ wdtReissueGoods: detail === null || detail === void 0 ? void 0 : detail.wdtReissueGoods
178
+ };
154
179
  break;
155
180
  case "WDT_LOGISTICS":
156
181
  prv[uniqueKey] = updateWdtItemListByConfigHandle(detail === null || detail === void 0 ? void 0 : detail.wdtLogistics, "logistics", config);
@@ -0,0 +1,2 @@
1
+ import getWarehouseDataAsync from './warehouseData';
2
+ export { getWarehouseDataAsync };
@@ -0,0 +1,2 @@
1
+ import getWarehouseDataAsync from "./warehouseData";
2
+ export { getWarehouseDataAsync };
@@ -0,0 +1,6 @@
1
+ declare type WarehouseType = {
2
+ label: string;
3
+ value: string;
4
+ };
5
+ declare const getWarehouseDataAsync: () => Promise<WarehouseType[]>;
6
+ export default getWarehouseDataAsync;
@@ -0,0 +1,38 @@
1
+ import { queryWdtWarehouseList } from "../../servers/index";
2
+ var singletonPromise;
3
+ var getWarehouseDataAsync = function getWarehouseDataAsync() {
4
+ if (!singletonPromise) {
5
+ singletonPromise = new Promise(function (resolve, reject) {
6
+ var list = [];
7
+ // PS: 接口最大支持100
8
+ var pageSize = 100;
9
+ var pageNo = 0;
10
+ function fetchList() {
11
+ queryWdtWarehouseList(pageNo, pageSize).then(function (res) {
12
+ var data = res.data;
13
+ var warehouses = (data === null || data === void 0 ? void 0 : data.warehouses) || [];
14
+ warehouses.map(function (_ref) {
15
+ var warehouseNo = _ref.warehouseNo,
16
+ name = _ref.name;
17
+ list.push({
18
+ label: name,
19
+ value: warehouseNo
20
+ });
21
+ });
22
+ pageNo++;
23
+ if (pageSize === warehouses.length) {
24
+ fetchList();
25
+ } else {
26
+ resolve(list);
27
+ }
28
+ }).catch(function (e) {
29
+ singletonPromise = null;
30
+ reject(e);
31
+ });
32
+ }
33
+ fetchList();
34
+ });
35
+ }
36
+ return singletonPromise;
37
+ };
38
+ export default getWarehouseDataAsync;
@@ -5,6 +5,7 @@ interface TreeOption {
5
5
  }
6
6
  export default class WdtAddressData {
7
7
  private static instance;
8
+ private static initSingleton;
8
9
  addrData: Record<string, [string, string | number]>;
9
10
  addrNameMap: Record<string, string>;
10
11
  addressOptions: TreeOption[];
@@ -26,6 +27,8 @@ export default class WdtAddressData {
26
27
  }[];
27
28
  getProCodeByName: (proName: string) => number | undefined;
28
29
  getNameByCode: (code: string | number) => string;
30
+ static initData: () => Promise<WdtAddressData>;
31
+ static getAddressOptions: () => Promise<TreeOption[]>;
29
32
  static getInstance(): WdtAddressData;
30
33
  }
31
34
  export declare type WdtAddressDataClass = WdtAddressData;
@@ -1,3 +1,6 @@
1
+ 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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
+ 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); } }
3
+ 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); }); }; }
1
4
  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
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
6
  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); } }
@@ -5,6 +8,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
8
  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; }
6
9
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
10
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
+ import { queryWdtAddressData } from "../servers";
8
12
  var WdtAddressData = /*#__PURE__*/function () {
9
13
  function WdtAddressData() {
10
14
  var _this = this;
@@ -62,4 +66,40 @@ var WdtAddressData = /*#__PURE__*/function () {
62
66
  return WdtAddressData;
63
67
  }();
64
68
  _defineProperty(WdtAddressData, "instance", void 0);
69
+ _defineProperty(WdtAddressData, "initSingleton", void 0);
70
+ _defineProperty(WdtAddressData, "initData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
71
+ var instance;
72
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
73
+ while (1) switch (_context.prev = _context.next) {
74
+ case 0:
75
+ instance = WdtAddressData.getInstance();
76
+ if (!WdtAddressData.initSingleton) {
77
+ WdtAddressData.initSingleton = queryWdtAddressData().catch(function (e) {
78
+ console.warn('init wdt data e', e);
79
+ WdtAddressData.initSingleton = null;
80
+ });
81
+ }
82
+ _context.next = 4;
83
+ return WdtAddressData.initSingleton;
84
+ case 4:
85
+ return _context.abrupt("return", instance);
86
+ case 5:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee);
91
+ })));
92
+ _defineProperty(WdtAddressData, "getAddressOptions", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
93
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
94
+ while (1) switch (_context2.prev = _context2.next) {
95
+ case 0:
96
+ return _context2.abrupt("return", WdtAddressData.initData().then(function () {
97
+ return WdtAddressData.instance.addressOptions || [];
98
+ }));
99
+ case 1:
100
+ case "end":
101
+ return _context2.stop();
102
+ }
103
+ }, _callee2);
104
+ })));
65
105
  export { WdtAddressData as default };
@@ -0,0 +1,14 @@
1
+ interface OptionsItem {
2
+ label: string;
3
+ value: string;
4
+ }
5
+ export default class WdtSendData {
6
+ private static instance;
7
+ wdtSendData: OptionsItem[];
8
+ getWdtSendData: () => OptionsItem[];
9
+ setWdtSendData: (val: OptionsItem[]) => OptionsItem[];
10
+ getWdtSendNameByCode: (code: string | number, returnCurrentValue?: boolean) => string | number;
11
+ getWdtSendCodeByName: (name: string | number, returnCurrentValue?: boolean) => string | number;
12
+ static getInstance(): WdtSendData;
13
+ }
14
+ export {};
@@ -0,0 +1,46 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
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; }
5
+ 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; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ var WdtSendData = /*#__PURE__*/function () {
9
+ function WdtSendData() {
10
+ var _this = this;
11
+ _classCallCheck(this, WdtSendData);
12
+ _defineProperty(this, "wdtSendData", []);
13
+ _defineProperty(this, "getWdtSendData", function () {
14
+ return _this.wdtSendData;
15
+ });
16
+ _defineProperty(this, "setWdtSendData", function (val) {
17
+ return _this.wdtSendData = val;
18
+ });
19
+ _defineProperty(this, "getWdtSendNameByCode", function (code) {
20
+ var returnCurrentValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
21
+ var item = (_this.wdtSendData || []).filter(function (item) {
22
+ return item.value === code;
23
+ });
24
+ return item.length ? item[0].label : returnCurrentValue ? code : "";
25
+ });
26
+ _defineProperty(this, "getWdtSendCodeByName", function (name) {
27
+ var returnCurrentValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
28
+ var item = (_this.wdtSendData || []).filter(function (item) {
29
+ return item.label === name;
30
+ });
31
+ return item.length ? item[0].value : returnCurrentValue ? name : "";
32
+ });
33
+ }
34
+ _createClass(WdtSendData, null, [{
35
+ key: "getInstance",
36
+ value: function getInstance() {
37
+ if (!WdtSendData.instance) {
38
+ WdtSendData.instance = new WdtSendData();
39
+ }
40
+ return WdtSendData.instance;
41
+ }
42
+ }]);
43
+ return WdtSendData;
44
+ }();
45
+ _defineProperty(WdtSendData, "instance", void 0);
46
+ export { WdtSendData as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/kmkf-utils",
3
- "version": "1.0.3",
3
+ "version": "1.0.4-rc.2",
4
4
  "module": "dist/esm/index.js",
5
5
  "typings": "dist/esm/index.d.ts",
6
6
  "files": [
@@ -40,7 +40,7 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "db3f4dcdeeebdd482f38d71184ecb11c91706e17",
43
+ "gitHead": "0cc6d4c478c778b020149a7d0e0ccf1abd05d20b",
44
44
  "gitHooks": {
45
45
  "pre-commit": "lint-staged"
46
46
  }