Commit b0386bf4 by hank

修复 日程bug

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