kts-component-invoice-operate 3.2.264 → 3.2.265

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 (31) hide show
  1. package/dist/DifferenceInputModal/demo.d.ts +4 -0
  2. package/dist/DifferenceInputModal/index.d.ts +67 -0
  3. package/dist/Invoice/Invoice-digtal/_test/differenceInput/index.d.ts +4 -0
  4. package/dist/Invoice/InvoiceController/InvoiceControllerState/DifferenceInputState/index.d.ts +9 -0
  5. package/dist/Invoice/InvoiceController/InvoiceControllerState/index.d.ts +3 -0
  6. package/dist/Invoice/_test/differenceInput/index.d.ts +4 -0
  7. package/dist/Invoice/ui/digtal/DifferenceInput/index.d.ts +3 -0
  8. package/dist/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.d.ts +1 -0
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.esm.js +892 -114
  11. package/dist/index.js +889 -110
  12. package/package.json +1 -1
  13. package/src/DifferenceInputModal/demo.tsx +22 -0
  14. package/src/DifferenceInputModal/index.less +102 -0
  15. package/src/DifferenceInputModal/index.md +5 -0
  16. package/src/DifferenceInputModal/index.tsx +450 -0
  17. package/src/Invoice/Invoice-digtal/_test/differenceInput/index.tsx +31 -0
  18. package/src/Invoice/Invoice-digtal/index.md +4 -1
  19. package/src/Invoice/InvoiceController/InvoiceControllerForm/index.ts +8 -2
  20. package/src/Invoice/InvoiceController/InvoiceControllerState/DifferenceInputState/index.ts +13 -0
  21. package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +4 -0
  22. package/src/Invoice/_test/differenceInput/index.tsx +25 -0
  23. package/src/Invoice/index.md +3 -0
  24. package/src/Invoice/index.tsx +18 -6
  25. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +7 -2
  26. package/src/Invoice/ui/default/GoodsList/ui/AddRowButton/index.tsx +4 -0
  27. package/src/Invoice/ui/digtal/DifferenceInput/index.tsx +39 -0
  28. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +15 -4
  29. package/src/Invoice/ui/digtal/GoodsList/ui/AddRowButton/index.tsx +7 -7
  30. package/src/TaxClassificationCodeModal/index.tsx +2 -0
  31. package/src/index.ts +3 -0
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import Invoice from '../..';
3
+ import 'antd/dist/antd.css';
4
+ import { Button } from 'kts-components-antd-x4';
5
+
6
+ export default () => {
7
+
8
+ const controller = React.useMemo(() => new Invoice.InvoiceController(), []);
9
+ const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
10
+ const [loading, setLoading] = React.useState(false);
11
+
12
+ return (
13
+ <div>
14
+ <Button loading={loading} onClick={ async () => {
15
+ setLoading(true);
16
+ await controller.pipeline(async (s) => {
17
+ s.differenceInputState.enabled = !s.differenceInputState.enabled;
18
+ })();
19
+ setLoading(false);
20
+ }}>{enabled ? '关闭差额开票' : '开启差额开票'}</Button>
21
+
22
+ <Invoice invoiceType='default' controller={controller} />
23
+ </div>
24
+ )
25
+ };
@@ -48,6 +48,9 @@
48
48
  ## 设置数据源 赋码 税收分类编码列表
49
49
  <code src="./_test/endowCode/index.tsx"></code>
50
50
 
51
+ ## 差额开票
52
+ <code src="./_test/differenceInput/index.tsx"></code>
53
+
51
54
  <!-- <API name="Invoice 发票组件 API" exports='["default"]' src="./index.tsx" ></API>
52
55
  <API name="InvoiceHeader 发票头 API" exports='["default"]' src="./ui/default/InvoiceHeader/index.tsx"></API>
53
56
  <API name="GoodsList 商品列表 API" exports='["default"]' src="./ui/default/GoodsList/index.tsx"></API>
@@ -31,6 +31,7 @@ import EndowCodeDrawer from './ui/default/EndowCodeDrawer';
31
31
  import AddComparisonDrawer from './ui/default/AddComparisonDrawer';
