kmkf-work-order-service-component 0.4.0-alpha.3 → 0.4.0-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,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { FormProps } from 'antd';
2
3
  import 'moment/locale/zh-cn';
3
4
  import './index.less';
4
5
  interface Option {
@@ -8,7 +9,7 @@ interface Option {
8
9
  }
9
10
  declare type FormRenderProps = {
10
11
  shopList: any[];
11
- shopId: string;
12
+ shopId?: string;
12
13
  record?: any;
13
14
  look?: boolean;
14
15
  templateId?: string[];
@@ -17,6 +18,7 @@ declare type FormRenderProps = {
17
18
  buyerNick?: string;
18
19
  platform?: string;
19
20
  templateList?: Option[];
21
+ formProps: FormProps;
20
22
  onTemplateChange?: (p: string) => any;
21
23
  onFormSubmitSuccess?: <T>(p: T) => void;
22
24
  };
@@ -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,
@@ -56,7 +90,9 @@ var FormRender = function FormRender(props, ref) {
56
90
  record = props.record,
57
91
  templateList = props.templateList,
58
92
  onFormSubmitSuccess = props.onFormSubmitSuccess,
59
- onTemplateChange = props.onTemplateChange;
93
+ onTemplateChange = props.onTemplateChange,
94
+ _props$formProps = props.formProps,
95
+ formProps = _props$formProps === void 0 ? {} : _props$formProps;
60
96
 
61
97
  var _useState = useState(false),
62
98
  _useState2 = _slicedToArray(_useState, 2),
@@ -86,6 +122,27 @@ var FormRender = function FormRender(props, ref) {
86
122
  setReplaceValue = _useState10[1]; //字段重复校验
87
123
 
88
124
 
125
+ var _useState11 = useState(currentShopId),
126
+ _useState12 = _slicedToArray(_useState11, 2),
127
+ shopId = _useState12[0],
128
+ setShopId = _useState12[1];
129
+
130
+ var _useState13 = useState([]),
131
+ _useState14 = _slicedToArray(_useState13, 2),
132
+ platIcon = _useState14[0],
133
+ setPlatIcon = _useState14[1];
134
+
135
+ useEffect(function () {
136
+ if (!currentShopId) {
137
+ getPlatList().then(function (list) {
138
+ return setPlatIcon(list);
139
+ });
140
+ }
141
+ }, [currentShopId]);
142
+ useEffect(function () {
143
+ setShopId(currentShopId);
144
+ }, [currentShopId]);
145
+
89
146
  var _Form$useForm = Form.useForm(),
90
147
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
91
148
  form = _Form$useForm2[0];
@@ -115,7 +172,7 @@ var FormRender = function FormRender(props, ref) {
115
172
  };
116
173
 
117
174
  var asyncDoSave = /*#__PURE__*/function () {
118
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(workOrderDetail, templateDetail) {
175
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(workOrderDetail, templateDetail) {
119
176
  var data, res, params, submitData, _yield$updateWorkOrde, success, result, platformMap, _params, hasEnterPrisePayment, getEnterPrisePaymentData, uniqueKey, componentConfig, _yield$addWorkOrder, _success, _result;
120
177
 
121
178
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -149,10 +206,10 @@ var FormRender = function FormRender(props, ref) {
149
206
 
150
207
  params = {
151
208
  apiName: 'updateWorkOrder',
152
- shopId: currentShopId,
209
+ shopId: shopId,
153
210
  uniqueKey: last(templateIdState),
154
211
  accessToken: get(find(shopList, function (s) {
155
- return s.shopId === currentShopId;
212
+ return s.shopId === shopId;
156
213
  }), 'accessToken', ''),
157
214
  workOrderUpdateKeyVos: {
158
215
  workOrderId: workOrderId,
@@ -195,11 +252,11 @@ var FormRender = function FormRender(props, ref) {
195
252
  };
196
253
  _params = {
197
254
  apiName: 'addWorkOrder',
198
- shopId: currentShopId,
255
+ shopId: shopId,
199
256
  uniqueKey: last(templateIdState),
200
257
  workOrderComponentVos: [],
201
258
  accessToken: get(find(shopList, function (s) {
202
- return s.shopId === currentShopId;
259
+ return s.shopId === shopId;
203
260
  }), 'accessToken', ''),
204
261
  source: get(platformMap, "".concat(platform), '工单通')
205
262
  };
@@ -275,7 +332,7 @@ var FormRender = function FormRender(props, ref) {
275
332
  }));
276
333
 
277
334
  return function asyncDoSave(_x, _x2) {
278
- return _ref.apply(this, arguments);
335
+ return _ref2.apply(this, arguments);
279
336
  };
280
337
  }();
281
338
 
@@ -305,7 +362,7 @@ var FormRender = function FormRender(props, ref) {
305
362
 
306
363
 
307
364
  var queryReplaceCount = /*#__PURE__*/function () {
308
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(componentValue) {
365
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(componentValue) {
309
366
  var needCheckComponentList, params, _yield$replaceCheck, resultList, resultParams;
310
367
 
311
368
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -356,7 +413,7 @@ var FormRender = function FormRender(props, ref) {
356
413
  }));
357
414
 
358
415
  return function queryReplaceCount(_x3) {
359
- return _ref2.apply(this, arguments);
416
+ return _ref3.apply(this, arguments);
360
417
  };
361
418
  }(); //自动返填重复校验
362
419
 
@@ -388,14 +445,14 @@ var FormRender = function FormRender(props, ref) {
388
445
  };
389
446
 
390
447
  var queryDetail = /*#__PURE__*/function () {
391
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
448
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
392
449
  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;
393
450
 
394
451
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
395
452
  while (1) {
396
453
  switch (_context3.prev = _context3.next) {
397
454
  case 0:
398
- templateId = _ref3.templateId, workOrderId = _ref3.workOrderId, shopId = _ref3.shopId, shopList = _ref3.shopList, record = _ref3.record, orderNo = _ref3.orderNo, buyerId = _ref3.buyerId, buyerNick = _ref3.buyerNick;
455
+ templateId = _ref4.templateId, workOrderId = _ref4.workOrderId, shopId = _ref4.shopId, shopList = _ref4.shopList, record = _ref4.record, orderNo = _ref4.orderNo, buyerId = _ref4.buyerId, buyerNick = _ref4.buyerNick;
399
456
  form.resetFields();
400
457
  _context3.prev = 2;
401
458
  setLoading(true);
@@ -495,7 +552,7 @@ var FormRender = function FormRender(props, ref) {
495
552
  }));
496
553
 
497
554
  return function queryDetail(_x4) {
498
- return _ref4.apply(this, arguments);
555
+ return _ref5.apply(this, arguments);
499
556
  };
500
557
  }();
501
558
 
@@ -504,14 +561,14 @@ var FormRender = function FormRender(props, ref) {
504
561
  queryDetail({
505
562
  templateId: last(templateIdState),
506
563
  workOrderId: workOrderId,
507
- shopId: currentShopId,
564
+ shopId: shopId,
508
565
  shopList: shopList,
509
566
  record: record,
510
567
  orderNo: orderNo,
511
568
  buyerId: buyerId,
512
569
  buyerNick: buyerNick
513
570
  });
514
- }, [templateIdState, workOrderId, currentShopId]); //订单返填
571
+ }, [templateIdState, workOrderId, shopId]); //订单返填
515
572
 
516
573
  var changeHandle = function changeHandle(order_no) {
517
574
  if (!order_no) return;
@@ -524,7 +581,7 @@ var FormRender = function FormRender(props, ref) {
524
581
  orderBack({
525
582
  order_no: order_no,
526
583
  form: form,
527
- shopId: currentShopId,
584
+ shopId: shopId,
528
585
  shopList: shopList,
529
586
  templateDetail: templateDetail,
530
587
  type: !!workOrderId ? 'edit' : 'add',
@@ -535,7 +592,7 @@ var FormRender = function FormRender(props, ref) {
535
592
 
536
593
 
537
594
  var componentOnBlur = /*#__PURE__*/function () {
538
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, type) {
595
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, type) {
539
596
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
540
597
  while (1) {
541
598
  switch (_context4.prev = _context4.next) {
@@ -566,7 +623,7 @@ var FormRender = function FormRender(props, ref) {
566
623
  }));
567
624
 
568
625
  return function componentOnBlur(_x5, _x6) {
569
- return _ref5.apply(this, arguments);
626
+ return _ref6.apply(this, arguments);
570
627
  };
571
628
  }(); // 切换店铺
572
629
 
@@ -600,13 +657,18 @@ var FormRender = function FormRender(props, ref) {
600
657
  var otherItems = get(templateDetail, 'componentDtoList', []).map(newRenderColumnItem({
601
658
  form: form,
602
659
  shopList: shopList,
603
- shopId: currentShopId,
660
+ shopId: shopId,
604
661
  isEditing: !!workOrderId,
605
662
  workOrderDetail: workOrderDetail,
606
663
  templateDetail: templateDetail
607
664
  }));
608
- return _toConsumableArray(otherItems);
609
- }, [templateDetail, shopList, currentShopId, workOrderDetail]);
665
+
666
+ if (!currentShopId) {
667
+ return [ShopName].concat(_toConsumableArray(otherItems));
668
+ }
669
+
670
+ return otherItems;
671
+ }, [templateDetail, shopList, shopId, workOrderDetail, currentShopId]);
610
672
  return /*#__PURE__*/_jsx(Spin, {
611
673
  spinning: loading,
612
674
  children: /*#__PURE__*/_jsxs(ConfigProvider, {
@@ -618,7 +680,7 @@ var FormRender = function FormRender(props, ref) {
618
680
  children: ["\u63D0\u793A\uFF1A\u8BE5", COMPONENT_MAP_NAME[key], "\u9488\u5BF9\u6B64\u6A21\u677F\u5DF2\u521B\u5EFA\u8FC7", replaceValue[key], "\u6761\u5DE5\u5355\uFF01"]
619
681
  });
620
682
  })
621
- }), /*#__PURE__*/_jsxs(Form, {
683
+ }), /*#__PURE__*/_jsxs(Form, _objectSpread(_objectSpread({
622
684
  form: form,
623
685
  labelCol: {
624
686
  span: 6
@@ -626,7 +688,8 @@ var FormRender = function FormRender(props, ref) {
626
688
  wrapperCol: {
627
689
  span: 18
628
690
  },
629
- className: "customizeFormModalClassName",
691
+ className: "customizeFormModalClassName"
692
+ }, formProps), {}, {
630
693
  children: [!templateId && /*#__PURE__*/_jsx(Form.Item, {
631
694
  label: "\u6A21\u677F\u540D\u79F0",
632
695
  required: true,
@@ -638,8 +701,14 @@ var FormRender = function FormRender(props, ref) {
638
701
  onChange: handleChangeTemplateId,
639
702
  allowClear: false
640
703
  })
704
+ }), !currentShopId && /*#__PURE__*/_jsx(ShopName, {
705
+ shopList: shopList,
706
+ platIconList: platIcon,
707
+ workOrderId: workOrderId,
708
+ look: look,
709
+ handleChangeShopId: setShopId
641
710
  }), finalFormItems]
642
- })]
711
+ }))]
643
712
  })
644
713
  });
645
714
  };
@@ -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;
@@ -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.3",
3
+ "version": "0.4.0-alpha.5",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",