feat(ywq): 增加已签列表时间筛选功能- 在 SignedView 页面添加时间筛选功能
- 实现根据选定月份筛选已签列表的逻辑 - 优化 UnSignView 和 UnSignBatchView 页面的样式 -改进 DatePickerView 组件,支持单独选择年、月、日- 在 TimeHelper 中添加获取月份天数的方法
这个提交包含在:
父节点
ebb40b70f4
当前提交
97b29f3e99
@ -16,6 +16,7 @@
|
|||||||
export class TimeHelper {
|
export class TimeHelper {
|
||||||
private constructor() {
|
private constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前时间戳
|
* 获取当前时间戳
|
||||||
* @returns
|
* @returns
|
||||||
@ -32,6 +33,7 @@ export class TimeHelper {
|
|||||||
static getTime(format: string = 'yyyy-MM-dd HH:mm:ss') {
|
static getTime(format: string = 'yyyy-MM-dd HH:mm:ss') {
|
||||||
return TimeHelper.formatDate(new Date(), format)
|
return TimeHelper.formatDate(new Date(), format)
|
||||||
}
|
}
|
||||||
|
|
||||||
static formatDate(date: Date, format: string) {
|
static formatDate(date: Date, format: string) {
|
||||||
const replacements: { [key: string]: string } = {
|
const replacements: { [key: string]: string } = {
|
||||||
yyyy: date.getFullYear().toString(),
|
yyyy: date.getFullYear().toString(),
|
||||||
@ -43,4 +45,14 @@ export class TimeHelper {
|
|||||||
};
|
};
|
||||||
return format.replace(/yyyy|MM|dd|HH|mm|ss/g, matched => replacements[matched]);
|
return format.replace(/yyyy|MM|dd|HH|mm|ss/g, matched => replacements[matched]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取月份天数
|
||||||
|
* @param year
|
||||||
|
* @param month
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
static getMonthDays(year: number, month: number) {
|
||||||
|
return new Date(year, month, 0).getDate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,9 @@ import { ToolsHelper } from '../ToolsHelper'
|
|||||||
export struct DatePickerView {
|
export struct DatePickerView {
|
||||||
@Prop option: DateDialogOptions | undefined = undefined
|
@Prop option: DateDialogOptions | undefined = undefined
|
||||||
@Prop dialogTag: string | undefined = undefined
|
@Prop dialogTag: string | undefined = undefined
|
||||||
|
@State showYear: boolean = false
|
||||||
|
@State showMonth: boolean = false
|
||||||
|
@State showDay: boolean = false
|
||||||
//年份相关
|
//年份相关
|
||||||
@State startYear: number = 1970
|
@State startYear: number = 1970
|
||||||
@State endYear: number = 1970
|
@State endYear: number = 1970
|
||||||
@ -26,7 +29,14 @@ export struct DatePickerView {
|
|||||||
if (!this.option?.type) {
|
if (!this.option?.type) {
|
||||||
this.option!.type = 'YYYY-MM-DD'
|
this.option!.type = 'YYYY-MM-DD'
|
||||||
}
|
}
|
||||||
if (this.option!.type.indexOf('YYYY') > -1) {
|
this.checkYear()
|
||||||
|
this.checkMonth()
|
||||||
|
this.checkDays()
|
||||||
|
}
|
||||||
|
|
||||||
|
checkYear() {
|
||||||
|
this.showYear = this.option!.type!.indexOf('YYYY') > -1
|
||||||
|
if (this.showYear) {
|
||||||
if (this.option?.startDate) {
|
if (this.option?.startDate) {
|
||||||
this.startYear = Number.parseInt(this.option.startDate?.split('-')[0])
|
this.startYear = Number.parseInt(this.option.startDate?.split('-')[0])
|
||||||
}
|
}
|
||||||
@ -46,12 +56,11 @@ export struct DatePickerView {
|
|||||||
this.currentYear = this.years.indexOf(new Date().getFullYear().toString())
|
this.currentYear = this.years.indexOf(new Date().getFullYear().toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.checkMonth()
|
|
||||||
this.checkDays()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMonth() {
|
checkMonth() {
|
||||||
if (this.option!.type!.indexOf('MM') > -1) {
|
this.showMonth = this.option!.type!.indexOf('MM') > -1
|
||||||
|
if (this.showMonth) {
|
||||||
if (this.option?.startDate) {
|
if (this.option?.startDate) {
|
||||||
this.startMonth = Number.parseInt(this.option.startDate?.split('-')[1])
|
this.startMonth = Number.parseInt(this.option.startDate?.split('-')[1])
|
||||||
}
|
}
|
||||||
@ -80,7 +89,8 @@ export struct DatePickerView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkDays() {
|
checkDays() {
|
||||||
if (this.option!.type!.indexOf('DD') > -1) {
|
this.showDay = this.option!.type!.indexOf('DD') > -1
|
||||||
|
if (this.showDay) {
|
||||||
if (this.option?.startDate) {
|
if (this.option?.startDate) {
|
||||||
this.startDay = Number.parseInt(this.option.startDate?.split('-')[2])
|
this.startDay = Number.parseInt(this.option.startDate?.split('-')[2])
|
||||||
}
|
}
|
||||||
@ -135,15 +145,21 @@ export struct DatePickerView {
|
|||||||
.padding(15)
|
.padding(15)
|
||||||
|
|
||||||
Row() {
|
Row() {
|
||||||
|
if (this.startYear) {
|
||||||
TextPicker({ range: this.years, selected: $$this.currentYear })
|
TextPicker({ range: this.years, selected: $$this.currentYear })
|
||||||
.onChange((value: string | string[], index: number | number[]) => {
|
.onChange((value: string | string[], index: number | number[]) => {
|
||||||
this.checkDays()
|
this.checkDays()
|
||||||
}).canLoop(false)
|
}).canLoop(false)
|
||||||
|
}
|
||||||
|
if (this.startMonth) {
|
||||||
TextPicker({ range: this.months, selected: $$this.currentMonth })
|
TextPicker({ range: this.months, selected: $$this.currentMonth })
|
||||||
.onChange((value: string | string[], index: number | number[]) => {
|
.onChange((value: string | string[], index: number | number[]) => {
|
||||||
this.checkDays()
|
this.checkDays()
|
||||||
}).canLoop(false)
|
}).canLoop(false)
|
||||||
|
}
|
||||||
|
if (this.startDay) {
|
||||||
TextPicker({ range: this.days, selected: $$this.currentDay })
|
TextPicker({ range: this.days, selected: $$this.currentDay })
|
||||||
|
}
|
||||||
|
|
||||||
}.width('100%').justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center)
|
}.width('100%').justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center)
|
||||||
}
|
}
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户