From 4fb1011fcde1e00bd46c2272a47959df6db669fa Mon Sep 17 00:00:00 2001
From: panliang <1163816051@qq.com>
Date: Sat, 2 Sep 2023 09:48:13 +0800
Subject: [PATCH] swipe
---
src/pages/patient/detail.vue | 37 +++++++++++++++++++++++-
src/pages/patient/index.vue | 27 +++++++++++++++--
src/pages/record/detail.vue | 38 ++++++++++++++++++++++--
src/pages/record/form.vue | 7 +++--
src/pages/record/index.vue | 56 +++++++++++++++++++++++++++++++-----
5 files changed, 150 insertions(+), 15 deletions(-)
diff --git a/src/pages/patient/detail.vue b/src/pages/patient/detail.vue
index 03dbc04..e2fc363 100644
--- a/src/pages/patient/detail.vue
+++ b/src/pages/patient/detail.vue
@@ -64,7 +64,9 @@
/>
-
+
+
+
{
+ if (result.confirm) {
+ this.delete(this.info.id)
+ }
+ }
+ })
+ },
+ delete(id) {
+ uni.showLoading()
+ this.$ajax.delete(`/admin-api/patient/${id}`).then(res => {
+ if (res.status == 0) {
+ uni.showToast({
+ title: '删除成功',
+ icon: 'success'
+ })
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1000)
+ }
+ })
+ }
}
}
@@ -227,6 +260,8 @@ export default {
}
.btn {
padding: 0 10px;
+ }
+ .btn .u-button {
margin-top: 20px;
}
diff --git a/src/pages/patient/index.vue b/src/pages/patient/index.vue
index 190217f..5b9e171 100644
--- a/src/pages/patient/index.vue
+++ b/src/pages/patient/index.vue
@@ -13,15 +13,19 @@
+
+
+
+
{
+ if (result.confirm) {
+ this.delete(item.id)
+ }
+ }
+ })
+ }
+ },
delete(id) {
uni.showLoading()
this.$ajax.delete(`/admin-api/patient/${id}`).then(res => {
diff --git a/src/pages/record/detail.vue b/src/pages/record/detail.vue
index c812b2c..3791720 100644
--- a/src/pages/record/detail.vue
+++ b/src/pages/record/detail.vue
@@ -87,6 +87,9 @@
:value="info.created_at"
/>
+
+
+
{
+ if (result.confirm) {
+ this.handleDelete(this.id)
+ }
+ }
+ })
+ },
+ handleDelete(id) {
+ uni.showLoading()
+ this.$ajax.delete(`/admin-api/record/${id}`).then(res => {
+ if (res.status == 0) {
+ uni.showToast({
+ title: '删除成功',
+ icon: 'success'
+ })
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1000)
+ }
+ })
+ }
}
}
-
-
\ No newline at end of file
diff --git a/src/pages/record/form.vue b/src/pages/record/form.vue
index 6912649..a4f0e0c 100644
--- a/src/pages/record/form.vue
+++ b/src/pages/record/form.vue
@@ -211,9 +211,12 @@ export default {
this.$ajax.get('/admin-api/category', {_action: 'getData'}).then(res => {
if (res.status == 0) {
this.typeList = res.data.items
- const type_id = uni.getStorageSync('medical_record_treat_type_id');
+ let type_id = e.type_id
+ if (!type_id) {
+ type_id = uni.getStorageSync('medical_record_treat_type_id')
+ }
if (type_id) {
- this.form.type_id = type_id
+ this.form.type_id = parseInt(type_id)
this.typeChange(type_id)
}
}
diff --git a/src/pages/record/index.vue b/src/pages/record/index.vue
index d6ce05e..a31bbc3 100644
--- a/src/pages/record/index.vue
+++ b/src/pages/record/index.vue
@@ -1,6 +1,9 @@
+
+
+
@@ -51,6 +54,7 @@ export default {
data() {
return {
patient_id: '',
+ patient: {},
typeIndex: 0,
perPage: 20,
typeList: [],
@@ -72,6 +76,12 @@ export default {
},
onLoad(e) {
this.patient_id = e.patient
+ this.$ajax.get(`/admin-api/patient/${this.patient_id}`, {_action: 'getData'}).then(res => {
+ if (res.status == 0) {
+ this.patient = res.data
+ uni.setNavigationBarTitle({ title: this.patient.name })
+ }
+ })
},
onShow() {
this.loadData(true)
@@ -83,6 +93,7 @@ export default {
this.$ajax.get('/admin-api/category', {_action: 'getData'}).then(res => {
if (res.status == 0) {
this.typeList = res.data.items
+ this.loadData()
}
})
},
@@ -96,12 +107,11 @@ export default {
this.list = []
this.page = 1
}
- uni.showLoading()
+ // 要等分类接口返回了, 然后再去查询记录
if (this.typeList.length == 0) {
- return setTimeout(() => {
- this.loadData(refresh)
- }, 800);
+ return
}
+ uni.showLoading()
const type = this.typeList[this.typeIndex]
this.$ajax.get('/admin-api/record?', {_action: 'getData', page: this.page, perPage: this.perPage, type_id: type.id, patient_id: this.patient_id}).then(res => {
uni.stopPullDownRefresh()
@@ -138,11 +148,37 @@ export default {
}
},
swipeClick(e) {
- console.log(e)
+ const action = e.index
+ if (action == 0) {
+ return uni.showModal({
+ title: '删除病历记录',
+ content: '是否确定?',
+ success: (result) => {
+ if (result.confirm) {
+ this.handleDelete(e.name)
+ }
+ }
+ })
+ }
},
- handleDelete() {
-
+ handleDelete(id) {
+ uni.showLoading()
+ this.$ajax.delete(`/admin-api/record/${id}`).then(res => {
+ if (res.status == 0) {
+ uni.showToast({
+ title: '删除成功',
+ icon: 'success'
+ })
+ setTimeout(() => {
+ this.loadData(true)
+ }, 1000)
+ }
+ })
},
+ add() {
+ const type = this.typeList[this.typeIndex]
+ return uni.navigateTo({ url: `/pages/record/form?patient=${this.patient_id}&type_id=${type.id}` })
+ }
}
}
@@ -165,4 +201,10 @@ export default {
.u-icon {
display: inline-block;
}
+ .add-button {
+ position: absolute;
+ bottom: 100px;
+ right: 50px;
+ z-index: 999;
+ }