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}
......
......@@ -4,18 +4,10 @@ import {
Modal,
Form,
Input,
Radio,
Cascader,
DatePicker,
Upload,
Icon,
message,
} from "antd";
import { connect } from "react-redux";
// import {gupList, gupfetch} from 'ACTIONS/upload';
import { gupList, gupfetch } from "@/common/UpLoad/redux/actions";
import Editor from "@/common/Editor/editor";
import UpLoad from "@/common/UpLoad";
import moment from "moment";
import validator from "@/common/validatorForm/index";
const FormItem = Form.Item;
......@@ -26,8 +18,6 @@ class addEdit extends React.Component {
this.state = {
uploadParams: {},
uploadAction: "",
editor: "",
tags: [],
fileList: [],
responseList: [],
previewVisible: false, // 控制预览模态框的显示与隐藏
......@@ -43,10 +33,7 @@ class addEdit extends React.Component {
componentDidMount() {
const { seeEdit, type } = this.props;
}
//多媒体组件事件
getEditorHtml = editor => {
this.props.onEditor(editor);
};
//上传文件
beforeUpload(file, fileList) {
console.log("检测打印变量=file ", file);
......@@ -83,66 +70,43 @@ class addEdit extends React.Component {
});
}
}
//123
handleUploadChange({ file, fileList }) {
// console.log(123,file.name.split('.')[1])
// if (file.name.indexOf("pdf") == -1) {
// message.error("请上传pdf文件");
// return;
// }
handleUploadChange({ file, fileList }) {
let temp = this.state.fileList;
if (file.status == "removed") {
temp = temp.filter(item => {
return item.uid != file.uid;
});
if (file.status === "removed") {
temp = temp.filter(item => item.uid !== file.uid);
this.setState({
fileList: temp,
responseList: temp.map(item => {
return {
fileName: item.name,
fileUrl: item.fileUrl
? item.fileUrl
: this.state.hostAndDir +
"/" +
item.uid +
"." +
item.name.substr(item.name.length - 3),
size: item.size + "",
suffix: "." + item.name.split(".")[1],
};
}),
responseList: temp.map(item => ({
fileName: item.name,
fileUrl: item.fileUrl
? item.fileUrl
: `${this.state.hostAndDir}/${item.uid}.${item.name.substr(item.name.length - 3)}`,
size: item.size + "",
suffix: `.${item.name.split(".")[1]}`,
})),
});
} else {
temp.push(fileList.pop());
this.setState({
fileList: temp.map(item => {
return {
uid: item.uid,
name: item.name,
size: item.size,
fileUrl: item.fileUrl,
};
}),
});
this.setState({
responseList: temp.map(item => {
return {
fileName: item.name,
fileUrl: item.fileUrl
? item.fileUrl
: this.state.hostAndDir +
"/" +
item.uid +
"." +
item.name.substr(item.name.length - 3),
size: item.size + "",
suffix: "." + item.name.split(".")[1],
};
}),
fileList: temp.map(item => ({
uid: item.uid,
name: item.name,
size: item.size,
fileUrl: item.fileUrl,
})),
responseList: temp.map(item => ({
fileName: item.name,
fileUrl: item.fileUrl
? item.fileUrl
: `${this.state.hostAndDir}/${item.uid}.${item.name.substr(item.name.length - 3)}`,
size: item.size + "",
suffix: `.${item.name.split(".")[1]}`,
})),
});
}
}
normFile = e => {
if (Array.isArray(e)) {
return e;
......@@ -151,12 +115,6 @@ class addEdit extends React.Component {
};
render() {
var fileUrl = "";
var fileName = "";
if (this.state.responseList[0]) {
var fileUrl = this.state.responseList[0].fileUrl;
var fileName = this.state.responseList[0].fileName;
}
const {
visible,
onCancel,
......@@ -168,7 +126,7 @@ class addEdit extends React.Component {
seeEdit = {},
type,
} = this.props;
const { uploadParams, uploadAction, tags } = this.state;
const { previewVisible, previewImage } = this.state;
const { getFieldDecorator } = form;
const formItemLayout = {
labelCol: {
......@@ -180,75 +138,78 @@ class addEdit extends React.Component {
sm: { span: 20 },
},
};
const { id, state } = this.props.seeEdit;
const { id, state } = seeEdit;
return (
<Modal
visible={visible}
title={title}
okText="确定"
width={1000}
destroyOnClose
onCancel={onCancel}
footer={
<>
{state == 1 && (
<Button key="1" type="primary" onClick={() => onApprove(id, 2)}>
接收
<>
<Modal
visible={visible}
title={title}
okText="确定"
width={1000}
destroyOnClose
onCancel={onCancel}
footer={
<>
{state === 1 && (
<Button key="1" type="primary" onClick={() => onApprove(id, 2)}>
接收
</Button>
)}
<Button key="3" type="primary" onClick={onCancel}>
返回
</Button>
)}
<Button key="3" type="primary" onClick={onCancel}>
返回
</Button>
</>
}
>
<Form>
<FormItem {...formItemLayout} label="留言标题">
{getFieldDecorator("name", {
initialValue: seeEdit && seeEdit.name,
})(
<Input
disabled={type != "edit" ? true : false}
style={{ width: "300px" }}
/>
)}
</FormItem>
<FormItem {...formItemLayout} label="留言图片">
{seeEdit.ossUrl &&
JSON.parse(seeEdit.ossUrl).length > 0 &&
JSON.parse(seeEdit.ossUrl).map((item, index) => (
<img
key={index}
src={item}
alt=""
style={{ width: "300px", cursor: 'pointer' }}
onClick={() => this.handlePreview(item)} // 点击图片触发预览
</>
}
>
<Form>
<FormItem {...formItemLayout} label="留言标题">
{getFieldDecorator("name", {
initialValue: seeEdit && seeEdit.name,
})(
<Input
disabled={type !== "edit"}
style={{ width: "300px" }}
/>
))}
</FormItem>
{/* 预览模态框 */}
<Modal
visible={previewVisible}
footer={null}
onCancel={this.handleCancel}
>
<img alt="preview" style={{ width: '100%' }} src={previewImage} />
</Modal>
<FormItem {...formItemLayout} label="内容">
{getFieldDecorator("content", {
initialValue: seeEdit && seeEdit.content,
})(
<textarea
disabled={type != "edit" ? true : false}
style={{ width: "600px", minHeight: "200px" }}
/>
)}
</FormItem>
</Form>
</Modal>
)}
</FormItem>
<FormItem {...formItemLayout} label="留言图片">
{seeEdit.ossUrl &&
JSON.parse(seeEdit.ossUrl).length > 0 &&
JSON.parse(seeEdit.ossUrl).map((item, index) => (
<img
key={index}
src={item}
alt=""
style={{ width: "200px", height: "240px", cursor: 'pointer' }}
onClick={() => this.handlePreview(item)}
/>
))}
</FormItem>
<FormItem {...formItemLayout} label="内容">
{getFieldDecorator("content", {
initialValue: seeEdit && seeEdit.content,
})(
<textarea
disabled={type !== "edit"}
style={{ width: "600px", minHeight: "200px" }}
/>
)}
</FormItem>
</Form>
</Modal>
{/* 预览模态框移到外层 */}
<Modal
visible={previewVisible}
footer={null}
onCancel={this.handleCancel}
>
<img alt="preview" style={{ width: '100%' }} src={previewImage} />
</Modal>
</>
);
}
// 处理图片预览
handlePreview = (url) => {
this.setState({
......@@ -259,92 +220,6 @@ class addEdit extends React.Component {
// 关闭预览模态框
handleCancel = () => this.setState({ previewVisible: false });
render() {
var fileUrl = "";
var fileName = "";
if (this.state.responseList[0]) {
var fileUrl = this.state.responseList[0].fileUrl;
var fileName = this.state.responseList[0].fileName;
}
const {
visible,
onCancel,
onCreate,
onApprove,
title,
fileList,
form,
seeEdit = {},
type,
} = this.props;
const { uploadParams, uploadAction, tags } = this.state;
const { getFieldDecorator } = form;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 },
},
};
const { id, state } = this.props.seeEdit;
return (
<Modal
visible={visible}
title={title}
okText="确定"
width={1000}
destroyOnClose
onCancel={onCancel}
footer={
<>
{state == 1 && (
<Button key="1" type="primary" onClick={() => onApprove(id, 2)}>
接收
</Button>
)}
<Button key="3" type="primary" onClick={onCancel}>
返回
</Button>
</>
}
>
<Form>
<FormItem {...formItemLayout} label="留言标题">
{getFieldDecorator("name", {
initialValue: seeEdit && seeEdit.name,
})(
<Input
disabled={type != "edit" ? true : false}
style={{ width: "300px" }}
/>
)}
</FormItem>
<FormItem {...formItemLayout} label="留言图片">
{seeEdit.ossUrl &&
JSON.parse(seeEdit.ossUrl).length > 0 &&
JSON.parse(seeEdit.ossUrl).map((item, index) => (
<img key={index} src={item} alt="" style={{ width: "300px" }} />
))}
</FormItem>
<FormItem {...formItemLayout} label="内容">
{getFieldDecorator("content", {
initialValue: seeEdit && seeEdit.content,
})(
<textarea
disabled={type != "edit" ? true : false}
style={{ width: "600px", minHeight: "200px" }}
/>
)}
</FormItem>
</Form>
</Modal>
);
}
}
function mapStateToProps(state, ownProps) {
......
......@@ -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