From 81faf43e714f19e52fec4c74722b793f4095cc7b Mon Sep 17 00:00:00 2001 From: kuaileWu <1432334894@qq.com> Date: Fri, 27 Jun 2025 17:31:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E4=BF=A1=E6=81=AF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/DoctorInformation.vue | 438 ++++++++++++++++++++-------------------- 1 file changed, 224 insertions(+), 214 deletions(-) diff --git a/src/views/DoctorInformation.vue b/src/views/DoctorInformation.vue index c21f046..0d60ac5 100644 --- a/src/views/DoctorInformation.vue +++ b/src/views/DoctorInformation.vue @@ -1,10 +1,10 @@ @@ -129,7 +137,6 @@ import GuipFormItem from '@/components/GuipFormItem.vue'; import GuipInput from '@/components/GuipInput.vue'; import GuipTextarea from '@/components/GuipTextarea.vue'; import GroupFormBtns from '@/components/GroupFormBtns.vue'; -import GuipSelect from '@/components/GuipSelect.vue'; import GuipRadio from '@/components/GuipRadio.vue'; export default { // 站点设置 @@ -140,10 +147,8 @@ export default { GuipFormItem, GuipRadio, GuipInput, - GuipSelect, GuipTextarea, GroupFormBtns - }, data() { return { @@ -152,6 +157,10 @@ export default { // { name: 'image.jpeg', url: 'http://jasonyizherenxin.checkcopy.com/user_avatar/1.png?v=93940df0b596961c42de23ef1f2d3257' } ], fileList1:[], + doctorAvatoFile:[], + doctorAvatorUrl: '', + approverWechatUrl:'', + approverWechatFile:[], options_payword: [{ value: '选项1', label: '黄金糕' @@ -174,15 +183,17 @@ export default { ], formData: null, siteForm: { - doctor_name: '', - idcard: '', + did:0, + name: '', + idcard: ' ', phone: '', avator: '', doctor_desc: '', doctor_detail: '', label: '', - first_visit_audit: '1', - approve_phone: '' + approver_phone:'', + approver_wechat:'', + first_visit_audit: '', }, oldForm: {}, siteFormrules2: { @@ -191,7 +202,7 @@ export default { ] }, siteFormrules: { - doctor_name: [ + name: [ { required: true, message: '请输入姓名', trigger: 'blur' } ], phone: [ @@ -226,202 +237,185 @@ export default { } }, computed: { - ...mapState(['pageTitle']) // 从Vuex映射showSidebar状态到组件的计算属性中 + ...mapState(['pageTitle']) }, mounted() { - const doctor_id = this.$route.query.doctor_id; // 获取 id 参数 + const doctor_id = this.$route.query.doctor_id; this.doctorId = doctor_id; - if (doctor_id) { - // 请求医生信息 - this.fetchDoctorData(doctor_id); - } + if (doctor_id) this.getDoctorData(doctor_id); }, methods: { - fetchDoctorData(id) { - this.$http('POST', '/api/admin/get_doctor_baseinfo', { - did: id - }).then(response => { - if (response.code == 0) { - let obj = JSON.parse(JSON.stringify(this.siteForm)) - this.oldForm = { ...obj, ...response.data } - this.siteForm = { ...this.siteForm, ...response.data } - if (response.data.avator) { - this.fileList = [{ - name: 'avator', - url: response.data.avator - }]; - } - if (response.data.avator) { - this.fileList = [{ - name: 'avator', - url: response.data.avator - }]; - } + setDoctorDesc() { + if(!this.doctorId) { + this.$message.error('请先设置医生基础信息') + return; + } + + var obj = new Object() + obj.did = this.doctorId + obj.desc = this.siteForm.doctor_desc + obj.detail = this.siteForm.doctor_detail + obj.label = this.siteForm.label + this.$http('POST', '/api/admin/set_doctor_desc', obj).then(response => { + if (response.code != 0) { + this.$message.error(response.msg) + return; } + this.$message.success(response.msg) }).catch(error => { console.error(error, 'error') + this.$message.error('设置失败') }) }, - handleUploadClick(e) { - console.log(e,'------e===='); - e.preventDefault(); - this.$refs.upload.$el.querySelector('input[type="file"]').click(); - }, - btnClick(e) { - console.log(e,'------e===='); - e.preventDefault(); - this.$refs.upload1.$el.querySelector('input[type="file"]').click(); + getDoctorData(doctor_id) { + this.$http('POST', '/api/admin/get_doctor_baseinfo', {did:doctor_id}).then(response => { + if (response.code != 0) { + this.$message.error(response.msg) + return; + } + this.siteForm = response.data + this.siteForm.did = doctor_id; + this.siteForm.name = this.siteForm.doctor_name + this.doctorAvatorUrl = this.siteForm.avator + this.approverWechatUrl = this.siteForm.approver_wechat + }).catch(error => { + console.error(error, 'error') + this.$message.error('设置失败') + }) }, + setDoctorInfo(param) { + this.$http('POST', '/api/admin/set_doctor_baseinfo', param).then(response => { + if (response.code != 0) { + this.$message.error(response.msg) + return; + } - customUpload(params) { - // 自定义上传逻辑 - const formData = new FormData(); - console.log(params.file,'-222----'); - formData.append('file', params.file); - // this.$http.post('/api/upload', formData).then() - }, - handleRemove(file, fileList) { - console.log(file, fileList); - }, - handlePreview(file) { - console.log(file); + this.$message.success(response.msg) + var data = response.data + if(this.doctorId) return; + setTimeout(() => { + location.href = location.href+'?doctor_id='+data.doctor_id + }, 800); + }).catch(error => { + console.error(error, 'error') + this.$message.error('设置失败') + }) }, - radioChange(data) { - console.log(data, 'radio--data'); + setDoctorBaseInfoUpload(param) { + let fileObj = param.file + let fd = new FormData() + fd.append('avatar_file', fileObj) + + var siteForm = this.siteForm + fd.append('did', this.doctorId) + fd.append('name', siteForm.name) + fd.append('phone', siteForm.phone) + fd.append('idcard', siteForm.idcard) + this.setDoctorInfo(fd) }, - uploadAvatar() { - return new Promise((resolve) => { - if (this.fileList.length) { - const formData = new FormData(); - formData.append('file', this.fileList[0].raw); - this.$http.post('/api/upload', formData).then(res => { - resolve(res.data.url); - }); - } else { - resolve(this.siteForm.avator); + submitDoctorBaseInfo() { + if(this.doctorAvatoFile.length == 0) { + if(this.doctorId) { + this.setDoctorInfo(this.siteForm) + return; } - }); - }, - handleFileChange(file, fileList) { - console.log(file, fileList, '======file'); - this.siteForm.avator = fileList.length ? 'uploaded' : ''; - this.$refs.siteForm.validateField('avator'); - this.fileList = fileList - - // 创建FormData对象 - this.formData = new FormData() - fileList.forEach(item => { - this.formData.append('files', item.raw) - }) + this.$message.error('请上传医生照片') + return; + } - // 可以在这里添加其他表单数据 - this.formData.append('extraParam', 'value') + this.$refs.avatorUpload.submit(); + }, + clearDocotorAvatorFiles(){ + this.doctorAvatorUrl = ''; + this.doctorAvatoFile = [] + this.$refs.avatorUpload.clearFiles(); }, - // 上传图片 - handleAvatarSuccess(res, file) { - this.imageUrl1 = URL.createObjectURL(file.raw); + clearApproverWechatFiles(){ + this.approverWechatUrl = ''; + this.approverWechatFile = [] + this.$refs.approverWechatUpload.clearFiles(); }, - beforeAvatarUpload(file) { - console.log(file, '=====file'); - const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'; - const isLt2M = file.size / 1024 / 1024 < 2; + setApproverWechatUpload(param) { + let fileObj = param.file + let fd = new FormData() - if (!isJPG) { - this.$message.error('上传头像图片只能是 JPG 或 PNG 格式!'); - } - if (!isLt2M) { - this.$message.error('上传头像图片大小不能超过 2MB!'); - } - return isJPG && isLt2M; + fd.append('approver_wechat', fileObj) + var siteForm = this.siteForm + fd.append('did', this.doctorId) + fd.append('first_visit_audit', siteForm.first_visit_audit) + fd.append('approver_phone', siteForm.approver_phone) + this.setApproverWechat(fd) }, - submitForm(form) { - let props = {}; - let url = { - siteForm:'/api/admin/get_doctor_baseinfo', - siteForm1:'/api/admin/set_doctor_desc', - siteForm2:'', - } - if (form == 'siteForm') { - this.$refs[form].validate((valid) => { - if (valid) { - props = { - name: this.siteForm.doctor_name, - idcard: this.siteForm.idcard, - avatar_file: this.siteForm.avator, - phone: this.siteForm.phone - } - } else { - return false; - } - }); - } else if(form == 'siteForm1') { - props = { - desc: form.doctor_desc, - detail: form.doctor_detail, - label: form.label - } - }else{ - props = { - first_visit_audit: form.first_visit_audit, - approver_phone: form.approver_phone, - approver_wechat: form.approver_wechat - } - } - if(this.doctorId){ - props.did = this.doctorId; - } - this.$http('POST', url[form], props).then(response => { - if (response.code == 0) { - this.$Message.success('修改成功') - this.fetchDoctorData() + setApproverWechat(param) { + this.$http('POST', '/api/admin/set_doctor_approver', param).then(response => { + if (response.code != 0) { + this.$message.error(response.msg) + return; } + + this.$message.success(response.msg) + var data = response.data + if(this.doctorId) return; + setTimeout(() => { + location.href = location.href+'?doctor_id='+data.doctor_id + }, 800); }).catch(error => { console.error(error, 'error') + this.$message.error('设置失败') }) }, - cancelClick(type) { - // siteForm - if (type == 'siteForm1') { - this.siteForm = { - ...this.siteForm, - doctor_desc: this.oldForm.doctor_desc, - doctor_detail: this.oldForm.doctor_detail, - label: this.oldForm.label, - } + submitApproverWechat() { + if(!this.doctorId) { + this.$message.error('请先设置医生基础信息') + return; + } - } else if(type== 'siteForm') { - this.siteForm = { - ...this.siteForm, - name: this.oldForm.name, - idcard: this.oldForm.idcard, - avatar_file: this.oldForm.avatar_file, - phone: this.oldForm.phone - } - }else { - this.siteForm = { - ...this.siteForm, - first_visit_audit: this.oldForm.first_visit_audit, - approver_phone: this.oldForm.approver_phone, - approver_wechat: this.oldForm.approver_wechat - } + if(this.approverWechatFile.length == 0) { + this.setApproverWechat(this.siteForm) + return; } + + this.$refs.approverWechatUpload.submit(); + }, + handleApproverWechatChange(file, fileList) { + console.log(file, fileList) + this.approverWechatFile = file + this.approverWechatUrl = URL.createObjectURL(file.raw); + }, + handleAvatarChange(file, fileList) { + console.log(file, fileList) + this.doctorAvatoFile = file + this.doctorAvatorUrl = URL.createObjectURL(file.raw); }, - confirmClick(type) { - console.log(type, '确认'); + radioChange(data) { + console.log(data, 'radio--data'); + }, + cancelClick(type) { + console.log(type) } - } } -