kts-component-invoice-operate 3.2.181-2 → 3.2.181-21

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 (27) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.d.ts +1 -0
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +1 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  4. package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.d.ts +1 -1
  5. package/dist/index.esm.js +961 -387
  6. package/dist/index.js +952 -378
  7. package/package.json +1 -1
  8. package/src/Invoice/InvoiceController/InvoiceControllerState/BuyerState/index.tsx +7 -0
  9. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +2 -0
  10. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +2 -1
  11. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +1 -1
  12. package/src/Invoice/InvoiceController/fns/importGoodsDrawer.ts +2 -3
  13. package/src/Invoice/tools/calculate/index.ts +1 -1
  14. package/src/Invoice/ui/default/Buyer/ui/BuyerNameInput/index.tsx +2 -2
  15. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +1 -2
  16. package/src/Invoice/ui/default/GoodsList/hook/useColumns/autoFillFn/index.ts +92 -36
  17. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +43 -14
  18. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +4 -1
  19. package/src/Invoice/ui/default/GoodsList/index.tsx +6 -6
  20. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +449 -139
  21. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.tsx +3 -3
  22. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/index.tsx +1 -1
  23. package/src/Invoice/ui/default/ImportBuyerDrawer/index.tsx +1 -1
  24. package/src/Invoice/ui/default/ImportGoodsDrawer/index.tsx +27 -14
  25. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +9 -2
  26. package/src/Invoice/ui/digtal/Sign/index.tsx +2 -2
  27. package/src/Invoice/ui/digtal/Stakeholder/index.tsx +28 -17
@@ -7,8 +7,10 @@
7
7
  */
8
8
 
9
9
  import React from 'react';
10
- import { Button, Drawer, Form, message, Input, Typography, Menu } from 'kts-components-antd-x3';
10
+ import { Button, message, Typography, Menu } from 'kts-components-antd-x3';
11
+ import { InputNumber, Radio, Space, Form as Form1, Drawer as Drawer1 } from "kts-xui";
11
12
  import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
13
+ import { bignumber } from 'mathjs';
12
14
  import { all, create } from 'mathjs';
13
15
  import { decorator } from 'grey-react-box';
14
16
  import Invoice from '../../../../../../..';
@@ -30,8 +32,7 @@ export default () => {
30
32
  const isAddDiscount = controller.useMemo(s => s.goodsListState.isAddDiscount, []);
31
33
 
32
34
  /** 是否开启抽屉 */
33
- const visible = controller.useMemo(s => s.goodsListState.discountGoodIndex.length > 0, []);
34
-
35
+ // const visible = controller.useMemo(s => s.goodsListState.discountGoodIndex.length > 0, []);
35
36
  /** 是否禁用 按钮 */
36
37
  const disabled = controller.useMemo((s) => {
37
38
  if (s.goodsListState.selectedGoodIndex.length <= 0) {
@@ -94,151 +95,460 @@ export default () => {
94
95
  ) : undefined
95
96
  }, [isAddDiscount, disabled, onClick])
96
97
 
97
- const drawer = React.useMemo(() => {
98
- return (
99
- <Drawer
100
- className="kts-invoice-operate-goods-list-add-discount-row"
101
- width={540}
102
- title="添加折扣行"
103
- placement="right"
104
- destroyOnClose={true}
105
- onClose={onClose}
106
- visible={visible}
107
- >
108
- <DrawerBody />
109
- </Drawer>
110
- )
111
- }, [visible, onClose])
98
+ // const drawer = React.useMemo(() => {
99
+ // return (
100
+ // <Drawer
101
+ // className="kts-invoice-operate-goods-list-add-discount-row"
102
+ // width={540}
103
+ // title="添加折扣行"
104
+ // placement="right"
105
+ // destroyOnClose={true}
106
+ // onClose={onClose}
107
+ // visible={visible}
108
+ // >
109
+ // <DrawerBody />
110
+ // </Drawer>
111
+ // )
112
+ // }, [visible, onClose])
112
113
 
113
- return { menuItem, drawer }
114
- };
115
114
 
116
- const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
117
- const { form } = props;
115
+ // 添加折扣(批量)
116
+ /** 是否启用 */
117
+ const isEnable = React.useMemo(() => {
118
+ if (model === 'readOnly') return false;
119
+ if (model === 'prefab') return false;
120
+ return !(isAddDiscount === false)
121
+ }, [isAddDiscount, model]);
118
122
 
119
- const { getFieldDecorator } = form;
123
+ /** 准备添加折扣的货物索引列表 */
124
+ const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex || [], []);
125
+ // 抽屉开启状态
126
+ const open = React.useMemo(() => discountGoodIndex.length > 0, [discountGoodIndex]);
120
127
 
