You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
2.5 KiB
1 lines
2.5 KiB
import{d as e,r as o,k as t,M as a,P as r,a9 as n,o as i,c as l,w as s,f as m,e as d,v as f,u,b as p,n as _,x as c,j as g,aZ as y,a_ as v}from"./index-ed377420.js";import{u as S}from"./useDiyForm.0a165a97.js";import{d as b}from"./index.e8233ef6.js";import{_ as h}from"./_plugin-vue_export-helper.1b428a4d.js";const T=h(e({__name:"index",props:["form_id","relate_id","storage_name","form_border"],setup(e,{expose:h}){const T=e,x=S({form_id:T.form_id,needLogin:!1}),F=o(null),R=t((()=>x.requestData)),j=a({});r((()=>{x.getData((()=>{var e;if(j.status=x.data.status,j.status){j.title=x.data.title,j.global=x.data.global,j.global&&(j.global.topStatusBar.isShow=!1,j.global.bottomTabBarSwitch=!1);let o=[];"none"==T.form_border&&(j.global.borderControl=!1),x.data.value.forEach((e=>{"diy_form"==e.componentType&&"FormSubmit"!=e.componentName&&o.push(e)})),j.value=o,j.componentRefs=null,null==(e=F.value)||e.refresh(),k()}}))}));const k=()=>{n((()=>j.value),((e,o)=>{if(e){let o={validTime:y(5),components:[]};e.forEach((e=>{if("diy_form"==e.componentType&&"FormSubmit"!=e.componentName){let t=v(e.field);delete t.remark,delete t.detailComponent,delete t.default,o.components.push({id:e.id,componentName:e.componentName,componentType:e.componentType,componentTitle:e.componentTitle,isHidden:e.isHidden,field:t})}})),o.components.length&&uni.setStorageSync("diyFormStorage_"+T.form_id,o)}}),{deep:!0})};return x.onHide(),x.onUnload(),h({verify:()=>{if(!j.status)return!0;if(!j.value)return!0;let e=!0,o=F.value.getFormRef().componentRefs;for(let a=0;a<j.value.length;a++){let t=j.value[a];if(t.field.required||t.field.value){let a=`diy${t.componentName}Ref`,r=!1;if(o[a]){for(let e=0;e<o[a].length;e++){let t=o[a][e].verify();if(t&&!t.code){r=!0,c({title:t.message,icon:"none"});break}}if(r){e=!1;break}}}}if(!e)return!1;const t={form_id:T.form_id,value:uni.getStorageSync("diyFormStorage_"+T.form_id),relate_id:T.relate_id||0};return T.storage_name&&uni.setStorageSync(T.storage_name,t),e},getData:()=>({form_id:T.form_id,value:j.value,relate_id:T.relate_id||0}),clearStorage:(e=[])=>{uni.removeStorageSync("diyFormStorage_"+T.form_id),T.storage_name&&uni.removeStorageSync(T.storage_name),e&&e.forEach((e=>{uni.removeStorageSync(e)}))}}),(e,o)=>{const t=g;return i(),l(t,{style:_(e.themeColor())},{default:s((()=>[m(" 自定义组件渲染 "),d(p(t,{class:"diy-template-wrap"},{default:s((()=>[p(b,{ref_key:"diyGroupRef",ref:F,data:j},null,8,["data"])])),_:1},512),[[f,1==u(R).status&&!u(x).getLoading()]])])),_:1},8,["style"])}}}),[["__scopeId","data-v-b5dd450b"]]);export{T as d};
|
|
|