32
32
  import MeiTanModal from './ui/default/MeiTanModal';
33
33
  import PassengerList from './ui/digtal/PassengerList';
34
+ import DifferenceInput from './ui/digtal/DifferenceInput';
34
35
  // import { create, all } from 'mathjs';
35
36
  // const config = {
36
37
  // number: 'BigNumber',
@@ -154,12 +155,9 @@ const Main = (props: IInvoiceProps) => {
154
155
  const [key, setKey] = React.useState(0);
155
156
 
156
157
  useToGenerateId(controller);
157
-
158
+ // useClearGoodsList(controller);
159
+
158
160
  React.useEffect(() => { setKey(key + 1) }, [controller]);
159
- // React.useEffect(() => {
160
- // setKey(key + 1)
161
- // controller.state.stakeholder.enables = ['taxAmount']
162
- // }, [controller]);
163
161
 
164
162
  return (
165
163
  <InvoiceContext.Provider key={key} value={controller}>
@@ -177,7 +175,8 @@ const Main = (props: IInvoiceProps) => {
177
175
  <ImportGoodsDrawer />{/* 导入货品的抽屉 */}
178
176
  <EndowCodeDrawer />{/* 给货品赋码的抽屉 */}
179
177
  <AddComparisonDrawer />{/* 添加商品对照的抽屉 */}
180
- <MeiTanModal /> {/* 煤炭类弹框 */}
178
+ <DifferenceInput />{/* 差额录入弹框 */}
179
+ <MeiTanModal /> {/* 煤炭类弹框 */}
181
180
  </InvoiceContext.Provider>
182
181
  );
183
182
  };
@@ -190,6 +189,7 @@ const Digtal = (props: IInvoiceProps) => {
190
189
  const [key, setKey] = React.useState(0);
191
190
 
192
191
  useToGenerateId(controller);
192
+ // useClearGoodsList(controller);
193
193
 
194
194
  React.useEffect(() => { setKey(key + 1) }, [controller]);
195
195
 
@@ -208,9 +208,21 @@ const Digtal = (props: IInvoiceProps) => {
208
208
  <ImportGoodsDrawer />{ /** 导入货品的抽屉 */}
209
209
  <ImportPassengerDrawer />{ /** 导入旅客运输的抽屉 */}
210
210
  <EndowCodeDrawer />{ /** 给货品赋码的抽屉 */}
211
+ <DifferenceInput />{/* 差额录入弹框 */}
211
212
  <MeiTanModal /> {/* 煤炭类弹框 */}
212
213
  </InvoiceContext.Provider>
213
214
  )
214
215
  }
215
216
 
216
217
 
218
+ // 切换到差额开票清楚商品列表
219
+ // function useClearGoodsList(controller: InvoiceController) {
220
+ // const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
221
+ // React.useEffect(() => {
222
+ // controller.run(async (s) => {
223
+ // if (enabled) {
224
+ // s.goodsListState.goodsList = [];
225
+ // }
226
+ // })
227
+ // }, [controller, enabled]);
228
+ // }
@@ -13,7 +13,7 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
13
13
  const rootElement = controller.useMemo(s => s.rootElement, []);
14
14
 
15
15
  const autoComplete = controller.useMemo(s => s.autoComplete, [])
16
-
16
+ const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
17
17
  const [options, setOptions] = React.useState<IGood[]>([]);
18
18
 
19
19
  const [selectLine, setSelectLine] = React.useState<any>(null);
@@ -40,10 +40,15 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
40
40
  }
41
41
  setSelectLine(null);
42
42
  }
43
+
44
+ // 失去焦点时,打开差额开票弹窗
45
+ if (enabled) {
46
+ controller.run(async (s) => { s.differenceInputState.open = true });
47
+ }
43
48
  } catch (error) {
44
49
  throw error;
45
50
  }
46
- }, [autoComplete.onItemNameBlur, selectLine, props.editGood])
51
+ }, [autoComplete.onItemNameBlur, selectLine, props.editGood, enabled])
47
52
 
