kts-component-invoice-operate 3.2.220-chinaship → 3.2.221-chinaship

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.220-chinaship",
3
+ "version": "3.2.221-chinaship",
4
4
  "scripts": {
5
5
  "dev": "dumi dev --max-old-space-size=6096",
6
6
  "start": "dumi dev",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import Invoice from '../../..';
3
3
  import moment from 'moment';
4
4
  import 'antd/dist/antd.css';
5
-
5
+ import { Button } from 'kts-components-antd-x3';
6
6
  export default () => {
7
7
 
8
8
  const controller = React.useMemo(() => new Invoice.InvoiceController(), []);
@@ -11,12 +11,27 @@ export default () => {
11
11
  controller.run(async s => {
12
12
  })
13
13
  }, [])
14
-
14
+ const onSave = async () => {
15
+ const formValues = await controller.validateFields();
16
+ console.log(formValues)
17
+ }
15
18
  return (
16
- <Invoice
17
- invoiceType='digtal'
18
- controller={controller}
19
- specialInfor={<Invoice.RealEstateInfo />}
20
- />
19
+ <>
20
+ <Button onClick={onSave}>输出表单内容</Button>
21
+ <Invoice
22
+ invoiceType='digtal'
23
+ controller={controller}
24
+ specialInfor={<Invoice.RealEstateInfo realEstateAddressOptions={[
25
+ {
26
+ "code": "11",
27
+ "name": "北京市"
28
+ }] || []}
29
+ realEstateAddressFieldNames={{
30
+ label: 'name',
31
+ value: 'name',
32
+ children: 'children'
33
+ }} />}
34
+ />
35
+ </>
21
36
  )
22
37
  };
@@ -1,7 +1,7 @@
1
1
  # 数电
2
2
 
3
- ## 简单用法
4
- <code src="./_test/easiest/index.tsx"></code>
3
+ <!-- ## 简单用法
4
+ <code src="./_test/easiest/index.tsx"></code> -->
5
5
 
6
6
  <!-- ## 建筑服务
7
7
  <code src="./_test/architecture/index.tsx"></code> -->
@@ -33,8 +33,7 @@
33
33
  ## 查看当前可用授信额度
34
34
  <code src="./_test/lineCredit/index.tsx"></code>
35
35
 
36
- ## 不动产经营租赁服务
37
- <code src="./_test/realEstateInfo/index.tsx"></code>
36
+
38
37
 
39
38
  -->
40
39
 
@@ -68,4 +68,6 @@ export default class InvoiceControllerState {
68
68
  * 货物运输列表
69
69
  */
70
70
  freightListState = new FreightListState();
71
+
72
+ addGoodsCheck?: any;
71
73
  }
@@ -1,12 +1,18 @@
1
1
  import React from 'react';
2
- import { Input } from 'kts-components-antd-x3';
2
+ import { Input, message } from 'kts-components-antd-x3';
3
3
  import Invoice from '../../';
4
4
  import 'antd/dist/antd.css';
5
5
 
6
6
  export default () => {
7
7
 
8
8
  const controller = React.useMemo(() => new MyController1(), [])
9
+ React.useEffect(() => {
10
+ controller.run(async s => {
11
+ s.addGoodsCheck=checkGood;
12
+
9
13
 
14
+ })
15
+ }, [])
10
16
  const [deduction, setDeduction] = React.useState<number | undefined>(0);
11
17
 
12
18
  const [goodMax, setgoodMax] = React.useState(0);
@@ -29,17 +35,33 @@ export default () => {
29
35
  </span>
30
36
  )
31
37
  }, [])
