Commit 81675eed by end

修改

parent 177a9418
No preview for this file type
......@@ -62,6 +62,7 @@
"react-dnd": "^2.6.0",
"react-dnd-html5-backend": "^2.6.0",
"react-dom": "^16.13.1",
"react-image-crop": "^11.0.10",
"react-intl-universal": "^2.2.5",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
......
......@@ -96,6 +96,7 @@ class InfoComment extends React.Component {
visible: false,
value: 3,
a: 1,
selectedRowKeys: [], // 新增:存储选中行的 key
};
this.columns = [
{
......@@ -202,6 +203,10 @@ class InfoComment extends React.Component {
this.handleDown = this.handleDown.bind(this);
this.downloadCommentFun = this.downloadCommentFun.bind(this);
this.seta = this.seta.bind(this);
this.handleRowSelectChange = this.handleRowSelectChange.bind(this); // 新增:绑定行选择变化处理函数
this.batchDown = this.batchDown.bind(this); // 新增:绑定批量下架处理函数
this.batchUp = this.batchUp.bind(this); // 新增:绑定批量上架处理函数
this.batchDelete = this.batchDelete.bind(this); // 新增:绑定批量删除处理函数
}
componentDidMount() {
......@@ -326,25 +331,87 @@ class InfoComment extends React.Component {
pageSize: size,
});
}
// 新增:行选择变化处理函数
handleRowSelectChange(selectedRowKeys) {
this.setState({ selectedRowKeys });
}
// 新增:批量下架处理函数
batchDown() {
const { selectedRowKeys } = this.state;
const { commentlist } = this.props;
const selectedRecords = commentlist.list.filter(record =>
selectedRowKeys.includes(record.id)
);
selectedRecords.forEach(record => {
if (!record.state) {
this.handleDown(record.id, record);
}
});
}
// 新增:批量上架处理函数
batchUp() {
const { selectedRowKeys } = this.state;
const { commentlist } = this.props;
const selectedRecords = commentlist.list.filter(record =>
selectedRowKeys.includes(record.id)
);
selectedRecords.forEach(record => {
if (record.state) {
this.handleUp(record.id, record);
}
});
}
// 新增:批量删除处理函数
batchDelete() {
const { selectedRowKeys } = this.state;
const { commentlist } = this.props;
const selectedRecords = commentlist.list.filter(record =>
selectedRowKeys.includes(record.id)
);
selectedRecords.forEach(record => {
this.tpCommentDel(record.id, record);
});
}
render() {
const { value } = this.state;
const { value, selectedRowKeys } = this.state;
const { commentlist } = this.props;
const rowSelection = {
selectedRowKeys,
onChange: this.handleRowSelectChange,
};
return (
<div className={styles.comment}>
<div className={styles.mar40}>
{/* <span>
<h2>{this.props.name}</h2>
<Row style={{ top: "-10px" }}>
<Col span={4} key={4} style={{ float: "right" }}>
<Popconfirm
title="确定下载评论信息?"
onConfirm={this.downloadCommentFun}
>
<Button type="primary">下载评论信息</Button>
</Popconfirm>
</Col>
</Row>
</span> */}
{/* 新增:批量操作按钮 */}
<div style={{ marginBottom: 16 }}>
<Button
type="primary"
style={{marginRight:'10px'}}
onClick={this.batchDown}
disabled={selectedRowKeys.length === 0}
>
批量下架
</Button>
<Button
type="primary"
style={{marginRight:'10px'}}
onClick={this.batchUp}
disabled={selectedRowKeys.length === 0}
>
批量上架
</Button>
<Button
type="danger"
onClick={this.batchDelete}
disabled={selectedRowKeys.length === 0}
>
批量删除
</Button>
</div>
<Table
columns={this.columns}
dataSource={commentlist.list}
......@@ -354,6 +421,7 @@ class InfoComment extends React.Component {
onExpand={this.handleExpand}
pagination={false}
rowKey="id"
rowSelection={rowSelection} // 新增:添加行选择属性
/>
<Pagination
className={styles.comment_pagination}
......
......@@ -166,7 +166,13 @@ class App extends React.Component {
},
};
}
const organizations = [
"安控管理党支部",
"设备工程党支部",
"机电运行党支部",
"机关、业务、IT党支部",
"系统运行党支部"
];
// debugger
return (
<div style={{ textAlign: "left" }}>
......@@ -364,20 +370,28 @@ class App extends React.Component {
<Col span={16}>
{getFieldDecorator("organizer", {
initialValue:
trainfirstinfo !== "" ? trainfirstinfo.organizer : "", //bug-11153-liyuan 修改新增活动会出现缓存名称和时间
trainfirstinfo !== "" ? trainfirstinfo.organizer?.split(',') : [],
rules: [
{
required: false,
validator: (rule, value, callback) => {
validator(rule, value, callback, "请输入组织方", 50);
const valueStr = Array.isArray(value) ? value.join(',') : value;
validator(rule, valueStr, callback, "请选择组织方", 50);
},
},
],
})(<Input placeholder="请输入组织方" disabled={usable} />)}
})(
<Select
mode="multiple"
placeholder="请选择组织方"
disabled={usable}
>
{organizations.map(org => (
<Option key={org} value={org}>{org}</Option>
))}
</Select>
)}
</Col>
{/*<Col span={6}>
<Button size="small" disabled={usable} >复制已有活动</Button>
</Col>*/}
</Row>
</FormItem>
<FormItem {...formItemLayout} label="活动奖励">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment