mh_jy_safe_web/src/components/CustomPages/BR/WorkWip.js
2025-08-25 10:08:30 +08:00

142 lines
4.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import { connect } from 'dva';
import { Row, Col, Table, Form } from 'antd';
import { Search } from '@woowalker/feui'
import {
initQueryFilter,
empty,
addRuleAndGroups
} from "../../../utils/common";
import styles from '../../Table/listPage.css';
//计划排产
class WorkWip extends React.Component {
constructor(props) {
super(props);
this.state = {
tableData: [],
tableColumns: [],
};
};
componentDidMount() {
this.loadData();
}
handleSearch=(value,code)=>{
this.loadData(value);
}
loadData = (rules) => {
const orgId = this.props.login.OrgId;
let json = initQueryFilter(orgId, 1, 200, "", 0);
if (rules) {
addRuleAndGroups(json,rules);
}
this.props.dispatch({
type: 'app/getDataByPost',
url:'WO/PDTOrder/WorkWip',
payload: json,
onComplete: (ret) => {
if (ret) {
//console.log(ret[0]);
let tableCol = [];
let tabledata = [];
//1.构造table 的columnwidthheight
if(ret.length>0 && !empty(ret[0].titleName)){
ret[0].titleName.forEach((n, i) => {
let colfiled=n.TITLE_KEY;
let col = {
title: n.TITLE_NAME,
key: colfiled,
dataIndex: colfiled,
sorter: (a, b) => i===0?a[colfiled]>b[colfiled]:Number(a[colfiled])-Number(b[colfiled]),
render: (text, record, index) => {
return text;
}
}
tableCol.push(col);
});
}
//console.log(tableCol);
//2.构造data
ret.forEach((x, z) => {
let data = {};
ret[0].titleName.forEach((y,j) => {
data[y.TITLE_KEY] = ret[z][y.TITLE_KEY];
});
tabledata.push(data);
});
this.setState({
//tableData: tabledata,
tableColumns: tableCol,
},()=>{
this.setState({
tableData: tabledata
});
})
}
}
});
}
getSearchComponent = (code) => {
return <Search formId={this.props.formId} onSearch={(value) => this.handleSearch(value, code)} code={code}/>
};
render() {
const paginationConfig = {
pageSizeOptions: ['5', '10', '20', '50', '100'],
//current: this.state.loadParamJson.PageIndex,
pageSize: 10,
total: this.state.tableData.length,
showSizeChanger: true,
size: 'small',
position:'both',
showTotal: () => `${this.state.tableData.length}`
};
return (
<div>
<div style={{marginTop: '25px'}}>
<div>
{this.getSearchComponent('search')}
</div>
{/*<div style={{marginTop: '25px'}}></div>*/}
<Row>
<div style={{marginTop: '25px'}}>
<Col span={24}>
<div className={styles.tableContent}>
<Table
rowKey="ID"
pagination={paginationConfig}
dataSource={this.state.tableData?this.state.tableData:[]}
columns={this.state.tableColumns}
// loading={isLoading}
//onChange={this.changeTable}
//rowClassName={(record, index) => styles[className(record)] }
// rowSelection={this.state.pageTable.SHOW_CHECK ? rowSelection : null}
//expandedRowRender={(this.state.hasChildren ? this.subTable : null)}
// scroll={{ x: '98%' }}
//scroll={{ x: this.state.width,y:this.state.heigth }}
/>
</div>
<div>
当前选中{this.state.tableData.length}条记录
</div>
</Col>
</div>
</Row>
</div>
</div>)
}
}
WorkWip.propTypes = {
};
export default connect(({ login, loading }) => ({ login, loading }))(Form.create()(WorkWip));