kts-component-invoice-operate 3.2.7 → 3.2.8
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.
- package/dist/Invoice/Invoice-digtal/_test/lineCredit/index.d.ts +4 -0
- package/dist/Invoice/ui/digtal/Stakeholder/index.d.ts +2 -0
- package/dist/index.esm.js +6 -3
- package/dist/index.js +5 -2
- package/package.json +1 -1
- package/src/Invoice/Invoice-digtal/_test/lineCredit/index.tsx +21 -0
- package/src/Invoice/Invoice-digtal/index.md +4 -1
- package/src/Invoice/ui/digtal/Stakeholder/index.tsx +12 -7
- package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/dist/index.js +0 -315
- package/src/Invoice/ui/digtal/Sign/dist/index.js +0 -68
|
@@ -6,6 +6,8 @@ export interface IStakeholder {
|
|
|
6
6
|
isShowImportButton?: boolean;
|
|
7
7
|
/** 点击了 */
|
|
8
8
|
onClickImportButton?: (e: InvoiceController) => void;
|
|
9
|
+
/** 查看当前可用授信额度 */
|
|
10
|
+
lineCredit?: React.ReactNode;
|
|
9
11
|
}
|
|
10
12
|
/** 干系人 */
|
|
11
13
|
declare const _default: React.FunctionComponent<IStakeholder>;
|
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { chain as chain$1, bignumber, create, all } from 'mathjs';
|
|
|
5
5
|
import { message, Form, Input, Icon as Icon$1, Tag as Tag$1, Select, Button, Tooltip, Switch as Switch$1, Typography, Menu, Dropdown, AutoComplete, Spin, Checkbox, Drawer, Descriptions, Empty, Divider, Popover, Table as Table$1, Tree, Modal as Modal$1, Row as Row$1, Col as Col$1 } from 'kts-components-antd-x3';
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import { TableManual, Switch, Row, Col, Button as Button$1,
|
|
8
|
+
import { TableManual, Switch, Row, Col, Button as Button$1, Tooltip as Tooltip$1, Input as Input$1, message as message$1, AutoComplete as AutoComplete$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Form as Form$1, Drawer as Drawer$1, Space, Radio, InputNumber, Popconfirm, Modal } from 'kts-xui';
|
|
9
9
|
import { Table } from 'kts-components-antd-x4-v4';
|
|
10
10
|
import { Input as Input$2, NumberPicker } from '@formily/antd-components';
|
|
11
11
|
import { createAsyncFormActions, FormEffectHooks, SchemaForm, FormButtonGroup, SchemaMarkupField } from '@formily/antd';
|
|
@@ -14237,13 +14237,16 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
14237
14237
|
className: "digtal-stakeholder-expand-button",
|
|
14238
14238
|
component: isExpand ? SvgArrowUp : SvgArrowDown,
|
|
14239
14239
|
onClick: onExpand
|
|
14240
|
-
})), React.createElement("div", null, !readOnly && React.createElement("div", {
|
|
14240
|
+
})), React.createElement("div", null, !readOnly && props.lineCredit && React.createElement("div", {
|
|
14241
14241
|
style: {
|
|
14242
14242
|
marginTop: 20
|
|
14243
14243
|
}
|
|
14244
|
+
}, React.createElement(Tooltip$1, {
|
|
14245
|
+
trigger: "click",
|
|
14246
|
+
title: props.lineCredit
|
|
14244
14247
|
}, React.createElement(Button$1, {
|
|
14245
14248
|
type: "link"
|
|
14246
|
-
}, "\u67E5\u770B\u5F53\u524D\u53EF\u7528\u6388\u4FE1\u989D\u5EA6")), React.createElement(Form, {
|
|
14249
|
+
}, "\u67E5\u770B\u5F53\u524D\u53EF\u7528\u6388\u4FE1\u989D\u5EA6"))), React.createElement(Form, {
|
|
14247
14250
|
className: "digtal-stakeholder-form"
|
|
14248
14251
|
}, React.createElement(Row, {
|
|
14249
14252
|
gutter: [16, 0]
|
package/dist/index.js
CHANGED
|
@@ -14247,13 +14247,16 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
14247
14247
|
className: "digtal-stakeholder-expand-button",
|
|
14248
14248
|
component: isExpand ? SvgArrowUp : SvgArrowDown,
|
|
14249
14249
|
onClick: onExpand
|
|
14250
|
-
})), React__default['default'].createElement("div", null, !readOnly && React__default['default'].createElement("div", {
|
|
14250
|
+
})), React__default['default'].createElement("div", null, !readOnly && props.lineCredit && React__default['default'].createElement("div", {
|
|
14251
14251
|
style: {
|
|
14252
14252
|
marginTop: 20
|
|
14253
14253
|
}
|
|
14254
|
+
}, React__default['default'].createElement(ktsXui.Tooltip, {
|
|
14255
|
+
trigger: "click",
|
|
14256
|
+
title: props.lineCredit
|
|
14254
14257
|
}, React__default['default'].createElement(ktsXui.Button, {
|
|
14255
14258
|
type: "link"
|
|
14256
|
-
}, "\u67E5\u770B\u5F53\u524D\u53EF\u7528\u6388\u4FE1\u989D\u5EA6")), React__default['default'].createElement(ktsComponentsAntdX3.Form, {
|
|
14259
|
+
}, "\u67E5\u770B\u5F53\u524D\u53EF\u7528\u6388\u4FE1\u989D\u5EA6"))), React__default['default'].createElement(ktsComponentsAntdX3.Form, {
|
|
14257
14260
|
className: "digtal-stakeholder-form"
|
|
14258
14261
|
}, React__default['default'].createElement(ktsXui.Row, {
|
|
14259
14262
|
gutter: [16, 0]
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Invoice from '../../..';
|
|
3
|
+
import 'antd/dist/antd.css';
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
return (
|
|
7
|
+
<Invoice
|
|
8
|
+
invoiceType='digtal'
|
|
9
|
+
stakeholder={
|
|
10
|
+
<Invoice.Stakeholder lineCredit={<LineCredit />} />
|
|
11
|
+
}
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function LineCredit() {
|
|
18
|
+
return (
|
|
19
|
+
<div>可用授信额度100</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import Icon from '@ant-design/icons';
|
|
4
4
|
import { decorator } from "grey-react-box";
|
|
5
5
|
import { Form } from "kts-components-antd-x3";
|
|
6
|
-
import { Button, Col, Input, InputProps, Row } from 'kts-xui'
|
|
6
|
+
import { Button, Col, Input, InputProps, Row, Tooltip } from 'kts-xui'
|
|
7
7
|
import { FormComponentProps } from "kts-components-antd-x3/lib/form";
|
|
8
8
|
import { ReactComponent as ArrowUpSvg } from './svg/arrowUp.svg';
|
|
9
9
|
import { ReactComponent as ArrowDownSvg } from './svg/arrowDown.svg';
|
|
@@ -46,9 +46,12 @@ export interface IStakeholder {
|
|
|
46
46
|
|
|
47
47
|
/** 点击了 */
|
|
48
48
|
onClickImportButton?: (e: InvoiceController) => void
|
|
49
|
+
|
|
50
|
+
/** 查看当前可用授信额度 */
|
|
51
|
+
lineCredit?: React.ReactNode;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
/** 干系人 */
|
|
54
|
+
/** 干系人 */
|
|
52
55
|
export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.create())(props => {
|
|
53
56
|
|
|
54
57
|
const { form, isShowImportButton, onClickImportButton } = props;
|
|
@@ -66,8 +69,8 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
66
69
|
const rulesMap = controller.useMemo(s => s.stakeholder.rulesMap || {}, []);
|
|
67
70
|
|
|
68
71
|
const readOnly = React.useMemo(() => {
|
|
69
|
-
if(model === 'readOnly') return true;
|
|
70
|
-
if(model === 'prefab') return true;
|
|
72
|
+
if (model === 'readOnly') return true;
|
|
73
|
+
if (model === 'prefab') return true;
|
|
71
74
|
return false;
|
|
72
75
|
}, [model]);
|
|
73
76
|
|
|
@@ -182,9 +185,11 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
182
185
|
</div>
|
|
183
186
|
<div>
|
|
184
187
|
{
|
|
185
|
-
!readOnly &&
|
|
188
|
+
!readOnly && props.lineCredit &&
|
|
186
189
|
<div style={{ marginTop: 20 }} >
|
|
187
|
-
<
|
|
190
|
+
<Tooltip trigger="click" title={props.lineCredit} >
|
|
191
|
+
<Button type="link" >查看当前可用授信额度</Button>
|
|
192
|
+
</Tooltip>
|
|
188
193
|
</div>
|
|
189
194
|
}
|
|
190
195
|
<Form className="digtal-stakeholder-form" >
|
|
@@ -215,7 +220,7 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
215
220
|
})(<MyInput readOnly={isReadOnly('sellerAddress')} placeholder="请输入" autoComplete="off" />)}
|
|
216
221
|
</Form.Item>
|
|
217
222
|
</Col>
|
|
218
|
-
|
|
223
|
+
|
|
219
224
|
<Col span={9} >
|
|
220
225
|
<Form.Item label='电话' colon={false}>
|
|
221
226
|
{getFieldDecorator('sellerPhone', {
|
package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/dist/index.js
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.__esModule = true;
|
|
50
|
-
var react_1 = require("react");
|
|
51
|
-
var mathjs_1 = require("mathjs");
|
|
52
|
-
var kts_xui_1 = require("kts-xui");
|
|
53
|
-
var __1 = require("../../../../../../..");
|
|
54
|
-
var InvoiceController_1 = require("../../../../../../../InvoiceController");
|
|
55
|
-
exports["default"] = (function () {
|
|
56
|
-
/** 控制器 */
|
|
57
|
-
var controller = __1["default"].useInvoiceController();
|
|
58
|
-
/** 组件模式 prefab 预制 readOnly 只读 */
|
|
59
|
-
var model = controller.useMemo(function (s) { return s.model; }, []);
|
|
60
|
-
/** 准备添加折扣的货物索引列表 */
|
|
61
|
-
var discountGoodIndex = controller.useMemo(function (s) { return s.goodsListState.discountGoodIndex || []; }, []);
|
|
62
|
-
/** 列表选中的货物索引列表 */
|
|
63
|
-
var selectedGoodIndex = controller.useMemo(function (s) { return s.goodsListState.selectedGoodIndex; }, []);
|
|
64
|
-
/** 货物字典 */
|
|
65
|
-
var goodsMap = controller.useMemo(function (s) { return s.goodsListState.goodsMap; }, []);
|
|
66
|
-
/** 是否能添加折扣行 */
|
|
67
|
-
var isAddDiscount = controller.useMemo(function (s) { return s.goodsListState.isAddDiscount; }, []);
|
|
68
|
-
// 抽屉开启状态
|
|
69
|
-
var open = react_1["default"].useMemo(function () { return discountGoodIndex.length > 0; }, [discountGoodIndex]);
|
|
70
|
-
/** 打开抽屉 */
|
|
71
|
-
var onOpen = react_1["default"].useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0: return [4 /*yield*/, controller.saveEditGood()];
|
|
75
|
-
case 1:
|
|
76
|
-
_a.sent();
|
|
77
|
-
return [4 /*yield*/, controller.wait()];
|
|
78
|
-
case 2:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [4 /*yield*/, controller.run(function (s) { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
-
var isOk;
|
|
82
|
-
return __generator(this, function (_a) {
|
|
83
|
-
isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
|
|
84
|
-
if (isOk) {
|
|
85
|
-
kts_xui_1.message.error({ content: '不能给编辑状态的行增加折扣!', key: '不能给编辑状态的行增加折扣!' });
|
|
86
|
-
return [2 /*return*/];
|
|
87
|
-
}
|
|
88
|
-
if (!isContinuityNum(s.goodsListState.selectedGoodIndex.map(function (e) { var _a; return ((_a = s.goodsListState.goodsMap.get(e)) === null || _a === void 0 ? void 0 : _a.serialNo) || -2; }).sort(function (a, b) { return a - b; }))) {
|
|
89
|
-
kts_xui_1.message.error({ content: '项目不连续,不允许添加折扣', key: '项目不连续,不允许添加折扣' });
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
isOk = s.goodsListState.selectedGoodIndex.some(function ($index) { var _a; return ((_a = s.goodsListState.goodsMap.get($index)) === null || _a === void 0 ? void 0 : _a.lineAttribute) !== InvoiceController_1.LineAttributeType.正常; });
|
|
93
|
-
if (isOk) {
|
|
94
|
-
kts_xui_1.message.error({ content: '不允许重复添加折扣', key: '不允许重复添加折扣' });
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
}
|
|
97
|
-
isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
|
|
98
|
-
var good = s.goodsListState.goodsMap.get($index);
|
|
99
|
-
return !good || (good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType);
|
|
100
|
-
});
|
|
101
|
-
if (isOk) {
|
|
102
|
-
kts_xui_1.message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
|
|
103
|
-
return [2 /*return*/];
|
|
104
|
-
}
|
|
105
|
-
isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
|
|
106
|
-
var good = s.goodsListState.goodsMap.get($index);
|
|
107
|
-
return "" + (good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
|
|
108
|
-
});
|
|
109
|
-
if (isOk) {
|
|
110
|
-
kts_xui_1.message.error({ content: '金额为0不能添加折扣行', key: '金额为0不能添加折扣行' });
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
|
|
114
|
-
return [2 /*return*/];
|
|
115
|
-
});
|
|
116
|
-
}); })];
|
|
117
|
-
case 3:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}); }, [controller]);
|
|
123
|
-
/** 关闭抽屉 */
|
|
124
|
-
var onClose = react_1["default"].useCallback(function () {
|
|
125
|
-
controller.run(function (s) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
s.goodsListState.discountGoodIndex = [];
|
|
128
|
-
return [2 /*return*/];
|
|
129
|
-
});
|
|
130
|
-
}); });
|
|
131
|
-
}, [controller]);
|
|
132
|
-
/** 是否禁用 */
|
|
133
|
-
var disabled = react_1["default"].useMemo(function () { return selectedGoodIndex.length === 0; }, [selectedGoodIndex, goodsMap]);
|
|
134
|
-
/** 是否启用 */
|
|
135
|
-
var isEnable = react_1["default"].useMemo(function () {
|
|
136
|
-
if (model === 'readOnly')
|
|
137
|
-
return false;
|
|
138
|
-
if (model === 'prefab')
|
|
139
|
-
return false;
|
|
140
|
-
return !(isAddDiscount === false);
|
|
141
|
-
}, [isAddDiscount, model]);
|
|
142
|
-
var button = react_1["default"].useMemo(function () {
|
|
143
|
-
if (isEnable) {
|
|
144
|
-
return (react_1["default"].createElement(react_1["default"].Fragment, null,
|
|
145
|
-
react_1["default"].createElement(kts_xui_1.Button, { size: 'small', onClick: onOpen, disabled: disabled }, "\u6DFB\u52A0\u6298\u6263"),
|
|
146
|
-
react_1["default"].createElement(AddDiscountRowDrawer, { open: open, onClose: onClose })));
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
return (react_1["default"].createElement(react_1["default"].Fragment, null));
|
|
150
|
-
}
|
|
151
|
-
}, [open, onOpen, onClose, isEnable, disabled]);
|
|
152
|
-
return {
|
|
153
|
-
button: button
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
/** 添加折扣行的抽屉 */
|
|
157
|
-
function AddDiscountRowDrawer(props) {
|
|
158
|
-
var _this = this;
|
|
159
|
-
var open = props.open, onClose = props.onClose;
|
|
160
|
-
var form = kts_xui_1.Form.useForm()[0];
|
|
161
|
-
var _a = react_1["default"].useState(), formValues = _a[0], setFormValues = _a[1];
|
|
162
|
-
/** 控制器 */
|
|
163
|
-
var controller = __1["default"].useInvoiceController();
|
|
164
|
-
/** 货物字典 */
|
|
165
|
-
var goodsMap = controller.useMemo(function (s) { return s.goodsListState.goodsMap; }, []);
|
|
166
|
-
/** 准备添加折扣的货物索引列表 */
|
|
167
|
-
var discountGoodIndex = controller.useMemo(function (s) { return s.goodsListState.discountGoodIndex || []; }, []);
|
|
168
|
-
/** 准备添加折扣的货物列表 */
|
|
169
|
-
var discountGood = react_1["default"].useMemo(function () { return discountGoodIndex.map(function (e) { return goodsMap.get(e); }); }, [discountGoodIndex, goodsMap]);
|
|
170
|
-
/** 总金额 */
|
|
171
|
-
var totalAmount = react_1["default"].useMemo(function () {
|
|
172
|
-
var sum = 0;
|
|
173
|
-
discountGood.forEach(function (e) {
|
|
174
|
-
var _a;
|
|
175
|
-
sum += (_a = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _a !== void 0 ? _a : 0;
|
|
176
|
-
});
|
|
177
|
-
return sum;
|
|
178
|
-
}, [discountGood]);
|
|
179
|
-
/** 表单变化 */
|
|
180
|
-
var onChangeForm = react_1["default"].useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
181
|
-
return __generator(this, function (_a) {
|
|
182
|
-
setFormValues(form.getFieldsValue());
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
});
|
|
185
|
-
}); }, [form]);
|
|
186
|
-
/** 点击了确认 */
|
|
187
|
-
var onDefine = react_1["default"].useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
188
|
-
var values, totalDiscoline, discolinesSum, discolines, surplus, i;
|
|
189
|
-
var _this = this;
|
|
190
|
-
return __generator(this, function (_a) {
|
|
191
|
-
switch (_a.label) {
|
|
192
|
-
case 0: return [4 /*yield*/, form.validateFields()];
|
|
193
|
-
case 1:
|
|
194
|
-
values = _a.sent();
|
|
195
|
-
totalDiscoline = values.discolineType === '1'
|
|
196
|
-
? mathjs_1.chain(mathjs_1.bignumber(values.discolineValue))
|
|
197
|
-
: mathjs_1.chain(mathjs_1.bignumber(totalAmount)).multiply(mathjs_1.bignumber(values.discolineValue)).multiply(mathjs_1.bignumber(0.01));
|
|
198
|
-
discolinesSum = mathjs_1.chain(mathjs_1.bignumber(0));
|
|
199
|
-
discolines = discountGood.map(function (e, i) {
|
|
200
|
-
var _a;
|
|
201
|
-
// 折扣金额占比
|
|
202
|
-
var share = mathjs_1.chain(mathjs_1.bignumber((_a = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _a !== void 0 ? _a : 0))
|
|
203
|
-
.divide(mathjs_1.bignumber(totalAmount));
|
|
204
|
-
// 折扣金额
|
|
205
|
-
var value = totalDiscoline
|
|
206
|
-
.multiply(share.done())
|
|
207
|
-
.multiply(mathjs_1.bignumber(100))
|
|
208
|
-
.round()
|
|
209
|
-
.divide(mathjs_1.bignumber(100))
|
|
210
|
-
.done();
|
|
211
|
-
discolinesSum = discolinesSum.add(value);
|
|
212
|
-
return value.toNumber();
|
|
213
|
-
});
|
|
214
|
-
surplus = totalDiscoline.subtract(discolinesSum.done());
|
|
215
|
-
// 补充剩余折扣金
|
|
216
|
-
for (i = 0; i < discolines.length; i++) {
|
|
217
|
-
if (surplus.smaller(0.01).done())
|
|
218
|
-
break;
|
|
219
|
-
discolines[i] = mathjs_1.chain(mathjs_1.bignumber(discolines[i])).add(mathjs_1.bignumber(0.01)).done().toNumber();
|
|
220
|
-
surplus = surplus.subtract(mathjs_1.bignumber(0.01));
|
|
221
|
-
}
|
|
222
|
-
// 给一组货物添加折扣行
|
|
223
|
-
return [4 /*yield*/, controller.addGoodDiscountV2(discolines.map(function (e, i) {
|
|
224
|
-
var _a;
|
|
225
|
-
return {
|
|
226
|
-
$index: (_a = discountGood[i]) === null || _a === void 0 ? void 0 : _a.$index,
|
|
227
|
-
discolineAmountunt: e
|
|
228
|
-
};
|
|
229
|
-
}))];
|
|
230
|
-
case 2:
|
|
231
|
-
// 给一组货物添加折扣行
|
|
232
|
-
_a.sent();
|
|
233
|
-
return [4 /*yield*/, controller.run(function (s) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
234
|
-
s.goodsListState.selectedGoodIndex = [];
|
|
235
|
-
return [2 /*return*/];
|
|
236
|
-
}); }); })
|
|
237
|
-
// 关闭抽屉
|
|
238
|
-
];
|
|
239
|
-
case 3:
|
|
240
|
-
_a.sent();
|
|
241
|
-
// 关闭抽屉
|
|
242
|
-
onClose();
|
|
243
|
-
return [2 /*return*/];
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
}); }, [discountGood, form, totalAmount, onClose, controller]);
|
|
247
|
-
// 打开抽屉时 重置form
|
|
248
|
-
react_1["default"].useEffect(function () {
|
|
249
|
-
if (open) {
|
|
250
|
-
form.resetFields();
|
|
251
|
-
setFormValues(form.getFieldsValue());
|
|
252
|
-
}
|
|
253
|
-
}, [open]);
|
|
254
|
-
// 切换 折扣方式 清空折扣值
|
|
255
|
-
react_1["default"].useEffect(function () {
|
|
256
|
-
form.setFieldsValue(__assign(__assign({}, formValues), { discolineValue: undefined }));
|
|
257
|
-
}, [formValues === null || formValues === void 0 ? void 0 : formValues.discolineType]);
|
|
258
|
-
return (react_1["default"].createElement(kts_xui_1.Drawer, { title: "\u6DFB\u52A0\u6298\u6263", placement: "right", width: 350, onClose: onClose, open: open, footer: react_1["default"].createElement(kts_xui_1.Space, { size: "middle", style: { display: 'flex', justifyContent: 'end' } },
|
|
259
|
-
react_1["default"].createElement(kts_xui_1.Button, { onClick: onDefine, type: 'primary' }, "\u786E\u5B9A"),
|
|
260
|
-
react_1["default"].createElement(kts_xui_1.Button, { onClick: onClose }, "\u53D6\u6D88")) },
|
|
261
|
-
react_1["default"].createElement(kts_xui_1.Form, { form: form, layout: 'vertical', onChange: onChangeForm },
|
|
262
|
-
react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u5546\u54C1\u91D1\u989D\uFF08\u542B\u7A0E\uFF09' },
|
|
263
|
-
totalAmount.toFixed(2),
|
|
264
|
-
"\uFF08\u5171 ",
|
|
265
|
-
discountGood.length,
|
|
266
|
-
" \u884C\uFF09"),
|
|
267
|
-
react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u6298\u6263\u65B9\u5F0F', name: 'discolineType', initialValue: '1' },
|
|
268
|
-
react_1["default"].createElement(kts_xui_1.Radio.Group, { options: [
|
|
269
|
-
{ label: '按金额折扣', value: '1' },
|
|
270
|
-
{ label: '按比例折扣', value: '2' },
|
|
271
|
-
] })),
|
|
272
|
-
(formValues === null || formValues === void 0 ? void 0 : formValues.discolineType) === '1' ?
|
|
273
|
-
(react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u6298\u6263\u91D1\u989D\uFF08\u5143\uFF09\uFF08\u542B\u7A0E\uFF09', name: 'discolineValue', rules: [
|
|
274
|
-
{ required: true, message: '必填' },
|
|
275
|
-
{
|
|
276
|
-
validator: function (_, value) { return __awaiter(_this, void 0, void 0, function () {
|
|
277
|
-
return __generator(this, function (_a) {
|
|
278
|
-
if (!value)
|
|
279
|
-
return [2 /*return*/];
|
|
280
|
-
if (value > totalAmount)
|
|
281
|
-
throw new Error('不可以大于商品金额');
|
|
282
|
-
return [2 /*return*/];
|
|
283
|
-
});
|
|
284
|
-
}); }
|
|
285
|
-
}
|
|
286
|
-
] },
|
|
287
|
-
react_1["default"].createElement(kts_xui_1.InputNumber, { style: { width: '100%' } }))) : (react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u6298\u6263\u6BD4\u4F8B\uFF08%\uFF09\uFF08\u542B\u7A0E\uFF09', name: 'discolineValue', rules: [
|
|
288
|
-
{ required: true, message: '必填' },
|
|
289
|
-
{
|
|
290
|
-
validator: function (_, value) { return __awaiter(_this, void 0, void 0, function () {
|
|
291
|
-
return __generator(this, function (_a) {
|
|
292
|
-
if (!value)
|
|
293
|
-
return [2 /*return*/];
|
|
294
|
-
if (value > 100)
|
|
295
|
-
throw new Error('不可以大于100');
|
|
296
|
-
return [2 /*return*/];
|
|
297
|
-
});
|
|
298
|
-
}); }
|
|
299
|
-
}
|
|
300
|
-
] },
|
|
301
|
-
react_1["default"].createElement(kts_xui_1.InputNumber, { style: { width: '100%' } }))))));
|
|
302
|
-
}
|
|
303
|
-
/** 判断数组是否连续 */
|
|
304
|
-
function isContinuityNum(array) {
|
|
305
|
-
var i = array[0];
|
|
306
|
-
var isContinuation = true;
|
|
307
|
-
for (var e in array) {
|
|
308
|
-
if (array[e] != i) {
|
|
309
|
-
isContinuation = false;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
i++;
|
|
313
|
-
}
|
|
314
|
-
return isContinuation;
|
|
315
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
exports.__esModule = true;
|
|
16
|
-
var react_1 = require("react");
|
|
17
|
-
var kts_xui_1 = require("kts-xui");
|
|
18
|
-
var kts_components_antd_x3_1 = require("kts-components-antd-x3");
|
|
19
|
-
var grey_react_box_1 = require("grey-react-box");
|
|
20
|
-
var __1 = require("../../..");
|
|
21
|
-
require("./index.less");
|
|
22
|
-
exports["default"] = grey_react_box_1.decorator(kts_components_antd_x3_1.Form.create())(function (props) {
|
|
23
|
-
var form = props.form;
|
|
24
|
-
var getFieldDecorator = form.getFieldDecorator;
|
|
25
|
-
/** 控制器 */
|
|
26
|
-
var controller = __1["default"].useInvoiceController();
|
|
27
|
-
var model = controller.useMemo(function (s) { return s.model; }, []);
|
|
28
|
-
var disableds = controller.useMemo(function (s) { return s.stakeholder.disableds || []; }, []);
|
|
29
|
-
var readOnly = react_1["default"].useMemo(function () { return model === 'readOnly'; }, [model]);
|
|
30
|
-
var isReadOnly = react_1["default"].useCallback(function (field) { return disableds.indexOf(field) >= 0; }, [disableds]);
|
|
31
|
-
// 注册 form
|
|
32
|
-
controller.useForm('sign', form);
|
|
33
|
-
if (readOnly) {
|
|
34
|
-
return (react_1["default"].createElement("div", { className: "kts-invoice-operate-sign-digtal-readOnly" },
|
|
35
|
-
react_1["default"].createElement("div", { className: 'sign-digtal-readOnly-cont' },
|
|
36
|
-
react_1["default"].createElement("div", null,
|
|
37
|
-
react_1["default"].createElement("span", null, "\u5907"),
|
|
38
|
-
react_1["default"].createElement("span", null, "\u6CE8")),
|
|
39
|
-
react_1["default"].createElement("div", null, getFieldDecorator('remark', {
|
|
40
|
-
initialValue: props.defaultRemark
|
|
41
|
-
})(react_1["default"].createElement(MyDiv, null)))),
|
|
42
|
-
react_1["default"].createElement(kts_components_antd_x3_1.Form, { layout: 'inline', className: 'digtal-readOnly-form' },
|
|
43
|
-
react_1["default"].createElement(kts_components_antd_x3_1.Form.Item, { label: '\u5F00\u7968\u4EBA' }, getFieldDecorator('issuer', {
|
|
44
|
-
initialValue: props.defaultRemark
|
|
45
|
-
})(react_1["default"].createElement(MyDiv, null))))));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return (react_1["default"].createElement("div", { className: "kts-invoice-operate-sign-digtal" },
|
|
49
|
-
react_1["default"].createElement("div", { className: 'sign-digtal-label' }, "\u5907\u6CE8\u4FE1\u606F"),
|
|
50
|
-
react_1["default"].createElement(kts_components_antd_x3_1.Form, null,
|
|
51
|
-
react_1["default"].createElement(kts_components_antd_x3_1.Form.Item, { label: "\u5907\u6CE8" }, getFieldDecorator('remarks', {
|
|
52
|
-
initialValue: props.defaultRemark
|
|
53
|
-
})(react_1["default"].createElement(kts_xui_1.Input.TextArea, { readOnly: isReadOnly('remarks'), autoSize: true, placeholder: '\u8BF7\u8F93\u5165' }))),
|
|
54
|
-
react_1["default"].createElement(kts_components_antd_x3_1.Form.Item, { label: "\u5F00\u7968\u4EBA" }, getFieldDecorator('drawer', {
|
|
55
|
-
initialValue: props.defaultIssuer
|
|
56
|
-
})(react_1["default"].createElement(kts_xui_1.Input, { readOnly: isReadOnly('drawer'), style: { width: 313 }, placeholder: '\u8BF7\u8F93\u5165' }))))));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
var MyDiv = /** @class */ (function (_super) {
|
|
60
|
-
__extends(MyDiv, _super);
|
|
61
|
-
function MyDiv() {
|
|
62
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
63
|
-
}
|
|
64
|
-
MyDiv.prototype.render = function () {
|
|
65
|
-
return (react_1["default"].createElement("div", null, this.props.value));
|
|
66
|
-
};
|
|
67
|
-
return MyDiv;
|
|
68
|
-
}(react_1["default"].Component));
|