Commit c61947f5 by hanjixin

数据修改

parent cfe737da
import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Input, Image, Button } from '@tarojs/components'
import { View } from '@tarojs/components'
import { AtAccordion, AtList } from 'taro-ui'
import MenuItem from '../menu-item'
import './index.scss'
......@@ -15,6 +15,7 @@ type PageOwnProps = {
pageIndex: number
open: boolean
activeIndex: number
setValue: () => void
}
type PageState = {}
......@@ -43,9 +44,8 @@ class EditMenu extends Component {
})
}
render() {
const { schemaData, itemList } = this.props
const { schemaData, itemList, setValue } = this.props
const activeIndex = this.state.activeIndex
console.log('activeIndex', activeIndex)
return (
<View className="edit-container">
<View className="temp-top-info">{itemList}</View>
......@@ -60,7 +60,7 @@ class EditMenu extends Component {
key={index + item.name}
>
<AtList hasBorder={false}>
<MenuItem item={item} schemaData={schemaData} isList={false} />
<MenuItem item={item} schemaData={schemaData} isList={false} setValue={setValue} />
</AtList>
</AtAccordion>
)
......
......@@ -12,6 +12,7 @@ type PageOwnProps = {
item: any
schemaData: object
isList: boolean
setValue: () => void
}
type PageState = {}
......@@ -25,12 +26,13 @@ interface MenuItem {
class MenuItem extends Component {
constructor() {
super(arguments)
super(...arguments)
this.setState({
isList: false
})
this.isSchemaIndex = this.isSchemaIndex.bind(this)
this.checkType = this.checkType.bind(this)
// this.inputValueChage = this.inputValueChage.bind(this)
}
isSchemaIndex(item) {
return item['schemaIndex'] ? item['schemaIndex'] : 0
......@@ -39,18 +41,26 @@ class MenuItem extends Component {
const { item } = this.props
return item.modelSchema[this.isSchemaIndex(item2)][key].type
}
listItem(item2) {}
inputValueChage(dataKey, e) {
const { setValue, schemaData } = this.props
const newSchemaData = JSON.parse(JSON.stringify(schemaData))
newSchemaData[dataKey] = e.target.value
setValue(newSchemaData)
console.log(arguments, 'inputValueChage')
}
render() {
const { item, schemaData, isList, setValue } = this.props
const mySet = setValue
? setValue
: e => {
console.log(e.target.value)
}
// let str: any = ''
const { item, schemaData } = this.props
item = item || {
type: ''
}
if (item.type === 'text') {
return (
<Input className="menu-item-input" value={schemaData[item.dataKey].value} onInput={mySet} />
<Input
className="menu-item-input"
value={schemaData[item.dataKey].value}
onInput={this.inputValueChage.bind(this, item.dataKey)}
/>
)
} else if (item.type === 'image') {
return (
......
......@@ -44,7 +44,7 @@ class FilmDetail extends Component {
filmInfo: {},
filmData: {}
}
this.chengDevice = this.chengDevice.bind(this)
this.setValue = this.setValue.bind(this)
}
componentWillMount() {
......@@ -75,12 +75,14 @@ class FilmDetail extends Component {
pageIndex: index
})
}
chengDevice() {
console.log('chengDevice')
const { filmId } = this.state
const url = `/pages/home/device/device_bind/index?filmId=${filmId}`
Taro.navigateTo({ url })
setValue(schemaData) {
const currentData = this.state.filmData
currentData[this.state.pageIndex] = schemaData
this.setState({
filmData: currentData
})
}
changeFilmName = ({ target }) => {
const { value } = target
this.setState({ createFilmName: value })
......@@ -133,7 +135,7 @@ class FilmDetail extends Component {
</View>
</ScrollView>
{filmData[pageIndex]}
<EditMenu {...filmData[pageIndex]} />
<EditMenu {...filmData[pageIndex]} setValue={this.setValue} />
</View>
<View className="film-detail-bottom-bar">
<Button type="primary" className="film-detail-bottom-bar-btn">
......
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 sign in to comment