Skip to content
Snippets Groups Projects
Commit 421c919b authored by 沈 芳's avatar 沈 芳
Browse files

dateselect

parent cc2e1106
No related branches found
No related tags found
No related merge requests found
...@@ -12,10 +12,11 @@ interface SysTimeResponse { ...@@ -12,10 +12,11 @@ interface SysTimeResponse {
@Component @Component
export default struct AddItem { export default struct AddItem {
@Consume('localPageStack') LocalPageStack: NavPathStack @Consume('localPageStack') LocalPageStack: NavPathStack
private selectedTime: Date = new Date('2022-07-22T08:00:00')
selectedDate: Date = new Date("2010-1-1")
@State itemName: string = '' @State itemName: string = ''
@State itemDisc: string = '' @State itemDisc: string = ''
@State isMilitaryTime: boolean = false
build() { build() {
NavDestination() { NavDestination() {
Column() { Column() {
...@@ -75,90 +76,11 @@ export default struct AddItem { ...@@ -75,90 +76,11 @@ export default struct AddItem {
}) })
} }
} }
} }
@Builder @Builder
MainPage() { MainPage() {
/* Column() {
Row() {
Text('标题')
.fontSize(CommonConstants.detail_title_font_size)
.fontWeight(FontWeight.Bold)
.width(CommonConstants.add_name_width)
.margin({
left: CommonConstants.detail_margin_Left
})
TextInput({ placeholder: '请输入事项名字'})
.width(CommonConstants.input_container_width)
.margin({ left: CommonConstants.input_margin_left })
.backgroundColor($r('app.color.grey'))
.caretColor(Color.Blue) //光标
.placeholderColor(Color.Grey)
.placeholderFont({size: CommonConstants.detail_font_size})
.fontSize(CommonConstants.detail_font_size)
.onChange((value: string) => {
this.itemName = value;
})
}
}
.margin({
top: CommonConstants.list_margin_top
})
.width(CommonConstants.list_width)
.height(CommonConstants.name_height)
.backgroundColor($r('app.color.white'))
.borderRadius(CommonConstants.border_radius)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Start)
Column() {
Row() {
Text('详情')
.fontSize(CommonConstants.detail_title_font_size)
.fontWeight(FontWeight.Bold)
.width(CommonConstants.add_name_width)
.margin({
left: CommonConstants.detail_margin_Left
})
*//* TextArea({ placeholder: '请输入事项描述'})
.width(CommonConstants.input_container_width)
.height(CommonConstants.input_disc_height)
.margin({ left: CommonConstants.input_margin_left })
.backgroundColor($r('app.color.grey'))
.caretColor(Color.Blue) //光标
.placeholderColor(Color.Grey)
.placeholderFont({size: CommonConstants.detail_font_size})
.fontSize(CommonConstants.detail_font_size)
.onChange((value: string) => {
this.itemDisc = value;
})*//*
}
Row(){
TextArea({ placeholder: '请输入事项描述'})
.width('80%')
.height(CommonConstants.input_disc_height)
.margin({ left: CommonConstants.input_margin_left })
.backgroundColor($r('app.color.grey'))
.caretColor(Color.Blue) //光标
.placeholderColor(Color.Grey)
.placeholderFont({size: CommonConstants.detail_font_size})
.fontSize(CommonConstants.detail_font_size)
.onChange((value: string) => {
this.itemDisc = value;
})
}
}
.margin({
top: CommonConstants.list_margin_top
})
.width(CommonConstants.list_width)
.height(CommonConstants.disc_height)
.backgroundColor($r('app.color.white'))
.borderRadius(CommonConstants.border_radius)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Start)*/
Column() { Column() {
// 标题和输入框行 // 标题和输入框行
Row() { Row() {
...@@ -187,6 +109,7 @@ export default struct AddItem { ...@@ -187,6 +109,7 @@ export default struct AddItem {
.justifyContent(FlexAlign.Center) .justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Top) .alignItems(VerticalAlign.Top)
// 详情输入框 // 详情输入框
Row() { Row() {
Text('详情') Text('详情')
...@@ -195,8 +118,16 @@ export default struct AddItem { ...@@ -195,8 +118,16 @@ export default struct AddItem {
.width('15%') .width('15%')
.margin({ left: 40 }) .margin({ left: 40 })
/* TextArea({ placeholder: '请输入事项描述' }) }
.width('70%') .margin({ top: CommonConstants.list_margin_top })
.width(CommonConstants.list_width)
.height('10vp')
.borderRadius(CommonConstants.border_radius)
.justifyContent(FlexAlign.Start)
Row() {
TextArea({ placeholder: '请输入事项描述' })
.width('90%')
.height(CommonConstants.input_disc_height) .height(CommonConstants.input_disc_height)
.margin({ left: CommonConstants.input_margin_left }) .margin({ left: CommonConstants.input_margin_left })
.backgroundColor('#EDEDED') // 设置背景透明 .backgroundColor('#EDEDED') // 设置背景透明
...@@ -206,39 +137,51 @@ export default struct AddItem { ...@@ -206,39 +137,51 @@ export default struct AddItem {
.fontSize(CommonConstants.detail_font_size) .fontSize(CommonConstants.detail_font_size)
.onChange((value: string) => { .onChange((value: string) => {
this.itemDisc = value; this.itemDisc = value;
})*/ })
} }
.margin({ top: CommonConstants.list_margin_top }) .margin({ top: CommonConstants.list_margin_top })
.width(CommonConstants.list_width) .width(CommonConstants.list_width)
.height('10vp') .height('400vp')
.borderRadius(CommonConstants.border_radius)
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Top)
Row() {
Button("选择截止日期")
.margin({ left: 40 })
.onClick(() => {
DatePickerDialog.show({
start: new Date("2025-1-18"),
end: new Date("2030-12-31"),
selected: this.selectedDate,
onAccept: (value: DatePickerResult) => {
// 通过Date的setFullYear方法设置按下确定按钮时的日期,这样当弹窗再次弹出时显示选中的是上一次确定的日期
this.selectedDate.setFullYear(value.year, value.month, value.day)
console.info("DatePickerDialog:onAccept()" + JSON.stringify(value))
},
onCancel: () => {
console.info("DatePickerDialog:onCancel()")
},
onChange: (value: DatePickerResult) => {
console.info("DatePickerDialog:onChange()" + JSON.stringify(value))
}
})
})
.height('50pv')
.width('50%')
}
.margin({ top: CommonConstants.list_margin_top })
.width(CommonConstants.list_width)
.height('80vp')
.borderRadius(CommonConstants.border_radius) .borderRadius(CommonConstants.border_radius)
.justifyContent(FlexAlign.Start) .justifyContent(FlexAlign.Start)
/* .justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Top )*/
}
Row() {
TextArea({ placeholder: '请输入事项描述' })
.width('90%')
.height(CommonConstants.input_disc_height)
.margin({ left: CommonConstants.input_margin_left })
.backgroundColor('#EDEDED') // 设置背景透明
.caretColor(Color.Blue) // 光标颜色
.placeholderColor(Color.Grey)
.placeholderFont({ size: CommonConstants.detail_font_size })
.fontSize(CommonConstants.detail_font_size)
.onChange((value: string) => {
this.itemDisc = value;
})
} }
.margin({ top: CommonConstants.list_margin_top })
.width(CommonConstants.list_width)
.height('400vp')
.borderRadius(CommonConstants.border_radius)
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Top)
} }
private async requestTime(): Promise<string> { //Todo:这个是请求当前时间,没有意义,需要添加一个输入ddl的日期组件 /* private async requestTime(): Promise<string> { //Todo:这个是请求当前时间,没有意义,需要添加一个输入ddl的日期组件
let httpRequest = http.createHttp() let httpRequest = http.createHttp()
let res = '' let res = ''
try { try {
...@@ -259,14 +202,14 @@ export default struct AddItem { ...@@ -259,14 +202,14 @@ export default struct AddItem {
httpRequest.destroy() httpRequest.destroy()
} }
return res return res
} }*/
private async addItem() { private async addItem() {
let time = '' /* let time = ''
while(time == '') { while(time == '') {
time = await this.requestTime() time = await this.requestTime()
} }*/
const res = await webAPI.addSingleItem(this.itemName, time, this.itemDisc) const res = await webAPI.addSingleItem(this.itemName, this.selectedDate.toLocaleDateString('en-CA'), this.itemDisc)
if(res == 'error') { if(res == 'error') {
promptAction.showToast({ promptAction.showToast({
message: '添加失败!' message: '添加失败!'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment