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 @@
-
+
@@ -49,6 +49,6 @@ export default {
diff --git a/src/pages/patient/detail.vue b/src/pages/patient/detail.vue
index 1469651..0173f18 100644
--- a/src/pages/patient/detail.vue
+++ b/src/pages/patient/detail.vue
@@ -1,13 +1,225 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/pages/patient/form.vue b/src/pages/patient/form.vue
index 722cbf8..0463205 100644
--- a/src/pages/patient/form.vue
+++ b/src/pages/patient/form.vue
@@ -73,6 +73,7 @@ export default {
components: {SelectAdminUser},
data() {
return {
+ id: '',
form: {
name: '',
sex: gender.none.value,
@@ -110,6 +111,32 @@ export default {
uni.setNavigationBarTitle({
title: '添加病人'
})
+ } else {
+ this.id = e.id
+ uni.showLoading()
+ this.$ajax.get(`/admin-api/patient/${e.id}`, {_action: 'getData'}).then(res => {
+ if (res.status == 0) {
+ this.form = {
+ id: res.data.id,
+ name: res.data.name,
+ sex: res.data.sex,
+ phone: res.data.phone,
+ birthday: res.data.birthday,
+ address: res.data.address,
+ treat_at: res.data.treat_at,
+ doctor_id: res.data.doctor_id,
+ illness: res.data.illness
+ }
+ this.genderSelect = res.data.sex_text
+ if (res.data.doctor) {
+ this.doctor = {
+ text: res.data.doctor.name,
+ value: res.data.doctor.id,
+ }
+ }
+ uni.setNavigationBarTitle({ title: this.form.name })
+ }
+ })
}
},
onReady() {
@@ -151,20 +178,39 @@ export default {
submit() {
this.$refs['form'].validate().then(res => {
uni.showLoading()
- this.$ajax.post('/admin-api/patient', this.form).then(res => {
- uni.hideLoading()
- if (res.status == 0) {
- uni.showToast({
- title: '提交成功',
- icon: 'success'
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1500);
- }
- })
+ if (this.id) {
+ this.update()
+ } else {
+ this.create()
+ }
}).catch(error => {})
},
+ update() {
+ this.$ajax.put(`/admin-api/patient/${this.id}`, this.form).then(res => {
+ if (res.status == 0) {
+ uni.showToast({
+ title: '保存成功',
+ icon: 'success'
+ })
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1500);
+ }
+ })
+ },
+ create() {
+ this.$ajax.post('/admin-api/patient', this.form).then(res => {
+ if (res.status == 0) {
+ uni.showToast({
+ title: '提交成功',
+ icon: 'success'
+ })
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1500);
+ }
+ })
+ }
}
}
diff --git a/src/pages/patient/index.vue b/src/pages/patient/index.vue
index d1fa743..2b41f33 100644
--- a/src/pages/patient/index.vue
+++ b/src/pages/patient/index.vue
@@ -13,23 +13,25 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -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