Commit d822ce8e authored by 熊成伟's avatar 熊成伟

debug

parent 73212b01
This diff is collapsed.
...@@ -3,19 +3,20 @@ import {Tabs} from 'antd-mobile' ...@@ -3,19 +3,20 @@ import {Tabs} from 'antd-mobile'
import './index.less' import './index.less'
const tabs = [ const tabs = [
{ title: '基本信息', sub: 'basic' }, { title: '基本信息', key: 'basic' },
{ title: '详情附件', sub: 'adjunct' }, { title: '详情附件', key: 'adjunct' },
{ title: '流程信息', sub: 'flow' }, { title: '流程信息', key: 'flow' },
{ title: '流转意见', sub: 'option' }, { title: '流转意见', key: 'option' },
] ]
const Index = (props) => { const Index = (props) => {
return ( return (
<div> <div>
<Tabs <Tabs
page={props.page}
tabs={tabs} tabs={tabs}
initialPage={"basic"} initialPage={"basic"}
onChange={(tab, index) => props.onClick(tab.sub)} onChange={(tab, index) => props.onClick(tab.key, index)}
/> />
</div> </div>
); );
......
...@@ -20,17 +20,17 @@ class Process extends Component { ...@@ -20,17 +20,17 @@ class Process extends Component {
constructor() { constructor() {
super(); super();
this.optionBlur = this.optionBlur.bind(this) this.optionBlur = this.optionBlur.bind(this)
// this.handleScroll = this.handleScroll.bind(this) this.handleScroll = this.handleScroll.bind(this)
this.state = { this.state = {
current: 'basic',
disabled: true, disabled: true,
footStatus: false, footStatus: false,
footButton: '处理' footButton: '处理'
} }
}; };
componentDidMount() { componentDidMount() {
// console.log(document.getElementsByClassName("option-text")[0])
document.getElementsByClassName("option-text")[0].addEventListener('focus', this.optionBlur, true) document.getElementsByClassName("option-text")[0].addEventListener('focus', this.optionBlur, true)
// window.addEventListener('scroll', this.handleScroll, true); window.addEventListener('scroll', this.handleScroll, true);
} }
optionBlur = () => { optionBlur = () => {
this.setState({footButton: '确认发送', footStatus: true}) this.setState({footButton: '确认发送', footStatus: true})
...@@ -38,25 +38,36 @@ class Process extends Component { ...@@ -38,25 +38,36 @@ class Process extends Component {
componentWillUnmount() { componentWillUnmount() {
document.getElementsByClassName("option-text")[0].removeEventListener('focus', this.optionBlur, true) document.getElementsByClassName("option-text")[0].removeEventListener('focus', this.optionBlur, true)
// window.removeEventListener('scroll', this.handleScroll, true); window.removeEventListener('scroll', this.handleScroll, true);
} }
// handleScroll() { handleScroll() {
// const basic = document.getElementById("event-basic").offsetTop; const adjunct = document.getElementById("event-adjunct").offsetTop;
// const adjunct = document.getElementById("event-adjunct").offsetTop; const flow = document.getElementById("event-flow").offsetTop;
// const flow = document.getElementById("event-flow").offsetTop; const option = document.getElementById("event-option").offsetTop;
// const option = document.getElementById("event-option").offsetTop; const event = document.getElementById('event');
// const top = document.documentElement.scrollTop; const top = event.scrollTop;
// const scrollHeight = event.scrollHeight;
// console.log(top) const clientHeight = event.clientHeight
//
// // console.log(basic, adjunct, flow, option); if (top >= 0 && top < adjunct - 9) {
// }; this.setState({current: 'basic'})
}else if (top >= adjunct && top < flow - 9) {
this.setState({current: 'adjunct'})
}else if (top >= flow && top < option - 9) {
this.setState({current: 'flow'})
}else if (top >= option) {
this.setState({current: 'option'})
}
if (top + clientHeight == scrollHeight) {
this.setState({current: 'option'})
}
};
tabClick = (name) => { tabClick = (name) => {
// console.log(document.getElementsByClassName("option-text")) this.setState({current: name})
name === 'option' && document.getElementsByClassName("option-text")[0].focus(); name === 'option' && document.getElementsByClassName("option-text")[0].focus();
name === 'option' && this.optionBlur() name === 'option' && this.optionBlur()
const top = document.getElementById(`event-${name}`).offsetTop; const top = document.getElementById(`event-${name}`).offsetTop;
document.getElementById("event").scrollTo(0,top - 9) document.getElementById("event").scrollTo(0,top - 9);
}; };
textClick = () => { textClick = () => {
const top = document.getElementById(`event-option`).offsetTop; const top = document.getElementById(`event-option`).offsetTop;
...@@ -74,7 +85,7 @@ class Process extends Component { ...@@ -74,7 +85,7 @@ class Process extends Component {
wrapProps, wrapProps,
}, },
(buttonIndex) => { (buttonIndex) => {
console.log(buttonIndex) // console.log(buttonIndex)
}); });
}; };
optionChange = val => { optionChange = val => {
...@@ -82,11 +93,11 @@ class Process extends Component { ...@@ -82,11 +93,11 @@ class Process extends Component {
} }
render() { render() {
console.log(this.props.match.params); console.log(this.state.current);
const {footButton, disabled, footStatus} = this.state const {footButton, disabled, footStatus, current} = this.state
return ( return (
<div> <div>
<TopTabs onClick={this.tabClick}/> <TopTabs page={current} onClick={this.tabClick}/>
<div id="event"> <div id="event">
<WingBlank> <WingBlank>
<WhiteSpace/> <WhiteSpace/>
...@@ -104,7 +115,7 @@ class Process extends Component { ...@@ -104,7 +115,7 @@ class Process extends Component {
{!footStatus && ( {!footStatus && (
<img alt="" src="/img/process-edit.png" className="process-edit"/> <img alt="" src="/img/process-edit.png" className="process-edit"/>
)} )}
{this.state.footButton} {footButton}
</div> </div>
</div> </div>
......
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