kmkf-work-order-service-component 0.3.5 → 0.3.6-alpha.1

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.
Files changed (36) hide show
  1. package/dist/esm/SingleShopWorkOrder/components/Card/index.d.ts +4 -0
  2. package/dist/esm/SingleShopWorkOrder/components/Card/index.js +157 -0
  3. package/dist/esm/SingleShopWorkOrder/components/Card/index.less +123 -0
  4. package/dist/esm/SingleShopWorkOrder/components/CustomizeFormModal/index.d.ts +17 -0
  5. package/dist/esm/SingleShopWorkOrder/components/CustomizeFormModal/index.js +676 -0
  6. package/dist/esm/SingleShopWorkOrder/components/CustomizeFormModal/index.less +134 -0
  7. package/dist/esm/SingleShopWorkOrder/components/DeleteCustomizeOrderModal/index.d.ts +5 -0
  8. package/dist/esm/SingleShopWorkOrder/components/DeleteCustomizeOrderModal/index.js +90 -0
  9. package/dist/esm/SingleShopWorkOrder/components/OrderList/index.d.ts +6 -0
  10. package/dist/esm/SingleShopWorkOrder/components/OrderList/index.js +16 -0
  11. package/dist/esm/SingleShopWorkOrder/index.d.ts +4 -0
  12. package/dist/esm/SingleShopWorkOrder/index.js +169 -0
  13. package/dist/esm/SingleShopWorkOrder/index.less +17 -0
  14. package/dist/esm/WorkOrder/components/Widget/basic/Rate/index.d.ts +13 -0
  15. package/dist/esm/WorkOrder/components/Widget/basic/Rate/index.js +144 -0
  16. package/dist/esm/WorkOrder/components/Widget/index.d.ts +2 -1
  17. package/dist/esm/WorkOrder/components/Widget/index.js +4 -0
  18. package/dist/esm/common/utils/tools.js +14 -6
  19. package/dist/esm/index.d.ts +1 -0
  20. package/dist/esm/index.js +1 -0
  21. package/dist/esm/model/servers/api.d.ts +10 -0
  22. package/dist/esm/model/servers/api.js +44 -0
  23. package/dist/esm/model/servers/request.d.ts +2 -2
  24. package/dist/esm/model/servers/request.js +1 -0
  25. package/dist/esm/model/singleShopWorkOrder/index.d.ts +12 -0
  26. package/dist/esm/model/singleShopWorkOrder/index.js +139 -0
  27. package/dist/esm/model/singleShopWorkOrder/selector.d.ts +58 -0
  28. package/dist/esm/model/singleShopWorkOrder/selector.js +22 -0
  29. package/dist/esm/model/singleShopWorkOrder/types.d.ts +11 -0
  30. package/dist/esm/model/singleShopWorkOrder/types.js +1 -0
  31. package/dist/esm/model/store.d.ts +3 -0
  32. package/dist/esm/model/store.js +3 -1
  33. package/dist/esm/model/types/singleWorkOrder.d.ts +10 -0
  34. package/dist/esm/model/types/singleWorkOrder.js +1 -0
  35. package/dist/esm/model/workOrder.js +1 -1
  36. package/package.json +3 -2