121
- const controller = Invoice.useInvoiceController();
128
+ /** 打开抽屉 */
129
+ const onOpen = React.useCallback(async () => {
130
+ await controller.saveEditGood();
131
+ await controller.wait();
132
+ await controller.run(async s => {
122
133
 
123
- /** 选中的货物索引列表 */
124
- const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex, []);
125
-
126
- /** 金额合计 */
127
- const lineAmountSum = controller.useMemo((s) => {
128
- let sum = chain(0);
129
- if (s.goodsListState.isTaxIncluded) {
130
- s.goodsListState.discountGoodIndex.forEach((e) => {
131
- const goods = s.goodsListState.goodsMap.get(e);
132
- sum = sum.add(goods?.lineAmountIncludeTax || 0);
133
- });
134
+ // 不能给编辑状态的行增加折扣!
135
+ let isOk = s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0;
136
+ if (isOk) {
137
+ message.error({ content: '不能给编辑状态的行增加折扣!', key: '不能给编辑状态的行增加折扣!' });
138
+ return;
139
+ }
140
+
141
+ // 项目不连续,不允许添加折扣
142
+ if (!isContinuityNum(s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)?.serialNo || -2).sort((a, b) => a - b))) {
143
+ message.error({ content: '项目不连续,不允许添加折扣', key: '项目不连续,不允许添加折扣' });
144
+ return;
145
+ }
146
+
147
+ // 不允许重复添加折扣
148
+ isOk = s.goodsListState.selectedGoodIndex.some($index => s.goodsListState.goodsMap.get($index)?.lineAttribute !== LineAttributeType.正常)
149
+ if (isOk) {
150
+ message.error({ content: '不允许重复添加折扣', key: '不允许重复添加折扣' });
151
+ return;
152
+ }
153
+
154
+ // 存在不同税率,不允许同时添加折扣
155
+ if (areAllValuesEqual(s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)?.taxRate)) === false) {
156
+ message.error({ content: '存在不同税率,不允许同时添加折扣', key: '存在不同税率,不允许同时添加折扣' });
157
+ return;
158
+ }
159
+
160
+ // 添加折扣时项目金额不能为空或零
161
+ isOk = s.goodsListState.selectedGoodIndex.some($index => {
162
+ const good = s.goodsListState.goodsMap.get($index);
163
+ return `${good?.lineAmountIncludeTax}` === '0'
164
+ })
165
+ if (isOk) {
166
+ message.error({ content: '添加折扣时项目金额不能为空或零', key: '添加折扣时项目金额不能为空或零' });
167
+ return;
168
+ }
169
+
170
+ // 零税率需要设置免税类型,请在赋码中设置!
171
+ isOk = s.goodsListState.selectedGoodIndex.some($index => {
172
+ const good = s.goodsListState.goodsMap.get($index);
173
+ return !good || (good.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !good.taxFreeType)
174
+ })
175
+ if (isOk) {
176
+ message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
177
+ return;
178
+ }
179
+
180
+ s.goodsListState.discountGoodIndex = s.goodsListState.selectedGoodIndex.slice();
181
+ });
182
+ }, [controller]);
183
+
184
+
185
+ const button = React.useMemo(() => {
186
+ if (isEnable) {
187
+ return (
188
+ <>
189
+ <Button
190
+ size='small'
191
+ onClick={onOpen}
192
+ disabled={disabled}
193
+ >
194
+ 添加折扣
195
+ </Button>
196
+ <AddDiscountRowDrawer open={open} onClose={onClose} />
197
+ </>
198
+ )
134
199
  } else {
135
- s.goodsListState.discountGoodIndex.forEach((e) => {
136
- const goods = s.goodsListState.goodsMap.get(e);
137
- sum = sum.add(goods?.lineAmountExcludeTax || 0);
138
- });
200
+ return (
201
+ <></>
202
+ )
139
203
  }
140
- return sum.done();
141
- }, []);
204
+ }, [open, onOpen, onClose, isEnable, disabled])
142
205
 
