|
|
@@ -1,7 +1,7 @@
|
|
|
import { IBestToast, YTAvoid, yTRouter, yTToast } from 'basic'
|
|
|
import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
|
|
import { DiaryDatePicker } from '../components/DiaryDatePicker';
|
|
|
-import { DiaryData, PageStatus } from '../models';
|
|
|
+import { DiaryData, PageStatus, Variable } from '../models';
|
|
|
import { DiaryViewModel } from '../viewModels/DiaryViewModel';
|
|
|
import { DateUtils } from '../utils/DateUtils';
|
|
|
import { DiaryTimePicker } from '../components/DiaryTimePicker';
|
|
|
@@ -59,6 +59,7 @@ struct IncreaseDiaryPage {
|
|
|
async onComplete() {
|
|
|
if(this.pageReadOnly) {
|
|
|
this.pageReadOnly = false;
|
|
|
+ Variable.pageReadOnly = false
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -171,7 +172,7 @@ struct IncreaseDiaryPage {
|
|
|
* @returns
|
|
|
*/
|
|
|
onRouterBack(): boolean {
|
|
|
- // if(this.diaryData.id) {
|
|
|
+ if(!Variable.pageReadOnly) {
|
|
|
yTToast.openToast(wrapBuilder(DoubleConfirm), {
|
|
|
text: "是否确认退出编辑",
|
|
|
click: async () => {
|
|
|
@@ -179,9 +180,9 @@ struct IncreaseDiaryPage {
|
|
|
yTRouter.routerBack()
|
|
|
}
|
|
|
})
|
|
|
- // } else {
|
|
|
- // yTRouter.routerBack()
|
|
|
- // }
|
|
|
+ } else {
|
|
|
+ yTRouter.routerBack()
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -197,6 +198,7 @@ struct IncreaseDiaryPage {
|
|
|
let id = (params?.id ?? -1) as number;
|
|
|
if (id != -1) {
|
|
|
this.pageReadOnly = true
|
|
|
+ Variable.pageReadOnly = true
|
|
|
if(this.pageStatus == PageStatus.DIARY) {
|
|
|
this.diaryData = await DiaryViewModel.queryDiaryLogById(id)
|
|
|
} else {
|
|
|
@@ -307,6 +309,20 @@ struct IncreaseDiaryPage {
|
|
|
.caretColor('app.color.main_ac_color_dark')
|
|
|
.placeholderFont({ size: 16, weight: FontWeight.Bold })
|
|
|
|
|
|
+ Row(){
|
|
|
+ if(this.diaryData.title && !this.pageReadOnly){
|
|
|
+ Image($r('app.media.Diary_close'))
|
|
|
+ .width(24)
|
|
|
+ .height(24)
|
|
|
+ .borderRadius(12)
|
|
|
+ .onClick(() => {
|
|
|
+ this.diaryData.title = ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .width(24)
|
|
|
+ .margin({right: 15})
|
|
|
+
|
|
|
Text(`${20 - (this.diaryData.title ? this.diaryData.title.length : 0) }`)
|
|
|
.fontColor("#BFBFBF")
|
|
|
}
|
|
|
@@ -319,18 +335,20 @@ struct IncreaseDiaryPage {
|
|
|
})
|
|
|
|
|
|
// 内容栏
|
|
|
- Row(){
|
|
|
- TextArea({ text: $$this.diaryData.content, placeholder: "记录此刻" })
|
|
|
- .padding(0)
|
|
|
- .fontSize(14)
|
|
|
- .width("100%")
|
|
|
- .height("100%")
|
|
|
- .borderRadius(0)
|
|
|
- .fontWeight(400)
|
|
|
- .placeholderColor("#BFBFBF")
|
|
|
- .placeholderFont({ size: 16 })
|
|
|
- .backgroundColor(Color.Transparent)
|
|
|
- .caretColor('app.color.main_ac_color_dark')
|
|
|
+ List(){
|
|
|
+ ListItem(){
|
|
|
+ TextArea({ text: $$this.diaryData.content, placeholder: "记录此刻" })
|
|
|
+ .padding(0)
|
|
|
+ .fontSize(14)
|
|
|
+ .width("100%")
|
|
|
+ .height("100%")
|
|
|
+ .borderRadius(0)
|
|
|
+ .fontWeight(400)
|
|
|
+ .placeholderColor("#BFBFBF")
|
|
|
+ .placeholderFont({ size: 16 })
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+ .caretColor('app.color.main_ac_color_dark')
|
|
|
+ }
|
|
|
}
|
|
|
.padding({top: 12})
|
|
|
.layoutWeight(1)
|
|
|
@@ -381,7 +399,8 @@ struct IncreaseDiaryPage {
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.padding({ top: 6, right: 18, bottom: 6, left: 18})
|
|
|
.onClick(() => {
|
|
|
- this.clearPhoto()
|
|
|
+ // this.clearPhoto()
|
|
|
+ this.diaryData.content = ''
|
|
|
})
|
|
|
|
|
|
// 相册
|
|
|
@@ -471,7 +490,6 @@ struct IncreaseDiaryPage {
|
|
|
this.showDatePicker = false
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
.width("100%")
|
|
|
.height("100%")
|
|
|
@@ -492,7 +510,8 @@ struct IncreaseDiaryPage {
|
|
|
}
|
|
|
.hideTitleBar(true)
|
|
|
.onBackPressed(() => {
|
|
|
- return this.onRouterBack()
|
|
|
+ console.log("返回"+this.pageReadOnly)
|
|
|
+ return this.onRouterBack.bind(this)
|
|
|
})
|
|
|
}
|
|
|
}
|