kmkf-work-order-service-component 0.4.0-alpha.3 → 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,
@@ -195,11 +250,11 @@ var FormRender = function FormRender(props, ref) {
195
250
  };
196
251
  _params = {
197
252
  apiName: 'addWorkOrder',
198
- shopId: currentShopId,
253
+ shopId: shopId,
199
254
  uniqueKey: last(templateIdState),
200
255
  workOrderComponentVos: [],
201
256
  accessToken: get(find(shopList, function (s) {
202
- return s.shopId === currentShopId;
257
+ return s.shopId === shopId;
203
258
  }), 'accessToken', ''),
204
259
  source: get(platformMap, "".concat(platform), '工单通')
205
260
  };
@@ -275,7 +330,7 @@ var FormRender = function FormRender(props, ref) {
275
330
  }));
276
331
 
277
332
  return function asyncDoSave(_x, _x2) {
278
- return _ref.apply(this, arguments);
333
+ return _ref2.apply(this, arguments);
279
334
  };
280
335
  }();
281
336
 
@@ -305,7 +360,7 @@ var FormRender = function FormRender(props, ref) {
305
360
 
306
361
 
307
362
  var queryReplaceCount = /*#__PURE__*/function () {
308
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(componentValue) {
363
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(componentValue) {
309
364
  var needCheckComponentList, params, _yield$replaceCheck, resultList, resultParams;
310
365
 
311
366
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -356,7 +411,7 @@ var FormRender = function FormRender(props, ref) {
356
411
  }));
357
412
 
358
413
  return function queryReplaceCount(_x3) {
359
- return _ref2.apply(this, arguments);
414
+ return _ref3.apply(this, arguments);
360
415
  };
361
416
  }(); //自动返填重复校验
362
417
 
@@ -388,14 +443,14 @@ var FormRender = function FormRender(props, ref) {
388
443
  };
389
444
 
390
445
  var queryDetail = /*#__PURE__*/function () {
391
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
446
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
392
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;
393
448
 
394
449
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
395
450
  while (1) {
396
451
  switch (_context3.prev = _context3.next) {
397
452
  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;
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;
399
454
  form.resetFields();
400
455
  _context3.prev = 2;
401
456
  setLoading(true);
@@ -495,7 +550,7 @@ var FormRender = function FormRender(props, ref) {
495
550
  }));
496
551
 
497
552
  return function queryDetail(_x4) {
498
- return _ref4.apply(this, arguments);
553
+ return _ref5.apply(this, arguments);
499
554
  };
500
555
  }();
501
556
 
@@ -504,14 +559,14 @@ var FormRender = function FormRender(props, ref) {
504
559
  queryDetail({
505
560
  templateId: last(templateIdState),
506
561
  workOrderId: workOrderId,
507
- shopId: currentShopId,
562
+ shopId: shopId,
508
563
  shopList: shopList,
509
564
  record: record,
510
565
  orderNo: orderNo,
511
566
  buyerId: buyerId,
512
567
  buyerNick: buyerNick
513
568
  });
514
- }, [templateIdState, workOrderId, currentShopId]); //订单返填
569
+ }, [templateIdState, workOrderId, shopId]); //订单返填
515
570
 
516
571
  var changeHandle = function changeHandle(order_no) {
517
572
  if (!order_no) return;
@@ -524,7 +579,7 @@ var FormRender = function FormRender(props, ref) {
524
579
  orderBack({
525
580
  order_no: order_no,
526
581
  form: form,
527
- shopId: currentShopId,
582
+ shopId: shopId,
528
583
  shopList: shopList,
529
584
  templateDetail: templateDetail,
530
585
  type: !!workOrderId ? 'edit' : 'add',
@@ -535,7 +590,7 @@ var FormRender = function FormRender(props, ref) {
535
590
 
536
591
 
537
592
  var componentOnBlur = /*#__PURE__*/function () {
538
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, type) {
593
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, type) {
539
594
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
540
595
  while (1) {
541
596
  switch (_context4.prev = _context4.next) {
@@ -566,7 +621,7 @@ var FormRender = function FormRender(props, ref) {
566
621
  }));
567
622
 
568
623
  return function componentOnBlur(_x5, _x6) {
569
- return _ref5.apply(this, arguments);
624
+ return _ref6.apply(this, arguments);
570
625
  };
571
626
  }(); // 切换店铺
572
627
 
@@ -600,13 +655,18 @@ var FormRender = function FormRender(props, ref) {
600
655
  var otherItems = get(templateDetail, 'componentDtoList', []).map(newRenderColumnItem({
601
656
  form: form,
602
657
  shopList: shopList,
603
- shopId: currentShopId,
658
+ shopId: shopId,
604
659
  isEditing: !!workOrderId,
605
660
  workOrderDetail: workOrderDetail,
606
661
  templateDetail: templateDetail
607
662
  }));
608
- return _toConsumableArray(otherItems);
609
- }, [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]);
610
670
  return /*#__PURE__*/_jsx(Spin, {
611
671
  spinning: loading,
612
672
  children: /*#__PURE__*/_jsxs(ConfigProvider, {
@@ -638,6 +698,12 @@ var FormRender = function FormRender(props, ref) {
638
698
  onChange: handleChangeTemplateId,
639
699
  allowClear: false
640
700
  })
701
+ }), !currentShopId && /*#__PURE__*/_jsx(ShopName, {
702
+ shopList: shopList,
703
+ platIconList: platIcon,
704
+ workOrderId: workOrderId,
705
+ look: look,
706
+ handleChangeShopId: setShopId
641
707
  }), finalFormItems]
642
708
  })]
643
709
  })
@@ -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.4",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",