143
- /** 关闭抽屉 */
144
- const onClose = React.useCallback(() => {
145
- controller.pipeline(async (s) => { s.goodsListState.discountGoodIndex = [] })();
146
- }, []);
206
+ return { menuItem, button }
207
+ };
147
208
 
148
- /** 点击了保存 */
149
- const onClickSave = React.useCallback(() => {
150
- form.validateFields((err, values) => {
151
- if (err) return;
152
- const discolineAmountunt = parseFloat(parseFloat(values.discolineAmountunt).toFixed(2));
153
- const discount = parseFloat(parseFloat(values.discount).toFixed(4));
154
- const indexList = discountGoodIndex;
155
- controller.pipeline(async s => { s.goodsListState.discountGoodIndex = []; })();
156
- controller.addGoodDiscount({ indexList, discount, discolineAmountunt });
209
+ // 批量折扣弹窗
210
+ /** 添加折扣行的抽屉 */
211
+ function AddDiscountRowDrawer(props: {
212
+
213
+ /** 是否打开 */
214
+ open: boolean;
215
+
216
+ /** 点击关闭 */
217
+ onClose: () => void;
218
+
219
+ }) {
220
+
221
+ const { open, onClose } = props;
222
+
223
+ const [form] = Form1.useForm();
224
+
225
+ const [formValues, setFormValues] = React.useState<{ discolineType: string }>()
226
+
227
+ /** 控制器 */
228
+ const controller = Invoice.useInvoiceController();
229
+
230
+ /** 货物字典 */
231
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
232
+
233
+ /** 准备添加折扣的货物索引列表 */
234
+ const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex || [], []);
235
+
236
+ /** 准备添加折扣的货物列表 */
237
+ const discountGood = React.useMemo(() => discountGoodIndex.map(e => goodsMap.get(e)), [discountGoodIndex, goodsMap])
238
+
239
+ /** 总金额 */
240
+ const totalAmount = React.useMemo(() => {
241
+ let sum = 0;
242
+ discountGood.forEach(e => {
243
+ sum += e?.lineAmountIncludeTax ?? 0;
244
+ })
245
+ return sum;
246
+ }, [discountGood])
247
+
248
+ /** 表单变化 */
249
+ const onChangeForm = React.useCallback(async () => {
250
+ // setFormValues(form.getFieldsValue())
251
+ const values = await form.getFieldsValue();
252
+ setFormValues(values);
253
+ }, [form])
254
+
255
+ /** 点击了确认 */
256
+ const onDefine = React.useCallback(async () => {
257
+ // 表单数据
258
+ const values = await form.validateFields();
259
+
260
+ // 折扣总金额
261
+ const totalDiscoline = values.discolineType === '1'
262
+ ? chain(bignumber(values.discolineValue))
263
+ : chain(bignumber(totalAmount)).multiply(bignumber(values.discolineValue)).multiply(bignumber(0.01));
264
+
265
+ let discolinesSum = chain(bignumber(0));
266
+
267
+ // 每行的折扣金额
268
+ const discolines: number[] = discountGood.map((e, i) => {
269
+ // 折扣金额占比
270
+ const share = chain(bignumber(e?.lineAmountIncludeTax ?? 0))
271
+ .divide(bignumber(totalAmount));
272
+
273
+ // 折扣金额
274
+ const value = totalDiscoline
275
+ .multiply(share.done())
276
+
277
+ .multiply(bignumber(100))
278
+ .round()
279
+ .divide(bignumber(100))
280
+
281
+ .done();
282
+
283
+ discolinesSum = discolinesSum.add(value);
284
+ return value.toNumber();
157
285
  });
158
- }, [controller, form, discountGoodIndex]);
159
-
160
- /** 折扣率变化 */
161
- const onChangeDiscount = React.useCallback(
162
- lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
163
- form.validateFields((err, values) => {
164
- if (err && err.discount) return;
165
- const discolineAmountunt = evaluate(`${lineAmountSum} * (${values.discount}/100)`).toFixed(2);
166
- form.setFieldsValue({ discolineAmountunt });
167
- });
168
- }, 300),
169
- [form, lineAmountSum],
170
- );
171
-
172
- /** 折扣变化 */
173
- const onChangeDiscolineAmountunt = React.useCallback(
174
- lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
175
- form.validateFields((err, values) => {
176
- if (err && err.discolineAmountunt) return;
177
- const discolineAmountunt = parseFloat(values.discolineAmountunt).toFixed(2);
178
- const discount = evaluate(`(${discolineAmountunt} / ${lineAmountSum}) * 100`).toFixed(4);
179
- form.setFieldsValue({ discount });
180
- });
181
- }, 300),
182
- [form, lineAmountSum],
183
- );
286
+
287
+ // 剩余折扣金额
288
+ let surplus = totalDiscoline.subtract(discolinesSum.done());
289
+
290
+ // 补充剩余折扣金
291
+ for (let i = 0; i < discolines.length; i++) {
292
+ if (surplus.smaller(0.01).done()) break;
293
+ discolines[i] = chain(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
294
+ surplus = surplus.subtract(bignumber(0.01));
295
+ }
296
+
297
+ // 给一组货物添加折扣行
298
+ await controller.addGoodDiscountV2(discolines.map((e, i) => {
299
+ return {
300
+ $index: discountGood[i]?.$index as string,
301
+ discolineAmountunt: e as number,
302
+ }
303
+ }))
304
+
305
+ await controller.run(async s => { s.goodsListState.selectedGoodIndex = [] })
306
+
307
+ // 关闭抽屉
308
+ onClose();
309
+ }, [discountGood, form, totalAmount, onClose, controller])
310
+
311
+ // 打开抽屉时 重置form
312
+ React.useEffect(() => {
313
+ if (open) {
314
+ form.resetFields();
315
+ form.setFieldsValue({ discolineType: '1', discolineValue: undefined }); // 强制设置初始值
316
+ setFormValues({ discolineType: '1' });
317
+ }
318
+ }, [open])
319
+
320
+ // 切换 折扣方式 清空折扣值
321
+ React.useEffect(() => {
322
+ form.setFieldsValue({ ...formValues, discolineValue: undefined })
323
+ }, [formValues?.discolineType])
184
324
 
