|
|
@@ -1,4 +1,4 @@
|
|
|
-import { YTHeader, yTRouter } from 'basic'
|
|
|
+import { YTHeader, yTRouter, yTToast, YTToast } from 'basic'
|
|
|
import { MainViewModel } from '../viewmodels/MainViewModel'
|
|
|
import { SwiperCom } from '../components/maincomponent/SwiperCom'
|
|
|
import { BuilderHeader } from '../components/maincomponent/BuilderHeader'
|
|
|
@@ -9,19 +9,58 @@ import { TaskItem } from '../components/maincomponent/TaskItem'
|
|
|
import { TaskGridCom } from '../components/maincomponent/BindSheetTask/TaskGridCom'
|
|
|
import { TaskGridIconGrid } from '../components/maincomponent/BindSheetTask/TaskGridIconGrid'
|
|
|
import { TaskGreenPlantsSelect } from '../components/maincomponent/BindSheetTask/TaskGreenPlantsSelect'
|
|
|
+import { GetGreenPlantsParams, GreenPlants, GreenPlantsApi } from '../api/GreenPlantApi'
|
|
|
+import { ClockTaskApi, ClockTaskIcon, ClockTaskItem,
|
|
|
+ InsertClockParam,
|
|
|
+ InsertEditClockTaskParam } from '../api/ClockTaskApi'
|
|
|
+import { SelectIcon } from '../components/maincomponent/BindSheetTask/SelectIcon'
|
|
|
+import dayjs from "dayjs"
|
|
|
+import { promptAction } from '@kit.ArkUI'
|
|
|
|
|
|
@ComponentV2
|
|
|
export struct MainView {
|
|
|
@Local isShowMaintenanceBuilder:boolean=false
|
|
|
- @Local greenPlantList:number[]=[1,2,3]
|
|
|
+ @Local greenPlantList: GreenPlants[]=[]
|
|
|
+ @Local clockTaskList:ClockTaskItem[]=[]
|
|
|
+ @Local ClockTaskIconList:ClockTaskIcon[]=[]
|
|
|
@Local vm:MainViewModel=new MainViewModel()
|
|
|
+ private page:number=1
|
|
|
+ private pageSize:number=20
|
|
|
select:number=-1
|
|
|
aboutToAppear(): void {
|
|
|
- this.getGreenList()
|
|
|
+ this.getGreenList({page:this.page,pageSizes:this.pageSize})
|
|
|
+ this.getClockTaskList()
|
|
|
+ this.getClockTaskIconList()
|
|
|
}
|
|
|
- async getGreenList(){
|
|
|
- this.greenPlantList=await Promise.resolve([1,2,3])
|
|
|
+ async getGreenList(param:GetGreenPlantsParams){
|
|
|
+ const arr=await GreenPlantsApi.getGreenPlants(param)
|
|
|
+ this.greenPlantList=arr.records as GreenPlants[]
|
|
|
}
|
|
|
+ async deleteGreenList(id:number){
|
|
|
+ return await GreenPlantsApi.deleteGreenPlants(id)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ async getClockTaskList(){
|
|
|
+ //获取打卡事项
|
|
|
+ this.clockTaskList=await ClockTaskApi.getClockTaskList()
|
|
|
+ }
|
|
|
+ async getClockTaskIconList(){
|
|
|
+ this.ClockTaskIconList=await ClockTaskApi.getClockTaskIconList()
|
|
|
+ }
|
|
|
+ async insertClockTaskItem(params:InsertEditClockTaskParam){
|
|
|
+ await ClockTaskApi.insertClockTask(params)
|
|
|
+ this.getClockTaskList()
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ async insertClockLog(params:InsertClockParam){
|
|
|
+ await ClockTaskApi.insertClockLog(params)
|
|
|
+ }
|
|
|
+
|
|
|
build() {
|
|
|
Stack({ alignContent: Alignment.BottomEnd }) {
|
|
|
Column() {
|
|
|
@@ -36,20 +75,21 @@ export struct MainView {
|
|
|
SearchGreenPlant({
|
|
|
submit:(keyword:string)=>{
|
|
|
//发送请求,搜索植物
|
|
|
+ this.getGreenList({plantsName:keyword,page:1,pageSizes:20})
|
|
|
}
|
|
|
})
|
|
|
Row() {
|
|
|
Text('最近添加').fontSize(14).fontColor('#333333')
|
|
|
Image($r('app.media.main_icon_edit')).width(24)
|
|
|
- }.width('100%').justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ }.width('100%').justifyContent(FlexAlign.SpaceBetween).margin({top:15,bottom:15})
|
|
|
|
|
|
List({ space: 16 }) {
|
|
|
- ForEach(this.greenPlantList, () => {
|
|
|
+ ForEach(this.greenPlantList, (item:GreenPlants,index:number) => {
|
|
|
ListItem() {
|
|
|
Row() {
|
|
|
Row() {
|
|
|
Column() {
|
|
|
- Image($r('app.media.app_icon')).width(55).height(79)
|
|
|
+ Image(item.plantsPicture).width(55).height(79)
|
|
|
}
|
|
|
.width(70)
|
|
|
.height(90)
|
|
|
@@ -60,15 +100,15 @@ export struct MainView {
|
|
|
.margin({ right: 9 })
|
|
|
|
|
|
Column({ space: 11 }) {
|
|
|
- Text('龟背竹').fontColor('#333333')
|
|
|
+ Text(item.plantsName).fontColor('#333333')
|
|
|
Row({ space: 5 }) {
|
|
|
- Image($r('app.media.main_icon_maintenance')).width(15).height(15)
|
|
|
- Text('今天|已浇水,施肥').fontColor('#333333').fontSize(12)
|
|
|
+ Image($r("app.media.main_icon_clockDesc")).width(15).height(15)
|
|
|
+ Text(item.clockDesc).fontColor('#333333').fontSize(12)
|
|
|
}
|
|
|
|
|
|
Row({ space: 5 }) {
|
|
|
- Image($r('app.media.main_icon_maintenance')).width(15).height(15)
|
|
|
- Text('3天后|需浇水').fontColor('#333333').fontSize(12)
|
|
|
+ Image($r("app.media.main_icon_remindDesc")).width(15).height(15)
|
|
|
+ Text(item.remindDesc).fontColor('#333333').fontSize(12)
|
|
|
}
|
|
|
}.justifyContent(FlexAlign.Start).alignItems(HorizontalAlign.Start)
|
|
|
|
|
|
@@ -85,7 +125,7 @@ export struct MainView {
|
|
|
bottom: 17
|
|
|
})
|
|
|
}.width('100%').onClick(()=>{
|
|
|
- yTRouter.pushPathByName("EditGreenPlantPage",'编辑绿植',(result:PopInfo)=>{
|
|
|
+ yTRouter.pushPathByName("EditGreenPlantPage",item.plantsId,(result:PopInfo)=>{
|
|
|
let ans=result.result as string
|
|
|
if(ans&&ans=='true'){
|
|
|
//刷新植物列表
|
|
|
@@ -117,7 +157,7 @@ export struct MainView {
|
|
|
.backgroundColor('#FF01A74D')
|
|
|
.margin({ bottom: 22, right: 22 })
|
|
|
.onClick(() => {
|
|
|
- yTRouter.pushPathByName("EditGreenPlantPage",'新增绿植',(result:PopInfo)=>{
|
|
|
+ yTRouter.pushPathByName("EditGreenPlantPage",-1,(result:PopInfo)=>{
|
|
|
let ans=result.result as string
|
|
|
if(ans&&ans=='true'){
|
|
|
//刷新植物列表
|
|
|
@@ -167,8 +207,20 @@ export struct MainView {
|
|
|
.backgroundColor(Color.Red)
|
|
|
.borderRadius(10)
|
|
|
.onClick(() => {
|
|
|
- // this.deleteMemorialById(id)
|
|
|
- // this.dayList=this.dayList.filter(item=>item.memorialId!=id)
|
|
|
+ //删除
|
|
|
+ yTToast.doubleConfirm({
|
|
|
+ message:"是否删除该绿植",
|
|
|
+ click:()=>{
|
|
|
+ this.deleteGreenList(id).then((res)=>{
|
|
|
+ if(res){
|
|
|
+ this.greenPlantList.filter(item=>item.plantsId!=id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ yTToast.hide()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
})
|
|
|
}
|
|
|
//养护打卡文字按钮builder
|
|
|
@@ -208,6 +260,13 @@ export struct MainView {
|
|
|
},
|
|
|
rightClick:()=>{
|
|
|
this.isShowMaintenanceBuilder=false
|
|
|
+ const params:InsertClockParam={
|
|
|
+ plantsId:this.vm.plantsId,
|
|
|
+ itemId:this.vm.taskItemId,
|
|
|
+ clockDate:this.vm.clockDate+" 00:00:00",
|
|
|
+ clockTime:this.vm.clockDate+" "+this.vm.clockTime
|
|
|
+ }
|
|
|
+ this.insertClockLog(params)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
@@ -218,14 +277,14 @@ export struct MainView {
|
|
|
Column() {
|
|
|
TaskItem({
|
|
|
title:"打卡事项",
|
|
|
- TaskText:"xxx",
|
|
|
+ TaskText:this.vm.taskItemName,
|
|
|
swiperChange:()=>{
|
|
|
this.vm.swiperController.changeIndex(1,true)
|
|
|
}
|
|
|
})
|
|
|
TaskItem({
|
|
|
title:"打卡植物",
|
|
|
- TaskText:"xxx",
|
|
|
+ TaskText:this.vm.plantsName,
|
|
|
swiperChange:()=>{
|
|
|
this.vm.swiperController.changeIndex(2,true)
|
|
|
}
|
|
|
@@ -237,14 +296,14 @@ export struct MainView {
|
|
|
Column() {
|
|
|
TaskItem({
|
|
|
title:"打卡日期",
|
|
|
- TaskText:"xxx",
|
|
|
+ TaskText:this.vm.clockDate,
|
|
|
swiperChange:()=>{
|
|
|
this.vm.swiperController.changeIndex(3,true)
|
|
|
}
|
|
|
})
|
|
|
TaskItem({
|
|
|
title:"打卡时间",
|
|
|
- TaskText:"xxx",
|
|
|
+ TaskText:this.vm.clockTime,
|
|
|
swiperChange:()=>{
|
|
|
this.vm.swiperController.changeIndex(4,true)
|
|
|
}
|
|
|
@@ -338,32 +397,24 @@ export struct MainView {
|
|
|
})
|
|
|
TaskGridCom({
|
|
|
// selectCurrentTask:this.select
|
|
|
+ clockTaskList:this.clockTaskList,
|
|
|
+ selectCurrenTaskBack:(task:ClockTaskItem)=>{
|
|
|
+ //获取到打卡事项
|
|
|
+ this.vm.taskItemId=task.itemId
|
|
|
+ this.vm.taskItemName=task.itemName
|
|
|
+ },
|
|
|
+ swiperChange:()=>{
|
|
|
+ this.vm.swiperComController[0].changeIndex(1, true)
|
|
|
+ }
|
|
|
+
|
|
|
})
|
|
|
- Column({space:24}) {
|
|
|
- Row() {
|
|
|
- Text('自定义')
|
|
|
- }.width('100%')
|
|
|
- .justifyContent(FlexAlign.Start)
|
|
|
- Grid() {
|
|
|
- ForEach([1], () => {
|
|
|
- GridItem() {
|
|
|
- Column() {
|
|
|
- Image($r('app.media.startIcon')).width(45).height(45)
|
|
|
- Text('xxxx')
|
|
|
- }.onClick(()=>{
|
|
|
- this.vm.swiperComController[0].changeIndex(1,true)
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }.columnsTemplate('1fr 1fr 1fr').layoutWeight(1)
|
|
|
- }
|
|
|
}.ColStyle('#F8F8F8')
|
|
|
.padding({top:16,left:16,right:16})
|
|
|
}
|
|
|
//创建打卡事项
|
|
|
@Builder
|
|
|
AddClockTask(){
|
|
|
- Column(){
|
|
|
+ Column({space:54}){
|
|
|
BuilderHeader({
|
|
|
leftTitle:'上一步',
|
|
|
centerTitle:'创建养护事项',
|
|
|
@@ -371,20 +422,25 @@ export struct MainView {
|
|
|
leftClick:()=>{
|
|
|
this.vm.swiperComController[0].changeIndex(0,true)
|
|
|
},
|
|
|
- rightClick:()=>{
|
|
|
+ rightClick:async ()=>{
|
|
|
this.vm.swiperComController[0].changeIndex(0,true)
|
|
|
//确定之后也返回,创建打卡事项成功
|
|
|
+ this.insertClockTaskItem({
|
|
|
+ itemId:0,
|
|
|
+ itemIcon:this.vm.taskUrl,
|
|
|
+ itemName:this.vm.taskName
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
- Column(){
|
|
|
-
|
|
|
- }.width(123)
|
|
|
- .height(123)
|
|
|
- .backgroundColor(Color.Green)
|
|
|
- .onClick(()=>{
|
|
|
- //选择图标
|
|
|
- this.vm.swiperComController[0].changeIndex(2,true)
|
|
|
+ SelectIcon({
|
|
|
+ swiperChange:()=>{
|
|
|
+ this.vm.swiperComController[0].changeIndex(2, true)
|
|
|
+ },
|
|
|
+ textBack:(text:string)=>{
|
|
|
+ this.vm.taskName=text
|
|
|
+ },
|
|
|
+ icon:this.vm.taskUrl
|
|
|
})
|
|
|
}.ColStyle()
|
|
|
.padding({top:16,left:16,right:16})
|
|
|
@@ -394,7 +450,7 @@ export struct MainView {
|
|
|
//选择打卡事项图标
|
|
|
@Builder
|
|
|
AddClockTaskAndSelectIcon(){
|
|
|
- Column(){
|
|
|
+ Column({space:10}){
|
|
|
BuilderHeader({
|
|
|
leftTitle:'上一步',
|
|
|
centerTitle:'选择事项图标',
|
|
|
@@ -407,7 +463,12 @@ export struct MainView {
|
|
|
//选择事项图标成功,返回
|
|
|
}
|
|
|
})
|
|
|
- TaskGridIconGrid()
|
|
|
+ TaskGridIconGrid({
|
|
|
+ iconList:this.ClockTaskIconList,
|
|
|
+ selectIcon:(clockTaskIcon:ClockTaskIcon)=>{
|
|
|
+ this.vm.taskUrl=clockTaskIcon.iconUrl
|
|
|
+ }
|
|
|
+ })
|
|
|
}.ColStyle()
|
|
|
.padding({top:16,left:16,right:16})
|
|
|
|
|
|
@@ -432,14 +493,16 @@ export struct MainView {
|
|
|
})
|
|
|
|
|
|
TaskGreenPlantsSelect({
|
|
|
- selectGreenPlant:(id:number)=>{
|
|
|
+ selectGreenPlant:(greenPlants:GreenPlants)=>{
|
|
|
//获取到选择的植物
|
|
|
+ this.vm.plantsName=greenPlants.plantsName
|
|
|
+ this.vm.plantsId=greenPlants.plantsId
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}
|
|
|
.padding({top:19,left:8,right:8})
|
|
|
- .ColStyle()
|
|
|
+ .ColStyle('#F8F8F8')
|
|
|
|
|
|
}
|
|
|
//选择日期
|
|
|
@@ -451,10 +514,10 @@ export struct MainView {
|
|
|
back:()=>{
|
|
|
this.vm.swiperController.changeIndex(0,true)
|
|
|
},
|
|
|
- selectDateBack:()=>{
|
|
|
+ selectDateBack:(data:Date)=>{
|
|
|
//需要带参数确定
|
|
|
this.vm.swiperController.changeIndex(0,true)
|
|
|
-
|
|
|
+ this.vm.clockDate=dayjs(data).format('YYYY-MM-DD')
|
|
|
}
|
|
|
|
|
|
})
|
|
|
@@ -468,8 +531,9 @@ export struct MainView {
|
|
|
onCancel:()=>{
|
|
|
this.vm.swiperController.changeIndex(0,true)
|
|
|
},
|
|
|
- onConfirm:()=>{
|
|
|
+ onConfirm:(time:string)=>{
|
|
|
this.vm.swiperController.changeIndex(0,true)
|
|
|
+ this.vm.clockTime=time
|
|
|
}
|
|
|
|
|
|
})
|