CommonClassify.js
6.39 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* eslint-disable */
/* eslint-disable array-callback-return,no-undef */
import React, { Component } from 'react';
import { Form } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Layout, Spin } from 'antd';
import styles from '@/index.less';
import Toolbar from '@/components/Common/ToolBar/ToolBarNew';
import CommonBase from '@/components/Common/CommonBase';
import CommonClassifyEvent from '@/components/Common/CommonClassifyEvent';
import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */
import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */
import SearchComponent from '@/components/Common/SearchComponent';/* 搜索组件 */
import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
import * as commonFunc from '@/components/Common/commonFunc';/* 通用单据方法 */ /* 通用单据方法 */
import * as commonUtils from '@/utils/utils';
import * as commonConfig from '@/utils/config';
const { Header, Content } = Layout;
class CommonClassify extends Component {
constructor(props) {
super(props);
this.state = {
};
}
handleCancelModal = (modelVisible) => {
this.props.onSaveState({
[modelVisible]: false,
});
}
/** 获取过滤树数据数据 */
handleGetFilterTreeData= (slaveConfig, slaveFilterCondition, page, slaveOrderBy, props) => {
const { app } = props === undefined ? this.props : props;
const { conditonValues } = app.currentPane;
const pageNum = commonUtils.isEmpty(page) ? 1 : page;
this.props.handleGetTreeDataSet({
name: 'slave',
configData: slaveConfig,
condition: {
pageNum, pageSize: commonConfig.pageSize, bFilter: slaveFilterCondition, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues,
},
flag: true,
clearSelectData: true,
});
};
render() {
const { pageLoading } = this.props;
return (
<div>
<Spin spinning={pageLoading}>
<div>
<CommonClassifyComponent
{...this.props}
{...this.state}
onCancelModal={this.handleCancelModal}
onGetFilterTreeData={this.handleGetFilterTreeData}
/>
</div>
</Spin>
</div>
);
}
}
const CommonClassifyComponent = Form.create({
mapPropsToFields(props) {
const { masterData } = props;
const obj = commonFunc.mapPropsToFields(masterData, Form);
return obj;
},
})((props) => {
const {
form, onReturnForm, slavePagination, slaveData, sModelsType, app, slaveConfig,
} = props;
/* 回带表单 */
onReturnForm(form);
const pagination = {
pageSize: commonUtils.isNotEmptyNumber(props.iPageSize) && props.iPageSize !== 0 ? props.iPageSize : commonConfig.pageSize,
...slavePagination,
onChange: props.onPaginationChange,
size: 'large',
// pageSize: commonUtils.isEmptyArr(slaveData) ? 0 : slaveData.length,
showQuickJumper: true,
hideOnSinglePage: true,
};
// eslint-disable-next-line no-unused-vars
const paginationEnabled = {
pageSize: commonUtils.isNotEmptyNumber(props.iPageSize) && props.iPageSize !== 0 ? props.iPageSize : commonConfig.pageSize,
total: commonUtils.isEmptyArr(slaveData) ? 0 : slaveData.length,
current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
size: 'large',
// pageSize: commonUtils.isEmptyArr(slaveData) ? 0 : slaveData.length,
showQuickJumper: true,
hideOnSinglePage: true,
};
let bTree = false;
if ((sModelsType === 'commonClassify/materialsClassify' || (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('children'))) && commonUtils.isNotEmptyArr(slaveData)) {
bTree = true;
}
/* 若关联性sSqlCondition配置 则取配置 */
let keyField = 'sId';
let keyParentField = 'sParentId';
let sSqlCondition = '';
if (commonUtils.isNotEmptyObject(slaveConfig)) {
sSqlCondition = slaveConfig.sSqlCondition;
if (commonUtils.isNotEmptyObject(sSqlCondition) && commonUtils.isNotEmptyArr(sSqlCondition.split('.')) && sSqlCondition.split('.').length > 2) {
keyField = sSqlCondition.split('.')[1];
keyParentField = sSqlCondition.split('.')[2];
}
}
const slaveTableProps = {
...commonBusiness.getTableTypes('slave', props),
tableProps: { pagination, onChange: props.onTitleChange },
bRowClick: true, /* 处理多选状态下 修改行字段 选不中问题 */
// tableProps: commonUtils.isEmpty(props.enabled) ? { pagination, onChange: props.onTitleChange } : { paginationEnabled, onChange: props.onTitleChangeEnabled },
data: bTree && commonUtils.isNotEmptyArr(slaveData) ? commonUtils.genTreeByArr(slaveData, keyField, keyParentField) : slaveData,
};
const sReportParams = commonUtils.isNotEmptyObject(commonFunc.showMessage(app.commonConst, 'sReportParams')) ?
commonFunc.showMessage(app.commonConst, 'sReportParams') : '上报参数标准';
const sParamProps = {
...commonBusiness.getTableTypes('sParam', props),
tableProps: {
rowKey: 'sId',
pagination,
onChange: props.onTitleChange,
sModelsType,
AutoTableHeight: 350,
rowSelection: null,
},
bRowClick: true,
enabled: props.enabled,
};
const onOkProps = {
disabled: !props.enabled,
};
return (
<Form>
<Layout>
<Header className={styles.header}>
<Toolbar {...props} />
</Header>
<Layout className={styles.clayout}>
<div className={styles.filterContent}>
<SearchComponent {...props} />
</div>
<Content className="xly-normal-list other-list">
<StaticEditTable {...slaveTableProps} footer="hidden" noVlist />
</Content>
</Layout>
</Layout>
{
props.sParamsModalVisible ?
<AntdDraggableModal
width="800px"
className="paramModal"
title={sReportParams}
visible={props.sParamsModalVisible}
onOk={props.onReportParamsOk}
okButtonProps={onOkProps}
onCancel={props.onCancelModal.bind(this, 'sParamsModalVisible')}
// footer={null}
>
<div className="xly-bill-list" >
<StaticEditTable {...sParamProps} footer="hidden" noVlist />
</div>
</AntdDraggableModal> : ''
}
</Form>
);
});
export default CommonBase(CommonClassifyEvent(CommonClassify));