diff --git a/src/components/CropPopup.vue b/src/components/CropPopup.vue
index 289242d..e4e5c23 100644
--- a/src/components/CropPopup.vue
+++ b/src/components/CropPopup.vue
@@ -5,6 +5,7 @@
:safe-area-inset-bottom="true"
:close-on-click-modal="true"
custom-style="border-radius: 32rpx 32rpx 0 0; padding: 40rpx 32rpx"
+ @close="handeClosePopup"
>
{{ patchStore.cropApiType === 'ADD' ? '新增作物' : '编辑作物' }}
@@ -59,7 +60,7 @@
{
+ patchStore.showPatchFab = true
+ patchStore.showRecordFab = true
+ }, 300)
+}
+
function cancelClick() {
- patchStore.showRecordPopup = false
+ patchStore.showCropPopup = false
+ handeClosePopup()
}
async function deleteClick() {
@@ -112,13 +120,16 @@ async function saveClick() {
if (patchStore.cropApiType === 'ADD') {
await patchStore.addCropApi()
await patchStore.queryPatch(patchStore.currentPatch.id)
+ await patchStore.queryPatchList()
uni.showToast({ title: '新增作物成功', icon: 'none' })
} else if (patchStore.cropApiType === 'UPDATE') {
await patchStore.updateCropApi(patchStore.cropForm.id)
await patchStore.queryPatch(patchStore.currentPatch.id)
+ await patchStore.queryPatchList()
uni.showToast({ title: '更新作物成功', icon: 'none' })
}
patchStore.showCropPopup = false
+ handeClosePopup()
}
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index f3072ca..77580de 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -15,10 +15,14 @@
+ @clear="patchStore.queryPatchList()">
+
+
+
+
@@ -38,7 +42,7 @@
-
+
{{ item.crop.name }}
{{ item.crop.variety }}
@@ -65,6 +69,7 @@
+
@@ -74,8 +79,9 @@ import { computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import appLogo from '@/static/logo.png'
import { usePatchStore } from "@/stores/patch";
-import type {ICrop, IPatch} from "@/types";
+import type { ICrop, IPatch } from "@/types";
import PatchPopup from "@/components/PatchPopup.vue";
+import CropPopup from "@/components/CropPopup.vue";
defineOptions({ name: 'Home' })
@@ -144,4 +150,12 @@ function handlePreview(crop: ICrop) {
const fullUrls = crop.images?.map(url => `${patchStore.baseUrl}/${url}`) as string[]
uni.previewImage({ urls: fullUrls, current: fullUrls[0] })
}
+
+function updateCropClick(patch: IPatch) {
+ patchStore.currentPatch = patch
+ patchStore.showPatchFab = false
+ patchStore.cropForm = JSON.parse(JSON.stringify(patch.crop))
+ patchStore.cropApiType = 'UPDATE'
+ patchStore.showCropPopup = true
+}
diff --git a/src/pages/record/index.vue b/src/pages/record/index.vue
index 11c0ed8..0293e9b 100644
--- a/src/pages/record/index.vue
+++ b/src/pages/record/index.vue
@@ -1 +1 @@
-
{{ patchStore.currentPatch.crop.name }}
{{ patchStore.currentPatch.crop.variety }}
点击添加作物
{{ item.type }}
{{ item.stage }}
{{ item.date }}
{{ item.content }}
\ No newline at end of file
+
{{ patchStore.currentPatch.crop.name }}
{{ patchStore.currentPatch.crop.variety }}
点击添加作物
{{ item.type }}
{{ item.stage }}
{{ item.date }}
{{ item.content }}
\ No newline at end of file
diff --git a/src/stores/patch.ts b/src/stores/patch.ts
index bdc36d0..50e91a0 100644
--- a/src/stores/patch.ts
+++ b/src/stores/patch.ts
@@ -38,12 +38,14 @@ export const usePatchStore = defineStore('patch', {
}),
actions: {
async queryPatchList() {
+ this.patchList = []
this.patchList = await this.queryPatchListApi()
},
async queryPatch(patchId: number) {
this.currentPatch = await this.queryPatchApi(patchId)
},
async queryRecordList(cropId: number) {
+ this.recordList = []
this.recordList = await this.queryRecordListApi(cropId)
},
async queryPatchListApi() {