Component({ mixins: [], data: { comSelectListId: 0, comSelectList: [] }, props: { iconType: 'icon', complete: false, multiple: false, }, didMount() { this.setData({ comSelectListId: this.props.comSelectListId, comSelectList: this.props.comSelectList }) }, didUpdate() { this.setData({ comSelectListId: this.props.comSelectListId }) }, didUnmount() { }, methods: { comSelectList(event) { if (this.props.multiple && event.currentTarget.dataset.item.id != -1) { if (this.data.comSelectList.includes(-1)) { this.setData({ comSelectList: [] }) } if (this.data.comSelectList.includes(event.target.dataset.item.id)) { this.data.comSelectList.forEach((item, index) => { if (item == event.target.dataset.item.id) { this.data.comSelectList.splice(index, 1) } return }) } else { this.data.comSelectList.push(event.target.dataset.item.id) } this.setData({ comSelectList: this.data.comSelectList }) } else if (this.props.multiple && event.currentTarget.dataset.item.id == -1) { this.setData({ comSelectList: [-1] }) } else if (!this.props.multiple) { this.setData({ comSelectListId: event.currentTarget.dataset.item.id }) this.props.onComSelectList(event) } }, complete(event) { let comSelectList = this.data.comSelectList.sort((a, b) => { return a - b }) this.props.onCompelete(comSelectList) } }, });