kts-component-invoice-operate 3.2.4 → 3.2.6

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.
@@ -0,0 +1,316 @@
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 add_svg_1 = require("./svg/add.svg");
54
+ var __1 = require("../../../../../../..");
55
+ var InvoiceController_1 = require("../../../../../../../InvoiceController");
56
+ exports["default"] = (function () {
57
+ /** 控制器 */
58
+ var controller = __1["default"].useInvoiceController();
59
+ /** 组件模式 prefab 预制 readOnly 只读 */
60
+ var model = controller.useMemo(function (s) { return s.model; }, []);
61
+ /** 准备添加折扣的货物索引列表 */
62
+ var discountGoodIndex = controller.useMemo(function (s) { return s.goodsListState.discountGoodIndex || []; }, []);
63
+ /** 列表选中的货物索引列表 */
64
+ var selectedGoodIndex = controller.useMemo(function (s) { return s.goodsListState.selectedGoodIndex; }, []);
65
+ /** 货物字典 */
66
+ var goodsMap = controller.useMemo(function (s) { return s.goodsListState.goodsMap; }, []);
67
+ /** 是否能添加折扣行 */
68
+ var isAddDiscount = controller.useMemo(function (s) { return s.goodsListState.isAddDiscount; }, []);
69
+ // 抽屉开启状态
70
+ var open = react_1["default"].useMemo(function () { return discountGoodIndex.length > 0; }, [discountGoodIndex]);
71
+ /** 打开抽屉 */
72
+ var onOpen = react_1["default"].useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0: return [4 /*yield*/, controller.saveEditGood()];
76
+ case 1:
77
+ _a.sent();
78
+ return [4 /*yield*/, controller.wait()];
79
+ case 2:
80
+ _a.sent();
81
+ return [4 /*yield*/, controller.run(function (s) { return __awaiter(void 0, void 0, void 0, function () {
82
+ var isOk;
83
+ return __generator(this, function (_a) {
84
+ isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
85
+ if (isOk) {
86
+ kts_xui_1.message.error({ content: '不能给编辑状态的行增加折扣!', key: '不能给编辑状态的行增加折扣!' });
87
+ return [2 /*return*/];
88
+ }
89
+ 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; }))) {
90
+ kts_xui_1.message.error({ content: '项目不连续,不允许添加折扣', key: '项目不连续,不允许添加折扣' });
91
+ return [2 /*return*/];
92
+ }
93
+ 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.正常; });
94
+ if (isOk) {
95
+ kts_xui_1.message.error({ content: '不允许重复添加折扣', key: '不允许重复添加折扣' });
96
+ return [2 /*return*/];
97
+ }
98
+ isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
99
+ var good = s.goodsListState.goodsMap.get($index);
100
+ return !good || (good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType);
101
+ });
102
+ if (isOk) {
103
+ kts_xui_1.message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
104
+ return [2 /*return*/];
105
+ }
106
+ isOk = s.goodsListState.selectedGoodIndex.some(function ($index) {
107
+ var good = s.goodsListState.goodsMap.get($index);
108
+ return "" + (good === null || good === void 0 ? void 0 : good.lineAmountIncludeTax) === '0';
109
+ });
110
+ if (isOk) {
111
+ kts_xui_1.message.error({ content: '金额为0不能添加折扣行', key: '金额为0不能添加折扣行' });
112
+ return [2 /*return*/];
113
+ }
114
+ s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
115
+ return [2 /*return*/];
116
+ });
117
+ }); })];
118
+ case 3:
119
+ _a.sent();
120
+ return [2 /*return*/];
121
+ }
122
+ });
123
+ }); }, [controller]);
124
+ /** 关闭抽屉 */
125
+ var onClose = react_1["default"].useCallback(function () {
126
+ controller.run(function (s) { return __awaiter(void 0, void 0, void 0, function () {
127
+ return __generator(this, function (_a) {
128
+ s.goodsListState.discountGoodIndex = [];
129
+ return [2 /*return*/];
130
+ });
131
+ }); });
132
+ }, [controller]);
133
+ /** 是否禁用 */
134
+ var disabled = react_1["default"].useMemo(function () { return selectedGoodIndex.length === 0; }, [selectedGoodIndex, goodsMap]);
135
+ /** 是否启用 */
136
+ var isEnable = react_1["default"].useMemo(function () {
137
+ if (model === 'readOnly')
138
+ return false;
139
+ if (model === 'prefab')
140
+ return false;
141
+ return !(isAddDiscount === false);
142
+ }, [isAddDiscount, model]);
143
+ var button = react_1["default"].useMemo(function () {
144
+ if (isEnable) {
145
+ return (react_1["default"].createElement(react_1["default"].Fragment, null,
146
+ react_1["default"].createElement(kts_xui_1.Button, { size: 'small', onClick: onOpen, disabled: disabled, icon: react_1["default"].createElement(add_svg_1.ReactComponent, null) }, "\u6DFB\u52A0\u6298\u6263"),
147
+ react_1["default"].createElement(AddDiscountRowDrawer, { open: open, onClose: onClose })));
148
+ }
149
+ else {
150
+ return (react_1["default"].createElement(react_1["default"].Fragment, null));
151
+ }
152
+ }, [open, onOpen, onClose, isEnable, disabled]);
153
+ return {
154
+ button: button
155
+ };
156
+ });
157
+ /** 添加折扣行的抽屉 */
158
+ function AddDiscountRowDrawer(props) {
159
+ var _this = this;
160
+ var open = props.open, onClose = props.onClose;
161
+ var form = kts_xui_1.Form.useForm()[0];
162
+ var _a = react_1["default"].useState(), formValues = _a[0], setFormValues = _a[1];
163
+ /** 控制器 */
164
+ var controller = __1["default"].useInvoiceController();
165
+ /** 货物字典 */
166
+ var goodsMap = controller.useMemo(function (s) { return s.goodsListState.goodsMap; }, []);
167
+ /** 准备添加折扣的货物索引列表 */
168
+ var discountGoodIndex = controller.useMemo(function (s) { return s.goodsListState.discountGoodIndex || []; }, []);
169
+ /** 准备添加折扣的货物列表 */
170
+ var discountGood = react_1["default"].useMemo(function () { return discountGoodIndex.map(function (e) { return goodsMap.get(e); }); }, [discountGoodIndex, goodsMap]);
171
+ /** 总金额 */
172
+ var totalAmount = react_1["default"].useMemo(function () {
173
+ var sum = 0;
174
+ discountGood.forEach(function (e) {
175
+ var _a;
176
+ sum += (_a = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _a !== void 0 ? _a : 0;
177
+ });
178
+ return sum;
179
+ }, [discountGood]);
180
+ /** 表单变化 */
181
+ var onChangeForm = react_1["default"].useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
182
+ return __generator(this, function (_a) {
183
+ setFormValues(form.getFieldsValue());
184
+ return [2 /*return*/];
185
+ });
186
+ }); }, [form]);
187
+ /** 点击了确认 */
188
+ var onDefine = react_1["default"].useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
189
+ var values, totalDiscoline, discolinesSum, discolines, surplus, i;
190
+ var _this = this;
191
+ return __generator(this, function (_a) {
192
+ switch (_a.label) {
193
+ case 0: return [4 /*yield*/, form.validateFields()];
194
+ case 1:
195
+ values = _a.sent();
196
+ totalDiscoline = values.discolineType === '1'
197
+ ? mathjs_1.chain(mathjs_1.bignumber(values.discolineValue))
198
+ : mathjs_1.chain(mathjs_1.bignumber(totalAmount)).multiply(mathjs_1.bignumber(values.discolineValue)).multiply(mathjs_1.bignumber(0.01));
199
+ discolinesSum = mathjs_1.chain(mathjs_1.bignumber(0));
200
+ discolines = discountGood.map(function (e, i) {
201
+ var _a;
202
+ // 折扣金额占比
203
+ var share = mathjs_1.chain(mathjs_1.bignumber((_a = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _a !== void 0 ? _a : 0))
204
+ .divide(mathjs_1.bignumber(totalAmount));
205
+ // 折扣金额
206
+ var value = totalDiscoline
207
+ .multiply(share.done())
208
+ .multiply(mathjs_1.bignumber(100))
209
+ .round()
210
+ .divide(mathjs_1.bignumber(100))
211
+ .done();
212
+ discolinesSum = discolinesSum.add(value);
213
+ return value.toNumber();
214
+ });
215
+ surplus = totalDiscoline.subtract(discolinesSum.done());
216
+ // 补充剩余折扣金
217
+ for (i = 0; i < discolines.length; i++) {
218
+ if (surplus.smaller(0.01).done())
219
+ break;
220
+ discolines[i] = mathjs_1.chain(mathjs_1.bignumber(discolines[i])).add(mathjs_1.bignumber(0.01)).done().toNumber();
221
+ surplus = surplus.subtract(mathjs_1.bignumber(0.01));
222
+ }
223
+ // 给一组货物添加折扣行
224
+ return [4 /*yield*/, controller.addGoodDiscountV2(discolines.map(function (e, i) {
225
+ var _a;
226
+ return {
227
+ $index: (_a = discountGood[i]) === null || _a === void 0 ? void 0 : _a.$index,
228
+ discolineAmountunt: e
229
+ };
230
+ }))];
231
+ case 2:
232
+ // 给一组货物添加折扣行
233
+ _a.sent();
234
+ return [4 /*yield*/, controller.run(function (s) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
235
+ s.goodsListState.selectedGoodIndex = [];
236
+ return [2 /*return*/];
237
+ }); }); })
238
+ // 关闭抽屉
239
+ ];
240
+ case 3:
241
+ _a.sent();
242
+ // 关闭抽屉
243
+ onClose();
244
+ return [2 /*return*/];
245
+ }
246
+ });
247
+ }); }, [discountGood, form, totalAmount, onClose, controller]);
248
+ // 打开抽屉时 重置form
249
+ react_1["default"].useEffect(function () {
250
+ if (open) {
251
+ form.resetFields();
252
+ setFormValues(form.getFieldsValue());
253
+ }
254
+ }, [open]);
255
+ // 切换 折扣方式 清空折扣值
256
+ react_1["default"].useEffect(function () {
257
+ form.setFieldsValue(__assign(__assign({}, formValues), { discolineValue: undefined }));
258
+ }, [formValues === null || formValues === void 0 ? void 0 : formValues.discolineType]);
259
+ 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' } },
260
+ react_1["default"].createElement(kts_xui_1.Button, { onClick: onDefine, type: 'primary' }, "\u786E\u5B9A"),
261
+ react_1["default"].createElement(kts_xui_1.Button, { onClick: onClose }, "\u53D6\u6D88")) },
262
+ react_1["default"].createElement(kts_xui_1.Form, { form: form, layout: 'vertical', onChange: onChangeForm },
263
+ react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u5546\u54C1\u91D1\u989D\uFF08\u542B\u7A0E\uFF09' },
264
+ totalAmount.toFixed(2),
265
+ "\uFF08\u5171 ",
266
+ discountGood.length,
267
+ " \u884C\uFF09"),
268
+ react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u6298\u6263\u65B9\u5F0F', name: 'discolineType', initialValue: '1' },
269
+ react_1["default"].createElement(kts_xui_1.Radio.Group, { options: [
270
+ { label: '按金额折扣', value: '1' },
271
+ { label: '按比例折扣', value: '2' },
272
+ ] })),
273
+ (formValues === null || formValues === void 0 ? void 0 : formValues.discolineType) === '1' ?
274
+ (react_1["default"].createElement(kts_xui_1.Form.Item, { label: '\u6298\u6263\u91D1\u989D\uFF08\u5143\uFF09\uFF08\u542B\u7A0E\uFF09', name: 'discolineValue', rules: [
275
+ { required: true, message: '必填' },
276
+ {
277
+ validator: function (_, value) { return __awaiter(_this, void 0, void 0, function () {
278
+ return __generator(this, function (_a) {
279
+ if (!value)
280
+ return [2 /*return*/];
281
+ if (value > totalAmount)
282
+ throw new Error('不可以大于商品金额');
283
+ return [2 /*return*/];
284
+ });
285
+ }); }
286
+ }
287
+ ] },
288
+ 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: [
289
+ { required: true, message: '必填' },
290
+ {
291
+ validator: function (_, value) { return __awaiter(_this, void 0, void 0, function () {
292
+ return __generator(this, function (_a) {
293
+ if (!value)
294
+ return [2 /*return*/];
295
+ if (value > 100)
296
+ throw new Error('不可以大于100');
297
+ return [2 /*return*/];
298
+ });
299
+ }); }
300
+ }
301
+ ] },
302
+ react_1["default"].createElement(kts_xui_1.InputNumber, { style: { width: '100%' } }))))));
303
+ }
304
+ /** 判断数组是否连续 */
305
+ function isContinuityNum(array) {
306
+ var i = array[0];
307
+ var isContinuation = true;
308
+ for (var e in array) {
309
+ if (array[e] != i) {
310
+ isContinuation = false;
311
+ break;
312
+ }
313
+ i++;
314
+ }
315
+ return isContinuation;
316
+ }
@@ -100,7 +100,7 @@ export default () => {
100
100
  size='small'
101
101
  onClick={onOpen}
102
102
  disabled={disabled}
103
- icon={<Icon component={AddSvg} />}
103
+ icon={<AddSvg />}
104
104
  >
105
105
  添加折扣
106
106
  </Button>
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ exports.__esModule = true;
39
+ var react_1 = require("react");
40
+ var kts_xui_1 = require("kts-xui");
41
+ require("./index.less");
42
+ function InvoiceTypeModal(props) {
43
+ var _this = this;
44
+ var _a = props.disableds, disableds = _a === void 0 ? [] : _a;
45
+ var _b = react_1["default"].useState({ billingType: props.defaultBillingType || 'digital' }), formValues = _b[0], setValues = _b[1];
46
+ var form = kts_xui_1.Form.useForm()[0];
47
+ var onConfirm = react_1["default"].useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
48
+ var values;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0: return [4 /*yield*/, form.validateFields()];
52
+ case 1:
53
+ values = _a.sent();
54
+ props.onOk && props.onOk(values);
55
+ return [2 /*return*/];
56
+ }
57
+ });
58
+ }); }, [props.onOk, form]);
59
+ var onChangeBillingType = react_1["default"].useCallback(function (e) {
60
+ props.onChange && props.onChange(e.target.value);
61
+ form.setFieldsValue({ invoiceType: null, business: null });
62
+ setValues(form.getFieldsValue());
63
+ }, [props.onChange, form]);
64
+ react_1["default"].useEffect(function () {
65
+ if (props.open) {
66
+ var values = {
67
+ billingType: props.defaultBillingType || 'digital',
68
+ invoiceType: props.defaultInvoiceType,
69
+ business: props.defaultBusiness
70
+ };
71
+ form.resetFields();
72
+ form.setFieldsValue(values);
73
+ setValues(values);
74
+ }
75
+ }, [props.open, props.defaultBillingType, props.defaultBusiness, props.defaultInvoiceType, form]);
76
+ return (react_1["default"].createElement(kts_xui_1.Modal, { title: props.modalTitle || "选择开具信息", open: props.open, onOk: onConfirm, onCancel: props.onCancel, okText: '\u786E\u5B9A', cancelText: '\u53D6\u6D88' },
77
+ react_1["default"].createElement(kts_xui_1.Form, { form: form, layout: "vertical", style: { paddingTop: 20 }, onValuesChange: function (_, e) { setValues(e); } },
78
+ react_1["default"].createElement(kts_xui_1.Row, { gutter: [16, 16] },
79
+ react_1["default"].createElement(kts_xui_1.Col, { span: 24 },
80
+ react_1["default"].createElement(kts_xui_1.Form.Item, { name: 'billingType' },
81
+ react_1["default"].createElement(kts_xui_1.Radio.Group, { size: 'large', className: "goods-list-digtal-reselect-invoice-typeModal-radio", optionType: "button", disabled: disableds.indexOf('billingType') >= 0, onChange: onChangeBillingType, options: [
82
+ { label: '数电发票', value: 'digital' },
83
+ { label: '税控发票', value: 'taxation' },
84
+ ] }))),
85
+ react_1["default"].createElement(kts_xui_1.Col, { span: 12 },
86
+ react_1["default"].createElement(kts_xui_1.Form.Item, { name: 'invoiceType', label: "\u9009\u62E9\u7968\u7C7B", rules: [{ required: true, message: '选择票类必填' }] },
87
+ react_1["default"].createElement(kts_xui_1.Select, { size: 'large', allowClear: true, placeholder: "\u8BF7\u9009\u62E9\uFF08\u5FC5\u586B\u9879\uFF09", disabled: disableds.indexOf('invoiceType') >= 0, options: props.invoiceTypeOptions }))),
88
+ react_1["default"].createElement(kts_xui_1.Col, { span: 12 },
89
+ react_1["default"].createElement(kts_xui_1.Form.Item, { name: 'business', label: "\u7279\u5B9A\u4E1A\u52A1" },
90
+ react_1["default"].createElement(kts_xui_1.Select, { size: 'large', allowClear: true, placeholder: "\u8BF7\u9009\u62E9\uFF08\u975E\u5FC5\u586B\u9879\uFF09", disabled: disableds.indexOf('business') >= 0 || !formValues.invoiceType, options: props.businessOptions })))))));
91
+ }
92
+ exports["default"] = InvoiceTypeModal;
@@ -63,7 +63,13 @@ export default function InvoiceTypeModal(props: IInvoiceTypeModalProps) {
63
63
  const onConfirm = React.useCallback(async () => {
64
64
  const values = await form.validateFields();
65
65
  props.onOk && props.onOk(values);
66
- }, [props.onOk])
66
+ }, [props.onOk, form])
67
+
68
+ const onChangeBillingType = React.useCallback(e => {
69
+ props.onChange && props.onChange(e.target.value);
70
+ form.setFieldsValue({ invoiceType: null, business: null });
71
+ setValues(form.getFieldsValue());
72
+ }, [props.onChange, form])
67
73
 
68
74
  React.useEffect(() => {
69
75
  if (props.open) {
@@ -102,7 +108,7 @@ export default function InvoiceTypeModal(props: IInvoiceTypeModalProps) {
102
108
  className="goods-list-digtal-reselect-invoice-typeModal-radio"
103
109
  optionType="button"
104
110
  disabled={disableds.indexOf('billingType') >= 0}
105
- onChange={e => { props.onChange && props.onChange(e.target.value) }}
111
+ onChange={onChangeBillingType}
106
112
  options={[
107
113
  { label: '数电发票', value: 'digital' },
108
114
  { label: '税控发票', value: 'taxation' },