@kmkf-fe-packages/kmkf-utils 0.6.3-alpha.3 → 0.6.3-alpha.5

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.
@@ -1,18 +1,27 @@
1
1
  interface OptionsItem {
2
2
  label: string | number;
3
3
  value: string | number;
4
+ expressName?: string;
5
+ expressCode?: string;
6
+ isInterface?: boolean;
7
+ interceptionTypeList?: any[];
8
+ interceptionStatusList?: any[];
4
9
  }
5
10
  export default class ExpressData {
6
11
  private static instance;
7
12
  expressData: OptionsItem[];
13
+ showInterceptionMap: any;
14
+ typeNameMap: any;
15
+ statusNameMap: any;
8
16
  constructor();
9
17
  initData: () => OptionsItem[] | undefined;
10
18
  getExpressData: () => OptionsItem[] | undefined;
19
+ getShowInterceptionBtn(): any;
20
+ getTypeNameMap(): any;
21
+ getStatusNameMap(): any;
11
22
  setExpressData: (val: OptionsItem[]) => OptionsItem[];
12
23
  getExpressNameByCode: (code: string | number) => string | number;
13
24
  getExpressNameByName: (name: string | number) => string | number;
14
- getInterceptionTypeName: (company: string, type: string) => any;
15
- getInterceptionStatusName: (company: string, status: string) => any;
16
25
  isInterfaceCompany: (company: string) => any;
17
26
  isShowNewAddress: (company: string, type: string) => any;
18
27
  static getInstance(): ExpressData;
@@ -1,4 +1,6 @@
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
5
  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
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -7,25 +9,124 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
7
9
  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
10
  import request from "../request";
9
11
  var ExpressData = /*#__PURE__*/function () {
12
+ //展示拦截按钮映射
13
+ //拦截类型映射
14
+ //拦截状态映射
10
15
  function ExpressData() {
11
16
  var _this = this;
12
17
  _classCallCheck(this, ExpressData);
13
18
  _defineProperty(this, "expressData", []);
19
+ _defineProperty(this, "showInterceptionMap", null);
20
+ _defineProperty(this, "typeNameMap", null);
21
+ _defineProperty(this, "statusNameMap", null);
14
22
  _defineProperty(this, "initData", function () {
15
23
  if (_this.expressData.length > 0) return _this.expressData;
16
24
  request({
17
- url: '/tianwen/print/queryAllDeliveryCompanyInfo',
18
- method: 'post',
25
+ url: "/tianwen/print/queryAllDeliveryCompanyInfo",
26
+ method: "post",
19
27
  data: {}
20
28
  }).then(function (res) {
21
29
  var data = res.data;
30
+ var mock = [{
31
+ name: "中通",
32
+ // 物流名称
33
+ cpCode: "ZT",
34
+ // 物流CODE
35
+ isInterface: true,
36
+ // 是否为已对接快递公司
37
+ interceptionTypeList: [
38
+ // 拦截类型列表
39
+ {
40
+ label: "退回",
41
+ value: "RETURN",
42
+ config: {
43
+ showAddress: false // 是否展示省市区组件
44
+ }
45
+ }, {
46
+ label: "转寄",
47
+ value: "FORWARD",
48
+ config: {
49
+ showAddress: true
50
+ }
51
+ }],
52
+ interceptionStatusList: [
53
+ // 拦截状态列表
54
+ ],
55
+ needAuth: true // 是否需要授权
56
+ }, {
57
+ name: "圆通",
58
+ cpCode: "YT",
59
+ isInterface: false,
60
+ interceptionTypeList: [{
61
+ label: "退回",
62
+ value: "RETURN",
63
+ config: {
64
+ showAddress: false
65
+ }
66
+ }, {
67
+ label: "转寄",
68
+ value: "FORWARD",
69
+ config: {
70
+ showAddress: true
71
+ }
72
+ }, {
73
+ label: "其他",
74
+ value: "OTHER",
75
+ config: {
76
+ showAddress: true
77
+ }
78
+ }],
79
+ interceptionStatusList: [
80
+ // 拦截状态
81
+ {
82
+ label: "拦截中",
83
+ value: "ITNTERCEPTING",
84
+ showInterceptionBtn: true
85
+ }, {
86
+ label: "拦截成功",
87
+ value: "ITNTERCEPT_SUCCESS",
88
+ showInterceptionBtn: false
89
+ }, {
90
+ label: "拦截失败",
91
+ value: "ITNTERCEPT_FAIL",
92
+ showInterceptionBtn: false
93
+ }, {
94
+ label: "其他",
95
+ value: "OTHER",
96
+ showInterceptionBtn: false
97
+ }],
98
+ needAuth: false
99
+ }];
22
100
  var expressList = data.deliveryCompanyInfoList.map(function (item) {
23
- return {
101
+ return _objectSpread(_objectSpread({}, item), {}, {
24
102
  label: item.name,
25
- value: item.deliveryCode
26
- };
103
+ value: item.cpCode
104
+ });
27
105
  });
28
106
  _this.expressData = expressList;
107
+ var showBtn = {},
108
+ typeMap = {},
109
+ statusMap = {};
110
+ expressList.forEach(function (item) {
111
+ var _item$interceptionSta, _item$interceptionTyp;
112
+ if (item !== null && item !== void 0 && (_item$interceptionSta = item.interceptionStatusList) !== null && _item$interceptionSta !== void 0 && _item$interceptionSta.length) {
113
+ item.interceptionStatusList.forEach(function (t) {
114
+ statusMap[t.value] = t.label;
115
+ });
116
+ var t = item === null || item === void 0 ? void 0 : item.interceptionStatusList.find(function (t) {
117
+ return t === null || t === void 0 ? void 0 : t.showInterceptionBtn;
118
+ });
119
+ (item === null || item === void 0 ? void 0 : item.value) && (showBtn[item === null || item === void 0 ? void 0 : item.value] = t.value);
120
+ }
121
+ if (item !== null && item !== void 0 && (_item$interceptionTyp = item.interceptionTypeList) !== null && _item$interceptionTyp !== void 0 && _item$interceptionTyp.length) {
122
+ item.interceptionTypeList.forEach(function (t) {
123
+ typeMap[t.value] = t.label;
124
+ });
125
+ }
126
+ });
127
+ _this.showInterceptionMap = showBtn;
128
+ _this.typeNameMap = typeMap;
129
+ _this.statusNameMap = statusMap;
29
130
  });
30
131
  });
31
132
  _defineProperty(this, "getExpressData", function () {
@@ -46,27 +147,7 @@ var ExpressData = /*#__PURE__*/function () {
46
147
  var item = (_this.expressData || []).filter(function (item) {
47
148
  return item.label === name;
48
149
  });
49
- return item.length ? item[0].value : name;
50
- });
51
- _defineProperty(this, "getInterceptionTypeName", function (company, type) {
52
- var _find;
53
- var item = (_this.expressData || []).find(function (item) {
54
- return item.value === company;
55
- });
56
- var label = (_find = ((item === null || item === void 0 ? void 0 : item.interceptionTypeList) || []).find(function (t) {
57
- return t.value === type;
58
- })) === null || _find === void 0 ? void 0 : _find.label;
59
- return label;
60
- });
61
- _defineProperty(this, "getInterceptionStatusName", function (company, status) {
62
- var _find2;
63
- var item = (_this.expressData || []).find(function (item) {
64
- return item.value === company;
65
- });
66
- var label = (_find2 = ((item === null || item === void 0 ? void 0 : item.interceptionStatusList) || []).find(function (t) {
67
- return t.value === status;
68
- })) === null || _find2 === void 0 ? void 0 : _find2.label;
69
- return label;
150
+ return item.length ? item[0].value : "";
70
151
  });
71
152
  _defineProperty(this, "isInterfaceCompany", function (company) {
72
153
  var item = (_this.expressData || []).find(function (item) {
@@ -75,17 +156,36 @@ var ExpressData = /*#__PURE__*/function () {
75
156
  return item === null || item === void 0 ? void 0 : item.isInterface;
76
157
  });
77
158
  _defineProperty(this, "isShowNewAddress", function (company, type) {
78
- var _find3, _find3$config;
159
+ var _find, _find$config;
79
160
  var item = (_this.expressData || []).find(function (item) {
80
161
  return item.value === company;
81
162
  });
82
- return (_find3 = ((item === null || item === void 0 ? void 0 : item.interceptionTypeList) || []).find(function (t) {
163
+ return (_find = ((item === null || item === void 0 ? void 0 : item.interceptionTypeList) || []).find(function (t) {
83
164
  return t.value === type;
84
- })) === null || _find3 === void 0 ? void 0 : (_find3$config = _find3.config) === null || _find3$config === void 0 ? void 0 : _find3$config.showAddress;
165
+ })) === null || _find === void 0 ? void 0 : (_find$config = _find.config) === null || _find$config === void 0 ? void 0 : _find$config.showAddress;
85
166
  });
86
167
  this.initData();
87
168
  }
88
- _createClass(ExpressData, null, [{
169
+ _createClass(ExpressData, [{
170
+ key: "getShowInterceptionBtn",
171
+ value:
172
+ //获取拦截按钮展示映射
173
+ function getShowInterceptionBtn() {
174
+ return this.showInterceptionMap;
175
+ }
176
+ //获取拦截类型映射
177
+ }, {
178
+ key: "getTypeNameMap",
179
+ value: function getTypeNameMap() {
180
+ return this.typeNameMap;
181
+ }
182
+ //获取拦截状态映射
183
+ }, {
184
+ key: "getStatusNameMap",
185
+ value: function getStatusNameMap() {
186
+ return this.statusNameMap;
187
+ }
188
+ }], [{
89
189
  key: "getInstance",
90
190
  value: function getInstance() {
91
191
  if (!ExpressData.instance) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/kmkf-utils",
3
- "version": "0.6.3-alpha.3",
3
+ "version": "0.6.3-alpha.5",
4
4
  "module": "dist/esm/index.js",
5
5
  "typings": "dist/esm/index.d.ts",
6
6
  "files": [
@@ -17,18 +17,18 @@
17
17
  "prettier --parser=typescript --write"
18
18
  ]
19
19
  },
20
- "devDependencies": {
21
- "father": "^4.1.7"
22
- },
23
20
  "dependencies": {
24
21
  "lodash": "^4.17.21",
25
22
  "umi-request": "^1.4.0"
26
23
  },
24
+ "devDependencies": {
25
+ "father": "^4.1.7"
26
+ },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
30
  "gitHooks": {
31
31
  "pre-commit": "lint-staged"
32
32
  },
33
- "gitHead": "021dc716b8d75e9cc0ce3abfe3be4b25724fa133"
33
+ "gitHead": "ca5660b4c7b1e71a004456cfd3aa818c9591a6dc"
34
34
  }