Commit ae4a75f2 by chengming

投票优化

parent df3681e1
...@@ -469,7 +469,7 @@ class homePage extends Component { ...@@ -469,7 +469,7 @@ class homePage extends Component {
xAxis: [ xAxis: [
{ {
type: "category", type: "category",
data: ["一次合格率", "补考合格率"], data: ["一次合格率", "合格率"],
boundaryGap: ["0%", "0%"], boundaryGap: ["0%", "0%"],
axisLine: { axisLine: {
show: false, // 确保显示 Y 轴线 show: false, // 确保显示 Y 轴线
......
...@@ -241,7 +241,8 @@ class Details extends Component { ...@@ -241,7 +241,8 @@ class Details extends Component {
companyCode + companyCode +
"/" + "/" +
siteCode + siteCode +
"/index/tool/question/question-management" "/index/tool/question/question-management?tab=" +
(this.state.isupdata == 1 ? "2" : "1")
); );
} }
}); });
...@@ -504,46 +505,46 @@ class Details extends Component { ...@@ -504,46 +505,46 @@ class Details extends Component {
</div> </div>
), ),
}, },
{ // {
title: "跳题策略", // title: "跳题策略",
dataIndex: "action", // dataIndex: "action",
key: "action", // key: "action",
width: 300, // width: 300,
render: (text, record) => ( // render: (text, record) => (
<div> // <div>
<div> // <div>
<Select // <Select
style={{ width: "200px" }} // style={{ width: "200px" }}
defaultValue={ // defaultValue={
record.jumpNum // record.jumpNum
? `跳转至编号${record.jumpNum}题目` // ? `跳转至编号${record.jumpNum}题目`
: record.jumpType == 1 // : record.jumpType == 1
? -1 // ? -1
: -2 // : -2
} // }
disabled
onChange={value => this.handleSelectChange(value, record)} // onChange={value => this.handleSelectChange(value, record)}
onDropdownVisibleChange={open => this.jump(open, record)} // onDropdownVisibleChange={open => this.jump(open, record)}
getPopupContainer={() => document.getElementById("djump")} // getPopupContainer={() => document.getElementById("djump")}
> // >
<Option value={-2}>按顺序填写下一题</Option> // <Option value={-2}>按顺序填写下一题</Option>
{record.type == 1 ? ( // {record.type == 1 ? (
<Option value={-1}>按选项跳题</Option> // <Option value={-1}>按选项跳题</Option>
) : null} // ) : null}
{children} // {children}
</Select> // </Select>
{record.jumpType == 1 ? ( // {record.jumpType == 1 ? (
<a // <a
style={{ marginLeft: "20px" }} // style={{ marginLeft: "20px" }}
onClick={() => this.showdanxuan(record)} // onClick={() => this.showdanxuan(record)}
> // >
查看选项跳题规则 // 查看选项跳题规则
</a> // </a>
) : null} // ) : null}
</div> // </div>
</div> // </div>
), // ),
}, // },
{ {
title: "操作", title: "操作",
dataIndex: "operation", dataIndex: "operation",
...@@ -763,7 +764,8 @@ class Details extends Component { ...@@ -763,7 +764,8 @@ class Details extends Component {
companyCode + companyCode +
"/" + "/" +
siteCode + siteCode +
"/index/tool/question/question-management" "/index/tool/question/question-management?tab=" +
(this.state.isupdata == 1 ? "2" : "1")
} }
> >
<Button>返回</Button> <Button>返回</Button>
......
...@@ -25,7 +25,7 @@ import { ...@@ -25,7 +25,7 @@ import {
import Breadcrumb from "@/common/Breadcrumb"; import Breadcrumb from "@/common/Breadcrumb";
const TabPane = Tabs.TabPane; const TabPane = Tabs.TabPane;
import styles from "./style/index.less"; import styles from "./style/index.less";
import { withRouter } from "react-router-dom";
var companyCode = location.pathname.split("/")[1]; var companyCode = location.pathname.split("/")[1];
var siteCode = location.pathname.split("/")[2]; var siteCode = location.pathname.split("/")[2];
...@@ -55,23 +55,32 @@ class Survey extends Component { ...@@ -55,23 +55,32 @@ class Survey extends Component {
} }
componentDidMount() { componentDidMount() {
this.props.getlist({ const searchParams = new URLSearchParams(this.props.location.search);
state: 1, const tab = searchParams.get('tab');
pageNo: 1, const initialKey = tab ? parseInt(tab) : 1;
pageSize: 20, this.setState({
bizType:1 key: initialKey
}); }, () => {
this.props.getlist({ // 根据初始key设置对应的action和deleteBtn状态
state: 2, this.callback(initialKey.toString());
pageNo: 1,
pageSize: 20, // 加载对应状态的数据
bizType:1 this.props.getlist({
state: initialKey,
pageNo: 1,
pageSize: 20,
bizType:1
});
}); });
this.props.getlist({ // 同时加载其他状态的数据(可选)
state: 0, const otherStates = [1, 2, 0].filter(state => state !== initialKey);
pageNo: 1, otherStates.forEach(state => {
pageSize: 20, this.props.getlist({
bizType:1 state: state,
pageNo: 1,
pageSize: 20,
bizType:1
});
}); });
} }
...@@ -464,7 +473,7 @@ class Survey extends Component { ...@@ -464,7 +473,7 @@ class Survey extends Component {
</div> </div>
<Tabs <Tabs
className={styles.survey_tabs} className={styles.survey_tabs}
defaultActiveKey="1" activeKey={this.state.key.toString()}
onChange={this.callback} onChange={this.callback}
> >
<TabPane tab="已上架" key="1"> <TabPane tab="已上架" key="1">
...@@ -558,4 +567,4 @@ function mapDispatchToProps(dispatch) { ...@@ -558,4 +567,4 @@ function mapDispatchToProps(dispatch) {
}; };
} }
export default connect(mapStateToProps, mapDispatchToProps)(Survey); export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Survey));
...@@ -164,10 +164,11 @@ class Details extends Component { ...@@ -164,10 +164,11 @@ class Details extends Component {
console.log("跳转", this.props); console.log("跳转", this.props);
this.props.history.push( this.props.history.push(
"/" + "/" +
companyCode + companyCode +
"/" + "/" +
siteCode + siteCode +
"/index/tool/survey/survey-management" "/index/tool/survey/survey-management?tab=" +
(this.state.isupdata == 1 ? "2" : "1")
); );
} }
}); });
...@@ -221,7 +222,7 @@ class Details extends Component { ...@@ -221,7 +222,7 @@ class Details extends Component {
const param = { const param = {
type: values.type, type: values.type,
content: values.content, content: values.content,
contentAppendixUrl: this.state.fileUrl ? this.state.fileUrl : "", contentAppendixUrl: this.state.fileUrl ? this.state.fileUrl : this.state.testItem.contentAppendixUrl ? this.state.testItem.contentAppendixUrl : "",
needAnswer: values.needAnswer ? 1 : 0, needAnswer: values.needAnswer ? 1 : 0,
questionOptions: objs, questionOptions: objs,
maxSelectItem: values.needAnswer2 ? values.maxSelectItem : "", maxSelectItem: values.needAnswer2 ? values.maxSelectItem : "",
...@@ -294,16 +295,15 @@ class Details extends Component { ...@@ -294,16 +295,15 @@ class Details extends Component {
}, },
defaultUrl: this.state.testItem.contentAppendixUrl defaultUrl: this.state.testItem.contentAppendixUrl
? [ ? [
{ {
uid: 1, uid: 1,
status: "done", status: "done",
url: this.state.testItem.contentAppendixUrl, url: this.state.testItem.contentAppendixUrl,
name: this.state.testItem.contentAppendixUrl.split("prefix=")[1], name: this.state.testItem.contentAppendixUrl.split("prefix=")[1],
}, },
] ]
: [], : [],
}; };
const formItemLayout = { const formItemLayout = {
labelCol: { span: 6 }, labelCol: { span: 6 },
wrapperCol: { span: 14 }, wrapperCol: { span: 14 },
...@@ -427,25 +427,25 @@ class Details extends Component { ...@@ -427,25 +427,25 @@ class Details extends Component {
<Input defaultValue={details.point} disabled /> <Input defaultValue={details.point} disabled />
</FormItem> </FormItem>
{// 修改 {// 修改
details.remind ? ( details.remind ? (
<MessageRemind <MessageRemind
formItemLayout={formItemLayout} formItemLayout={formItemLayout}
style={{ marginLeft: "170px" }} style={{ marginLeft: "170px" }}
relationId={this.id} relationId={this.id}
remind={details.remind} remind={details.remind}
usable={true} usable={true}
relationType={3} relationType={3}
wrappedComponentRef={form => (this.messageRemind = form)} wrappedComponentRef={form => (this.messageRemind = form)}
/> />
) : ( ) : (
<MessageRemind <MessageRemind
formItemLayout={formItemLayout} formItemLayout={formItemLayout}
style={{ marginLeft: "170px" }} style={{ marginLeft: "170px" }}
relationType={3} relationType={3}
usable={true} usable={true}
wrappedComponentRef={form => (this.messageRemind = form)} wrappedComponentRef={form => (this.messageRemind = form)}
/> />
)} )}
<div <div
style={{ style={{
display: "flex", display: "flex",
...@@ -491,7 +491,8 @@ class Details extends Component { ...@@ -491,7 +491,8 @@ class Details extends Component {
companyCode + companyCode +
"/" + "/" +
siteCode + siteCode +
"/index/tool/survey/survey-management" "/index/tool/survey/survey-management?tab=" +
(this.state.isupdata == 1 ? "2" : "1")
} }
> >
<Button>返回</Button> <Button>返回</Button>
...@@ -518,7 +519,7 @@ class Details extends Component { ...@@ -518,7 +519,7 @@ class Details extends Component {
<LinkUser <LinkUser
type={this.type == "2" ? "look" : ""} type={this.type == "2" ? "look" : ""}
invisible={false} invisible={false}
getData={() => {}} getData={() => { }}
initData={details.authorizes} initData={details.authorizes}
types={"research"} types={"research"}
groupTypes={"research"} groupTypes={"research"}
......
...@@ -25,7 +25,8 @@ import { ...@@ -25,7 +25,8 @@ import {
import Breadcrumb from "@/common/Breadcrumb"; import Breadcrumb from "@/common/Breadcrumb";
const TabPane = Tabs.TabPane; const TabPane = Tabs.TabPane;
import styles from "./style/index.less"; import styles from "./style/index.less";
// 在import部分添加
import { withRouter } from "react-router-dom";
var companyCode = location.pathname.split("/")[1]; var companyCode = location.pathname.split("/")[1];
var siteCode = location.pathname.split("/")[2]; var siteCode = location.pathname.split("/")[2];
...@@ -54,21 +55,36 @@ class Survey extends Component { ...@@ -54,21 +55,36 @@ class Survey extends Component {
this.handleEdit = this.handleEdit.bind(this); this.handleEdit = this.handleEdit.bind(this);
} }
// 修改componentDidMount方法
componentDidMount() { componentDidMount() {
this.props.getlist({ // 解析URL参数
state: 1, const searchParams = new URLSearchParams(this.props.location.search);
pageNo: 1, const tab = searchParams.get('tab');
pageSize: 20, const initialKey = tab ? parseInt(tab) : 1;
}); this.setState({
this.props.getlist({ key: initialKey
state: 2, }, () => {
pageNo: 1, // 根据初始key设置对应的action和deleteBtn状态
pageSize: 20, this.callback(initialKey.toString());
// 加载对应状态的数据
this.props.getlist({
state: initialKey,
pageNo: 1,
pageSize: 20,
});
}); });
this.props.getlist({
state: 0, // 同时加载其他状态的数据(可选)
pageNo: 1, const otherStates = [1, 2, 0].filter(state => state !== initialKey);
pageSize: 20, otherStates.forEach(state => {
this.props.getlist({
state: state,
pageNo: 1,
pageSize: 20,
});
}); });
} }
...@@ -114,7 +130,7 @@ class Survey extends Component { ...@@ -114,7 +130,7 @@ class Survey extends Component {
{ {
searchValue, searchValue,
}, },
function() { function () {
this.setState( this.setState(
{ {
pageNo: 1, pageNo: 1,
...@@ -281,8 +297,8 @@ class Survey extends Component { ...@@ -281,8 +297,8 @@ class Survey extends Component {
key === 1 key === 1
? record.releaseTime ? record.releaseTime
: key === 2 : key === 2
? record.unReleaseTime ? record.unReleaseTime
: record.createTime : record.createTime
).format("YYYY-MM-DD HH:mm")} ).format("YYYY-MM-DD HH:mm")}
</span> </span>
), ),
...@@ -307,7 +323,7 @@ class Survey extends Component { ...@@ -307,7 +323,7 @@ class Survey extends Component {
) : key == 2 ? ( ) : key == 2 ? (
<Link <Link
to={`/${companyCode}/${siteCode}/index/tool/survey/survey-management/details/${record.id}/1`} to={`/${companyCode}/${siteCode}/index/tool/survey/survey-management/details/${record.id}/1`}
// to={`/${companyCode}/${siteCode}/index/tool/survey/survey-management/create/${record.id}`} // to={`/${companyCode}/${siteCode}/index/tool/survey/survey-management/create/${record.id}`}
> >
<span <span
className={styles.survey_list_btn} className={styles.survey_list_btn}
...@@ -442,7 +458,7 @@ class Survey extends Component { ...@@ -442,7 +458,7 @@ class Survey extends Component {
</div> </div>
<Tabs <Tabs
className={styles.survey_tabs} className={styles.survey_tabs}
defaultActiveKey="1" activeKey={this.state.key.toString()}
onChange={this.callback} onChange={this.callback}
> >
<TabPane tab="已上架" key="1"> <TabPane tab="已上架" key="1">
...@@ -536,4 +552,4 @@ function mapDispatchToProps(dispatch) { ...@@ -536,4 +552,4 @@ function mapDispatchToProps(dispatch) {
}; };
} }
export default connect(mapStateToProps, mapDispatchToProps)(Survey); export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Survey));
\ No newline at end of file
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