| | |
| | | left-text="返回" |
| | | left-arrow |
| | | @click-left="onClickLeft" |
| | | /> |
| | | /> |
| | | <van-address-list |
| | | v-model="chosenAddressId" |
| | | :list="list" |
| | | default-tag-text="默认" |
| | | @add="onAdd" |
| | | @edit="onEdit" |
| | | /> |
| | | /> |
| | | </van-popup> |
| | | <van-popup v-model:show="editDizhi" position="bottom" :style="{ height: '100%' }"> |
| | | <van-nav-bar |
| | |
| | | left-text="返回" |
| | | left-arrow |
| | | @click-left="onClickLeft2" |
| | | /> |
| | | <van-address-edit |
| | | ref="addressEditRef" |
| | | :area-list="areaList" |
| | | show-delete |
| | | show-set-default |
| | | show-search-result |
| | | :address-info="addressInfo" |
| | | :area-columns-placeholder="['请选择', '请选择', '请选择']" |
| | | @save="onSave" |
| | | @delete="onDelete" |
| | | /> |
| | | /> |
| | | <van-address-edit |
| | | ref="addressEditRef" |
| | | :area-list="areaList" |
| | | show-delete |
| | | show-set-default |
| | | show-search-result |
| | | :address-info="addressInfo" |
| | | :area-columns-placeholder="['请选择', '请选择', '请选择']" |
| | | @save="onSave" |
| | | @delete="onDelete" |
| | | /> |
| | | </van-popup> |
| | | </div> |
| | | </template> |
| | | <script setup lang="ts"> |
| | | |
| | | import { Toast } from 'vant'; |
| | | import { ref } from 'vue'; |
| | | import { areaList } from '@vant/area-data'; |
| | | import type { AddressEditInstance } from 'vant'; |
| | | name:"dizhibianji" |
| | | const emit = defineEmits(['fanhuiFun']) |
| | | const showDizhi=ref(false) |
| | | const editDizhi=ref(false) |
| | | const addressEditRef = ref<AddressEditInstance>(); |
| | | const chosenAddressId = ref('1') |
| | | const addressInfo=ref({ |
| | | name:'', |
| | | tel:'', |
| | | province:'', |
| | | city:"", |
| | | county:'', |
| | | addressDetail:'', |
| | | isDefault:false |
| | | }) |
| | | const list =[ |
| | | { |
| | | id: '1', |
| | | name: '张三', |
| | | tel: '13000000000', |
| | | address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室', |
| | | isDefault: true, |
| | | }, |
| | | { |
| | | id: '2', |
| | | name: '李四', |
| | | tel: '1310000000', |
| | | address: '浙江省杭州市拱墅区莫干山路 50 号', |
| | | }, |
| | | ] |
| | | const openShow=()=>{ |
| | | showDizhi.value=true |
| | | } |
| | | const onClickLeft=()=>{ |
| | | showDizhi.value=false |
| | | } |
| | | const onClickLeft2=()=>{ |
| | | addressEditRef.value?.setAddressDetail('3434343'); |
| | | editDizhi.value=false |
| | | } |
| | | const onAdd = () =>{ |
| | | editDizhi.value=true |
| | | addressInfo.value={ |
| | | import { Toast } from 'vant' |
| | | import { ref } from 'vue' |
| | | import { areaList } from '@vant/area-data' |
| | | import type { AddressEditInstance } from 'vant' |
| | | import { ajaxPost } from '@/utils/axios' |
| | | import { userInfoStore } from '@/stores/userInfo' |
| | | const userInfo = userInfoStore() |
| | | const emit = defineEmits(['fanhuiFun']) |
| | | const showDizhi=ref(false) |
| | | const editDizhi=ref(false) |
| | | const addressEditRef = ref<AddressEditInstance>() |
| | | const chosenAddressId = ref(1) |
| | | const addressInfo=ref({ |
| | | code:'', |
| | | id:0, |
| | | name:'', |
| | | tel:'17717874345', |
| | | province:'', |
| | | city:"", |
| | | county:'', |
| | | addressDetail:'', |
| | | isDefault:false |
| | | } |
| | | } |
| | | const onEdit = (item:any, index:number) =>{ |
| | | console.log(item) |
| | | addressInfo.value={ |
| | | name:item.name, |
| | | tel:item.tel, |
| | | province:'', |
| | | city:"", |
| | | tel:'', |
| | | city:'', |
| | | county:'', |
| | | addressDetail:item.address, |
| | | isDefault:item.isDefault |
| | | areaCode:'', |
| | | address:'', |
| | | isDefault:false |
| | | }) |
| | | const list = ref([ |
| | | { |
| | | id: 0, |
| | | code:'', |
| | | name:'', |
| | | tel:'', |
| | | province:'', |
| | | city:'', |
| | | county:'', |
| | | areaCode:'', |
| | | address:'', |
| | | isDefault:false |
| | | }, |
| | | ]) |
| | | const getDefDizhi=(isload:boolean)=>{ |
| | | const pasm=`page=0&size=0&wherecondition=patient_code="${userInfo.patient.patientInfo.code}"` |
| | | ajaxPost('/patient/address/list', pasm).then((re: any) => { |
| | | console.log('默认地址') |
| | | console.log(re) |
| | | if (re.list.length===0){ |
| | | list.value=[] |
| | | onAdd() |
| | | } else { |
| | | list.value=[] |
| | | re.list.forEach((e:any)=>{ |
| | | list.value.push({ |
| | | id: e.id, |
| | | code:e.code, |
| | | name:e.receivePersonName, |
| | | tel:e.receivePersonMobile, |
| | | province:'', |
| | | city:e.addressArea.split(',')[0], |
| | | county:e.addressArea.split(',')[1], |
| | | areaCode:e.remark, |
| | | address:e.patientAddress, |
| | | isDefault:e.patientIsDefault===1?true:false, |
| | | }) |
| | | if (isload){ |
| | | if (e.patientIsDefault===1){ |
| | | chosenAddressId.value=(e.id) |
| | | } |
| | | } |
| | | }) |
| | | console.log(list.value) |
| | | } |
| | | |
| | | }) |
| | | } |
| | | editDizhi.value=true |
| | | } |
| | | const onSave = (form:any) => { |
| | | Toast('save'); |
| | | console.log(form) |
| | | |
| | | } |
| | | const onDelete = () => Toast('delete'); |
| | | defineExpose({ |
| | | openShow |
| | | } ) |
| | | // 打开地址列表 |
| | | const openShow=(id:number)=>{ |
| | | showDizhi.value=true |
| | | chosenAddressId.value=id |
| | | getDefDizhi(false) |
| | | } |
| | | const onClickLeft=()=>{ |
| | | showDizhi.value=false |
| | | console.log('返回父级组件',chosenAddressId.value) |
| | | const row=list.value.find((e:any)=> e.id===chosenAddressId.value) |
| | | emit('fanhuiFun',row) |
| | | } |
| | | const onClickLeft2=()=>{ |
| | | addressEditRef.value?.setAddressDetail('3434343') |
| | | editDizhi.value=false |
| | | } |
| | | const onAdd = () =>{ |
| | | editDizhi.value=true |
| | | console.log('用户信息') |
| | | console.log(userInfo.patient) |
| | | addressInfo.value={ |
| | | code:'', |
| | | id:0, |
| | | name:userInfo.patient.patientInfo.patientName, |
| | | addressDetail:userInfo.patient.patientInfo.patientAddress, |
| | | tel:userInfo.patient.patientInfo.patientTelNo, |
| | | city:'', |
| | | county:'', |
| | | areaCode:'', |
| | | address:'', |
| | | isDefault:false |
| | | } |
| | | } |
| | | const onEdit = (item:any, index:number) =>{ |
| | | console.log(item,index) |
| | | addressInfo.value={ |
| | | code:item.code, |
| | | id:item.id, |
| | | name:item.name, |
| | | addressDetail:item.address, |
| | | tel:item.tel, |
| | | city:item.city, |
| | | county:item.county, |
| | | areaCode:item.areaCode, |
| | | address:'', |
| | | isDefault:item.isDefault |
| | | } |
| | | editDizhi.value=true |
| | | } |
| | | const onSave = (form:any) => { |
| | | const pasm={ |
| | | addressArea: [form.city,form.county].toString(), |
| | | id: addressInfo.value.id, |
| | | code:addressInfo.value.code, |
| | | patientAddress: form.addressDetail, |
| | | patientCode: userInfo.patient.patientInfo.code, |
| | | patientIsDefault: form.isDefault===true?1:0, |
| | | receivePersonMobile: form.tel, |
| | | receivePersonName: form.name, |
| | | // 存地址code |
| | | remark: form.areaCode, |
| | | } |
| | | if (pasm.id===0){ |
| | | ajaxPost('/patient/address/add', pasm).then((re: any) => { |
| | | console.log('默认地址') |
| | | console.log(re) |
| | | Toast.success('保存成功') |
| | | getDefDizhi(false) |
| | | chosenAddressId.value=re.id |
| | | editDizhi.value=false |
| | | }) |
| | | } else { |
| | | ajaxPost('/patient/address/update', pasm).then((re: any) => { |
| | | console.log('默认地址') |
| | | chosenAddressId.value=re.id |
| | | console.log(re) |
| | | Toast.success('保存成功') |
| | | getDefDizhi(false) |
| | | editDizhi.value=false |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | const onDelete = () => { |
| | | ajaxPost('patient/address/delete','id='+addressInfo.value.id).then(re=>{ |
| | | editDizhi.value=false |
| | | console.log(re) |
| | | Toast.success('删除成功!') |
| | | }).finally(()=>{ |
| | | getDefDizhi(true) |
| | | }) |
| | | } |
| | | defineExpose({ |
| | | openShow |
| | | } ) |
| | | </script> |