@kmkf-fe-packages/services-components 2.2.4 → 2.3.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1019 +0,0 @@
1
- "use strict";
2
-
3
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) {
5
- return value instanceof P ? value : new P(function (resolve) {
6
- resolve(value);
7
- });
8
- }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) {
11
- try {
12
- step(generator.next(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- }
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
- function step(result) {
25
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
26
- }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- var __generator = this && this.__generator || function (thisArg, body) {
31
- var _ = {
32
- label: 0,
33
- sent: function sent() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- },
40
- f,
41
- y,
42
- t,
43
- g;
44
- return g = {
45
- next: verb(0),
46
- "throw": verb(1),
47
- "return": verb(2)
48
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
49
- return this;
50
- }), g;
51
- function verb(n) {
52
- return function (v) {
53
- return step([n, v]);
54
- };
55
- }
56
- function step(op) {
57
- if (f) throw new TypeError("Generator is already executing.");
58
- while (_) try {
59
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
60
- if (y = 0, t) op = [op[0] & 2, t.value];
61
- switch (op[0]) {
62
- case 0:
63
- case 1:
64
- t = op;
65
- break;
66
- case 4:
67
- _.label++;
68
- return {
69
- value: op[1],
70
- done: false
71
- };
72
- case 5:
73
- _.label++;
74
- y = op[1];
75
- op = [0];
76
- continue;
77
- case 7:
78
- op = _.ops.pop();
79
- _.trys.pop();
80
- continue;
81
- default:
82
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
- _ = 0;
84
- continue;
85
- }
86
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
- _.label = op[1];
88
- break;
89
- }
90
- if (op[0] === 6 && _.label < t[1]) {
91
- _.label = t[1];
92
- t = op;
93
- break;
94
- }
95
- if (t && _.label < t[2]) {
96
- _.label = t[2];
97
- _.ops.push(op);
98
- break;
99
- }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop();
102
- continue;
103
- }
104
- op = body.call(thisArg, _);
105
- } catch (e) {
106
- op = [6, e];
107
- y = 0;
108
- } finally {
109
- f = t = 0;
110
- }
111
- if (op[0] & 5) throw op[1];
112
- return {
113
- value: op[0] ? op[1] : void 0,
114
- done: true
115
- };
116
- }
117
- };
118
- var __spreadArrays = this && this.__spreadArrays || function () {
119
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
120
- for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
121
- return r;
122
- };
123
- exports.__esModule = true;
124
- exports.AlipayBill = exports.MsgContent = exports.BsSystemOrderTable = exports.FileRender = exports.BsGoodsTable = exports.BsGoodPic = exports.BsExchangeList = exports.BsGoodImage = exports.CommonOrderContent = exports.BsExpressRender = exports.JstGoodImage = exports.GoodImage = exports.ShowTotalImage = exports.showImage = exports.getFormItem = void 0;
125
- var antd_1 = require("antd");
126
- var react_1 = require("react");
127
- var kmkf_utils_1 = require("@kmkf-fe-packages/kmkf-utils");
128
- var api_1 = require("../../service/api");
129
- var react_copy_to_clipboard_1 = require("react-copy-to-clipboard");
130
- var index_module_less_1 = require("./index.module.less");
131
- var default_img_png_1 = require("./img/default-img.png");
132
- var CopyText_1 = require("../../commonComponents/CopyText");
133
- var kmkf_utils_2 = require("@kmkf-fe-packages/kmkf-utils");
134
- var columnsBaseInfoMap_1 = require("./constants/columnsBaseInfoMap");
135
- var Paragraph = antd_1.Typography.Paragraph;
136
- exports.getFormItem = function (_a) {
137
- var name = _a.name,
138
- title = _a.title,
139
- _b = _a.rules,
140
- rules = _b === void 0 ? [] : _b,
141
- required = _a.required,
142
- component = _a.component;
143
- var newRules = rules;
144
- if (required) {
145
- newRules = rules.concat({
146
- required: true,
147
- message: "\u8BF7\u8F93\u5165" + title
148
- });
149
- }
150
- return react_1["default"].createElement("div", {
151
- className: "form-item--wrap",
152
- style: {
153
- position: "relative"
154
- }
155
- }, react_1["default"].createElement(antd_1.Form.Item, {
156
- name: name,
157
- label: title,
158
- rules: newRules,
159
- className: "form-item-label--index"
160
- }, component));
161
- };
162
- //图片展示
163
- exports.showImage = function (_a) {
164
- var item = _a.item,
165
- type = _a.type,
166
- index = _a.index,
167
- showHeader = _a.showHeader;
168
- var picUrl = item.picUrl ? (item === null || item === void 0 ? void 0 : item.platform) !== "tabao" ? item.picUrl : item.picUrl + "_40x40.jpg" : default_img_png_1["default"];
169
- var mapping_itemCode = kmkf_utils_2.getMapping(kmkf_utils_2.columnsGoodsList);
170
- return react_1["default"].createElement("div", {
171
- className: index_module_less_1["default"].goodImgBox,
172
- key: index
173
- }, type === "itemCode" && !showHeader.includes("picUrl") ? null : (item === null || item === void 0 ? void 0 : item.platform) === "taobao" ? react_1["default"].createElement("a", {
174
- target: "_blank",
175
- href: item.numIid ? "https://item.taobao.com/item.htm?id=" + item.numIid : "javascript:void(0);"
176
- }, react_1["default"].createElement("img", {
177
- style: {
178
- width: "40px",
179
- height: "40px",
180
- objectFit: "contain"
181
- },
182
- src: picUrl
183
- })) : react_1["default"].createElement("img", {
184
- style: {
185
- width: "40px",
186
- height: "40px",
187
- objectFit: "contain"
188
- },
189
- src: picUrl
190
- }), react_1["default"].createElement("div", {
191
- className: index_module_less_1["default"].options,
192
- onClick: function onClick() {
193
- console.log("show---", showHeader);
194
- }
195
- }, type === "itemId" && react_1["default"].createElement(TextTool, {
196
- title: "商品id",
197
- text: item.numIid
198
- }), type === "itemCode" && react_1["default"].createElement(react_1["default"].Fragment, null, showHeader.filter(function (dataIndex) {
199
- return dataIndex !== "picUrl";
200
- }).map(function (dataIndex) {
201
- return react_1["default"].createElement(TextTool, {
202
- title: mapping_itemCode[dataIndex],
203
- text: item[dataIndex]
204
- });
205
- })), (type === "itemThird" || type === "jstItemThird") && (item.itemId || item.supplierItemOuterId) && react_1["default"].createElement(TextTool, {
206
- title: "供应商编码",
207
- text: item.itemId || item.supplierItemOuterId
208
- }), (type === "itemThird" || type === "jstItemThird") && item.supplierName && react_1["default"].createElement(TextTool, {
209
- title: "供应商名称",
210
- text: item.supplierName
211
- }), type !== "itemCode" && item.propertiesName && react_1["default"].createElement(TextTool, {
212
- title: "规格",
213
- text: item.propertiesName
214
- })));
215
- };
216
- //文字提示
217
- var TextTool = function TextTool(_a) {
218
- var title = _a.title,
219
- text = _a.text;
220
- return react_1["default"].createElement(antd_1.Tooltip, {
221
- placement: "topLeft",
222
- title: text
223
- }, react_1["default"].createElement("div", {
224
- style: {
225
- overflow: "hidden",
226
- whiteSpace: "nowrap",
227
- textOverflow: "ellipsis"
228
- }
229
- }, title, ":", text));
230
- };
231
- //查看更多图片
232
- exports.ShowTotalImage = function (_a) {
233
- var total = _a.total,
234
- _b = _a.allImage,
235
- allImage = _b === void 0 ? [] : _b,
236
- type = _a.type,
237
- _c = _a.showHeader,
238
- showHeader = _c === void 0 ? [] : _c;
239
- var _d = react_1.useState(false),
240
- visible = _d[0],
241
- setVisible = _d[1];
242
- var mapping_itemCode = kmkf_utils_2.getMapping(kmkf_utils_2.columnsGoodsList);
243
- return react_1["default"].createElement(react_1["default"].Fragment, null, react_1["default"].createElement(antd_1.Button, {
244
- type: "link",
245
- onClick: function onClick() {
246
- return setVisible(true);
247
- }
248
- }, "\u67E5\u770B\u5168\u90E8(" + total + ")"), react_1["default"].createElement(antd_1.Modal, {
249
- visible: visible,
250
- footer: null,
251
- onCancel: function onCancel() {
252
- return setVisible(false);
253
- },
254
- title: "\u6240\u6709\u9009\u62E9\u5B9D\u8D1D"
255
- }, react_1["default"].createElement("div", {
256
- style: {
257
- display: "flex",
258
- flexWrap: "wrap"
259
- }
260
- }, allImage.map(function (i, index) {
261
- return react_1["default"].createElement("div", {
262
- style: {
263
- width: "50%"
264
- },
265
- key: index
266
- }, type === "itemCode" && !showHeader.includes("picUrl") ? null : react_1["default"].createElement("a", {
267
- href: i.link || ((i === null || i === void 0 ? void 0 : i.platform) === "taobao" && i.numIid ? "https://item.taobao.com/item.htm?id=" + i.numIid : "javascript:void(0);"),
268
- target: "__blank",
269
- style: {
270
- marginRight: "12px",
271
- marginTop: "8px",
272
- padding: "2px",
273
- border: "1px dashed #ccc",
274
- display: "inline-block"
275
- }
276
- }, react_1["default"].createElement("img", {
277
- alt: "",
278
- src: i.picUrl || default_img_png_1["default"],
279
- style: {
280
- width: "72px",
281
- height: "72px",
282
- objectFit: "contain"
283
- }
284
- })), react_1["default"].createElement("div", null, type === "itemId" && react_1["default"].createElement(TextTool, {
285
- title: "商品id",
286
- text: i.numIid
287
- }), type === "itemCode" && react_1["default"].createElement(react_1["default"].Fragment, null, showHeader.filter(function (dataIndex) {
288
- return dataIndex !== "picUrl";
289
- }).map(function (dataIndex) {
290
- return react_1["default"].createElement(TextTool, {
291
- title: mapping_itemCode[dataIndex],
292
- text: i[dataIndex]
293
- });
294
- })), (type === "itemThird" || type === "jstItemThird") && (i.itemId || i.supplierItemOuterId) && react_1["default"].createElement(TextTool, {
295
- title: "供应商编码",
296
- text: i.itemId || i.supplierItemOuterId
297
- }), (type === "itemThird" || type === "jstItemThird") && i.supplierName && react_1["default"].createElement(TextTool, {
298
- title: "供应商名称",
299
- text: i.supplierName
300
- }), type !== "itemCode" && i.propertiesName && react_1["default"].createElement(TextTool, {
301
- title: "规格",
302
- text: i.propertiesName
303
- })));
304
- }))));
305
- };
306
- //商品列表展示
307
- exports.GoodImage = function (_a) {
308
- var _b;
309
- var list = _a.list,
310
- _c = _a.type,
311
- type = _c === void 0 ? "" : _c,
312
- _d = _a.showHeader,
313
- showHeader = _d === void 0 ? [] : _d;
314
- var total = (list === null || list === void 0 ? void 0 : list.length) || 0;
315
- var initShowTotal = 3;
316
- var showHeaderMap = react_1.useMemo(function () {
317
- var isStringArray = Array.isArray(showHeader) && typeof showHeader[0] === "string";
318
- var isObjectArray = Array.isArray(showHeader) && Object.prototype.toString.call(showHeader[0]) === "[object Object]";
319
- var dataIndexList = [];
320
- if (isStringArray) {
321
- dataIndexList = showHeader;
322
- } else if (isObjectArray) {
323
- dataIndexList = showHeader.filter(function (item) {
324
- return item.show !== false;
325
- }).map(function (item) {
326
- return item.dataIndex;
327
- });
328
- }
329
- return dataIndexList;
330
- }, [showHeader]);
331
- return (list === null || list === void 0 ? void 0 : list.length) > 0 ? react_1["default"].createElement("div", {
332
- style: {
333
- display: type === "itemSelect" ? "flex" : "block"
334
- }
335
- }, (_b = list === null || list === void 0 ? void 0 : list.slice(0, initShowTotal)) === null || _b === void 0 ? void 0 : _b.map(function (item, index) {
336
- return exports.showImage({
337
- item: item,
338
- type: type,
339
- index: index,
340
- showHeader: showHeaderMap
341
- });
342
- }), total > initShowTotal && react_1["default"].createElement(exports.ShowTotalImage, {
343
- total: total,
344
- allImage: list,
345
- showHeader: showHeaderMap,
346
- type: type
347
- })) : null;
348
- };
349
- var content = function content(item, index) {
350
- return react_1["default"].createElement("div", {
351
- style: {
352
- maxHeight: "300px",
353
- overflowY: "auto"
354
- }
355
- }, react_1["default"].createElement("div", {
356
- style: {
357
- textAlign: "center"
358
- }
359
- }, "\u5305\u88F9" + (index + 1) + "\u5546\u54C1\u4FE1\u606F", item.sid && react_1["default"].createElement("span", null, "(\u7CFB\u7EDF\u5355\u53F7:", item.sid, ")")), ((item === null || item === void 0 ? void 0 : item.items) || []).map(function (t, index) {
360
- return react_1["default"].createElement("div", {
361
- key: index
362
- }, react_1["default"].createElement(antd_1.Space, null, react_1["default"].createElement(antd_1.Image, {
363
- width: 70,
364
- src: t.picUrl,
365
- preview: false
366
- }), react_1["default"].createElement("div", null, react_1["default"].createElement("div", null, t.title), react_1["default"].createElement("div", null, "\u7F16\u7801\uFF1A", t.skuId))));
367
- }));
368
- };
369
- exports.JstGoodImage = function (_a) {
370
- var _b = _a.list,
371
- list = _b === void 0 ? [] : _b,
372
- type = _a.type,
373
- _c = _a.platformType,
374
- platformType = _c === void 0 ? "default" : _c;
375
- var getSendName = function getSendName(item) {
376
- return kmkf_utils_1.SendDataCenter.getInstance(platformType).getSendNameByCode(item.sendName);
377
- };
378
- return (list === null || list === void 0 ? void 0 : list.length) ? (list || []).map(function (item, index) {
379
- var logisticsCompany = item.logisticsCompany;
380
- var company = kmkf_utils_1.ExpressData.getInstance(platformType).getExpressNameByCode(logisticsCompany);
381
- return react_1["default"].createElement("div", null, react_1["default"].createElement(antd_1.Space, null, react_1["default"].createElement(antd_1.Popover, {
382
- content: content(item, index),
383
- overlayStyle: {
384
- zIndex: 1080
385
- }
386
- }, react_1["default"].createElement("span", {
387
- key: index,
388
- style: {
389
- color: "#1890ff",
390
- cursor: "pointer"
391
- }
392
- }, "\u5305\u88F9" + (index + 1), ":")), type === 1 ? react_1["default"].createElement("span", null, company && item.logisticsCode ? react_1["default"].createElement(react_1["default"].Fragment, null, company, "/", react_1["default"].createElement(CopyText_1["default"], {
393
- text: item.logisticsCode
394
- })) : company ? company : item.logisticsCode ? react_1["default"].createElement(CopyText_1["default"], {
395
- text: item.logisticsCode
396
- }) : null) : null, type === 2 ? react_1["default"].createElement("span", null, item.supplyName && item.supplyId ? [item.supplyId, item.supplyName].join("/") : item.supplyId ? item.supplyId : item.supplyName) : null, type === 3 ? react_1["default"].createElement("span", null, item.sendName && item.sendId ? [item.sendId, getSendName(item)].join("/") : item.sendId ? item.sendId : getSendName(item)) : null, type === 4 ? react_1["default"].createElement("span", null, (item === null || item === void 0 ? void 0 : item.deliveryNo) || "") : null));
397
- }) : null;
398
- };
399
- exports.BsExpressRender = function (_a) {
400
- var _b = _a.list,
401
- list = _b === void 0 ? [] : _b,
402
- _c = _a.showField,
403
- showField = _c === void 0 ? "" : _c,
404
- _d = _a.platformType,
405
- platformType = _d === void 0 ? "default" : _d;
406
- return (list === null || list === void 0 ? void 0 : list.length) ? (list || []).map(function (item, index) {
407
- var logisticsCompany = item.logisticsCompany;
408
- var company = kmkf_utils_1.ExpressData.getInstance(platformType).getExpressNameByCode(logisticsCompany);
409
- return react_1["default"].createElement("div", null, react_1["default"].createElement(antd_1.Space, null, react_1["default"].createElement(antd_1.Popover, {
410
- content: content(item, index),
411
- overlayStyle: {
412
- zIndex: 1080
413
- }
414
- }, react_1["default"].createElement("span", {
415
- key: index,
416
- style: {
417
- color: "#1890ff",
418
- cursor: "pointer"
419
- }
420
- }, "\u5305\u88F9", ":")), showField === "company" ? react_1["default"].createElement("span", null, company ? company : null) : null, showField === "code" ? react_1["default"].createElement("span", null, item.logisticsCode ? react_1["default"].createElement(CopyText_1["default"], {
421
- text: item.logisticsCode
422
- }) : null) : null));
423
- }) : null;
424
- };
425
- exports.CommonOrderContent = function (_a) {
426
- var _b = _a.list,
427
- list = _b === void 0 ? [] : _b,
428
- initValueKey = _a.valueKey,
429
- failValue = _a.failValue,
430
- _c = _a.options,
431
- options = _c === void 0 ? [] : _c,
432
- _d = _a.isShowPopover,
433
- isShowPopover = _d === void 0 ? true : _d;
434
- var getContentData = function getContentData(item, index) {
435
- if (item.platformId) return {
436
- text: "平台售后单号",
437
- id: item.platformId
438
- };
439
- if (item.returnLogisticsCode) return {
440
- text: "物流单号",
441
- id: item.returnLogisticsCode
442
- };
443
- return {
444
- text: "系统订单号" + (index + 1),
445
- id: item.systemOrderId
446
- };
447
- };
448
- var orderContent = function orderContent(item, index) {
449
- var contentData = getContentData(item, index);
450
- return react_1["default"].createElement("div", null, react_1["default"].createElement("div", {
451
- style: {
452
- textAlign: "center"
453
- }
454
- }, contentData.text, "\uFF1A", contentData.id));
455
- };
456
- return (list === null || list === void 0 ? void 0 : list.length) ? (list || []).map(function (item, index) {
457
- var _a;
458
- var valueKey = "";
459
- if (Array.isArray(initValueKey)) {
460
- for (var index_1 = 0; index_1 < initValueKey.length; index_1++) {
461
- var itemKey = initValueKey[index_1];
462
- if (item[itemKey]) {
463
- valueKey = itemKey;
464
- break;
465
- }
466
- }
467
- } else {
468
- valueKey = initValueKey;
469
- }
470
- var color = ((_a = options.find(function (it) {
471
- return item[valueKey] === it.value;
472
- })) === null || _a === void 0 ? void 0 : _a.color) || "#000";
473
- var currentOption = options.find(function (option) {
474
- return item[valueKey] === option.value;
475
- });
476
- return react_1["default"].createElement("div", null, react_1["default"].createElement(antd_1.Space, null, isShowPopover ? react_1["default"].createElement(antd_1.Popover, {
477
- content: orderContent(item, index),
478
- overlayStyle: {
479
- zIndex: 1080
480
- }
481
- }, react_1["default"].createElement("span", {
482
- key: index,
483
- style: {
484
- color: "#1890ff",
485
- cursor: "pointer"
486
- }
487
- }, "" + getContentData(item, index).text, ":")) : null, react_1["default"].createElement("span", {
488
- style: {
489
- color: color
490
- }
491
- }, currentOption ? currentOption.label : (item === null || item === void 0 ? void 0 : item[valueKey]) || "")), item.reason && (item === null || item === void 0 ? void 0 : item[valueKey]) !== "成功" && react_1["default"].createElement("div", {
492
- className: "c-red"
493
- }, item.reason));
494
- }) : null;
495
- };
496
- //bs商品展示 todo
497
- exports.BsGoodImage = function (_a) {
498
- var item = _a.item,
499
- index = _a.index;
500
- var picUrl = item.picUrl || default_img_png_1["default"];
501
- var keyMap = {
502
- name: "bs名称",
503
- code: "bs编码",
504
- skuId: "bssku编码",
505
- money: "bs实付金额",
506
- number: "bs数量",
507
- share: "bs分摊价",
508
- type: "bs赠品类型"
509
- };
510
- return react_1["default"].createElement("div", {
511
- className: index_module_less_1["default"].goodImgBox,
512
- key: index
513
- }, react_1["default"].createElement("img", {
514
- style: {
515
- width: "40px",
516
- height: "40px",
517
- objectFit: "contain"
518
- },
519
- src: picUrl
520
- }), react_1["default"].createElement("div", {
521
- className: index_module_less_1["default"].options
522
- }, Object.keys(keyMap).map(function (key) {
523
- return item[key] ? react_1["default"].createElement(TextTool, {
524
- title: keyMap[key],
525
- text: item[key]
526
- }) : null;
527
- })));
528
- };
529
- //bs换货 todo
530
- exports.BsExchangeList = function (_a) {
531
- var list = _a.list,
532
- showHeader = _a.showHeader;
533
- return react_1["default"].createElement("div", {
534
- className: index_module_less_1["default"].bsImgBox
535
- }, list.map(function (item) {
536
- return react_1["default"].createElement(react_1["default"].Fragment, null, exports.BsGoodsTable({
537
- list: (item === null || item === void 0 ? void 0 : item.bsExchangeReturnGoods) || [],
538
- showHeader: showHeader,
539
- text: "退回"
540
- }), exports.BsGoodsTable({
541
- list: item === null || item === void 0 ? void 0 : item.bsExchangeSwapOutGoods,
542
- showHeader: showHeader,
543
- text: "换出"
544
- }));
545
- }));
546
- };
547
- //bs图片展示
548
- exports.BsGoodPic = function (list) {
549
- return list.map(function (t) {
550
- return react_1["default"].createElement(antd_1.Image, {
551
- width: 60,
552
- src: t
553
- });
554
- });
555
- };
556
- exports.BsGoodsTable = function (_a) {
557
- var list = _a.list,
558
- showHeader = _a.showHeader,
559
- _b = _a.text,
560
- text = _b === void 0 ? "" : _b,
561
- type = _a.type;
562
- //商品信息
563
- var COLUMNS_MAP = function COLUMNS_MAP(text) {
564
- if (text === void 0) {
565
- text = "";
566
- }
567
- return function (type) {
568
- var _a;
569
- var columnsMap = columnsBaseInfoMap_1.getColumnsMap({
570
- text: text
571
- });
572
- return (_a = columnsMap[type]) !== null && _a !== void 0 ? _a : columnsMap["default"];
573
- };
574
- };
575
- //商品信息
576
- var GOODS_INFO_COLUMNS = function GOODS_INFO_COLUMNS(text) {
577
- if (text === void 0) {
578
- text = "";
579
- }
580
- var COLUMNS_INFO = COLUMNS_MAP(text);
581
- return COLUMNS_INFO(type);
582
- };
583
- // const GOODS_INFO_COLUMNS = (text = '') => {
584
- // return
585
- // }
586
- var newColumns = react_1.useMemo(function () {
587
- var initBaseInfoColumns = GOODS_INFO_COLUMNS();
588
- var baseInfoColumns = [];
589
- var isStringArray = Array.isArray(showHeader) && typeof showHeader[0] === "string";
590
- var isObjectArray = Array.isArray(showHeader) && Object.prototype.toString.call(showHeader[0]) === "[object Object]";
591
- if (isStringArray) {
592
- baseInfoColumns = initBaseInfoColumns.filter(function (col) {
593
- return showHeader.includes(col.dataIndex);
594
- });
595
- } else if (isObjectArray) {
596
- baseInfoColumns = showHeader.filter(function (col) {
597
- return col.show !== false;
598
- }).map(function (col) {
599
- var currentCol = initBaseInfoColumns.find(function (item) {
600
- return item.dataIndex === col.dataIndex;
601
- });
602
- return currentCol ? currentCol : undefined;
603
- }).filter(Boolean);
604
- }
605
- var columnList = __spreadArrays([{
606
- dataIndex: "",
607
- title: "序号",
608
- align: "center",
609
- ellipsis: true,
610
- width: 50,
611
- render: function render(val, record, index) {
612
- return react_1["default"].createElement("span", null, index + 1);
613
- }
614
- }], baseInfoColumns);
615
- return columnList;
616
- }, [showHeader, list]);
617
- return react_1["default"].createElement(antd_1.Table, {
618
- columns: newColumns,
619
- dataSource: list,
620
- rowKey: "uuid",
621
- size: "small",
622
- pagination: false,
623
- scroll: {
624
- x: "100%"
625
- },
626
- locale: {
627
- emptyText: "暂无数据"
628
- }
629
- });
630
- };
631
- exports.FileRender = function (_a) {
632
- var _b = _a.fileList,
633
- fileList = _b === void 0 ? [] : _b,
634
- _c = _a.canDownload,
635
- canDownload = _c === void 0 ? false : _c;
636
- var _d = react_1.useState(false),
637
- visible = _d[0],
638
- setVisible = _d[1];
639
- var _e = react_1.useState(""),
640
- fileUrl = _e[0],
641
- setFileUrl = _e[1];
642
- var _f = react_1.useState(""),
643
- fileType = _f[0],
644
- setFileType = _f[1];
645
- var _g = react_1.useState(""),
646
- fileName = _g[0],
647
- setFileName = _g[1];
648
- var _h = react_1.useState(false),
649
- downloading = _h[0],
650
- setDownloading = _h[1];
651
- var handleCancel = function handleCancel() {
652
- setFileUrl("");
653
- setFileName("");
654
- setVisible(false);
655
- setDownloading(false);
656
- };
657
- var onPreview = function onPreview(file) {
658
- var _a;
659
- var fileArr = (_a = file === null || file === void 0 ? void 0 : file.url) === null || _a === void 0 ? void 0 : _a.split(".");
660
- var fileType = fileArr[fileArr.length - 1];
661
- if (["png", "jpg", "jpeg", "gif", "bmp", "svg"].includes(fileType.toLowerCase())) {
662
- setFileUrl(file === null || file === void 0 ? void 0 : file.url);
663
- setFileName(file === null || file === void 0 ? void 0 : file.name);
664
- setFileType("pic");
665
- setVisible(true);
666
- } else if (["mp4", "avi", "mpeg", "asf", "mov", "3gp", "wmv", "rmvb"].includes(fileType.toLowerCase())) {
667
- setFileUrl(file === null || file === void 0 ? void 0 : file.url);
668
- setFileName(file === null || file === void 0 ? void 0 : file.name);
669
- setFileType("video");
670
- setVisible(true);
671
- } else {
672
- window.open(file === null || file === void 0 ? void 0 : file.url);
673
- }
674
- };
675
- var download = function download(url, name) {
676
- setDownloading(true);
677
- fetch(url).then(function (res) {
678
- return res.blob();
679
- }).then(function (blob) {
680
- var a = document.createElement("a");
681
- document.body.appendChild(a);
682
- a.style.display = "none";
683
- var url = window.URL.createObjectURL(blob);
684
- a.href = url;
685
- a.download = name;
686
- a.click();
687
- document.body.removeChild(a);
688
- window.URL.revokeObjectURL(url);
689
- })["finally"](function () {
690
- setDownloading(false);
691
- });
692
- };
693
- return react_1["default"].createElement(react_1["default"].Fragment, null, fileList.map(function (item) {
694
- return react_1["default"].createElement("a", {
695
- style: {
696
- color: "#1890ff",
697
- cursor: "pointer",
698
- display: "block"
699
- },
700
- onClick: function onClick(e) {
701
- e.preventDefault();
702
- onPreview(item);
703
- },
704
- href: item === null || item === void 0 ? void 0 : item.url
705
- }, item.name);
706
- }), react_1["default"].createElement(antd_1.Modal, {
707
- visible: visible,
708
- title: fileName,
709
- footer: null,
710
- onCancel: handleCancel
711
- }, canDownload ? react_1["default"].createElement(antd_1.Button, {
712
- type: "link",
713
- onClick: function onClick() {
714
- return download(fileUrl, fileName);
715
- },
716
- loading: downloading
717
- }, "\u4E0B\u8F7D") : react_1["default"].createElement(react_copy_to_clipboard_1.CopyToClipboard, {
718
- text: fileUrl,
719
- onCopy: function onCopy() {
720
- antd_1.message.success("复制成功");
721
- }
722
- }, react_1["default"].createElement(antd_1.Button, {
723
- type: "link"
724
- }, "\u4E0B\u8F7D\u5730\u5740")), fileType === "pic" ? react_1["default"].createElement("img", {
725
- alt: "example",
726
- style: {
727
- width: "100%"
728
- },
729
- src: fileUrl
730
- }) : react_1["default"].createElement("video", {
731
- style: {
732
- width: "100%",
733
- height: "100%"
734
- },
735
- autoPlay: true,
736
- controls: true,
737
- src: fileUrl
738
- })));
739
- };
740
- exports.BsSystemOrderTable = function (_a) {
741
- var value = _a.value,
742
- type = _a.type;
743
- var columnMap = {
744
- BS_SYSTEM_ORDER: [{
745
- dataIndex: "billType",
746
- title: "订单类型"
747
- }, {
748
- dataIndex: "billNo",
749
- title: "系统订单号"
750
- }, {
751
- dataIndex: "billTag",
752
- title: "标签"
753
- }, {
754
- title: "主播名称",
755
- dataIndex: "authorName"
756
- }, {
757
- title: "主播ID",
758
- dataIndex: "authorId"
759
- }],
760
- KM_SYSTEM_ORDER: kmkf_utils_2.KM_SYSTEM_ORDER_CONFIG.columns,
761
- WLN_SYSTEM_ORDER: [{
762
- dataIndex: "billType",
763
- title: "单据类型"
764
- }, {
765
- dataIndex: "billNo",
766
- title: "系统订单号"
767
- }, {
768
- dataIndex: "billTag",
769
- title: "标签"
770
- }],
771
- WDT_SYSTEM_ORDER: [{
772
- dataIndex: "billType",
773
- title: "订单类型"
774
- }, {
775
- dataIndex: "billNo",
776
- title: "系统订单号"
777
- }, {
778
- dataIndex: "billTag",
779
- title: "订单标签"
780
- }],
781
- BS_E3_SYSTEM_ORDER: [{
782
- title: "系统订单号",
783
- dataIndex: "orderSn",
784
- width: 150,
785
- ellipsis: true
786
- }, {
787
- title: "订单状态",
788
- dataIndex: "orderStatus",
789
- width: 100,
790
- ellipsis: true,
791
- render: function render(val) {
792
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_ORDER_STATUS_MAP[val] || val);
793
- }
794
- }, {
795
- title: "是否被拆分",
796
- dataIndex: "isSplit",
797
- width: 100,
798
- ellipsis: true,
799
- render: function render(val) {
800
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_BOOLEAN_STATUS_MAP[val] || val);
801
- }
802
- }, {
803
- title: "是否拆分子单",
804
- dataIndex: "isSplitNew",
805
- width: 100,
806
- ellipsis: true,
807
- render: function render(val) {
808
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_BOOLEAN_STATUS_MAP[val] || val);
809
- }
810
- }, {
811
- title: "是否被合并",
812
- dataIndex: "isCombine",
813
- width: 100,
814
- ellipsis: true,
815
- render: function render(val) {
816
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_BOOLEAN_STATUS_MAP[val] || val);
817
- }
818
- }, {
819
- title: "是否合并新单",
820
- dataIndex: "isCombineNew",
821
- width: 100,
822
- ellipsis: true,
823
- render: function render(val) {
824
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_BOOLEAN_STATUS_MAP[val] || val);
825
- }
826
- }, {
827
- title: "是否复制单",
828
- dataIndex: "isCopy",
829
- width: 100,
830
- ellipsis: true,
831
- render: function render(val) {
832
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_BOOLEAN_STATUS_MAP[val] || val);
833
- }
834
- }, {
835
- title: "是否换货单",
836
- dataIndex: "isExchangeOrder",
837
- width: 100,
838
- ellipsis: true,
839
- render: function render(val) {
840
- return react_1["default"].createElement("span", null, kmkf_utils_1.BS_E3_BOOLEAN_STATUS_MAP[val] || val);
841
- }
842
- }, {
843
- title: "订单备注",
844
- dataIndex: "orderMsg",
845
- width: 100,
846
- ellipsis: true
847
- }],
848
- GY_SYSTEM_ORDER: kmkf_utils_2.GY_SYSTEM_ORDER_CONFIG.columns
849
- };
850
- var rowKeyMap = {
851
- BS_SYSTEM_ORDER: "billNo",
852
- KM_SYSTEM_ORDER: "billNo",
853
- WLN_SYSTEM_ORDER: "billNo",
854
- WDT_SYSTEM_ORDER: "billNo",
855
- BS_E3_SYSTEM_ORDER: "orderSn",
856
- GY_SYSTEM_ORDER: "billNo"
857
- };
858
- var rowSelection = {
859
- selectedRowKeys: (value === null || value === void 0 ? void 0 : value.selectIds) || ((value === null || value === void 0 ? void 0 : value.showOrderInfo) || []).reduce(function (prv, next) {
860
- if (next.select) {
861
- prv.push(next[rowKeyMap[type]] || "billNo");
862
- }
863
- return prv;
864
- }, []),
865
- getCheckboxProps: function getCheckboxProps(record) {
866
- return {
867
- disabled: true,
868
- name: record.name
869
- };
870
- }
871
- };
872
- return react_1["default"].createElement(antd_1.Table, {
873
- dataSource: (value === null || value === void 0 ? void 0 : value.showOrderInfo) || [],
874
- columns: columnMap[type] || [],
875
- rowSelection: rowSelection,
876
- rowKey: rowKeyMap[type] || "billNo",
877
- size: "small",
878
- pagination: false,
879
- scroll: {
880
- x: "100%"
881
- },
882
- locale: {
883
- emptyText: "暂无数据"
884
- }
885
- });
886
- };
887
- // interface MsgItemType {
888
- // msgRuleId: string
889
- // msgType: string
890
- // ruleName: string
891
- // status: string
892
- // }
893
- exports.MsgContent = function (_a) {
894
- var _b = _a.horizontal,
895
- horizontal = _b === void 0 ? true : _b,
896
- _c = _a.list,
897
- list = _c === void 0 ? [] : _c,
898
- valueKey = _a.valueKey,
899
- failValue = _a.failValue,
900
- _d = _a.options,
901
- options = _d === void 0 ? [] : _d;
902
- var getColorByStatus = function getColorByStatus(value) {
903
- var _a;
904
- return ((_a = options.find(function (innerItem) {
905
- return value === innerItem.label || value === innerItem.oldValue;
906
- })) === null || _a === void 0 ? void 0 : _a.color) || "#000";
907
- };
908
- var detailContent = function detailContent(item) {
909
- var _a;
910
- return react_1["default"].createElement("div", null, react_1["default"].createElement("div", {
911
- style: {
912
- textAlign: "left"
913
- }
914
- }, ((_a = item.msgReceivers) === null || _a === void 0 ? void 0 : _a.length) ? item.msgReceivers.map(function (msgItem, index) {
915
- return react_1["default"].createElement("div", {
916
- key: index,
917
- style: {
918
- color: getColorByStatus(msgItem.status)
919
- }
920
- }, msgItem.failReason ? msgItem.name + "\uFF0C" + msgItem.status + "\uFF0C\u5931\u8D25\u539F\u56E0\uFF1A" + msgItem.failReason : msgItem.name + "\uFF0C" + msgItem.status + ";");
921
- }) : item.failReason && react_1["default"].createElement("div", {
922
- style: {
923
- color: getColorByStatus(item.status)
924
- }
925
- }, "\u5931\u8D25\u539F\u56E0\uFF1A", item.failReason)));
926
- };
927
- return react_1["default"].createElement(antd_1.Space, {
928
- direction: !horizontal ? "vertical" : "horizontal"
929
- }, Array.isArray(list) ? (list || []).map(function (item, index) {
930
- var _a;
931
- var color = getColorByStatus(item[valueKey]);
932
- var currentOption = options.find(function (option) {
933
- return item[valueKey] === option.value;
934
- });
935
- var key = item.msgType || "ding";
936
- var formatMsgContent = react_1["default"].createElement("span", {
937
- key: index
938
- }, kmkf_utils_2.msgTypeCh[key], "-", item.ruleName, "-", currentOption ? currentOption.label : (item === null || item === void 0 ? void 0 : item[valueKey]) || "");
939
- return react_1["default"].createElement("div", {
940
- key: "wrap_" + index,
941
- style: {
942
- color: color,
943
- cursor: "pointer"
944
- }
945
- }, ((_a = item.msgReceivers) === null || _a === void 0 ? void 0 : _a.some(function (msgItem) {
946
- return Array.isArray(failValue) ? failValue.includes(msgItem === null || msgItem === void 0 ? void 0 : msgItem.status) : (msgItem === null || msgItem === void 0 ? void 0 : msgItem.status) === failValue;
947
- })) || item.failReason ? react_1["default"].createElement(antd_1.Popover, {
948
- content: detailContent(item),
949
- overlayStyle: {
950
- zIndex: 9999
951
- }
952
- }, formatMsgContent) : formatMsgContent);
953
- }) : null);
954
- };
955
- //获取付款凭证
956
- exports.AlipayBill = function (props) {
957
- var value = props.value,
958
- platform = props.platform;
959
- var _a = react_1.useState(false),
960
- visible = _a[0],
961
- setVisible = _a[1];
962
- var _b = react_1.useState(""),
963
- msg = _b[0],
964
- setMsg = _b[1];
965
- var _c = react_1.useState(false),
966
- hasUrl = _c[0],
967
- setHasUrl = _c[1];
968
- var voucherHandle = function voucherHandle(e) {
969
- return __awaiter(void 0, void 0, void 0, function () {
970
- var params, res, data, msg;
971
- return __generator(this, function (_a) {
972
- switch (_a.label) {
973
- case 0:
974
- e.stopPropagation();
975
- params = {
976
- alipayBillReceiptDetailId: value
977
- };
978
- return [4 /*yield*/, api_1.getAlipayBillReceipt(params)];
979
- case 1:
980
- res = _a.sent();
981
- data = res.data, msg = res.message;
982
- if (data) {
983
- setHasUrl(true);
984
- if (["fxg"].includes(platform)) {
985
- setMsg(data);
986
- setVisible(true);
987
- } else {
988
- window.open(data);
989
- }
990
- } else {
991
- setHasUrl(false);
992
- setMsg(msg);
993
- setVisible(true);
994
- }
995
- return [2 /*return*/];
996
- }
997
- });
998
- });
999
- };
1000
-
1001
- var closeHandle = function closeHandle(e) {
1002
- e.stopPropagation();
1003
- setVisible(false);
1004
- };
1005
- return react_1["default"].createElement(react_1["default"].Fragment, null, react_1["default"].createElement("span", {
1006
- style: {
1007
- color: "#1890ff",
1008
- cursor: "pointer"
1009
- },
1010
- onClick: voucherHandle
1011
- }, value), react_1["default"].createElement(antd_1.Modal, {
1012
- title: "\u4ED8\u6B3E\u51ED\u8BC1",
1013
- visible: visible,
1014
- footer: false,
1015
- onCancel: closeHandle
1016
- }, ["fxg"].includes(platform) && hasUrl ? react_1["default"].createElement("div", null, "\u8BF7\u590D\u5236\u94FE\u63A5\u5728\u6D4F\u89C8\u5668\u4E0A\u6253\u5F00\uFF0C\u94FE\u63A5\uFF1A", react_1["default"].createElement(Paragraph, {
1017
- copyable: true
1018
- }, msg)) : msg));
1019
- };