From 360825af63ecdb68fa241fc94836c5761e5e7f0b Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 22 Sep 2023 11:00:18 +0800 Subject: [PATCH] form editor preview --- src/pages/patient/detail.vue | 25 +++++++++++++------------ src/pages/patient/form.vue | 12 ++++++------ src/pages/record/detail.vue | 10 +++------- src/pages/record/form.vue | 12 ++++++------ src/utils/request.js | 8 ++++++-- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/pages/patient/detail.vue b/src/pages/patient/detail.vue index 31b4dab..2753cbf 100644 --- a/src/pages/patient/detail.vue +++ b/src/pages/patient/detail.vue @@ -55,12 +55,9 @@ title="病情描述" isLink rightIcon="edit-pen" + value="点击修改" @click="openEditor" - > - - - - + /> { + this.update(params).then(res => { this.modal.show = false if (res.status == 0) { this.info[key] = value @@ -182,7 +179,7 @@ export default { this.$refs['editor'].open(this.info.illness) }, confirmEditor(e) { - this.$ajax.put(`/admin-api/patient/${this.id}`, { id: this.id, illness: e.html }).then(res => { + this.update({ illness: e.html }).then(res => { if (res.status == 0) { this.info.illness = e.html } @@ -192,7 +189,7 @@ export default { this.genderSheet.show = !this.genderSheet.show }, selectGender(e) { - this.$ajax.put(`/admin-api/patient/${this.id}`, {id: this.id, sex: e.value}).then(res => { + this.update({ sex: e.value }).then(res => { if (res.status == 0) { this.info.sex = e.value this.info.sex_text = e.name @@ -209,9 +206,9 @@ export default { selectBirthday(e) { const time = Math.floor(e.value / 1000) const key = this.datePicker.name - const params = { id: this.id } + const params = {} params[key] = time - this.$ajax.put(`/admin-api/patient/${this.id}`, params).then(res => { + this.update(params).then(res => { if (res.status == 0) { this.info[key] = e.value this.toggleBirthday() @@ -225,7 +222,7 @@ export default { this.$refs['select-admin-user'].close() }, selectDoctor(e) { - this.$ajax.put(`/admin-api/patient/${this.id}`, {id: this.id, doctor_id: e.id}).then(res => { + this.update({ doctor_id: e.id }).then(res => { if (res.status == 0) { this.info.doctor_id = e.id this.info.doctor.name = e.name @@ -250,6 +247,10 @@ export default { } }) }, + update(data) { + const params = Object.assign({id: this.id}, data) + return this.$ajax.put(`/admin-api/patient/${this.id}`, params, { custom: { loading: true } }) + }, delete(id) { uni.showLoading() this.$ajax.delete(`/admin-api/patient/${id}`).then(res => { diff --git a/src/pages/patient/form.vue b/src/pages/patient/form.vue index 1d4ac05..c4ce7b9 100644 --- a/src/pages/patient/form.vue +++ b/src/pages/patient/form.vue @@ -39,8 +39,8 @@ - - 点击填写病情描述 + + {{form.illness ? '点击修改' : '点击填写'}} @@ -66,7 +66,7 @@ @close="toggleGender" @select="selectGender" /> - + @@ -104,7 +104,7 @@ export default { show: false, name: '', value: (new Date).getTime(), - minDate: (new Date('1900-1-1')).getTime() + minDate: (new Date('1900/1/1')).getTime() }, doctor: { text: '', @@ -128,9 +128,9 @@ export default { name: res.data.name, sex: res.data.sex, phone: res.data.phone, - birthday: res.data.birthday, + birthday: res.data.birthday ? res.data.birthday.replaceAll('-', '/') : '', address: res.data.address, - treat_at: res.data.treat_at, + treat_at: res.data.treat_at ? res.data.treat_at.replaceAll('-', '/') : '', doctor_id: res.data.doctor_id, illness: res.data.illness } diff --git a/src/pages/record/detail.vue b/src/pages/record/detail.vue index 15e276e..bb3515b 100644 --- a/src/pages/record/detail.vue +++ b/src/pages/record/detail.vue @@ -49,15 +49,11 @@ /> - - - - + /> - - 点击填写诊疗情况 + + {{form.content ? '点击修改' : '点击填写'}} @@ -158,7 +158,7 @@ export default { show: false, name: '', value: (new Date).getTime(), - minDate: (new Date('1900-1-1')).getTime() + minDate: (new Date('1900/1/1')).getTime() }, adminUser: { key: '' @@ -202,14 +202,14 @@ export default { patient_id: this.info.patient_id, type_id: this.info.type_id, doctor_id: this.info.doctor_id, - treat_at: this.info.treat_at, + treat_at: this.info.treat_at ? this.info.treat_at.replaceAll('-', '/') : '', origin_price: this.info.origin_price, sell_price: this.info.sell_price, order_status: this.info.order_status, content: this.info.content, - next_treat_at: this.info.next_treat_at, + next_treat_at: this.info.next_treat_at ? this.info.next_treat_at.replaceAll('-', '/') : '', notify_user_id: this.info.notify_user_id, - notify_at: this.info.notify_at, + notify_at: this.info.notify_at ? this.info.notify_at.replaceAll('-', '/') : '', notify_remarks: this.info.notify_remarks } } diff --git a/src/utils/request.js b/src/utils/request.js index 9869767..08300eb 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -5,7 +5,8 @@ module.exports = () => { uni.$u.http.setConfig((config) => { config.baseURL = process.env.VUE_APP_BASE_API config.custom = { - toast: true + toast: true, + loading: false } return config }) @@ -18,6 +19,9 @@ module.exports = () => { config.header['Authorization'] = `Bearer ${token}` } config.header['Accept'] = 'application/json' + if (config.custom.loading) { + uni.showLoading() + } return config }, config => { @@ -31,7 +35,7 @@ module.exports = () => { uni.hideLoading() const res = response.data - if (res.status != 0 && res.doNotDisplayToast != 1) { + if (response.config.custom.toast && res.status != 0 && res.doNotDisplayToast != 1) { uni.showModal({ title: res.msg, showCancel: false