48
53
  const onSearch = React.useCallback(async (searchText: string) => {
49
54
  try {
@@ -22,6 +22,9 @@ export default (props: any) => {
22
22
  /** 产品最大数 */
23
23
  const goodMax = controller.useMemo(s => s.goodsListState.goodMax, []);
24
24
 
25
+ /** 是否是差额开票模式 */
26
+ const isDifferenceInput = controller.useMemo(s => s.differenceInputState.enabled, []);
27
+
25
28
  /** 按钮是否禁用 */
26
29
  const disabled = React.useMemo(() => typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue, [goodMax, goodsNum, searchValue])
27
30
 
@@ -39,6 +42,7 @@ export default (props: any) => {
39
42
  if (isAddRow === false) return <></>;
40
43
  if (model === 'prefab') return <></>;
41
44
  if (model === 'readOnly') return <></>;
45
+ if (isDifferenceInput && goodsNum >= 1) return <></>;
42
46
 
43
47
  return (
44
48
  <Button onClick={onClick} disabled={disabled}>
@@ -0,0 +1,39 @@
1
+
2
+ import { DifferenceInputModal, IData } from "../../../../DifferenceInputModal";
3
+ import React from "react";
4
+ import Invoice from "../../../index";
5
+
6
+ export default () => {
7
+
8
+ const controller = Invoice.useInvoiceController();
9
+ const open = controller.useMemo((s) => s.differenceInputState.open && s.differenceInputState.enabled && !s.goodsListState.importGoods.isVisibleDrawer, []);
10
+ const data = controller.useMemo((s) => s.differenceInputState.data, []);
11
+
12
+ const value = React.useMemo(() => {
13
+ return {
14
+ rows: data?.rows || [],
15
+ projectCode: data?.projectCode || '',
16
+ voucherTotal: data?.voucherTotal || 0,
17
+ deductTotal: data?.deductTotal || 0,
18
+ }
19
+ }, [data, open]);
20
+
21
+ console.log('DifferenceInput data ===>', data)
22
+
23
+ return (
24
+ <DifferenceInputModal
25
+ value={value}
26
+ open={open}
27
+ onCancel={() => {
28
+ controller.run(async (s) => { s.differenceInputState.open = false });
29
+ }}
30
+ onOk={(data: IData) => {
31
+ controller.run(async (s) => {
32
+ s.differenceInputState.data = data;
33
+ s.goodsListState.deduction = data.deductTotal;
34
+ s.differenceInputState.open = false;
35
+ });
36
+ }}
37
+ />
38
+ );
39
+ };
@@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
5
5
  import { IGood, Invoice } from '../../../../../../../..';
6
6
  import './index.less';
7
7
 
8
+ /** 商品名称输入框 */
8
9
  export default function ItemNameInput(props: {
9
10
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void,
10
11
  suffix?: React.ReactNode,
@@ -14,7 +15,7 @@ export default function ItemNameInput(props: {
14
15
  }) {
15
16
 
16
17
  const controller = Invoice.useInvoiceController();
17
-
18
+ const enabled = controller.useMemo((s) => s.differenceInputState.enabled, []);
18
19
  const rootElement = controller.useMemo(s => s.rootElement, []);
19
20
 
20
21
  const autoComplete = controller.useMemo(s => s.autoComplete, [])
@@ -43,10 +44,15 @@ export default function ItemNameInput(props: {
43
44
  }
44
45
  setSelectLine(null);
45
46
  }
47
+
48
+ // 失去焦点时,打开差额开票弹窗
49
+ if (enabled) {
50
+ controller.run(async (s) => { s.differenceInputState.open = true });
51
+ }
46
52
  } catch (error) {
47
53
  throw error;
48
54
  }
49
- }, [autoComplete.onItemNameBlur, selectLine, props.editGood])
55
+ }, [autoComplete.onItemNameBlur, selectLine, props.editGood, enabled])
50
56
 
51
57
  const onChangeAutoComplete = React.useCallback(async (_, i) => {
52
58
  const record = options.filter(e => e.$index === i.value)[0] as any;
@@ -79,8 +85,13 @@ export default function ItemNameInput(props: {
79
85
  options={options.map(e => ({ value: e.$index, label: e.itemName }))}
80
86
  getPopupContainer={() => rootElement || document.body}
81
87
  onSelect={onChangeAutoComplete}
82
- >
83
- <Input style={{ height: '100%' }} onChange={onChange} suffix={props.suffix} onBlur={onBlur} />
88
+ >
89
+ <Input
90
+ style={{ height: '100%' }}
91
+ onChange={onChange}
92
+ suffix={props.suffix}
93
+ onBlur={onBlur}
94
+ />
84
95
  </AutoComplete>
85
96
  </div>
86
97
  )
@@ -13,6 +13,9 @@ export default () => {
13
13
  /** 产品数据量 */
14
14
  const goodsNum = controller.useMemo(s => s.goodsListState.goodsList.length, []);
15
15
 
16
+ /** 是否是差额开票模式 */
17
+ const isDifferenceInput = controller.useMemo(s => s.differenceInputState.enabled, []);
18
+
16
19
  /** 搜索条件 */
17
20
  const searchValue = controller.useMemo(s => s.goodsListState.searchValue, []);
18
21
 
@@ -35,6 +38,7 @@ export default () => {
35
38
  if (isAddRow === false) return <></>;
36
39
  if (model === 'prefab') return <></>;
37
40
  if (model === 'readOnly') return <></>;
41
+ if (isDifferenceInput && goodsNum >= 1) return <></>;
38
42
 
39
43
  return (
40
44
  <Button size='small' type='primary' onClick={onClick} disabled={disabled}>
@@ -45,22 +49,18 @@ export default () => {
45
49
 
46
50
  /** 添加一个空货物 */
47
51
  async function addGood(controller: InvoiceController) {
48
- await controller.formList.get('realEstateInfo')?.validateFields(async (err: any, values: any) => {
49
52
 
53
+ await controller.formList.get('realEstateInfo')?.validateFields(async (err: any, values: any) => {
50
54
  if (err) {
51
55
  message.error('请先填写发票行信息,再添加新的行');
52
56
  return;
53
57
  }
54
58
  });
59
+
55
60
  await controller.saveEditGood();
56
- await controller.wait();
61
+ await controller.wait();
57
62
  await controller.run(async (s) => {
58
63
  if (s.goodsListState.editGood) {
59
- // message.error({
60
- // content: '你正在编辑一个货物',
61
- // key: '你正在编辑一个货物',
62
- // });
63
- // return;
64
64
  const isValidateGood = controller.state.goodsListState.isValidateGood;
65
65
  if (isValidateGood) {
66
66
  await controller.state.goodsListState.form?.validateFields(async (err: any, values: any) => {
@@ -3,6 +3,7 @@ import React from "react";
3
3
  import { Drawer, Input, Tree, Form, Button, Card, FormReadOnly } from "kts-xui";
4
4
  import { Icon, message } from "kts-components-antd-x3";
5
5
  import './index.less';
6
+
6
7
  export interface TaxClassificationProps {
7
8
 
8
9
  /** 是否开启 */
@@ -29,6 +30,7 @@ export interface TaxClassificationProps {
29
30
  info?: any;
30
31
  }
31
32
 
33
+
32
34
  export default function TaxClassificationModal(props: TaxClassificationProps) {
33
35
  const [form] = Form.useForm<any>();
34
36
 
package/src/index.ts CHANGED
@@ -11,3 +11,6 @@ export type { IInvoiceTypeModalProps } from './InvoiceTypeModal';
11
11
  export { default as TaxClassificationModal } from './TaxClassificationCodeModal';
12
12
  export type { TaxClassificationProps } from './TaxClassificationCodeModal';
13
13
 
14
+ /** */
15
+ export { DifferenceInputModal } from './DifferenceInputModal';
16
+ export type { IDifferenceInputModalProps } from './DifferenceInputModal';