| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import Taro, { canIUse, Component } from '@tarojs/taro'
- import { View, Picker, ScrollView } from '@tarojs/components'
- import { connect } from '@tarojs/redux'
- import * as template from '@actions/template'
- import * as actions from '@actions/increase'
- import { getWindowHeight } from '@utils/style'
- import './increase.scss'
- const RECOMMEND_SIZE = 20
- @connect(state => state.home, { ...actions, ...template })
- class Increase extends Component {
- config = {
- navigationBarTitleText: '生成报告'
- }
- state = {
- selector: [],
- loaded: false,
- loading: false,
- lastItemId: 0,
- hasMore: true,
- selectorChecked: {},
- }
- componentDidMount() {
- this.getData()
- }
- getData() {
- let payload = {}
- this.props.getList(payload).then((data) => {
- let list = data.items
- list.push({
- id: null,
- name: "空白模板"
- })
- this.setState({
- loading: false,
- selector: list,
- })
- }).catch(() => {
- this.setState({ loading: false })
- })
- }
- onChange = e => {
- this.creatReports(this.state.selector[e.detail.value])
- }
- // 创建报告
- creatReports(obj) {
- const payload = {
- templateId: obj.id,
- }
- this.props.creatReport(payload).then((data) => {
- this.setState({
- loading: false,
- })
- Taro.navigateTo({
- url: "/pages/user/reportdetail?id=" + data
- })
- }).catch(() => {
- this.setState({ loading: false })
- })
- }
- render() {
- return (
- <View className='home'>
- <ScrollView
- scrollY
- className='home__wrap'
- onScrollToLower={this.loadRecommend}
- style={{ height: getWindowHeight() }}
- >
- <View className='increase'>
- <View className='increase__item'>
- <Picker
- mode='selector'
- rangeKey="name"
- range={this.state.selector}
- onChange={this.onChange}>
- <View className='increase__item-buttom'>
- + 新建报告
- </View>
- </Picker>
- </View>
- </View>
- </ScrollView>
- </View>
- )
- }
- }
- export default Increase
|