kmkf-work-order-service-component 0.4.0-alpha.2 → 0.4.0-alpha.4

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,7 +8,7 @@ interface Option {
8
8
  }
9
9
  declare type FormRenderProps = {
10
10
  shopList: any[];
11
- shopId: string;
11
+ shopId?: string;
12
12
  record?: any;
13
13
  look?: boolean;
14
14
  templateId?: string[];
@@ -39,10 +39,44 @@ import { get, find, some, set, last } from 'lodash';
39
39
  import 'moment/locale/zh-cn';
40
40
  import { calcWorkOrderList, submitDataTransOldFormat, orderBack, getReplaceWarnValues, COMPONENT_MAP_NAME } from "../common/utils/tools";
41
41
  import { queryTemplateDetail, addWorkOrder, queryWorkOrderDetail, updateWorkOrder, replaceCheck } from "../model/servers/api";
42
+ import { getPlatList } from "../model/customizeWorkOrder/api";
42
43
  import { factory } from "../WorkOrder/components/Widget";
44
+ import ShopList from "../ShopList";
43
45
  import "./index.less";
44
- import { jsxs as _jsxs } from "react/jsx-runtime";
45
46
  import { jsx as _jsx } from "react/jsx-runtime";
47
+ import { jsxs as _jsxs } from "react/jsx-runtime";
48
+
49
+ var ShopName = function ShopName(_ref) {
50
+ var shopList = _ref.shopList,
51
+ platIconList = _ref.platIconList,
52
+ workOrderId = _ref.workOrderId,
53
+ look = _ref.look,
54
+ handleChangeShopId = _ref.handleChangeShopId;
55
+ return /*#__PURE__*/_jsx("div", {
56
+ className: "form-item--wrap",
57
+ style: {
58
+ position: 'relative'
59
+ },
60
+ children: /*#__PURE__*/_jsx(Form.Item, {
61
+ name: "shopId",
62
+ label: "\u5E97\u94FA\u540D\u79F0",
63
+ className: "form-item-label--index",
64
+ rules: [{
65
+ required: true,
66
+ message: '请选择店铺名称'
67
+ }],
68
+ children: /*#__PURE__*/_jsx(ShopList, {
69
+ shopList: shopList,
70
+ platIconList: platIconList,
71
+ disabled: !!workOrderId || look,
72
+ setShopId: handleChangeShopId,
73
+ placeholder: "\u8BF7\u9009\u62E9\u5E97\u94FA\u540D\u79F0",
74
+ showSearch: true,
75
+ optionFilterProp: "label"
76
+ })
77
+ })
78
+ }, 'shopId');
79
+ };
46
80
 
47
81
  var FormRender = function FormRender(props, ref) {
48
82
  var shopList = props.shopList,
@@ -86,6 +120,27 @@ var FormRender = function FormRender(props, ref) {
86
120
  setReplaceValue = _useState10[1]; //字段重复校验
87
121
 
88
122
 
123
+ var _useState11 = useState(currentShopId),
124
+ _useState12 = _slicedToArray(_useState11, 2),
125
+ shopId = _useState12[0],
126
+ setShopId = _useState12[1];
127
+
128
+ var _useState13 = useState([]),
129
+ _useState14 = _slicedToArray(_useState13, 2),
130
+ platIcon = _useState14[0],
131
+ setPlatIcon = _useState14[1];
132
+
133
+ useEffect(function () {
134
+ if (!currentShopId) {
135
+ getPlatList().then(function (list) {
136
+ return setPlatIcon(list);
137
+ });
138
+ }
139
+ }, [currentShopId]);
140
+ useEffect(function () {
141
+ setShopId(currentShopId);
142
+ }, [currentShopId]);
143
+
89
144
  var _Form$useForm = Form.useForm(),
90
145
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
91
146
  form = _Form$useForm2[0];
@@ -115,7 +170,7 @@ var FormRender = function FormRender(props, ref) {
115
170
  };
116
171
 
117
172
  var asyncDoSave = /*#__PURE__*/function () {
118
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(workOrderDetail, templateDetail) {
173
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(workOrderDetail, templateDetail) {
119
174
  var data, res, params, submitData, _yield$updateWorkOrde, success, result, platformMap, _params, hasEnterPrisePayment, getEnterPrisePaymentData, uniqueKey, componentConfig, _yield$addWorkOrder, _success, _result;
120
175
 
121
176
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -149,10 +204,10 @@ var FormRender = function FormRender(props, ref) {
149
204
 
150
205
  params = {
151
206
  apiName: 'updateWorkOrder',
152
- shopId: currentShopId,
207
+ shopId: shopId,
153
208
  uniqueKey: last(templateIdState),
154
209
  accessToken: get(find(shopList, function (s) {
155
- return s.shopId === currentShopId;
210
+ return s.shopId === shopId;
156
211
  }), 'accessToken', ''),
157
212
  workOrderUpdateKeyVos: {
158
213
  workOrderId: workOrderId,
@@ -190,15 +245,16 @@ var FormRender = function FormRender(props, ref) {
190
245
  ks: '快手',
191
246
  pdd: '拼多多',
192
247
  jd: '京东',
193
- xiaozhi: '小智'
248
+ xiaozhi: '小智',
249
+ pc: 'PC'
194
250
  };
195
251
  _params = {
196
252
  apiName: 'addWorkOrder',
197
- shopId: currentShopId,
253
+ shopId: shopId,
198
254
  uniqueKey: last(templateIdState),
199
255
  workOrderComponentVos: [],
200
256
  accessToken: get(find(shopList, function (s) {
201
- return s.shopId === currentShopId;
257
+ return s.shopId === shopId;
202
258
  }), 'accessToken', ''),
203
259
  source: get(platformMap, "".concat(platform), '工单通')
204
260
  };
@@ -274,7 +330,7 @@ var FormRender = function FormRender(props, ref) {
274
330
  }));
275
331
 
276
332
  return function asyncDoSave(_x, _x2) {
277
- return _ref.apply(this, arguments);
333
+ return _ref2.apply(this, arguments);
278
334
  };
279
335
  }();
280
336
 
@@ -304,7 +360,7 @@ var FormRender = function FormRender(props, ref) {
304
360
 
305
361
 
306
362
  var queryReplaceCount = /*#__PURE__*/function () {
307
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(componentValue) {
363
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(componentValue) {
308
364
  var needCheckComponentList, params, _yield$replaceCheck, resultList, resultParams;
309
365
 
310
366
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -355,7 +411,7 @@ var FormRender = function FormRender(props, ref) {
355
411
  }));
356
412
 
357
413
  return function queryReplaceCount(_x3) {
358
- return _ref2.apply(this, arguments);
414
+ return _ref3.apply(this, arguments);
359
415
  };
360
416
  }(); //自动返填重复校验
361
417
 
@@ -387,14 +443,14 @@ var FormRender = function FormRender(props, ref) {
387
443
  };
388
444
 
389
445
  var queryDetail = /*#__PURE__*/function () {
390
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
446
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
391
447
  var templateId, workOrderId, shopId, shopList, record, orderNo, buyerId, buyerNick, _workOrderDetail2, _workOrderDetail2$dat, _workOrderDetail2$dat2, _workOrderDetail, _templateDetail, _workOrderDetail3, _templateDetail$data, transData, _templateDetail$data2, _templateDetail$data3, jsonMap, _transData, antFormEl;
392
448
 
393
449
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
394
450
  while (1) {
395
451
  switch (_context3.prev = _context3.next) {
396
452
  case 0:
397
- templateId = _ref3.templateId, workOrderId = _ref3.workOrderId, shopId = _ref3.shopId, shopList = _ref3.shopList, record = _ref3.record, orderNo = _ref3.orderNo, buyerId = _ref3.buyerId, buyerNick = _ref3.buyerNick;
453
+ templateId = _ref4.templateId, workOrderId = _ref4.workOrderId, shopId = _ref4.shopId, shopList = _ref4.shopList, record = _ref4.record, orderNo = _ref4.orderNo, buyerId = _ref4.buyerId, buyerNick = _ref4.buyerNick;
398
454
  form.resetFields();
399
455
  _context3.prev = 2;
400
456
  setLoading(true);
@@ -494,7 +550,7 @@ var FormRender = function FormRender(props, ref) {
494
550
  }));
495
551
 
496
552
  return function queryDetail(_x4) {
497
- return _ref4.apply(this, arguments);
553
+ return _ref5.apply(this, arguments);
498
554
  };
499
555
  }();
500
556
 
@@ -503,14 +559,14 @@ var FormRender = function FormRender(props, ref) {
503
559
  queryDetail({
504
560
  templateId: last(templateIdState),
505
561
  workOrderId: workOrderId,
506
- shopId: currentShopId,
562
+ shopId: shopId,
507
563
  shopList: shopList,
508
564
  record: record,
509
565
  orderNo: orderNo,
510
566
  buyerId: buyerId,
511
567
  buyerNick: buyerNick
512
568
  });
513
- }, [templateIdState, workOrderId, currentShopId]); //订单返填
569
+ }, [templateIdState, workOrderId, shopId]); //订单返填
514
570
 
515
571
  var changeHandle = function changeHandle(order_no) {
516
572
  if (!order_no) return;
@@ -523,7 +579,7 @@ var FormRender = function FormRender(props, ref) {
523
579
  orderBack({
524
580
  order_no: order_no,
525
581
  form: form,
526
- shopId: currentShopId,
582
+ shopId: shopId,
527
583
  shopList: shopList,
528
584
  templateDetail: templateDetail,
529
585
  type: !!workOrderId ? 'edit' : 'add',
@@ -534,7 +590,7 @@ var FormRender = function FormRender(props, ref) {
534
590
 
535
591
 
536
592
  var componentOnBlur = /*#__PURE__*/function () {
537
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, type) {
593
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, type) {
538
594
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
539
595
  while (1) {
540
596
  switch (_context4.prev = _context4.next) {
@@ -565,7 +621,7 @@ var FormRender = function FormRender(props, ref) {
565
621
  }));
566
622
 
567
623
  return function componentOnBlur(_x5, _x6) {
568
- return _ref5.apply(this, arguments);
624
+ return _ref6.apply(this, arguments);
569
625
  };
570
626
  }(); // 切换店铺
571
627
 
@@ -599,13 +655,18 @@ var FormRender = function FormRender(props, ref) {
599
655
  var otherItems = get(templateDetail, 'componentDtoList', []).map(newRenderColumnItem({
600
656
  form: form,
601
657
  shopList: shopList,
602
- shopId: currentShopId,
658
+ shopId: shopId,
603
659
  isEditing: !!workOrderId,
604
660
  workOrderDetail: workOrderDetail,
605
661
  templateDetail: templateDetail
606
662
  }));
607
- return _toConsumableArray(otherItems);
608
- }, [templateDetail, shopList, currentShopId, workOrderDetail]);
663
+
664
+ if (!currentShopId) {
665
+ return [ShopName].concat(_toConsumableArray(otherItems));
666
+ }
667
+
668
+ return otherItems;
669
+ }, [templateDetail, shopList, shopId, workOrderDetail, currentShopId]);
609
670
  return /*#__PURE__*/_jsx(Spin, {
610
671
  spinning: loading,
611
672
  children: /*#__PURE__*/_jsxs(ConfigProvider, {
@@ -637,6 +698,12 @@ var FormRender = function FormRender(props, ref) {
637
698
  onChange: handleChangeTemplateId,
638
699
  allowClear: false
639
700
  })
701
+ }), !currentShopId && /*#__PURE__*/_jsx(ShopName, {
702
+ shopList: shopList,
703
+ platIconList: platIcon,
704
+ workOrderId: workOrderId,
705
+ look: look,
706
+ handleChangeShopId: setShopId
640
707
  }), finalFormItems]
641
708
  })]
642
709
  })
@@ -34,6 +34,12 @@
34
34
  }
