import{bp as e,az as t,aD as a,aC as l,_ as s,b as i,h as c,d as o,o as n,p as r,w as u,e as h,t as d,v as m,f as p,a4 as f,k as _,F as y,y as D,i as b,C as x,S as g}from"./index-2PZN6pGH.js";const k=s({name:"uni-stat-select",mixins:[e.mixinDatacom||{}],data:()=>({showSelector:!1,current:"",mixinDatacomResData:[],apps:[],channels:[]}),props:{localdata:{type:Array,default:()=>[]},value:{type:[String,Number],default:""},modelValue:{type:[String,Number],default:""},label:{type:String,default:""},placeholder:{type:String,default:"请选择"},emptyTips:{type:String,default:"无选项"},clear:{type:Boolean,default:!0},defItem:{type:Number,default:0},disabled:{type:Boolean,default:!1},format:{type:String,default:""}},created(){this.last=`${this.collection}_last_selected_option_value`,this.collection&&!this.localdata.length&&this.query()},computed:{typePlaceholder(){const e=this.placeholder,t={"opendb-stat-app-versions":"版本","opendb-app-channels":"渠道","opendb-app-list":"应用"}[this.collection];return t?e+t:e}},watch:{localdata:{immediate:!0,handler(e,t){Array.isArray(e)&&t!==e&&(this.mixinDatacomResData=e)}},modelValue(){this.initDefVal()},mixinDatacomResData:{immediate:!0,handler(e){e.length&&this.initDefVal()}}},methods:{query(){this.mixinDatacomEasyGet()},onMixinDatacomPropsChange(){this.collection&&this.query()},initDefVal(){let e="";if(!this.value&&0!==this.value||this.isDisabled(this.value))if(!this.modelValue&&0!==this.modelValue||this.isDisabled(this.modelValue)){let a;if(this.collection&&(a=t(this.last)),a||0===a)e=a;else{let t="";this.defItem>0&&this.defItem<=this.mixinDatacomResData.length&&(t=this.mixinDatacomResData[this.defItem-1].value),e=t}(e||0===e)&&this.emit(e)}else e=this.modelValue;else e=this.value;const a=this.mixinDatacomResData.find((t=>t.value===e));this.current=a?this.formatItemName(a):""},isDisabled(e){let t=!1;return this.mixinDatacomResData.forEach((a=>{a.value===e&&(t=a.disable)})),t},clearVal(){this.emit(""),this.collection&&a(this.last)},change(e){e.disable||(this.showSelector=!1,this.current=this.formatItemName(e),this.emit(e.value))},emit(e){this.$emit("change",e),this.$emit("input",e),this.$emit("update:modelValue",e),this.collection&&l(this.last,e)},toggleSelector(){this.disabled||(this.showSelector=!this.showSelector)},formatItemName(e){let{text:t,value:a,channel_code:l}=e;if(l=l?`(${l})`:"",this.format){let t="";t=this.format;for(let a in e)t=t.replace(new RegExp(`{${a}}`,"g"),e[a]);return t}return this.collection.indexOf("app-list")>0?`${t}(${a})`:t||`未命名${l}`}}},[["render",function(e,t,a,l,s,k){const S=b,v=i(o("uni-icons"),c),V=x,w=g;return n(),r(S,{class:"uni-stat__select"},{default:u((()=>[a.label?(n(),h("span",{key:0,class:"uni-label-text hide-on-phone"},d(a.label+"："),1)):m("",!0),p(S,{class:f(["uni-stat-box",{"uni-stat__actived":s.current}])},{default:u((()=>[p(S,{class:f(["uni-select",{"uni-select--disabled":a.disabled}])},{default:u((()=>[p(S,{class:"uni-select__input-box",onClick:k.toggleSelector},{default:u((()=>[s.current?(n(),r(S,{key:0,class:"uni-select__input-text"},{default:u((()=>[_(d(s.current),1)])),_:1})):(n(),r(S,{key:1,class:"uni-select__input-text uni-select__input-placeholder"},{default:u((()=>[_(d(k.typePlaceholder),1)])),_:1})),s.current&&a.clear?(n(),r(v,{key:2,type:"clear",color:"#c0c4cc",size:"24",onClick:k.clearVal},null,8,["onClick"])):(n(),r(v,{key:3,type:s.showSelector?"top":"bottom",size:"14",color:"#999"},null,8,["type"]))])),_:1},8,["onClick"]),s.showSelector?(n(),r(S,{key:0,class:"uni-select--mask",onClick:k.toggleSelector},null,8,["onClick"])):m("",!0),s.showSelector?(n(),r(S,{key:1,class:"uni-select__selector"},{default:u((()=>[p(S,{class:"uni-popper__arrow"}),p(w,{"scroll-y":"true",class:"uni-select__selector-scroll"},{default:u((()=>[0===s.mixinDatacomResData.length?(n(),r(S,{key:0,class:"uni-select__selector-empty"},{default:u((()=>[p(V,null,{default:u((()=>[_(d(a.emptyTips),1)])),_:1})])),_:1})):(n(!0),h(y,{key:1},D(s.mixinDatacomResData,((e,t)=>(n(),r(S,{class:"uni-select__selector-item",key:t,onClick:t=>k.change(e)},{default:u((()=>[p(V,{class:f({"uni-select__selector__disabled":e.disable})},{default:u((()=>[_(d(k.formatItemName(e)),1)])),_:2},1032,["class"])])),_:2},1032,["onClick"])))),128))])),_:1})])),_:1})):m("",!0)])),_:1},8,["class"])])),_:1},8,["class"])])),_:1})}],["__scopeId","data-v-5d6768e2"]]);export{k as _};
