提交 7477923c authored 作者: 钟是志's avatar 钟是志

20459 考核批次--添加全选功能

上级 4a68bae9
import React from 'react';
import { Button, message, Modal, Tag, Table } from 'antd';
import FormList from './formList/index';
import { connect } from 'dva';
import React from "react";
import { Button, message, Modal, Table, Tag } from "antd";
import FormList from "./formList/index";
import { connect } from "dva";
@connect(({ DataColumn, SqlManageEntity, loading }) => ({
DataColumn,
......@@ -74,14 +74,43 @@ export default class TableSelect extends React.Component {
selects[kk] = obj;
selects[kk].selectKey = kk;
}
if (!('value' in this.props)) {
this.setState({ selects });
}
this.triggerChange({ selects });
};
selectAll = () => {
let { selects } = this.state;
const { dataSource, json } = this.props;
let { valueName, optionType } = json;
const { list } = dataSource;
console.log(list);
if (optionType == 'reference' && this.props.dataColumn.referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName;
}
if (list && Array.isArray(list)) {
for (let item of list) {
let kk = item[valueName];
selects[kk] = item;
selects[kk].selectKey = kk;
}
}
if (!('value' in this.props)) {
this.setState({ selects });
}
this.triggerChange({ selects });
};
close = (i) => {
cancelAll = () => {
let selects = {};
if (!('value' in this.props)) {
this.setState({ selects });
}
this.triggerChange({ selects });
};
close = (i) => {
var { values, labels } = this.state;
values.splice(i, 1);
labels.splice(i, 1);
......@@ -107,6 +136,7 @@ export default class TableSelect extends React.Component {
this.triggerChange({ visiable: false });
};
render() {
const {
json: { isMultiple, sql, optionType, showTable },
......@@ -157,8 +187,8 @@ export default class TableSelect extends React.Component {
columns3.map((item, index) => {
if (index === columns3.length - 1) {
item.fixed = 'right';
item.width = 50;
allWidth += 50;
item.width = 90;
allWidth += 90;
return item;
}
if (index === columns3.length - 2) {
......@@ -175,6 +205,8 @@ export default class TableSelect extends React.Component {
});
}
// console.log(this.props);
// console.log(this.state);
return (
<div>
{Object.keys(selects).length > 0 ? (
......@@ -238,13 +270,33 @@ export default class TableSelect extends React.Component {
sql={sql}
/>
) : (
<Table
rowKey={valueName}
size="small"
dataSource={dataSource.list}
columns={columns3}
scroll={{ x: allWidth }}
/>
<>
{isMultiple && (
<>
{' '}
<Button
type={'primary'}
style={{ margin: '0 10px 10px 0' }}
onClick={this.selectAll}>
全选
</Button>
<Button
type={'primary'}
style={{ marginBottom: '10px' }}
onClick={this.cancelAll}>
取消全选
</Button>
</>
)}
<Table
rowKey={valueName}
size="small"
dataSource={dataSource.list}
columns={columns3}
scroll={{ x: allWidth }}
/>
</>
)}
</Modal>
)}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论