35
35
 
36
36
  .customizeFormModalClassName {
37
+ :global(.ant-cascader-menu-item-content) {
38
+ max-width: 200px;
39
+ overflow: hidden;
40
+ white-space: nowrap;
41
+ text-overflow: ellipsis;
42
+ }
37
43
  :global(.goods-uploaded-state) {
38
44
  margin: 6px 0 5px 0;
39
45
  padding-left: 7px;
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ declare type Shop = {
3
+ auditStatus: number;
4
+ shopId: string;
5
+ shopName: string;
6
+ shopSource: string | number;
7
+ };
8
+ declare type ShopListProps = {
9
+ shopList: Shop[];
10
+ platIconList: {
11
+ alreadyJoin: boolean;
12
+ img: string;
13
+ platformType: number;
14
+ }[];
15
+ disabled?: boolean;
16
+ [prop: string]: any;
17
+ };
18
+ declare const ShopList: ({ shopList, platIconList, disabled, onChange, setShopId, ...prop }: ShopListProps) => JSX.Element;
19
+ export default ShopList;
@@ -0,0 +1,88 @@
1
+ var _excluded = ["platIcon", "shopId", "styles"],
2
+ _excluded2 = ["shopList", "platIconList", "disabled", "onChange", "setShopId"];
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
+
12
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
+
14
+ import { Select } from 'antd';
15
+ import React, { useMemo } from 'react';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+
19
+ var PlatformAvatar = function PlatformAvatar(props) {
20
+ var platIcon = props.platIcon,
21
+ shopId = props.shopId,
22
+ styles = props.styles,
23
+ other = _objectWithoutProperties(props, _excluded);
24
+
25
+ if (platIcon[shopId]) {
26
+ return /*#__PURE__*/_jsx("img", _objectSpread({
27
+ alt: "",
28
+ src: platIcon[shopId],
29
+ style: _objectSpread({
30
+ width: '20px',
31
+ height: '20px',
32
+ objectFit: 'contain'
33
+ }, styles)
34
+ }, other));
35
+ }
36
+
37
+ return null;
38
+ };
39
+
40
+ var ShopList = function ShopList(_ref) {
41
+ var shopList = _ref.shopList,
42
+ platIconList = _ref.platIconList,
43
+ disabled = _ref.disabled,
44
+ onChange = _ref.onChange,
45
+ setShopId = _ref.setShopId,
46
+ prop = _objectWithoutProperties(_ref, _excluded2);
47
+
48
+ var handleChange = function handleChange(val) {
49
+ onChange === null || onChange === void 0 ? void 0 : onChange(val);
50
+ setShopId === null || setShopId === void 0 ? void 0 : setShopId(val);
51
+ };
52
+
53
+ var platIcon = useMemo(function () {
54
+ var iconParams = {};
55
+ (shopList || []).forEach(function (item) {
56
+ var plat = platIconList.find(function (t) {
57
+ return +t.platformType === +item.shopSource;
58
+ });
59
+ plat && (iconParams[item.shopId] = plat.img);
60
+ });
61
+ return iconParams;
62
+ }, [shopList, platIconList]);
63
+ return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
64
+ disabled: disabled,
65
+ onChange: handleChange
66
+ }, prop), {}, {
67
+ children: shopList.filter(function (item) {
68
+ return (item === null || item === void 0 ? void 0 : item.auditStatus) === 1;
69
+ }).map(function (item) {
70
+ var shopId = item.shopId;
71
+ return /*#__PURE__*/_jsxs(Select.Option, {
72
+ value: item.shopId,
73
+ label: item.shopName,
74
+ children: [/*#__PURE__*/_jsx(PlatformAvatar, {
75
+ shopId: shopId,
76
+ styles: {
77
+ marginRight: 5
78
+ },
79
+ platIcon: platIcon
80
+ }), /*#__PURE__*/_jsx("span", {
81
+ children: item.shopName
82
+ })]
83
+ });
84
+ })
85
+ }));
86
+ };
87
+
88
+ export default ShopList;
@@ -176,8 +176,7 @@ var CustomizeWorkOrderList = function CustomizeWorkOrderList(_ref3) {
176
176
  pagination = tableProps.pagination,
177
177
  _onChange = tableProps.onChange;
178
178
  useEffect(function () {
179
- // 当total有值以后将不在执行,以便从后面切换到第一页时闪动
180
- if (pagination.current === 1 && total === 0) {
179
+ if (pagination.current === 1) {
181
180
  setTotal(pagination.total);
182
181
  }
183
182
  }, [pagination, total]);
@@ -357,7 +356,7 @@ var CustomizeWorkOrderList = function CustomizeWorkOrderList(_ref3) {
357
356
  width: platform === PlatForm.XIAOZHI ? '100%' : '90%'
358
357
  }), /*#__PURE__*/_jsx(Drawer, {
359
358
  closeIcon: /*#__PURE__*/_jsx(LeftOutlined, {}),
360
- title: title,
359
+ title: (record === null || record === void 0 ? void 0 : record.templateName) || title,
361
360
  width: platform === PlatForm.XIAOZHI ? '100%' : '90%',
362
361
  open: formRenderVisible,
363
362
  onClose: handleCloseFormModal,
@@ -1,6 +1,11 @@
1
1
  import { serverProps } from '../servers/request';
2
- import { ColumnsConfigI } from './types';
2
+ import { ColumnsConfigI, PlatIProp } from './types';
3
3
  export declare const queryAllComponentList: (data: any) => Promise<serverProps<{
4
4
  fixedColumns: ColumnsConfigI[];
5
5
  nonFixedColumns: ColumnsConfigI[];
6
6
  }>>;
7
+ export declare const getPlatList: (data: any) => Promise<serverProps<{
8
+ all: PlatIProp[];
9
+ alreadyJoinedList: PlatIProp[];
10
+ notJoinList: PlatIProp[];
11
+ }>>;
@@ -1,3 +1,15 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ 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); }
6
+
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ 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; }
12
+
1
13
  import request from "../servers/request";
