Commit ade8068a by hanjixin

fix schedule-add bug

parent e25e69c0
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
"dev:h5": "npm run build:h5 -- --watch", "dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch", "dev:rn": "npm run build:rn -- --watch",
"lint": "tslint --project ./tsconfig.json && stylelint \"./src/**/*.scss\"", "lint": "tslint --project ./tsconfig.json && stylelint \"./src/**/*.scss\"",
"precommit": "npm run lint",
"run:shell": "cd ../taro-native-shell/ && yarn android" "run:shell": "cd ../taro-native-shell/ && yarn android"
}, },
"author": "", "author": "",
......
...@@ -43,8 +43,6 @@ class ScheduleItem extends Component { ...@@ -43,8 +43,6 @@ class ScheduleItem extends Component {
render() { render() {
let { templateUrl, filmName, templateDescribe, templateShow, isList, time } = this.props let { templateUrl, filmName, templateDescribe, templateShow, isList, time } = this.props
templateUrl = templateUrl || '' templateUrl = templateUrl || ''
console.log(templateShow, this.props)
let time2 = this.state.time
return ( return (
<View className="films-item"> <View className="films-item">
<View className="films-item-img-box"> <View className="films-item-img-box">
...@@ -62,10 +60,10 @@ class ScheduleItem extends Component { ...@@ -62,10 +60,10 @@ class ScheduleItem extends Component {
{isList ? ( {isList ? (
<View className="picker">当前选择:{this.state.time}</View> <View className="picker">当前选择:{this.state.time}</View>
) : ( ) : (
<Picker mode="time" onChange={this.onTimeChange} value={time2}> <Picker mode="time" onChange={this.onTimeChange} value={time ? time : '00:00'}>
<View className="picker">{time ? time : '选择时间'}</View> <View className="picker">{time ? time : '选择时间'}</View>
</Picker> </Picker>
)} )}
</View> </View>
</View> </View>
</View> </View>
......
...@@ -33,6 +33,8 @@ export interface IMilmListItme { ...@@ -33,6 +33,8 @@ export interface IMilmListItme {
interface PageState { interface PageState {
checked: Set<string> checked: Set<string>
showTemplate: string showTemplate: string
oldFilms: any[]
oldArr: any[]
} }
type IProps = PageStateProps & PageDispatchProps & PageOwnProps type IProps = PageStateProps & PageDispatchProps & PageOwnProps
...@@ -64,7 +66,9 @@ class Films extends Component { ...@@ -64,7 +66,9 @@ class Films extends Component {
// 判断缓存数据是否存在 // 判断缓存数据是否存在
this.setState({ this.setState({
checked: new Set(), checked: new Set(),
showTemplate: 'HORIZONTAL' showTemplate: 'HORIZONTAL',
oldFilms: [],
oldArr: []
}) })
} }
...@@ -72,12 +76,19 @@ class Films extends Component { ...@@ -72,12 +76,19 @@ class Films extends Component {
Taro.getStorage({ key: 'schedule-add-films' }) Taro.getStorage({ key: 'schedule-add-films' })
.then(res => { .then(res => {
console.log(res.data, 'schedule-add-films') console.log(res.data, 'schedule-add-films')
let arr = JSON.parse(res.data).map(item => { let data = JSON.parse(res.data)
let arr = data.map(item => {
return item.filmId return item.filmId
}) })
console.log(Taro.getStorageSync('schedule-type-state')) // this.setState({
// oldFilms: data,
// oldArr: arr
// })
console.log(arr, data)
this.setState( this.setState(
{ {
oldFilms: data,
oldArr: arr,
checked: new Set(arr), checked: new Set(arr),
showTemplate: showTemplate:
JSON.parse(res.data)[0]['templateShow'] || Taro.getStorageSync('schedule-type-state') JSON.parse(res.data)[0]['templateShow'] || Taro.getStorageSync('schedule-type-state')
...@@ -183,17 +194,23 @@ class Films extends Component { ...@@ -183,17 +194,23 @@ class Films extends Component {
} }
enter() { enter() {
const { list } = this.props const { list } = this.props
const { oldFilms, oldArr } = this.state
let checkedArr: any = [] let checkedArr: any = []
list.map(item => { list.map(item => {
if (this.state.checked.has(item.filmId)) { if (this.state.checked.has(item.filmId)) {
checkedArr.push(item) if (oldArr.indexOf(item.filmId) !== -1) {
checkedArr.push(oldFilms[oldArr.indexOf(item.filmId)])
} else {
checkedArr.push(Object.assign({ time: '00:00' }, item))
}
} }
}) })
Taro.setStorage({ Taro.setStorage({
key: 'schedule-add-films', key: 'schedule-add-films',
data: JSON.stringify([...checkedArr]) data: JSON.stringify([...checkedArr])
}).then(() => {
Taro.navigateBack()
}) })
Taro.navigateBack()
} }
render() { render() {
...@@ -211,9 +228,7 @@ class Films extends Component { ...@@ -211,9 +228,7 @@ class Films extends Component {
className={ className={
showTemplate === 'HORIZONTAL' showTemplate === 'HORIZONTAL'
? 'type-tab-item type-tab-item-active' ? 'type-tab-item type-tab-item-active'
: 'type-tab-item' : 'type-tab-item'} >
}
>
横版 横版
</Text> </Text>
<Text <Text
...@@ -221,9 +236,7 @@ class Films extends Component { ...@@ -221,9 +236,7 @@ class Films extends Component {
this.typeChange('VERTICAL') this.typeChange('VERTICAL')
}} }}
className={ className={
showTemplate === 'VERTICAL' ? 'type-tab-item type-tab-item-active' : 'type-tab-item' showTemplate === 'VERTICAL' ? 'type-tab-item type-tab-item-active' : 'type-tab-item'} >
}
>
竖版 竖版
</Text> </Text>
<Text <Text
...@@ -231,9 +244,7 @@ class Films extends Component { ...@@ -231,9 +244,7 @@ class Films extends Component {
this.typeChange('OTHER') this.typeChange('OTHER')
}} }}
className={ className={
showTemplate === 'OTHER' ? 'type-tab-item type-tab-item-active' : 'type-tab-item' showTemplate === 'OTHER' ? 'type-tab-item type-tab-item-active' : 'type-tab-item'} >
}
>
异形屏 异形屏
</Text> </Text>
</View> </View>
...@@ -243,8 +254,7 @@ class Films extends Component { ...@@ -243,8 +254,7 @@ class Films extends Component {
height={myHeight} height={myHeight}
dataListLength={list.length} dataListLength={list.length}
pullingUp={done => this.onScrollToLower(done)} pullingUp={done => this.onScrollToLower(done)}
pullingDown={done => this.onDownRefresh(done)} pullingDown={done => this.onDownRefresh(done)} >
>
{list.map(item => ( {list.map(item => (
<View key={item.filmId}> <View key={item.filmId}>
<Label className="films-bind-item" onClick={() => this.changeItem(item)}> <Label className="films-bind-item" onClick={() => this.changeItem(item)}>
......
...@@ -89,7 +89,7 @@ class ScheduleAdd extends Component { ...@@ -89,7 +89,7 @@ class ScheduleAdd extends Component {
console.log(id) console.log(id)
id && id &&
api.common.getScheduleDetail(id).then(res => { api.common.getScheduleDetail(id).then(res => {
console.log(res) // console.log(res)
const { equipmentInfos, calendarName, filmInfos } = res const { equipmentInfos, calendarName, filmInfos } = res
this.setState({ this.setState({
filmList: filmInfos, filmList: filmInfos,
...@@ -140,6 +140,10 @@ class ScheduleAdd extends Component { ...@@ -140,6 +140,10 @@ class ScheduleAdd extends Component {
this.setState({ this.setState({
filmList: myFilmList filmList: myFilmList
}) })
Taro.setStorage({
key: 'schedule-add-films',
data: JSON.stringify(myFilmList)
})
} }
async deleteAction() { async deleteAction() {
const { id } = this.$router.params const { id } = this.$router.params
...@@ -208,7 +212,6 @@ class ScheduleAdd extends Component { ...@@ -208,7 +212,6 @@ class ScheduleAdd extends Component {
} }
render() { render() {
const { list, height, count } = this.props
const { deviceList, filmList, scheduleName, id } = this.state const { deviceList, filmList, scheduleName, id } = this.state
return ( return (
<View className="schedule-add"> <View className="schedule-add">
......
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