refactor component: phoneContactTimePicker
| | |
| | | :options="weekOptions.options" |
| | | :nameOfSelectAll="weekOptions.selectAll"> |
| | | </MultiSelectBtn> |
| | | <div class="pam-popUp-confirm-bolck mt-30"> |
| | | <div class="pam-popUp-confirm-block mt-30"> |
| | | <button class="pam-select-confirm" |
| | | :class="[initPickerControl.selectWeekOptions.length?'el-button--primary' :'is-disabled']" |
| | | @click="confirmByStep_1"> |
| | |
| | | :options="timesOfDayOptions.options" |
| | | :nameOfSelectAll="timesOfDayOptions.selectAll"> |
| | | </MultiSelectBtn> |
| | | <div class="pam-popUp-confirm-bolck mt-30"> |
| | | <div class="pam-popUp-confirm-block mt-30"> |
| | | <button class="pam-select-confirm" |
| | | :class="[initPickerControl.selectTimesOptions.length ?'el-button--primary' :'is-disabled']" |
| | | @click="confirmByStep_2"> |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { Component,PropSync,Vue } from "nuxt-property-decorator"; |
| | | |
| | | import * as _ from "lodash"; |
| | | |
| | | import { weekDays } from "~/shared/const/week-days"; |
| | | import { dayTimeFrames } from "~/shared/const/day-time-frames"; |
| | | |
| | | import { OptionBtnDto } from "./singleSelectBtn.vue"; |
| | | @Component |
| | | export default class PhoneContactTimePicker extends Vue { |
| | | @PropSync('scheduleList',{type:Array,default:()=>[]}) syncScheduleList!:scheduleDto[]; |
| | | |
| | | @PropSync('scheduleList',{type:Array,default:()=>[]}) |
| | | syncScheduleList!:scheduleDto[]; |
| | | |
| | | private weekOptions ={ |
| | | selectAll:'æ¯å¤©', |
| | | options:[ |
| | | { |
| | | title:'ææä¸', |
| | | label:'ææä¸' |
| | | }, |
| | | { |
| | | title:'ææäº', |
| | | label:'ææäº' |
| | | }, |
| | | { |
| | | title:'ææä¸', |
| | | label:'ææä¸' |
| | | }, |
| | | { |
| | | title:'ææå', |
| | | label:'ææå' |
| | | }, |
| | | { |
| | | title:'ææäº', |
| | | label:'ææäº' |
| | | }, { |
| | | title:'ææå
', |
| | | label:'ææå
' |
| | | }, |
| | | { |
| | | title:'æææ¥', |
| | | label:'æææ¥' |
| | | }, |
| | | ], |
| | | options : weekDays, |
| | | }; |
| | | |
| | | private timesOfDayOptions ={ |
| | | selectAll:'å
¨å¤©', |
| | | options:[ |
| | | { |
| | | title:'9:00~12:00', |
| | | label:'9:00~12:00', |
| | | }, |
| | | { |
| | | title:'12:00~14:00', |
| | | label:'12:00~14:00', |
| | | }, |
| | | { |
| | | title:'14:00~18:00', |
| | | label:'14:00~18:00', |
| | | }, |
| | | { |
| | | title:'18:00~21:00', |
| | | label:'18:00~21:00', |
| | | } |
| | | ], |
| | | options : dayTimeFrames, |
| | | }; |
| | | private dialogWidth="376px"; |
| | | private selectedSchedule!:scheduleDto; |
| | | |
| | | // popUp frame |
| | | private isOpenByStep_1=false; |
| | | private isOpenByStep_2=false; |
| | | private popUpTitle=''; |
| | | private initPickerControl={ |
| | | selectWeekOptions:[] as string[], |
| | | selectTimesOptions:[] as string[], |
| | | } |
| | | |
| | | // popUp frame |
| | | private dialogWidth : string = "376px"; |
| | | private isOpenByStep_1 : boolean = false; |
| | | private isOpenByStep_2 : boolean = false; |
| | | private popUpTitle : string= ''; |
| | | private selectedSchedule!: scheduleDto; |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | |
| | | openPopUp(schedule:scheduleDto,index:number):void{ |
| | | this.isOpenByStep_1 = true; |
| | | this.popUpTitle = this.titleFormatByIndex(index); |
| | | this.selectedSchedule = schedule; |
| | | this.initPickerControl = _.cloneDeep(schedule); |
| | | } |
| | | |
| | | addNewSchedule(): void { |
| | | const newScheduleDto={ |
| | | selectWeekOptions:[], |
| | | selectTimesOptions:[], |
| | | } |
| | | this.syncScheduleList.push(newScheduleDto) |
| | | } |
| | | |
| | | confirmByStep_1():void{ |
| | |
| | | this.selectedSchedule.selectWeekOptions = this.getOptionsBySort(this.weekOptions.options,this.initPickerControl.selectWeekOptions); |
| | | this.selectedSchedule.selectTimesOptions = this.getOptionsBySort(this.timesOfDayOptions.options,this.initPickerControl.selectTimesOptions); |
| | | } |
| | | getOptionsBySort(options:OptionBtnDto[],selectedOptions:string[]):string[]{ |
| | | |
| | | private getOptionsBySort(options:OptionBtnDto[],selectedOptions:string[]): string[] { |
| | | return options.map( o => _.includes(selectedOptions,o.title) ? o.title :'').filter(String); |
| | | // return |
| | | } |
| | | addNewSchedule():void{ |
| | | const newScheduleDto={ |
| | | selectWeekOptions:[], |
| | | selectTimesOptions:[], |
| | | } |
| | | this.syncScheduleList.push(newScheduleDto) |
| | | } |
| | | |
| | | deleteScheduleItem(index:number):void{ |
| | |
| | | |
| | | checkFormHasDone(item:scheduleDto):boolean{ |
| | | if (!item) return false; |
| | | return item.selectWeekOptions?.length>0 && item.selectTimesOptions?.length>0; |
| | | return item.selectWeekOptions?.length > 0 |
| | | && item.selectTimesOptions?.length > 0; |
| | | } |
| | | |
| | | titleFormatByIndex(index:number):string{ |
| | | const chineseNumber = ['ä¸','äº','ä¸','å','äº','å
','ä¸','å
«','ä¹','å'] |
| | | return 'ææ®µ'+chineseNumber[index]; |
| | | } |
| | | |
| | | optionsFormat(options:OptionBtnDto[],needToCompareList:OptionDto):string{ |
| | | return _.isEqual(options.length,needToCompareList.options.length) ? needToCompareList.selectAll: _.join(options,','); |
| | | } |
| | | } |
| | | |
| | | export interface scheduleDto{ |
| | | selectWeekOptions:string[]|[]; |
| | | selectTimesOptions:string[]|[]; |
| | | } |
| | | type scheduleKey = keyof scheduleDto |
| | | |
| | | interface OptionDto{ |
| | | selectAll:string, |
| | | options:string[], |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | |
| | | display: flex; |
| | | justify-content: center; |
| | | } |
| | | .pam-popUp-confirm-bolck{ |
| | | .pam-popUp-confirm-block { |
| | | display: flex; |
| | | justify-content: center; |
| | | } |
¤ñ¹ï·sÀÉ®× |
| | |
| | | export const dayTimeFrames = [ |
| | | { |
| | | title:'9:00~12:00', |
| | | label:'9:00~12:00', |
| | | }, |
| | | { |
| | | title:'12:00~14:00', |
| | | label:'12:00~14:00', |
| | | }, |
| | | { |
| | | title:'14:00~18:00', |
| | | label:'14:00~18:00', |
| | | }, |
| | | { |
| | | title:'18:00~21:00', |
| | | label:'18:00~21:00', |
| | | } |
| | | ]; |
¤ñ¹ï·sÀÉ®× |
| | |
| | | export const weekDays = [ |
| | | { |
| | | title:'ææä¸', |
| | | label:'ææä¸' |
| | | }, |
| | | { |
| | | title:'ææäº', |
| | | label:'ææäº' |
| | | }, |
| | | { |
| | | title:'ææä¸', |
| | | label:'ææä¸' |
| | | }, |
| | | { |
| | | title:'ææå', |
| | | label:'ææå' |
| | | }, |
| | | { |
| | | title:'ææäº', |
| | | label:'ææäº' |
| | | }, { |
| | | title:'ææå
', |
| | | label:'ææå
' |
| | | }, |
| | | { |
| | | title:'æææ¥', |
| | | label:'æææ¥' |
| | | }, |
| | | ]; |