Commit c61947f5 by hanjixin

数据修改

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