acdr-ui/dist/build/mp-weixin/pages/address/components/AddAddress.js

2 lines
3.0 KiB
JavaScript

"use strict";var e=Object.defineProperty,l=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(l,a,o)=>a in l?e(l,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):l[a]=o,t=(e,t)=>{for(var d in t||(t={}))a.call(t,d)&&s(e,d,t[d]);if(l)for(var d of l(t))o.call(t,d)&&s(e,d,t[d]);return e};const d=require("../../../common/vendor.js"),r=require("../../../hooks/useColPickerData.js");if(!Array){(d.resolveComponent("wd-input")+d.resolveComponent("wd-picker")+d.resolveComponent("wd-col-picker")+d.resolveComponent("wd-form"))()}Math||((()=>"../../../node-modules/wot-design-uni/components/wd-input/wd-input.js")+(()=>"../../../node-modules/wot-design-uni/components/wd-picker/wd-picker.js")+(()=>"../../../node-modules/wot-design-uni/components/wd-col-picker/wd-col-picker.js")+(()=>"../../../node-modules/wot-design-uni/components/wd-form/wd-form.js"))();const u={__name:"AddAddress",props:{initialAddress:{type:Object,default:()=>({name:"",phone:"",address:"",detailAddress:"",type:"",customType:""})}},emits:["save-address"],setup(e,{emit:l}){const{colPickerData:a,findChildrenByCode:o}=r.useColPickerData(),s=d.ref([]),u=e;d.ref([]);const n=d.ref([a.map((e=>({value:e.value,label:e.text})))]),i=d.ref(["家","公司","自定义"]),p=d.ref(!1),v=({selectedItem:e,resolve:l,finish:s})=>{const t=o(a,e.value);t&&t.length?l(t.map((e=>({value:e.value,label:e.text})))):s()},c=e=>e.map((e=>e.label)).join("-");function m({value:e,selectedItems:l}){w.value.address=l.map((e=>e.label)).join("-")}function f({value:e}){p.value="自定义"===e,p.value||(w.value.customType="")}const y=l,w=d.ref(t({},u.initialAddress));d.watch((()=>u.initialAddress),(e=>{w.value=t({},e),p.value="自定义"===e.type}));const b=()=>{w.value.name&&w.value.phone&&w.value.detailAddress&&("自定义"!==w.value.type||w.value.customType)?(y("save-address",w.value),h()):d.index.showToast({title:"请填写完整的地址信息",icon:"error"})},h=()=>{w.value={name:"",phone:"",address:"",detailAddress:"",type:"",customType:""},s.value=[],p.value=!1};return(e,l)=>d.e({a:d.o((e=>w.value.name=e)),b:d.p({label:"姓名",required:!0,modelValue:w.value.name}),c:d.o((e=>w.value.phone=e)),d:d.p({label:"电话",required:!0,type:"tel",modelValue:w.value.phone}),e:d.o(f),f:d.o((e=>w.value.type=e)),g:d.p({columns:i.value,label:"地址类型",modelValue:w.value.type}),h:p.value},p.value?{i:d.o((e=>w.value.customType=e)),j:d.p({label:"自定义类型",required:!0,modelValue:w.value.customType})}:{},{k:d.o(m),l:d.o((e=>s.value=e)),m:d.p({label:"选择地址",columns:n.value,"column-change":v,"display-format":c,modelValue:s.value}),n:w.value.address.length&&w.value.address&&!s.value.length},w.value.address.length&&w.value.address&&!s.value.length?{o:d.t(w.value.address)}:{},{p:d.o((e=>w.value.detailAddress=e)),q:d.p({label:"详细地址",required:!0,modelValue:w.value.detailAddress}),r:d.o(b),s:d.sr("addressForm","49793e66-0")})}},n=d._export_sfc(u,[["__scopeId","data-v-49793e66"]]);wx.createComponent(n);