@@ -0,0 +1,676 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+
5
+ 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."); }
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 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; }
12
+
13
+ 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; }
14
+
15
+ 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; }
16
+
17
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
18
+
19
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
20
+
21
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
22
+
23
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
+
25
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
+
27
+ 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); }
28
+
29
+ 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; }
30
+
31
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
32
+
33
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
+
35
+ import React, { useState, useMemo, useCallback, useEffect, useRef } from 'react';
36
+ import { useSelector, useDispatch } from 'react-redux';
37
+ import { Drawer, Form, Spin, ConfigProvider, Button, message, Space } from 'antd';
38
+ import { LeftOutlined } from '@ant-design/icons';
39
+ import { get, find, some, set, debounce } from 'lodash';
40
+ import zhCN from 'antd/es/locale/zh_CN';
41
+ import moment from 'moment';
42
+ import 'moment/locale/zh-cn';
43
+ import { calcWorkOrderList, submitDataTransOldFormat, orderBack, getReplaceWarnValues, COMPONENT_MAP_NAME } from "../../../common/utils/tools";
44
+ import { factory } from "../../../WorkOrder/components/Widget";
45
+ import { querySingleShopTemplateDetail, addWorkOrder, querySingleShopWorkOrderDetail, updateSingleShopWorkOrder, replaceCheck } from "../../../model/servers/api";
46
+ import { selectorFormModalVisible, selectorCurrentCustomizeRecord } from "../../../model/singleShopWorkOrder/selector";
47
+ import { setFormModalVisible } from "../../../model/singleShopWorkOrder";
48
+ import "./index.less";
49
+ import { jsx as _jsx } from "react/jsx-runtime";
50
+ import { jsxs as _jsxs } from "react/jsx-runtime";
51
+ moment.locale('zh-cn');
52
+
53
+ var CustomizeFormModal = function CustomizeFormModal(props) {
54
+ var shopList = props.shopList,
55
+ templateId = props.templateId,
56
+ onSuccess = props.onSuccess,
57
+ look = props.look,
58
+ width = props.width,
59
+ currentShopId = props.shopId,
60
+ orderNo = props.orderNo,
61
+ buyerId = props.buyerId,
62
+ buyerNick = props.buyerNick,
63
+ platform = props.platform;
64
+
65
+ var _useState = useState(false),
66
+ _useState2 = _slicedToArray(_useState, 2),
67
+ loading = _useState2[0],
68
+ setLoading = _useState2[1];
69
+
70
+ var record = useSelector(selectorCurrentCustomizeRecord);
71
+ var workOrderId = record === null || record === void 0 ? void 0 : record.id;
72
+
73
+ var _useState3 = useState({}),
74
+ _useState4 = _slicedToArray(_useState3, 2),
75
+ templateDetail = _useState4[0],
76
+ setTemplateDetail = _useState4[1];
77
+
78
+ var _useState5 = useState({}),
79
+ _useState6 = _slicedToArray(_useState5, 2),
80
+ workOrderDetail = _useState6[0],
81
+ setWorkOrderDetail = _useState6[1];
82
+
83
+ var _useState7 = useState({}),
84
+ _useState8 = _slicedToArray(_useState7, 2),
85
+ replaceValue = _useState8[0],
86
+ setReplaceValue = _useState8[1]; //字段重复校验
87
+
88
+
89
+ var visible = useSelector(selectorFormModalVisible);
90
+
91
+ var _Form$useForm = Form.useForm(),
92
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
93
+ form = _Form$useForm2[0];
94
+
95
+ var dispatch = useDispatch();
96
+ var time = useRef();
97
+ useEffect(function () {
98
+ if (visible) {
99
+ queryDetail({
100
+ templateId: templateId,
101
+ workOrderId: workOrderId,
102
+ shopId: currentShopId,
103
+ shopList: shopList,
104
+ record: record,
105
+ orderNo: orderNo,
106
+ buyerId: buyerId,
107
+ buyerNick: buyerNick
108
+ });
109
+ setReplaceValue({});
110
+ }
111
+ }, [visible, templateId, workOrderId, currentShopId]);
112
+
113
+ var asyncDoSave = /*#__PURE__*/function () {
114
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(workOrderDetail, templateDetail) {
115
+ var data, res, params, submitData, _yield$updateSingleSh, success, result, platformMap, _params, hasEnterPrisePayment, getEnterPrisePaymentData, uniqueKey, componentConfig, _yield$addWorkOrder, _success, _result;
116
+
117
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
118
+ while (1) {
119
+ switch (_context.prev = _context.next) {
120
+ case 0:
121
+ _context.prev = 0;
122
+ _context.next = 3;
123
+ return form.validateFields();
124
+
125
+ case 3:
126
+ data = _context.sent;
127
+ console.debug('表单内容', data);
128
+ console.debug('templateDetail内容', templateDetail);
129
+ res = verifyHandle(data, templateDetail);
130
+
131
+ if (res.success) {
132
+ _context.next = 10;
133
+ break;
134
+ }
135
+
136
+ message.error(res.message);
137
+ return _context.abrupt("return");
138
+
139
+ case 10:
140
+ if (!workOrderId) {
141
+ _context.next = 22;
142
+ break;
143
+ }
144
+
145
+ params = {
146
+ apiName: 'updateWorkOrder',
147
+ uniqueKey: templateId,
148
+ workOrderUpdateKeyVos: {
149
+ workOrderId: workOrderId,
150
+ workOrderUpdateKeySupVos: []
151
+ }
152
+ };
153
+ submitData = submitDataTransOldFormat(data, templateDetail, !!workOrderId, workOrderDetail, params);
154
+ params.workOrderUpdateKeyVos.workOrderUpdateKeySupVos = submitData.reduce(function (nex, cur) {
155
+ return nex.concat(cur === null || cur === void 0 ? void 0 : cur.contentVoList);
156
+ }, []);
157
+ _context.next = 16;
158
+ return updateSingleShopWorkOrder(params);
159
+
160
+ case 16:
161
+ _yield$updateSingleSh = _context.sent;
162
+ success = _yield$updateSingleSh.success;
163
+ result = _yield$updateSingleSh.data;
164
+
165
+ if (success && typeof onSuccess === 'function') {
166
+ closeModal();
167
+ form.resetFields();
168
+ message.success('编辑成功');
169
+ onSuccess({
170
+ type: 'EDIT',
171
+ result: result,
172
+ id: workOrderId
173
+ });
174
+ }
175
+
176
+ _context.next = 35;
177
+ break;
178
+
179
+ case 22:
180
+ platformMap = {
181
+ tb: '淘宝',
182
+ fxg: '抖音',
183
+ ks: '快手',
184
+ pdd: '拼多多',
185
+ jd: '京东',
186
+ xiaozhi: '小智'
187
+ };
188
+ _params = {
189
+ apiName: 'addWorkOrder',
190
+ shopId: currentShopId,
191
+ uniqueKey: templateId,
192
+ workOrderComponentVos: [],
193
+ accessToken: get(find(shopList, function (s) {
194
+ return s.shopId === currentShopId;
195
+ }), 'accessToken', ''),
196
+ source: platformMap[platform] || '工单通'
197
+ };
198
+ _params.workOrderComponentVos = submitDataTransOldFormat(data, templateDetail, !!workOrderId, workOrderDetail, _params);
199
+ hasEnterPrisePayment = some(templateDetail === null || templateDetail === void 0 ? void 0 : templateDetail.componentDtoList, function (item) {
200
+ return item.workOrderComponentType === 'ENTERPRISE_PAYMENT';
201
+ });
202
+ console.debug('是否有打款组件', hasEnterPrisePayment);
203
+
204
+ if (hasEnterPrisePayment) {
205
+ getEnterPrisePaymentData = find(templateDetail === null || templateDetail === void 0 ? void 0 : templateDetail.componentDtoList, function (item) {
206
+ return item.workOrderComponentType === 'ENTERPRISE_PAYMENT';
207
+ }) || {};
208
+ uniqueKey = getEnterPrisePaymentData.uniqueKey, componentConfig = getEnterPrisePaymentData.componentConfig;
209
+ _params.paymentOrderAddVo = {
210
+ buyerNick: get(data, "".concat(uniqueKey, ".enterprisePaymentBuyerNick"), ''),
211
+ buyerOpenUid: get(data, "".concat(uniqueKey, ".enterprisePaymentBuyerOpenUid"), ''),
212
+ paymentFee: get(data, "".concat(uniqueKey, ".enterprisePaymentRefundFee"), ''),
213
+ tid: get(data, "".concat(uniqueKey, ".enterprisePaymentTid"), ''),
214
+ alipayNick: get(data, "".concat(uniqueKey, ".enterprisePaymentAlipayNick"), ''),
215
+ alipayNo: get(data, "".concat(uniqueKey, ".enterprisePaymentAlipayNo"), ''),
216
+ templateId: templateId,
217
+ templateName: templateDetail.name,
218
+ required: get(componentConfig, 'required')
219
+ };
220
+ }
221
+
222
+ console.debug('增加数据参数', _params);
223
+ _context.next = 31;
224
+ return addWorkOrder(_params);
225
+
226
+ case 31:
227
+ _yield$addWorkOrder = _context.sent;
228
+ _success = _yield$addWorkOrder.success;
229
+ _result = _yield$addWorkOrder.data;
230
+
231
+ if (_success && typeof onSuccess === 'function') {
232
+ closeModal();
233
+ form.resetFields();
234
+ message.success('添加成功');
235
+ onSuccess({
236
+ type: 'ADD',
237
+ result: _result === null || _result === void 0 ? void 0 : _result.data
238
+ });
239
+ }
240
+
241
+ case 35:
242
+ console.groupEnd();
243
+ _context.next = 41;
244
+ break;
245
+
246
+ case 38:
247
+ _context.prev = 38;
248
+ _context.t0 = _context["catch"](0);
249
+
250
+ // 表单校验失败错误时,将错误第一项滚动到可视区域
251
+ if (get(_context.t0, 'errorFields.length') > 0) {
252
+ setTimeout(function () {
253
+ var _get;
254
+
255
+ var errorList = document.querySelectorAll('.ant-form-item-has-error');
256
+ (_get = get(errorList, '0')) === null || _get === void 0 ? void 0 : _get.scrollIntoView({
257
+ block: 'center',
258
+ behavior: 'smooth'
259
+ });
260
+ }, 0);
261
+ }
262
+
263
+ case 41:
264
+ case "end":
265
+ return _context.stop();
266
+ }
267
+ }
268
+ }, _callee, null, [[0, 38]]);
269
+ }));
270
+
271
+ return function asyncDoSave(_x, _x2) {
272
+ return _ref.apply(this, arguments);
273
+ };
274
+ }(); //表单额外校验
275
+
276
+
277
+ var verifyHandle = function verifyHandle(data, templateDetail) {
278
+ var _templateDetail$compo, _templateDetail$compo2, _data$paymentUniqueKe, _data$paymentUniqueKe2;
279
+
280
+ var res = {
281
+ success: true,
282
+ message: ''
283
+ };
284
+ var tradeIdUniqueKey = (_templateDetail$compo = templateDetail.componentDtoList.find(function (item) {
285
+ return item.workOrderComponentType === 'TRADE_ID_INPUT';
286
+ })) === null || _templateDetail$compo === void 0 ? void 0 : _templateDetail$compo.uniqueKey;
287
+ var paymentUniqueKey = (_templateDetail$compo2 = templateDetail.componentDtoList.find(function (item) {
288
+ return item.workOrderComponentType === 'ENTERPRISE_PAYMENT';
289
+ })) === null || _templateDetail$compo2 === void 0 ? void 0 : _templateDetail$compo2.uniqueKey;
290
+
291
+ if (tradeIdUniqueKey && paymentUniqueKey && data[tradeIdUniqueKey] && (_data$paymentUniqueKe = data[paymentUniqueKey]) !== null && _data$paymentUniqueKe !== void 0 && _data$paymentUniqueKe.enterprisePaymentTid && data[tradeIdUniqueKey] != ((_data$paymentUniqueKe2 = data[paymentUniqueKey]) === null || _data$paymentUniqueKe2 === void 0 ? void 0 : _data$paymentUniqueKe2.enterprisePaymentTid)) {
292
+ res.success = false;
293
+ res.message = '订单组件和打款组件的订单号必须一致';
294
+ }
295
+
296
+ return res;
297
+ };
298
+
299
+ var handleSubmit = useCallback(function () {
300
+ return asyncDoSave(workOrderDetail, templateDetail);
301
+ }, [workOrderDetail, templateDetail]); // 切换店铺
302
+
303
+ var newRenderColumnItem = function newRenderColumnItem(effects) {
304
+ return function (item, formItemIndex) {
305
+ // 录入工单表头的序号,默认算入了店铺名称的行,所以之后的序列+2
306
+ formItemIndex += 2;
307
+
308
+ if (look) {
309
+ item.componentConfig = _objectSpread(_objectSpread({}, item.componentConfig), {}, {
310
+ disabled: true
311
+ });
312
+ }
313
+
314
+ var instance = factory(item.workOrderComponentType, {
315
+ id: item.uniqueKey,
316
+ name: item.name,
317
+ componentConfig: item.componentConfig,
318
+ effects: effects,
319
+ formItemIndex: formItemIndex
320
+ });
321
+ return instance.editRender({
322
+ formItemIndex: formItemIndex,
323
+ onBlur: componentOnBlur
324
+ });
325
+ };
326
+ }; //组件失焦事件
327
+
328
+
329
+ var componentOnBlur = /*#__PURE__*/function () {
330
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value, type) {
331
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
332
+ while (1) {
333
+ switch (_context2.prev = _context2.next) {
334
+ case 0:
335
+ if (value) {
336
+ _context2.next = 3;
337
+ break;
338
+ }
339
+
340
+ setReplaceValue(function (prev) {
341
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, type, 0));
342
+ });
343
+ return _context2.abrupt("return");
344
+
345
+ case 3:
346
+ queryReplaceCount(_defineProperty({}, type, value));
347
+
348
+ if (type === 'tradeId' || type === 'enterprisePaymentTid') {
349
+ changeHandle(value);
350
+ }
351
+
352
+ case 5:
353
+ case "end":
354
+ return _context2.stop();
355
+ }
356
+ }
357
+ }, _callee2);
358
+ }));
359
+
360
+ return function componentOnBlur(_x3, _x4) {
361
+ return _ref2.apply(this, arguments);
362
+ };
363
+ }(); //查询重复数量
364
+
365
+
366
+ var queryReplaceCount = /*#__PURE__*/function () {
367
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(componentValue) {
368
+ var needCheckComponentList, params, _yield$replaceCheck, resultList, resultParams;
369
+
370
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
371
+ while (1) {
372
+ switch (_context3.prev = _context3.next) {
373
+ case 0:
374
+ _context3.next = 2;
375
+ return filterStarValues(componentValue);
376
+
377
+ case 2:
378
+ needCheckComponentList = getReplaceWarnValues(templateDetail, componentValue);
379
+
380
+ if (!needCheckComponentList.length) {
381
+ _context3.next = 11;
382
+ break;
383
+ }
384
+
385
+ params = {
386
+ templateId: templateDetail.uniqueKey,
387
+ workOrderUniqueKey: workOrderDetail === null || workOrderDetail === void 0 ? void 0 : workOrderDetail.uniqueKey,
388
+ needCheckComponentList: needCheckComponentList
389
+ };
390
+ _context3.next = 7;
391
+ return replaceCheck(params);
392
+
393
+ case 7:
394
+ _yield$replaceCheck = _context3.sent;
395
+ resultList = _yield$replaceCheck.data.resultList;
396
+ resultParams = (resultList || []).reduce(function (prv, next) {
397
+ var _next$componentKey$sp = next.componentKey.split('_'),
398
+ _next$componentKey$sp2 = _slicedToArray(_next$componentKey$sp, 2),
399
+ _ = _next$componentKey$sp2[0],
400
+ name = _next$componentKey$sp2[1];
401
+
402
+ prv[name] = next.repeatCount;
403
+ return prv;
404
+ }, {});
405
+ setReplaceValue(function (prev) {
406
+ return _objectSpread(_objectSpread({}, prev), resultParams);
407
+ });
408
+
409
+ case 11:
410
+ case "end":
411
+ return _context3.stop();
412
+ }
413
+ }
414
+ }, _callee3);
415
+ }));
416
+
417
+ return function queryReplaceCount(_x5) {
418
+ return _ref3.apply(this, arguments);
419
+ };
420
+ }(); //带*参数提示清空
421
+
422
+
423
+ var filterStarValues = function filterStarValues() {
424
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
425
+ var obj = {};
426
+ Object.keys(params).forEach(function (key) {
427
+ var _params$key;
428
+
429
+ if (params[key] && ((_params$key = params[key]) === null || _params$key === void 0 ? void 0 : _params$key.indexOf('*')) > -1) {
430
+ obj[key] = 0;
431
+ }
432
+ });
433
+ setReplaceValue(function (value) {
434
+ return _objectSpread(_objectSpread({}, value), obj);
435
+ });
436
+ }; //订单返填
437
+
438
+
439
+ var changeHandle = function changeHandle(order_no) {
440
+ if (!order_no) return;
441
+
442
+ if (time.current) {
443
+ clearTimeout(time.current);
444
+ }
445
+
446
+ time.current = setTimeout(function () {
447
+ orderBack({
448
+ order_no: order_no,
449
+ form: form,
450
+ shopId: currentShopId,
451
+ shopList: shopList,
452
+ templateDetail: templateDetail,
453
+ type: !!workOrderId ? 'edit' : 'add',
454
+ callback: orderBackReplace
455
+ });
456
+ }, 1000);
457
+ }; //自动返填重复校验
458
+
459
+
460
+ var orderBackReplace = function orderBackReplace(value) {
461
+ var tradeId = value.tradeId,
462
+ buyer = value.buyer,
463
+ receiveMobile = value.receiveMobile,
464
+ alipayAccount = value.alipayAccount,
465
+ expressLogisticsCode = value.expressLogisticsCode;
466
+ queryReplaceCount({
467
+ tradeId: tradeId,
468
+ buyerNick: buyer === null || buyer === void 0 ? void 0 : buyer.buyerNick,
469
+ receiveMobile: receiveMobile,
470
+ alipayAccount: alipayAccount,
471
+ expressLogisticsCode: expressLogisticsCode
472
+ });
473
+ };
474
+
475
+ var finalFormItems = useMemo(function () {
476
+ var otherItems = get(templateDetail, 'componentDtoList', []).map(newRenderColumnItem({
477
+ form: form,
478
+ shopList: shopList,
479
+ shopId: currentShopId,
480
+ isEditing: !!workOrderId,
481
+ workOrderDetail: workOrderDetail,
482
+ templateDetail: templateDetail
483
+ }));
484
+ return _toConsumableArray(otherItems);
485
+ }, [templateDetail, shopList, currentShopId, workOrderDetail]);
486
+
487
+ var queryDetail = /*#__PURE__*/function () {
488
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref4) {
489
+ 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;
490
+
491
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
492
+ while (1) {
493
+ switch (_context4.prev = _context4.next) {
494
+ case 0:
495
+ templateId = _ref4.templateId, workOrderId = _ref4.workOrderId, shopId = _ref4.shopId, shopList = _ref4.shopList, record = _ref4.record, orderNo = _ref4.orderNo, buyerId = _ref4.buyerId, buyerNick = _ref4.buyerNick;
496
+ form.resetFields();
497
+ _context4.prev = 2;
498
+ setLoading(true);
499
+ _workOrderDetail = {};
500
+
501
+ if (!workOrderId) {
502
+ _context4.next = 9;
503
+ break;
504
+ }
505
+
506
+ _context4.next = 8;
507
+ return querySingleShopWorkOrderDetail({
508
+ workOrderId: workOrderId
509
+ });
510
+
511
+ case 8:
512
+ _workOrderDetail = _context4.sent;
513
+
514
+ case 9:
515
+ _context4.next = 11;
516
+ return querySingleShopTemplateDetail({
517
+ uniqueKey: templateId || ((_workOrderDetail2 = _workOrderDetail) === null || _workOrderDetail2 === void 0 ? void 0 : (_workOrderDetail2$dat = _workOrderDetail2.data) === null || _workOrderDetail2$dat === void 0 ? void 0 : (_workOrderDetail2$dat2 = _workOrderDetail2$dat.jsonMap) === null || _workOrderDetail2$dat2 === void 0 ? void 0 : _workOrderDetail2$dat2.templateId)
518
+ });
519
+
520
+ case 11:
521
+ _templateDetail = _context4.sent;
522
+ setTemplateDetail(_templateDetail.data);
523
+ setWorkOrderDetail(_workOrderDetail.data);
524
+
525
+ if (workOrderId) {
526
+ transData = calcWorkOrderList([(_workOrderDetail3 = _workOrderDetail) === null || _workOrderDetail3 === void 0 ? void 0 : _workOrderDetail3.data], _templateDetail === null || _templateDetail === void 0 ? void 0 : (_templateDetail$data = _templateDetail.data) === null || _templateDetail$data === void 0 ? void 0 : _templateDetail$data.componentDtoList);
527
+ console.log(transData);
528
+ form.setFieldsValue(_objectSpread(_objectSpread({}, get(transData, '0', {})), {}, {
529
+ shopId: shopId,
530
+ shopName: record.shopName,
531
+ submitter: record.submitter,
532
+ created: record.created,
533
+ processTime: record.processTime
534
+ }));
535
+ } else {
536
+ //获取一些默认数据
537
+ jsonMap = _templateDetail === null || _templateDetail === void 0 ? void 0 : (_templateDetail$data2 = _templateDetail.data) === null || _templateDetail$data2 === void 0 ? void 0 : _templateDetail$data2.componentDtoList.reduce(function (prv, next) {
538
+ if (next.workOrderComponentType === 'BUYER_NICK_INPUT') {
539
+ prv["".concat(next.uniqueKey, "_buyerOpenUid")] = buyerId;
540
+ prv["".concat(next.uniqueKey, "_buyerNick")] = buyerNick;
541
+ }
542
+
543
+ if (next.workOrderComponentType === 'ENTERPRISE_PAYMENT') {
544
+ prv["".concat(next.uniqueKey, "_enterprisePaymentTid")] = orderNo || '';
545
+ prv["".concat(next.uniqueKey, "_enterprisePaymentBuyerOpenUid")] = buyerId;
546
+ prv["".concat(next.uniqueKey, "_enterprisePaymentBuyerNick")] = buyerNick;
547
+ }
548
+
549
+ return prv;
550
+ }, {});
551
+ _transData = calcWorkOrderList([{
552
+ jsonMap: jsonMap
553
+ }], _templateDetail === null || _templateDetail === void 0 ? void 0 : (_templateDetail$data3 = _templateDetail.data) === null || _templateDetail$data3 === void 0 ? void 0 : _templateDetail$data3.componentDtoList, 'init');
554
+ form.setFieldsValue(_objectSpread({}, get(_transData, '0', {})));
555
+ } //如果有订单号 订单返填
556
+
557
+
558
+ if (orderNo) {
559
+ orderBack({
560
+ order_no: orderNo,
561
+ form: form,
562
+ shopId: shopId,
563
+ shopList: shopList,
564
+ templateDetail: _templateDetail === null || _templateDetail === void 0 ? void 0 : _templateDetail.data,
565
+ callback: orderBackReplace
566
+ });
567
+ }
568
+
569
+ antFormEl = document.getElementsByClassName('ant-form');
570
+ (antFormEl === null || antFormEl === void 0 ? void 0 : antFormEl.length) > 0 && set(antFormEl, '0.scrollTop', 0);
571
+ _context4.next = 23;
572
+ break;
573
+
574
+ case 20:
575
+ _context4.prev = 20;
576
+ _context4.t0 = _context4["catch"](2);
577
+ console.error('获取模板信息错误', _context4.t0);
578
+
579
+ case 23:
580
+ _context4.prev = 23;
581
+ setLoading(false);
582
+ return _context4.finish(23);
583
+
584
+ case 26:
585
+ case "end":
586
+ return _context4.stop();
587
+ }
588
+ }
589
+ }, _callee4, null, [[2, 20, 23, 26]]);
590
+ }));
591
+
592
+ return function queryDetail(_x6) {
593
+ return _ref5.apply(this, arguments);
594
+ };
595
+ }();
596
+
597
+ var closeModal = function closeModal() {
598
+ dispatch(setFormModalVisible(false));
599
+ form.resetFields();
600
+ };
601
+
602
+ var renderFooter = function renderFooter() {
603
+ var btnGroup = [];
604
+
605
+ if (look) {
606
+ btnGroup = /*#__PURE__*/_jsx(Space, {
607
+ style: {
608
+ float: 'right'
609
+ },
610
+ children: /*#__PURE__*/_jsx(Button, {
611
+ type: "primary",
612
+ onClick: function onClick() {
613
+ closeModal();
614
+ },
615
+ children: "\u5173\u95ED"
616
+ })
617
+ });
618
+ } else {
619
+ btnGroup = /*#__PURE__*/_jsxs(Space, {
620
+ style: {
621
+ float: 'right'
622
+ },
623
+ children: [/*#__PURE__*/_jsx(Button, {
624
+ onClick: function onClick() {
625
+ return closeModal();
626
+ },
627
+ children: "\u53D6\u6D88"
628
+ }), /*#__PURE__*/_jsx(Button, {
629
+ type: "primary",
630
+ onClick: debounce(handleSubmit, 300),
631
+ children: "\u786E\u5B9A"
632
+ })]
633
+ });
634
+ }
635
+
636
+ return btnGroup;
637
+ };
638
+
639
+ return /*#__PURE__*/_jsx(Drawer, {
640
+ closeIcon: /*#__PURE__*/_jsx(LeftOutlined, {}),
641
+ title: (templateDetail === null || templateDetail === void 0 ? void 0 : templateDetail.name) || '工单录入',
642
+ width: width,
643
+ open: visible,
644
+ onClose: closeModal,
645
+ footer: renderFooter(),
646
+ destroyOnClose: true,
647
+ children: /*#__PURE__*/_jsx(Spin, {
648
+ spinning: loading,
649
+ children: /*#__PURE__*/_jsxs(ConfigProvider, {
650
+ locale: zhCN,
651
+ children: [/*#__PURE__*/_jsx("div", {
652
+ className: "tipBox",
653
+ children: Object.keys(replaceValue).map(function (key) {
654
+ return replaceValue[key] > 0 && /*#__PURE__*/_jsxs("div", {
655
+ children: ["\u63D0\u793A\uFF1A\u8BE5", COMPONENT_MAP_NAME[key], "\u9488\u5BF9\u6B64\u6A21\u677F\u5DF2\u521B\u5EFA\u8FC7", replaceValue[key], "\u6761\u5DE5\u5355\uFF01"]
656
+ });
657
+ })
658
+ }), /*#__PURE__*/_jsx(Form, {
659
+ form: form,
660
+ labelCol: {
661
+ span: 6
662
+ },
663
+ wrapperCol: {
664
+ span: 18
665
+ },
666
+ className: "customizeFormModalClassName",
667
+ style: {// maxHeight: '500px',
668
+ },
669
+ children: finalFormItems
670
+ })]
671
+ })
672
+ })
673
+ });
674
+ };
675
+
676
+ export default CustomizeFormModal;