38
+ const checkGood = async () => {
39
+ await new Promise((resolve,) => {
40
+ setTimeout(() => {
41
+ const a = Math.random();
42
+ if (a > 0.5) {
43
+ message.error('请先填写发票行信息,再添加新的行');
44
+ return false;
45
+ } else {
46
+ resolve(true)
47
+ console.log(11112)
48
+ }
32
49
 
50
+ }, 1000)
51
+ })
52
+ }
33
53
  return (
34
54
  <Invoice
35
55
  controller={controller}
36
56
  goodsList={
37
57
  <Invoice.GoodsList
38
- isSwitchTax={false} // 是否可以切换(含税/不含税)状态
39
- isAddDiscount={false} // 不能添加折扣行
40
- goodMax={goodMax} // 控制能可以添加的货物函数
41
- deduction={deduction} // 扣除额
42
- menuExpansion={menuExpansion} // 扩展
58
+
59
+ // addGoodsCheck={checkGood}
60
+ // isSwitchTax={false} // 是否可以切换(含税/不含税)状态
61
+ // isAddDiscount={false} // 不能添加折扣行
62
+ // goodMax={goodMax} // 控制能可以添加的货物函数
63
+ // deduction={deduction} // 扣除额
64
+ // menuExpansion={menuExpansion} // 扩展
43
65
  />
44
66
  }
45
67
  />
@@ -7,12 +7,12 @@
7
7
  <code src="./_test/draft/index.tsx" title="类似的操作,请查看API" ></code>
8
8
 
9
9
  ## 设置购买方名称搜索
10
- <code src="./_test/buyerNameSearch/index.tsx"></code>
10
+ <code src="./_test/buyerNameSearch/index.tsx"></code> -->
11
11
 
12
12
  ## 设置扣除额(差额征税)
13
13
  <code src="./_test/deduction/index.tsx"></code>
14
14
 
15
- ## 设置单位列表、税率列表
15
+ <!-- ## 设置单位列表、税率列表
16
16
  <code src="./_test/unit/index.tsx" ></code>
17
17
 
18
18
  ## 发票头类型设置和购买方信息配置
@@ -47,6 +47,8 @@ export interface IGoodsListProps {
47
47
 
48
48
  /** 是否可以切换(含税/不含税)状态 */
49
49
  isSwitchTax?: boolean;
50
+
51
+ addGoodsCheck?:()=>void;
50
52
  }
51
53
 
52
54
  export default class GoodsList extends React.Component<IGoodsListProps>{
@@ -137,7 +139,7 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
137
139
  <div className="kts-invoice-operate-goods-list-able">
138
140
  <div className="kts-invoice-operate-goods-list-able-list">
139
141
  {/* 添加行 */}
140
- <AddRowButton />
142
+ <AddRowButton addGoodsCheck={props.addGoodsCheck}/>
141
143
 
142
144
  {/* 批量菜单 */}
143
145
  {/* <BulkMenu /> */}
@@ -3,7 +3,7 @@ import Invoice from '../../../../..';
3
3
  import { Button, message } from 'kts-components-antd-x3';
4
4
  import InvoiceController, { LineAttributeType } from '../../../../../InvoiceController';
5
5
 
6
- export default () => {
6
+ export default (props: any) => {
7
7
  const controller = Invoice.useInvoiceController();
8
8
 
9
9
  const model = controller.useMemo(s => s.model, []);
@@ -26,6 +26,12 @@ export default () => {
26
26
  const disabled = React.useMemo(() => typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue, [goodMax, goodsNum, searchValue])
27
27
 
28
28
  const onClick = React.useCallback(async () => {
29
+ await controller.run(async (s) => {
30
+ if (s.addGoodsCheck) {
31
+ await s.addGoodsCheck();
32
+ }
33
+ });
34
+ console.log('continue')
29
35
  await addGood(controller);
30
36
  await rollBottom(controller, rootElement);
31
37
  }, [controller, rootElement]);
@@ -43,6 +49,7 @@ export default () => {
43
49
 
44
50
  /** 添加一个空货物 */
45
51
  async function addGood(controller: InvoiceController) {
52
+
46
53
  await controller.saveEditGood();
47
54
  await controller.wait();
48
55
  await controller.run(async (s) => {
@@ -40,7 +40,7 @@ export default decorator<RealEstateInfoProps, FormComponentProps & RealEstateInf
40
40
 
41
41
  return (
42
42
  <div className="kts-invoice-operate-real-estate-info-digtal">
43
- <div className='real-estate-info-digtal-label' >特殊信息-建筑服务</div>
43
+ <div className='real-estate-info-digtal-label' >特定信息-建筑服务</div>
44
44
  <Row gutter={[17, 0]}>
45
45
  <Col span={6} >
46
46
  <Form.Item label='土地增值税项目编号' >
@@ -94,7 +94,7 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
94
94
  // controller.useForm('freightInfo', form);
95
95
  return (
96
96
  <div className="kts-invoice-operate-freight">
97
- <div className='real-estate-info-digtal-label' >特殊信息-货物运输</div>
97
+ <div className='real-estate-info-digtal-label' >特定信息-货物运输</div>
98
98
  <div className="kts-invoice-operate-goods-list-digtal" onClick={(e) => { e.stopPropagation() }} >
99
99
  <div className="kts-invoice-operate-freight-list-able">
100
100
  {/* 添加行 */}
@@ -257,14 +257,14 @@ export default (form: WrappedFormUtils) => {
257
257
  { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '数量必须为数字' },
258
258
  {
259
259
  validator: async (_, value, callback) => {
260
-
260
+
261
261
  if (isValidateGood) {
262
262
  await controller.wait();
263
263
  const isvalue = !!value || value === 0;
264
264
  const isPrice = !!getFieldValue(isTaxIncluded ? 'priceIncludeTax' : 'priceExcludeTax') || getFieldValue(isTaxIncluded ? 'priceIncludeTax' : 'priceExcludeTax') === 0;
265
265
  if (isvalue || isPrice === isvalue) return;
266
266
  callback('请输入数量');
267
- }else{
267
+ } else {
268
268
  callback();
269
269
  }
270
270
  }
@@ -473,7 +473,7 @@ export default (form: WrappedFormUtils) => {
473
473
  key: 'taxRate',
474
474
  align: 'right',
475
475
  width: 70,
476
- render: (value: string, record: IGood) => {
476
+ render: (value: string|number, record: IGood) => {
477
477
  if (editGood?.$index === record.$index && !disableds.includes('taxRate') && !(model === 'prefab' && calculateType === '3')) {
478
478
  return (
479
479
  <Form.Item>
@@ -508,7 +508,7 @@ export default (form: WrappedFormUtils) => {
508
508
  </Form.Item>
509
509
  );
510
510
  } else {
511
- if (value || value === '0') {
511
+ if (value || value === '0' || value === 0) {
512
512
  return <span style={{ padding: '0 10px' }}>{isDutyFree(record) ? '免税' : `${value}%`}</span>;
513
513
  } else {
514
514
  return ''
@@ -45,6 +45,13 @@ export default () => {
45
45
 
46
46
  /** 添加一个空货物 */
47
47
  async function addGood(controller: InvoiceController) {
48
+ await controller.formList.get('realEstateInfo')?.validateFields(async (err: any, values: any) => {
49
+
50
+ if (err) {
51
+ message.error('请先填写发票行信息,再添加新的行');
52
+ return;
53
+ }
54
+ });
48
55
  await controller.saveEditGood();
49
56
  await controller.wait();
50
57
  await controller.run(async (s) => {
@@ -12,4 +12,11 @@
12
12
  .ktsAnt3x-row.ktsAnt3x-form-item {
13
13
  margin-bottom: 0;
14
14
  }
15
+ .ktsAntX-row{
16
+ border-bottom: 1px dashed #9F613E;
17
+ &:last-child {
18
+ border-bottom: none;
19
+ }
20
+ }
21
+
15
22
  }
@@ -1,5 +1,5 @@
1
1
 
2
- import React from "react";
2
+ import React, { useEffect } from "react";
3
3
  import { decorator } from 'grey-react-box';
4
4
  import { Form } from 'kts-components-antd-x3';
5
5
  import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
@@ -36,110 +36,160 @@ export default decorator<RealEstateInfoProps, FormComponentProps & RealEstateInf
36
36
 
37
37
  const readOnly = React.useMemo(() => model === 'readOnly', [model]);
38
38
 
39
+ const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
40
+ const indexRef = React.useRef<any>([]);
41
+ useEffect(() => {
42
+ const dd = goodsList?.reduce((acc: any, cur: any) => {
43
+ if (cur.lineAttribute !==1) {
44
+ acc.push(cur.$index)
45
+ }
46
+ return acc
47
+ }, [])
48
+ indexRef.current = dd;
49
+ }, [goodsList, indexRef])
39
50
  // 注册 form
51
+
40
52
  controller.useForm('realEstateInfo', form);
41
-
53
+ const getList = () => {
54
+ const decrease = indexRef.current.length > goodsList.length
55
+ if (decrease) {
56
+ //已删行列表
57
+ const diff = indexRef.current.filter((item: any) => !goodsList.find(i => i.$index === item));
58
+
59
+ const formData: any[] = form.getFieldValue('realEstateDataDto');
60
+ if (Array.isArray(formData) && diff.length > 0) {
61
+
62
+ const newForm = formData?.filter(item => !diff.find((i: any) => i === item.$index));
63
+
64
+ form.setFieldsValue({
65
+ realEstateDataDto: newForm
66
+ });
67
+ } else {
68
+ form.setFieldsValue({
69
+ realEstateDataDto: undefined
70
+ });
71
+ }
72
+ }
73
+ console.log('goodsList',goodsList)
74
+ return goodsList.filter(item=>item.lineAttribute !== 1).map((item, index) => {
75
+ if (item.lineAttribute !== 1) {
76
+ return <Row gutter={[17, 0]} >
77
+ <Col span={6} >
78
+ <Form.Item style={{ display: 'none' }}>
79
+ {getFieldDecorator(`realEstateDataDto[${index}].$index`, {
80
+ initialValue: item.$index,
81
+ })(
82
+ <Input />
83
+ )}
84
+ </Form.Item>
85
+ <Form.Item label='不动产地址'>
86
+ {getFieldDecorator(`realEstateDataDto[${index}].realEstateAddress`, {
87
+ rules: readOnly ? [] : [{ required: true, message: '请选择不动产地址' }]
88
+ })(
89
+ readOnly
90
+ ? (<MyArrString />)
91
+ : (<Cascader
92
+ style={{ width: '100%' }}
93
+ options={props.realEstateAddressOptions}
94
+ fieldNames={props.realEstateAddressFieldNames}
95
+ placeholder="请选择省市区县"
96
+ />)
97
+ )}
98
+ </Form.Item>
99
+ </Col>
100
+ <Col span={6} >
101
+ <Form.Item label='详细地址' >
102
+ {getFieldDecorator(`realEstateDataDto[${index}].realEstateDetailedAddress`, {
103
+ rules: readOnly ? [] : [
104
+ { required: true, message: '请输入详细地址' },
105
+ { max: 120, message: '详细地址最多120个字符' },
106
+ {
107
+ validator: async (_, value, callback) => {
108
+ const pattern = /街|路|村|乡|镇|道|巷|号/;
109
+ if (pattern.test(value)) {
110
+ callback()
111
+ } else {
112
+ callback('地址必须包含“街”、“路”、“村”、“乡”、“镇”、“道”、“巷”、“号”等任意一个关键词')
113
+ }
114
+ }
115
+ }
116
+ ]
117
+ })(
118
+ readOnly
119
+ ? <MyDiv />
120
+ : <Input autoComplete='off' placeholder="请输入详细地址" />
121
+ )}
122
+ </Form.Item>
123
+ </Col>
124
+ <Col span={6} >
125
+ <Form.Item label='租赁期起止' >
126
+ {getFieldDecorator(`realEstateDataDto[${index}].leaseTerm`, {
127
+ rules: readOnly ? [] : [{ required: true, message: '请输入租赁期' }]
128
+ })(
129
+ readOnly
130
+ ? <MyArrMoment />
131
+ : <RangePicker style={{ width: '100%' }} />
132
+ )}
133
+ </Form.Item>
134
+ </Col>
135
+ <Col span={6} >
136
+ <Form.Item label='跨地(市)标志' >
137
+ {getFieldDecorator(`realEstateDataDto[${index}].crossCitiesSign`, {
138
+ rules: readOnly ? [] : [
139
+ { required: true, message: '请选择跨地(市)标志' }
140
+ ]
141
+ })(
142
+ readOnly
143
+ ? <MyNY />
144
+ : <Select placeholder='请选择' style={{ width: '100%' }} >
145
+ <Select.Option value='Y'>是</Select.Option>
146
+ <Select.Option value='N'>否</Select.Option>
147
+ </Select>
148
+ )}
149
+ </Form.Item>
150
+ </Col>
151
+ <Col span={6} >
152
+ <Form.Item label='产权证书/不动产权证号' >
153
+ {getFieldDecorator(`realEstateDataDto[${index}].realEstateNumber`, {
154
+ rules: readOnly ? [] : [
155
+ { required: true, message: '请输入证书编号,若没有证书填写“无”' },
156
+ { max: 40, message: '证书编号最多40个字符' },
157
+ ]
158
+ })(
159
+ readOnly
160
+ ? <MyDiv />
161
+ : <Input autoComplete='off' placeholder="请输入证书编号,若没有证书填写“无”" />
162
+ )}
163
+ </Form.Item>
164
+ </Col>
165
+ <Col span={6} >
166
+ <Form.Item label='面积单位' >
167
+ {getFieldDecorator(`realEstateDataDto[${index}].realEstateUnit`, {
168
+ rules: readOnly ? [] : [{ required: true, message: '请选择面积单位' }]
169
+ })(
170
+ readOnly
171
+ ? <MyDiv />
172
+ : <Select placeholder='请选择' style={{ width: '100%' }} >
173
+ <Select.Option value="平方千米">平方千米</Select.Option>
174
+ <Select.Option value="平方米">平方米</Select.Option>
175
+ <Select.Option value="公顷">公顷</Select.Option>
176
+ <Select.Option value="亩">亩</Select.Option>
177
+ <Select.Option value="h㎡">h㎡</Select.Option>
178
+ <Select.Option value="k㎡">k㎡</Select.Option>
179
+ <Select.Option value="㎡">㎡</Select.Option>
180
+ </Select>
181
+ )}
182
+ </Form.Item>
183
+ </Col>
184
+ </Row>
185
+ }
186
+ })
187
+ }
42
188
  return (
43
189
  <div className="kts-invoice-operate-real-estate-info-digtal">
44
- <div className='real-estate-info-digtal-label' >特殊信息-不动产经营租赁服务</div>
45
- <Row gutter={[17, 0]}>
46
- <Col span={6} >
47
- <Form.Item label='不动产地址' >
48
- {getFieldDecorator('realEstateAddress', {
49
- rules: readOnly ? [] : [{ required: true, message: '请选择不动产地址' }]
50
- })(
51
- readOnly
52
- ? (<MyArrString />)
53
- : (<Cascader
54
- style={{ width: '100%' }}
55
- options={props.realEstateAddressOptions}
56
- fieldNames={props.realEstateAddressFieldNames}
57
- placeholder="请选择省市区县"
58
- />)
59
- )}
60
- </Form.Item>
61
- </Col>
62
- <Col span={6} >
63
- <Form.Item label='详细地址' >
64
- {getFieldDecorator('realEstateDetailedAddress', {
65
- rules: readOnly ? [] : [
66
- { required: true, message: '请输入详细地址' },
67
- { max: 120, message: '详细地址最多120个字符' },
68
- {
69
- validator: (_, value) => {
70
- const pattern = /街|路|村|乡|镇|道|巷|号/;
71
- return pattern.test(value) ? Promise.resolve() : Promise.reject('地址必须包含“街”、“路”、“村”、“乡”、“镇”、“道”、“巷”、“号”等任意一个关键词');
72
- }
73
- }
74
- ]
75
- })(
76
- readOnly
77
- ? <MyDiv />
78
- : <Input autoComplete='off' placeholder="请输入详细地址" />
79
- )}
80
- </Form.Item>
81
- </Col>
82
- <Col span={6} >
83
- <Form.Item label='租赁期起止' >
84
- {getFieldDecorator('leaseTerm', {
85
- rules: readOnly ? [] : [{ required: true, message: '请输入租赁期' }]
86
- })(
87
- readOnly
88
- ? <MyArrMoment />
89
- : <RangePicker style={{ width: '100%' }} />
90
- )}
91
- </Form.Item>
92
- </Col>
93
- <Col span={6} >
94
- <Form.Item label='跨地(市)标志' >
95
- {getFieldDecorator('crossCitiesSign', {
96
- rules: readOnly ? [] : [
97
- { required: true, message: '请选择跨地(市)标志' }
98
- ]
99
- })(
100
- readOnly
101
- ? <MyNY />
102
- : <Select placeholder='请选择' style={{ width: '100%' }} >
103
- <Select.Option value='Y'>是</Select.Option>
104
- <Select.Option value='N'>否</Select.Option>
105
- </Select>
106
- )}
107
- </Form.Item>
108
- </Col>
109
- <Col span={6} >
110
- <Form.Item label='产权证书/不动产权证号' >
111
- {getFieldDecorator('realEstateNumber', {
112
- rules: readOnly ? [] : [
113
- { required: true, message: '请输入证书编号,若没有证书填写“无”' },
114
- { max: 40, message: '证书编号最多40个字符' },
115
- ]
116
- })(
117
- readOnly
118
- ? <MyDiv />
119
- : <Input autoComplete='off' placeholder="请输入证书编号,若没有证书填写“无”" />
120
- )}
121
- </Form.Item>
122
- </Col>
123
- <Col span={6} >
124
- <Form.Item label='面积单位' >
125
- {getFieldDecorator('realEstateUnit', {
126
- rules: readOnly ? [] : [{ required: true, message: '请选择面积单位' }]
127
- })(
128
- readOnly
129
- ? <MyDiv />
130
- : <Select placeholder='请选择' style={{ width: '100%' }} >
131
- <Select.Option value="平方千米">平方千米</Select.Option>
132
- <Select.Option value="平方米">平方米</Select.Option>
133
- <Select.Option value="公顷">公顷</Select.Option>
134
- <Select.Option value="亩">亩</Select.Option>
135
- <Select.Option value="h㎡">h㎡</Select.Option>
136
- <Select.Option value="k㎡">k㎡</Select.Option>
137
- <Select.Option value="㎡">㎡</Select.Option>
138
- </Select>
139
- )}
140
- </Form.Item>
141
- </Col>
142
- </Row>
190
+ <div className='real-estate-info-digtal-label' >特定信息-不动产经营租赁服务</div>
191
+ {getList()}
192
+
143
193
  </div>
144
194
  )
145
195
  })
@@ -172,7 +222,7 @@ class MyArrMoment extends React.Component<{ value?: moment.Moment[], style?: Rea
172
222
  <div style={this.props.style}>
173
223
  <span>{moment.isMoment(value[0]) && value[0].format('YYYY-MM-DD')}</span>
174
224
  <span style={{ color: '#9F603D', fontWeight: 600 }} > - </span>
175
- <span>{moment.isMoment(value[1]) && value[0].format('YYYY-MM-DD')}</span>
225
+ <span>{moment.isMoment(value[1]) && value[1].format('YYYY-MM-DD')}</span>
176
226
  </div>
177
227
  )
178
228
  }