import{_ as _sfc_main$1}from"./FormItem.vue_vue_type_script_setup_true_lang-d5469e61-1780912037814v=1.0.0.js";import{r as ref,V as provide,q as http,d as defineComponent,an as watchEffect,a as resolveComponent,b as openBlock,c as createBlock,w as withCtx,h as createElementBlock,F as Fragment,i as renderList,f as unref,k as createBaseVNode,t as toDisplayString,e as createVNode,Q as mergeProps}from"./index-d052b22f-1780912037814v=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 e={},l=[],t={};baseList.value.map((async a=>{let r=[];a.field_info&&a.field_info.length>0&&a.field_info.map((async l=>{var a,s;if(l.key=keyPre+l.field_id,[8,7,5].indexOf(l.field_type)>-1){if(e[l.key]=[],l.field_default_value&&(e[l.key]=l.field_default_value.split(",")),l.value){let t=[];8==l.field_type?(l.value=JSON.parse(l.value),l.value.map((e=>{t.push({name:e.name,url:e.full_url,imgPath:e.url})}))):t=l.value.split(","),e[l.key]=t}}else e[l.key]=null!=(s=null!=(a=l.value)?a:l.field_default_value)?s:"";r.push(handleFormList(l)),t[l.key]=handleRule(l),await setEnumMap(l)})),l.push({name:a.name,field_info_list:r})})),form.value=e,ruleList.value=t,formList.value=l},setEnumMap=async e=>{if(1==e.field_select_type){let l=JSON.parse(e.field_select_value);l.map((e=>{e.value=String(e.value)})),enumMap.value.set(e.key,l)}else if(2==e.field_select_type){let l=await http.post(e.field_select_url,JSON.parse(e.field_select_post),{headers:{noLoading:!0}});enumMap.value.set(e.key,l.data)}},handleFormList=e=>{let l=elMap[e.field_type];return{prop:e.key,label:e.field_name,el:l.el,render:l.render,elmentProperty:l,placeholder:e.field_desc?e.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(error){}return 1==e.m&&_rules.push({required:!0,message:e.field_name+"不能为空",trigger:"blur"}),_rules.map((e=>{e.pattern&&(e.pattern=new RegExp(e.pattern))})),_rules};return{enumMap:enumMap,form:form,formList:formList,ruleList:ruleList,keyPre:keyPre,baseList:baseList,handleList:handleList}},_hoisted_1={class:"divider mt30 mb30"},_sfc_main=defineComponent({__name:"SpecialInfo",props:{list:{type:Array,default:()=>[]}},setup(e,{expose:l}){const{form:t,formList:a,ruleList:r,keyPre:s,baseList:n,handleList:i}=useFormItem(),o=e;watchEffect((()=>{o.list.length>0&&(n.value=o.list,i())}));const u=ref();return l({ruleFormRef:u,form:t,getFormData:()=>{const e=JSON.parse(JSON.stringify(t.value));let l={};for(const t in e)if(e[t])if(e[t]instanceof Array&&e[t].length>0&&Object.hasOwn(e[t][0],"url")){let a=e[t].map((e=>({name:e.name,url:e.imgPath,full_url:e.url})));l[t.replace(s,"")]=JSON.stringify(a)}else e[t]instanceof Array&&(e[t]=e[t].join(",")),l[t.replace(s,"")]=e[t];return l}}),(e,l)=>{const s=resolveComponent("FormCol"),n=resolveComponent("FormRow"),i=resolveComponent("el-form");return openBlock(),createBlock(i,{model:unref(t),ref_key:"ruleFormRef",ref:u,rules:unref(r),"label-width":"170px",class:"default-form"},{default:withCtx((()=>[(openBlock(!0),createElementBlock(Fragment,null,renderList(unref(a),((e,l)=>(openBlock(),createElementBlock("div",{key:l},[createBaseVNode("div",_hoisted_1,toDisplayString(e.name),1),createVNode(n,null,{default:withCtx((()=>[(openBlock(!0),createElementBlock(Fragment,null,renderList(e.field_info_list,((e,l)=>(openBlock(),createBlock(s,{key:l},{default:withCtx((()=>[createVNode(_sfc_main$1,mergeProps({value:unref(t)[e.prop],"onUpdate:value":l=>unref(t)[e.prop]=l,ref_for:!0},e),null,16,["value","onUpdate:value"])])),_:2},1024)))),128))])),_:2},1024)])))),128))])),_:1},8,["model","rules"])}}});export{_sfc_main as _};
