import{_ as _sfc_main$1}from"./FormItem.vue_vue_type_script_setup_true_lang-f90a1eeb-1778929502341v=1.0.0.js";import{r as ref,au as provide,D as http,d as defineComponent,a1 as watchEffect,e as resolveComponent,o as openBlock,f as createBlock,w as withCtx,c as createElementBlock,L as Fragment,M as renderList,h as unref,n as createBaseVNode,t as toDisplayString,g as createVNode,W as mergeProps}from"./index-17740f03-1778929502341v=1.0.0.js";const useFormItem=()=>{const keyPre="id_",elMap={1:{el:"input",type:"text"},2:{el:"input",type:"textarea"},3:{el:"switch"},4:{el:"radio-group"},5:{el:"checkbox-group"},6:{el:"select"},7:{el:"select",multiple:!0},8:{el:"Imgs"},9:{el:"date-picker",type:"date",valueFormat:"YYYY-MM-DD",format:"YYYY-MM-DD"}},baseList=ref([]),enumMap=ref(new Map);provide("enumMap",enumMap);const form=ref({}),formList=ref([]),ruleList=ref({}),handleList=()=>{let t={},r=[],s={};baseList.value.map(async o=>{let p=[];o.field_info&&o.field_info.length>0&&o.field_info.map(async l=>{var c,m;if(l.key=keyPre+l.field_id,[8,7,5].indexOf(l.field_type)>-1){if(t[l.key]=[],l.field_default_value&&(t[l.key]=l.field_default_value.split(",")),l.value){let i=[];l.field_type==8?(l.value=JSON.parse(l.value),l.value.map(f=>{i.push({name:f.name,url:f.full_url,imgPath:f.url})})):i=l.value.split(","),t[l.key]=i}}else t[l.key]=(m=(c=l.value)!=null?c:l.field_default_value)!=null?m:"";p.push(handleFormList(l)),s[l.key]=handleRule(l),await setEnumMap(l)}),r.push({name:o.name,field_info_list:p})}),form.value=t,ruleList.value=s,formList.value=r},setEnumMap=async t=>{if(t.field_select_type==1){let r=JSON.parse(t.field_select_value);r.map(s=>{s.value=String(s.value)}),enumMap.value.set(t.key,r)}else if(t.field_select_type==2){let r=await http.post(t.field_select_url,JSON.parse(t.field_select_post),{headers:{noLoading:!0}});enumMap.value.set(t.key,r.data)}},handleFormList=t=>{let r=elMap[t.field_type];return{prop:t.key,label:t.field_name,el:r.el,render:r.render,elmentProperty:r,placeholder:t.field_desc?t.field_name:""}},handleRule=e=>{let _rules=[];try{if(e.field_check){let field_check=JSON.parse(e.field_check);field_check.map(e=>{e.pattern&&(e.pattern=eval(e.pattern))}),_rules=field_check}}catch(t){console.error("rule\u89E3\u6790\u9519\u8BEF",t)}return e.m==1&&_rules.push({required:!0,message:e.field_name+"\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}),_rules.map(t=>{t.pattern&&(t.pattern=new RegExp(t.pattern))}),_rules};return{enumMap,form,formList,ruleList,keyPre,baseList,handleList}},_hoisted_1={class:"divider mt30 mb30"},_sfc_main=defineComponent({__name:"SpecialInfo",props:{list:{type:Array,default:()=>[]}},setup(t,{expose:r}){const{form:s,formList:o,ruleList:p,keyPre:l,baseList:c,handleList:m}=useFormItem(),i=t;watchEffect(()=>{i.list.length>0&&(c.value=i.list,m())});const f=ref();return r({ruleFormRef:f,form:s,getFormData:()=>{const n=JSON.parse(JSON.stringify(s.value));let d={};for(const a in n)if(n[a])if(n[a]instanceof Array&&n[a].length>0&&Object.hasOwn(n[a][0],"url")){let _=n[a].map(u=>({name:u.name,url:u.imgPath,full_url:u.url}));d[a.replace(l,"")]=JSON.stringify(_)}else n[a]instanceof Array&&(n[a]=n[a].join(",")),d[a.replace(l,"")]=n[a];return d}}),(n,d)=>{const a=resolveComponent("FormCol"),_=resolveComponent("FormRow"),u=resolveComponent("el-form");return openBlock(),createBlock(u,{model:unref(s),ref_key:"ruleFormRef",ref:f,rules:unref(p),"label-width":"170px",class:"default-form"},{default:withCtx(()=>[(openBlock(!0),createElementBlock(Fragment,null,renderList(unref(o),(y,k)=>(openBlock(),createElementBlock("div",{key:k},[createBaseVNode("div",_hoisted_1,toDisplayString(y.name),1),createVNode(_,null,{default:withCtx(()=>[(openBlock(!0),createElementBlock(Fragment,null,renderList(y.field_info_list,(h,v)=>(openBlock(),createBlock(a,{key:v},{default:withCtx(()=>[createVNode(_sfc_main$1,mergeProps({value:unref(s)[h.prop],"onUpdate:value":g=>unref(s)[h.prop]=g,ref_for:!0},h),null,16,["value","onUpdate:value"])]),_:2},1024))),128))]),_:2},1024)]))),128))]),_:1},8,["model","rules"])}}});export{_sfc_main as _};
