"use strict";(("undefined"!==typeof self?self:this)["webpackChunklib"]=("undefined"!==typeof self?self:this)["webpackChunklib"]||[]).push([[367],{3951:function(e,t,i){i(7658);var s=i(8927),l=i(2003),d=i(3288),a=i(4791);const n={data(){return{updateValue:0,widgetId:"widget-"+Math.random().toString(15).slice(2,15)}},mixins:[l.Z],props:{field:{type:Object,default:()=>({})},schema:{type:Object,default:()=>({})},values:{type:Object,default:()=>({})},colors:{type:Object,default:()=>({})},fieldErrors:{type:Object,default:()=>({})},hideFields:{type:Object,default:()=>({})},isDark:{type:Boolean,default:!1},form:{type:Object,default:()=>({})}},inject:["formId","dependencies","regExpFields","isDeepValues","flatFields","context"],computed:{value:{get(){this.updateValue++;let e={value:this.isDeepValues?this.deepPick(this.field.name.split("."),this.values):this.friendValue()};return e.value},set(e){let t=this.beforeChange(e);this.changeValue(t)}}},created(){this.load()},methods:{actionEmit(e,t){if(t){let i={type:e,arg:t};s.Z.$emit(`${this.formId}:action`,i)}},load(){this.setFieldAttr(),this.pickHideFields(),this.pickDependencies(),this.pickRegExp(),this.loadCompleteDispatch(),this.pickFlatField()},pickFlatField(){this.field.name&&(this.flatFields[this.field.name]=this.field)},loadCompleteDispatch(){for(let e in this.hideFields)this.dispatchHide(e);this.context.loadDebounce&&clearTimeout(this.context.loadDebounce),this.context.loadDebounce=setTimeout((()=>{for(let e in this.dependencies)this.dispatchOptions(e);this.context.loadCompleted=!0}),500)},setFieldAttr(){const e=this.defaultFieldAttr();let t=(0,d.mergeDeepRight)(e,this.field);for(const[i,s]of Object.entries(t))this.field[i]=s},defaultFieldAttr(){return{}},beforeChange(e){return"number"==this.schema.type&&parseFloat(e)?parseFloat(e):e},changeValue(e){this.updateValue++,this.$emit("changeValue",this.field.name,this.schema,e,this.field)},friendValue(){let e=null,t=this.values[this.field.name];try{switch(this.schema.type){case"array":e=Array.isArray(t)?t:(0,a.Vq)(t);break;case"number":e="Number"==(0,d.type)(t)?t:parseFloat(t);break;case"datetime":e=new Date(t);break;case"boolean":e="Boolean"==(0,d.type)(t)?t:!!t&&Boolean(t);break;case"integer":e="Number"==(0,d.type)(t)?t:t?parseInt(t):t;break}e&&(this.values[this.field.name]=e)}catch(i){console.error(`转换友好值错了：${i}`)}return e||t},pickHideFields(){const e=this.field.hideRely;if(!e)return;const t=Array.isArray(e)?e:"String"==(0,d.type)(e)?[e]:[];t.map((e=>{let t=e.split("==");if(2!=t.length)return;let i=t[0].trim(),s=t[1].trim();this.hideFields[i]||(this.hideFields[i]=[]);for(let l in this.hideFields){let e=this.hideFields[l].find((e=>{if(e.key==i&&e.value==s&&e.name==this.field.name)return e.field=this.field,!0}));if(e)return}this.hideFields[i].push({name:this.field.name,key:i,value:s,field:this.field})}))},async pickDependencies(){if(this.field.hasOwnProperty("dict")&&0!=this.field.length)if("string"==typeof this.field.dict&&(0,a.CB)(this.field.dict)){const{method:e,respProp:t,params:i,pickValues:s}=this.field.dictConfig;s.map((e=>{void 0!=this.values[e]&&(i[e]=this.values[e])}));const l=await(0,a.od)(this.field.dict,i,e),d=this.deepPick(t.split("."),l);if(Array.isArray(d)&&d.length>0&&(this.field.options=d),this.field.defaultOption>=0&&this.field.options.length>0){let e=d[this.field.defaultOption];this.values[this.field.name]="object"==typeof e?e[this.field.defaultProp.value]:e}}else if(Object.keys(this.field.dict).length>0)for(let e in this.field.dict){let t=this.field.dict[e],i=e.split("=="),s=i[0].trim(),l=i[1].trim();this.dependencies[s]||(this.dependencies[s]=[]);let d=this.dependencies[s].find((e=>{if(e.keyValue==l&&e.name==this.field.name)return e.field=this.field,!0}));d||this.dependencies[s].push({name:this.field.name,beRelyKey:s,keyValue:l,dictValue:t,field:this.field,type:this.schema.type,options:JSON.parse(JSON.stringify(this.field.options))})}},pickRegExp(){const e=this.field.regExp;e&&e.map((e=>{const{relyName:t}=e;this.regExpFields[t]||(this.regExpFields[t]=[]),this.regExpFields[t].find((t=>t.childrenName==this.field.name&&t.relyName==e.relyName))||this.regExpFields[t].push({...e,childrenName:this.field.name,field:this.field})}))}}};t.Z=n},9367:function(e,t,i){i.r(t),i.d(t,{default:function(){return f}});var s=i(748);const l=["id"],d=["innerHTML"];function a(e,t,i,a,n,h){return(0,s.openBlock)(),(0,s.createElementBlock)("div",{class:"slot-widget",id:e.widgetId},[(0,s.createElementVNode)("div",{innerHTML:e.field.html,style:(0,s.normalizeStyle)({color:e.colors.fontColor})},null,12,d)],8,l)}var n=i(3951),h={mixins:[n.Z],methods:{defaultFieldAttr(){return{}}}},r=i(3744);const o=(0,r.Z)(h,[["render",a]]);var f=o}}]);