2
14
  // 所有组件信息
3
15
  export var queryAllComponentList = function queryAllComponentList(data) {
@@ -6,4 +18,18 @@ export var queryAllComponentList = function queryAllComponentList(data) {
6
18
  method: 'get',
7
19
  data: data
8
20
  });
21
+ }; // 平台信息
22
+
23
+ export var getPlatList = function getPlatList(data) {
24
+ return request({
25
+ url: '/qy/platform/listPlatform',
26
+ method: 'get',
27
+ data: data
28
+ }).then(function (res) {
29
+ var platType = res.data || {};
30
+ platType.alreadyJoinedList = platType.alreadyJoinedList || [];
31
+ platType.notJoinList = platType.notJoinList || [];
32
+ var list = [].concat(_toConsumableArray(platType.alreadyJoinedList), _toConsumableArray(platType.notJoinList));
33
+ return list;
34
+ });
9
35
  };
@@ -35,3 +35,8 @@ export declare type ComponentColumnsT = {
35
35
  uniqueKey: string;
36
36
  name: string;
37
37
  };
38
+ export declare type PlatIProp = {
39
+ alreadyJoin: boolean;
40
+ img: string;
41
+ platformType: number;
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kmkf-work-order-service-component",
3
- "version": "0.4.0-alpha.2",
3
+ "version": "0.4.0-alpha.4",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",