185
325
  return (
186
- <>
187
- <div className="add-discount-row-body">
188
- <p>
189
- 当前选择<Text type="danger">{discountGoodIndex.length}</Text>
190
- 行被折扣商品行,金额合计¥
191
- <Text type="danger">{lineAmountSum.toFixed(2)}</Text>
192
- </p>
193
- <Form.Item label="折扣率:">
194
- {getFieldDecorator('discount', {
195
- rules: [
196
- { required: true, message: '请输入折扣金额' },
197
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '请输入数字' },
198
- {
199
- validator: (_, value: string, callback) => {
200
- if (!value) { callback(); return; }
201
- if (!value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)?.length) { callback(); return; }
202
- if (parseFloat(value) > 100 || parseFloat(value) < 0) { callback('请输入大于0小于100的数字'); }
203
- callback();
204
- },
205
- },
206
- ],
207
- })(
208
- <Input
209
- placeholder="请输入大于0小于100的数字"
210
- suffix="%"
211
- onChange={onChangeDiscount}
212
- />,
213
- )}
214
- </Form.Item>
215
- <Form.Item label="折扣金额:">
216
- {getFieldDecorator('discolineAmountunt', {
217
- rules: [
218
- { required: true, message: '请输入折扣金额' },
219
- { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '请输入数字' },
220
- {
221
- validator: (_, value: string, callback) => {
222
- if (!value) { callback(); return; }
223
- if (!value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)?.length) { callback(); return; }
224
- if (parseFloat(value) > lineAmountSum || parseFloat(value) <= 0) { callback('请输入大于0小于金额合计的数字'); }
225
- callback();
226
- },
227
- },
228
- ],
229
- })(
230
- <Input
231
- placeholder="请输入大于0小于金额合计的数字"
232
- suffix="¥"
233
- onChange={onChangeDiscolineAmountunt}
234
- />,
235
- )}
236
- </Form.Item>
237
- </div>
238
- <div className="add-discount-row-footer">
239
- <Button block style={{ marginBottom: 12 }} onClick={onClose}>取消</Button>
240
- <Button type="primary" block onClick={onClickSave}>保存</Button>
241
- </div>
242
- </>
243
- );
244
- });
326
+ <Drawer1
327
+ title="添加折扣"
328
+ placement="right"
329
+ width={350}
330
+ onClose={onClose}
331
+ open={open}
332
+ footer={
333
+ <Space size="middle" style={{ display: 'flex', justifyContent: 'end' }}>
334
+ <Button onClick={onDefine} type='primary' >确定</Button>
335
+ <Button onClick={onClose} >取消</Button>
336
+ </Space>
337
+ }
338
+ >
339
+ <Form1
340
+ form={form}
341
+ layout='vertical'
342
+ onChange={onChangeForm}
343
+ >
344
+ <Form1.Item label='商品金额(含税)' >
345
+ {totalAmount.toFixed(2)}(共 {discountGood.length} 行)
346
+ </Form1.Item>
347
+
348
+ <Form1.Item
349
+ label='折扣方式'
350
+ name='discolineType'
351
+ initialValue='1'
352
+ >
353
+ <Radio.Group options={[
354
+ { label: '按金额折扣', value: '1' },
355
+ { label: '按比例折扣', value: '2' },
356
+ ]} />
357
+ </Form1.Item>
358
+ {
359
+ formValues?.discolineType === '2' ?
360
+ (
361
+ <Form1.Item
362
+ label='折扣比例(%)(含税)'
363
+ name='discolineValue'
364
+ rules={[
365
+ { required: true, message: '必填' },
366
+ {
367
+ validator: async (_, value) => {
368
+ if (isNaN(parseFloat(value))) return;
369
+ if (value <= 0) throw new Error('需大于0');
370
+ if (value > 100) throw new Error('不可以大于100');
371
+ }
372
+ }
373
+ ]}
374
+ >
375
+ <InputNumber style={{ width: '100%' }} />
376
+ </Form1.Item>
377
+ ) :
378
+ (
379
+ <Form1.Item
380
+ label='折扣金额(元)(含税)'
381
+ name='discolineValue'
382
+ rules={[
383
+ { required: true, message: '必填' },
384
+ {
385
+ validator: async (_, value) => {
386
+ if (isNaN(parseFloat(value))) return;
387
+ if (value <= 0) throw new Error('需大于0');
388
+ if (value > totalAmount) throw new Error('不可以大于商品金额');
389
+ }
390
+ }
391
+ ]}
392
+ >
393
+ <InputNumber style={{ width: '100%' }} />
394
+ </Form1.Item>
395
+ )
396
+ }
397
+ </Form1>
398
+ </Drawer1>
399
+ )
400
+ }
401
+
402
+ /** 判断数组是否连续 */
403
+ function isContinuityNum(array: number[]) {
404
+ var i = array[0];
405
+ var isContinuation = true;
406
+ for (var e in array) {
407
+ if (array[e] != i) {
408
+ isContinuation = false;
409
+ break;
410
+ }
411
+ i++;
412
+ }
413
+ return isContinuation;
414
+ }
415
+
416
+ /** 数组的值是否相等 */
417
+ function areAllValuesEqual(arr: any[]) {
418
+ for (let i = 1; i < arr.length; i++) {
419
+ if (arr[i] !== arr[0]) {
420
+ return false;
421
+ }
422
+ }
423
+ return true;
424
+ }
425
+
426
+ // const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
427
+ // const { form } = props;
428
+
429
+ // const { getFieldDecorator } = form;
430
+
431
+ // const controller = Invoice.useInvoiceController();
432
+
433
+ // /** 选中的货物索引列表 */
434
+ // const discountGoodIndex = controller.useMemo(s => s.goodsListState.discountGoodIndex, []);
435
+
436
+ // /** 金额合计 */
437
+ // const lineAmountSum = controller.useMemo((s) => {
438
+ // let sum = chain(0);
439
+ // if (s.goodsListState.isTaxIncluded) {
440
+ // s.goodsListState.discountGoodIndex.forEach((e) => {
441
+ // const goods = s.goodsListState.goodsMap.get(e);
442
+ // sum = sum.add(goods?.lineAmountIncludeTax || 0);
443
+ // });
444
+ // } else {
445
+ // s.goodsListState.discountGoodIndex.forEach((e) => {
446
+ // const goods = s.goodsListState.goodsMap.get(e);
447
+ // sum = sum.add(goods?.lineAmountExcludeTax || 0);
448
+ // });
449
+ // }
450
+ // return sum.done();
451
+ // }, []);
452
+
453
+ // /** 关闭抽屉 */
454
+ // const onClose = React.useCallback(() => {
455
+ // controller.pipeline(async (s) => { s.goodsListState.discountGoodIndex = [] })();
456
+ // }, []);
457
+
458
+ // /** 点击了保存 */
459
+ // const onClickSave = React.useCallback(() => {
460
+ // form.validateFields((err, values) => {
461
+ // if (err) return;
462
+ // const discolineAmountunt = parseFloat(parseFloat(values.discolineAmountunt).toFixed(2));
463
+ // const discount = parseFloat(parseFloat(values.discount).toFixed(4));
464
+ // const indexList = discountGoodIndex;
465
+ // controller.pipeline(async s => { s.goodsListState.discountGoodIndex = []; })();
466
+ // controller.addGoodDiscount({ indexList, discount, discolineAmountunt });
467
+ // });
468
+ // }, [controller, form, discountGoodIndex]);
469
+
470
+ // /** 折扣率变化 */
471
+ // const onChangeDiscount = React.useCallback(
472
+ // lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
473
+ // form.validateFields((err, values) => {
474
+ // if (err && err.discount) return;
475
+ // const discolineAmountunt = evaluate(`${lineAmountSum} * (${values.discount}/100)`).toFixed(2);
476
+ // form.setFieldsValue({ discolineAmountunt });
477
+ // });
478
+ // }, 300),
479
+ // [form, lineAmountSum],
480
+ // );
481
+
482
+ // /** 折扣变化 */
483
+ // const onChangeDiscolineAmountunt = React.useCallback(
484
+ // lazyFn((e: React.ChangeEvent<HTMLInputElement>) => {
485
+ // form.validateFields((err, values) => {
486
+ // if (err && err.discolineAmountunt) return;
487
+ // const discolineAmountunt = parseFloat(values.discolineAmountunt).toFixed(2);
488
+ // const discount = evaluate(`(${discolineAmountunt} / ${lineAmountSum}) * 100`).toFixed(4);
489
+ // form.setFieldsValue({ discount });
490
+ // });
491
+ // }, 300),
492
+ // [form, lineAmountSum],
493
+ // );
494
+
495
+ // return (
496
+ // <>
497
+ // <div className="add-discount-row-body">
498
+ // <p>
499
+ // 当前选择<Text type="danger">{discountGoodIndex.length}</Text>
500
+ // 行被折扣商品行,金额合计¥
501
+ // <Text type="danger">{lineAmountSum.toFixed(2)}</Text>
502
+ // </p>
503
+ // <Form.Item label="折扣率:">
504
+ // {getFieldDecorator('discount', {
505
+ // rules: [
506
+ // { required: true, message: '请输入折扣金额' },
507
+ // { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '请输入数字' },
508
+ // {
509
+ // validator: (_, value: string, callback) => {
510
+ // if (!value) { callback(); return; }
511
+ // if (!value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)?.length) { callback(); return; }
512
+ // if (parseFloat(value) > 100 || parseFloat(value) < 0) { callback('请输入大于0小于100的数字'); }
513
+ // callback();
514
+ // },
515
+ // },
516
+ // ],
517
+ // })(
518
+ // <Input
519
+ // placeholder="请输入大于0小于100的数字"
520
+ // suffix="%"
521
+ // onChange={onChangeDiscount}
522
+ // />,
523
+ // )}
524
+ // </Form.Item>
525
+ // <Form.Item label="折扣金额:">
526
+ // {getFieldDecorator('discolineAmountunt', {
527
+ // rules: [
528
+ // { required: true, message: '请输入折扣金额' },
529
+ // { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '请输入数字' },
530
+ // {
531
+ // validator: (_, value: string, callback) => {
532
+ // if (!value) { callback(); return; }
533
+ // if (!value.match(/^[+-]?(0|([1-9]\d*))(\.\d+)?$/)?.length) { callback(); return; }
534
+ // if (parseFloat(value) > lineAmountSum || parseFloat(value) <= 0) { callback('请输入大于0小于金额合计的数字'); }
535
+ // callback();
536
+ // },
537
+ // },
538
+ // ],
539
+ // })(
540
+ // <Input
541
+ // placeholder="请输入大于0小于金额合计的数字"
542
+ // suffix="¥"
543
+ // onChange={onChangeDiscolineAmountunt}
544
+ // />,
545
+ // )}
546
+ // </Form.Item>
547
+ // </div>
548
+ // <div className="add-discount-row-footer">
549
+ // <Button block style={{ marginBottom: 12 }} onClick={onClose}>取消</Button>
550
+ // <Button type="primary" block onClick={onClickSave}>保存</Button>
551
+ // </div>
552
+ // </>
553
+ // );
554
+ // });
@@ -10,7 +10,7 @@ export default () => {
10
10
  const model = controller.useMemo(s => s.model, []);
11
11
 
12
12
  const isRemRow = controller.useMemo(s => s.goodsListState.isRemRow, []);
13
-
13
+ const isBatchRemRow = controller.useMemo(s => s.goodsListState.isBatchRemRow, []);
14
14
  /** 是否禁用 */
15
15
  const disabled = controller.useMemo((s) => {
16
16
  if (s.goodsListState.selectedGoodIndex.length <= 0) return true;
@@ -55,7 +55,7 @@ export default () => {
55
55
  }, [model, onClick, disabled])
56
56
 
57
57
  const button = React.useMemo(() => {
58
-
58
+ if (isBatchRemRow === false) return <></>;
59
59
  if (isRemRow === false) return <></>;
60
60
  if (model === 'prefab') return <></>;
61
61
  if (model === 'readOnly') return <></>;
@@ -63,7 +63,7 @@ export default () => {
63
63
  return (
64
64
  <Button onClick={onClick} disabled={disabled} >批量删除</Button>
65
65
  )
66
- }, [model, onClick, disabled, isRemRow])
66
+ }, [model, onClick, disabled, isRemRow, isBatchRemRow])
67
67
 
68
68
  return { button, menuItem };
69
69
  };
@@ -32,7 +32,7 @@ export default function BulkMenu() {
32
32
  批量操作行
33
33
  </Button>
34
34
  </Dropdown>
35
- {addDiscountRowButton.drawer}
35
+ {/* {addDiscountRowButton.drawer} */}
36
36
  </>
37
37
  )
38
38
  }
@@ -60,7 +60,7 @@ const DrawerBody = () => {
60
60
  onRow={(record) => {
61
61
  return {
62
62
  onClick: async () => {
63
- const re = await controller.state.buyerState.onRowClick(record);
63
+ const re = await controller.state.buyerState.onRowClick(record);
64
64
  if (re) {
65
65
  controller.formList.get('buyer')?.setFieldsValue(re);
66
66
  controller.pipeline(async (s) => {