TabFinancePeriod.js
5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import moment from 'moment';
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Row, Col, message, DatePicker, Button } from 'antd-v4';
import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */
import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */
import styles from '@/index.less';
import commonConfig from '@/utils/config';
import * as commonServices from '@/services/services';
import * as commonUtils from '@/utils/utils';
import * as commonFunc from '@/components/Common/commonFunc';/* 通用方法 */
const FormItem = Form.Item;
class TabFinancePeriodComponent extends Component {
constructor(props) {
super(props);
this.state = {
mode: 'year',
open: false,
value: moment(new Date().getFullYear().toString(), 'YYYY'), /* 年份 */
};
}
handleOpenChange = (open) => {
if (open) {
this.setState({ mode: 'year', open: true });
}
};
handlePanelChange = async (value, mode) => {
const bFilterValue = moment(value).format('YYYY');
this.setState({ mode, open: false, value });
const {
token, sModelsId, sysaccountperiodConfig, masterConfig,
} = this.props;
const condition = {
sSqlCondition: {
sParentId: masterConfig.sId,
},
bFilter: [{
bFilterName: 'sPeriodId',
bFilterValue,
bFilterCondition: 'like',
}],
};
const configDataId = sysaccountperiodConfig.sId;
const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows[0].dataSet;
this.props.onSaveState({ sysaccountperiodData: returnData, year: bFilterValue });
} else {
this.props.getServiceError(dataReturn);
}
};
handleAddData = async () => {
const year = moment(this.state.value).format('YYYY');
const bFilterValue = year - 1;
const {
token, sModelsId, sysaccountperiodConfig, masterConfig,
} = this.props;
const condition = {
sSqlCondition: {
sParentId: masterConfig.sId,
},
bFilter: [{
bFilterName: 'sPeriodId',
bFilterValue,
bFilterCondition: 'like',
}],
};
const configDataId = sysaccountperiodConfig.sId;
const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows[0].dataSet;
if (commonUtils.isEmptyObject(returnData)) {
message.error('请先添加上一年度数据');
} else {
returnData.forEach((row, index) => {
returnData[index].bAP = false;
returnData[index].bAR = false;
returnData[index].bFrozen = false;
returnData[index].sId = commonUtils.createSid();
returnData[index].sPeriodId = (Number(returnData[index].sPeriodId) + 100).toString();
returnData[index].tEndDate = moment(returnData[index].tEndDate, 'YYYY-MM-DD HH:mm:ss').add(1, 'years').format('YYYY-MM-DD HH:mm:ss');
returnData[index].tStartDate = moment(returnData[index].tStartDate, 'YYYY-MM-DD HH:mm:ss').add(1, 'years').format('YYYY-MM-DD HH:mm:ss');
// returnData[index].tForzenDate = '';
// returnData[index].tARDate = '';
// returnData[index].tAPDate = '';
returnData[index].handleType = 'add';
});
}
this.props.onSaveState({ sysaccountperiodData: returnData });
} else {
this.props.getServiceError(dataReturn);
}
};
render() {
const { open, value, mode } = this.state;
const { enabled, app } = this.props;
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 15 } };
const Year = commonFunc.showMessage(app.commonConst, 'Year');/* 年度 */
const BtnDefaultValueIncrease = commonFunc.showMessage(app.commonConst, 'BtnDefaultValueIncrease');/* 默认值增加 */
return (
<FormItem className={styles.searchSlaveForm}>
<div className={styles.tableOptionSys}>
<Row>
<Col span={6}>
<FormItem
{...formItemLayout}
label={Year}
>
<DatePicker
format="YYYY"
open={open}
value={value}
mode={mode}
onOpenChange={this.handleOpenChange}
onPanelChange={this.handlePanelChange}
/>
</FormItem>
</Col>
<Col span={6}>
<Button disabled={!enabled} onClick={this.handleAddData} >{BtnDefaultValueIncrease}</Button>
</Col>
</Row>
<div className="financePeriod">
<StaticEditTable {...commonBusiness.getTableTypes('sysaccountperiod', this.props)} />
</div>
</div>
</FormItem>
);
}
}
export default TabFinancePeriodComponent;