From 000ebef2f0bf5f364a6a9fbc5f0031030f044f63 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 1 Sep 2023 10:10:11 +0800 Subject: [PATCH] patient form --- src/App.vue | 9 +- src/components/select-admin-user.vue | 6 +- src/pages/patient/detail.vue | 222 ++++++++++++++++++++++++++- src/pages/patient/form.vue | 70 +++++++-- src/pages/patient/index.vue | 97 +++++++++--- src/utils/ajax.js | 3 +- 6 files changed, 357 insertions(+), 50 deletions(-) diff --git a/src/App.vue b/src/App.vue index e30bb66..72c8e08 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,9 @@ - - diff --git a/src/components/select-admin-user.vue b/src/components/select-admin-user.vue index f51f7f7..f219f84 100644 --- a/src/components/select-admin-user.vue +++ b/src/components/select-admin-user.vue @@ -1,5 +1,5 @@ @@ -42,10 +44,18 @@ export default { perPage: 20, total: 0, search: '', - options: [ - {text: '修改', style: { backgroundColor: '#007aff' }}, - {text: '删除', style: { backgroundColor: '#dd524d' }} - ], + option: { + id: '', + show: false, + list: [ + { name: "详细", color: '#4cd964', action: 'detail'}, + { name: "修改", color: "#007aff", action: 'edit' }, + { name: "添加病历", color: "#f0ad4e", action: 'record-add' }, + { name: "查看病历", color: "#4cd964", action: 'record' }, + { name: "删除", color: "#dd524d", action: 'delete' }, + ], + title: '', + } } }, onShow() { @@ -87,8 +97,49 @@ export default { url: '/pages/patient/form' }) }, - swipeAction(e) { - console.log(e) + openOption(index) { + const item = this.list[index] + this.option.title = item.name + this.option.id = item.id + this.option.show = true + }, + closeOption() { + this.option.show = false + }, + chooseOption(e) { + const id = this.option.id + if (e.action == 'detail') { + return uni.navigateTo({ url: `/pages/patient/detail?id=${id}` }) + } + if (e.action == 'edit') { + return uni.navigateTo({ url: `/pages/patient/form?id=${id}` }) + } + if (e.action == 'delete') { + uni.showModal({ + title: '删除 ' + this.option.title, + content: '是否确定?', + success: (result) => { + if (result.confirm) { + this.delete(id) + } + } + }) + + } + }, + delete(id) { + uni.showLoading() + this.$ajax.delete(`/admin-api/patient/${id}`).then(res => { + if (res.status == 0) { + uni.showToast({ + title: '删除成功', + icon: 'success' + }) + setTimeout(() => { + this.loadData(true) + }, 1000) + } + }) } } } diff --git a/src/utils/ajax.js b/src/utils/ajax.js index c7259d1..0358e19 100644 --- a/src/utils/ajax.js +++ b/src/utils/ajax.js @@ -12,6 +12,7 @@ instance.interceptors.request.use( if (token) { config.header['Authorization'] = `Bearer ${token}` } + config.header['Accept'] = 'application/json' return config }, error => { @@ -25,7 +26,7 @@ instance.interceptors.response.use( response => { uni.hideLoading() const res = response.data - if (res.status != 0 && res.doNotDisplayToast == 0) { + if (res.status != 0 && res.doNotDisplayToast != 1) { uni.showModal({ title: res.msg, showCancel: false