Commit b0386bf4 by hank

修复 日程bug

parent 128a9629
......@@ -27,6 +27,7 @@ type PageState = {
list: any[]
activeIndex: number
allCount: string
cId: string
}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps
......@@ -43,9 +44,10 @@ class DeviceSelect extends Component {
constructor(props) {
super(props)
const { filmId } = this.$router.params
const { cId, fId } = this.$router.params
this.state = {
filmId,
filmId: fId,
cId,
page: 1,
checked: new Set(),
showModal: false,
......@@ -63,26 +65,28 @@ class DeviceSelect extends Component {
checked: new Set(),
showTempalte: 'HORIZONTAL'
})
Taro.getStorage({ key: 'schedule-add-device' })
.then(res => {
let arr = JSON.parse(res.data).map(item => {
return item.equipmentId
})
this.setState({
checked: new Set(arr)
cId === undefined &&
Taro.getStorage({ key: 'schedule-add-device' })
.then(res => {
let arr = JSON.parse(res.data).map(item => {
return item.equipmentId
})
this.setState({
checked: new Set(arr)
})
})
})
.catch(() => {
this.setState({
checked: new Set()
.catch(() => {
this.setState({
checked: new Set()
})
})
})
}
componentWillMount() {
this.getData()
this.getGroupList()
this.getCDetail()
this.getFilmDetail()
}
getData(name?: string | '') {
......@@ -98,11 +102,27 @@ class DeviceSelect extends Component {
})
})
}
getFilmDetail() {
const { fId } = this.$router.params
fId &&
api.common.getFilmDetailInfo(fId).then(res => {
this.setState(
{
cId: res.calendarId
},
() => {
this.getCDetail()
}
)
console.log(res.calendarId, 'filmData')
})
}
getCDetail() {
/**
* 获取日程详情
*/
const { cId } = this.$router.params
const { cId } = this.state
console.log(cId == null, cId, 'cId')
cId &&
cId !== 'null' &&
api.common.getScheduleDetail(cId).then(res => {
......@@ -178,23 +198,25 @@ class DeviceSelect extends Component {
async updateBind() {
// 更新设备绑定
const { checked, list } = this.state
let { cId, fId } = this.$router.params
let { cId } = this.state
let { fId } = this.$router.params
if (cId === 'null') {
cId = ''
}
console.log(cId, 'cId')
let checkedArr: any = []
const equipmentsIds = []
const equipmentTopicList = []
list.map(item => {
if (checked.has(item.equipmentId)) {
checkedArr.push(item)
if (cId) {
if (cId || cId === '') {
equipmentsIds.push(item.equipmentId)
equipmentTopicList.push(item.mqttTopic)
}
}
})
if (cId) {
if (cId || cId === '') {
let obj = {
calendarName: 'DEFAULstring',
filmInfos: [
......@@ -205,12 +227,13 @@ class DeviceSelect extends Component {
],
equipmentsIds: equipmentsIds,
equipmentTopicList: equipmentTopicList,
calendarType: cId ? 'CUSTOME' : 'DEFAUL',
calendarType: 'DEFAUL',
calendarId: ''
}
if (!cId) {
if (cId === '') {
console.log('createSchedule')
delete obj.calendarId
api.common.createdSchedule(obj).then(() => {
api.common.createSchedule(obj).then(() => {
Taro.navigateBack()
})
} else {
......
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