| | |
| | | import { dayTimeFrames } from "~/shared/const/day-time-frames"; |
| | | import { OptionBtnDto, OptionDto } from "~/shared/models/optionBtnDto.model"; |
| | | import { weekDays } from "~/shared/const/week-days"; |
| | | import * as _ from "lodash"; |
| | | @Component({ |
| | | filters:{ |
| | | titleFormatByIndex(index:number):string{ |
| | | const chineseNumber = ['一','二','三','四','五','六','七','八','九','十']; |
| | | return '時段'+chineseNumber[index]; |
| | | }, |
| | | optionsFormat(selectedOptions:string[]|[], compareOptions:OptionDto): string{ |
| | | return _.isEqual(selectedOptions.length,compareOptions.options.length) |
| | | optionsFormat(selectedOptions = [], compareOptions) { |
| | | return selectedOptions.length === compareOptions.options.length |
| | | ? compareOptions.selectAll |
| | | : _.join(selectedOptions,','); |
| | | }, |
| | | : selectedOptions.join(','); |
| | | } |
| | | } |
| | | }) |
| | | export default class PhoneContactTimePicker extends Vue { |
| | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | get isOpenByDayPopUp(): boolean{ |
| | | return _.isEqual(this.popUpMode , TimePickerMode.SELECT_DAY) |
| | | return this.popUpMode === TimePickerMode.SELECT_DAY; |
| | | } |
| | | |
| | | set isOpenByDayPopUp(value:boolean){ |
| | |
| | | } |
| | | |
| | | get isOpenByTimePopUp(): boolean{ |
| | | return _.isEqual(this.popUpMode , TimePickerMode.SELECT_TIME); |
| | | return this.popUpMode === TimePickerMode.SELECT_TIME; |
| | | } |
| | | |
| | | set isOpenByTimePopUp(value:boolean){ |
| | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | openPopUp(schedule:scheduleDto,index:number):void{ |
| | | this.initPickerControl = _.cloneDeep(schedule); |
| | | this.initPickerControl = JSON.parse(JSON.stringify(schedule)); |
| | | this.popUpMode = TimePickerMode.SELECT_DAY; |
| | | this.scheduleIndex = index; |
| | | } |
| | |
| | | } |
| | | |
| | | private initPickerFormatSort(initPickerControl:scheduleDto):scheduleDto{ |
| | | _.keys(initPickerControl).forEach(keyName=>{ |
| | | const options = _.isEqual(keyName,'selectWeekOptions') ? weekDays : dayTimeFrames; |
| | | Object.keys(initPickerControl).forEach(keyName=>{ |
| | | const options = keyName === 'selectWeekOptions' ? weekDays : dayTimeFrames; |
| | | initPickerControl[keyName] = this.getOptionsBySort(initPickerControl[keyName],options); |
| | | }) |
| | | return initPickerControl; |
| | |
| | | |
| | | // 資料重新排序,回復一開始清單順序 |
| | | private getOptionsBySort( selectedOptions:string[] , options:OptionBtnDto[]): string[] { |
| | | return options.map( o => _.includes(selectedOptions , o.label) ? o.label as string : '').filter(String); |
| | | return options.map( o => selectedOptions.includes(o.label as string) ? o.label as string : '').filter(String); |
| | | } |
| | | |
| | | addNewSchedule(): void { |