Commit ade8068a by hanjixin

fix schedule-add bug

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