import{c as d}from"./cloneDeep.65307636.js";import{r as m,w as v,u as y}from"./framework.e8f655c8.js";import{n as h,e as c,L as _}from"./index.8c202964.js";const b="must",g={name:"AdvancedSearch",props:{formModel:Array,optionsLabel:{type:String,default:""},relationSelList:{type:Array,default:()=>[{label:"\u4E0E",value:"must"},{label:"\u6216",value:"should"}]},searchRuleList:{type:Array,default:()=>[{label:"\u6A21\u7CCA",value:"fuzzy"},{label:"\u7CBE\u51C6",value:"term"}]},fieldList:{type:Array,default:()=>[]},selectType:{type:String,default:"select"}},emits:["advance_search"],setup(n,{emit:t}){const a=()=>({relation:"must",field:n.selectType==="select"?n.fieldList[0].value:"",keyword:"",match:"fuzzy"});let l=m([a()]),r=m([]);v(()=>n.formModel,s=>{l.value=d(s)},{deep:!0});const e=()=>{l.value=[a()]},p=()=>{if(!u())return;t("advance_search",(()=>{const o=d(y(l)),[i,f]=o;return i.relation=o.length===1?b:f.relation,_(i.field)&&(i.field=i.field[1]),o})())};function u(){for(const s of l.value){if(!s.keyword)return c("\u8BF7\u8F93\u5165\u68C0\u7D22\u6761\u4EF6"),!1;if(!s.field)return c("\u8BF7\u9009\u62E9\u8981\u67E5\u8BE2\u7684\u7C7B\u522B"),!1}return!0}return{expertFormList:l,otherFieldList:r,getDefaultFormItem:a,addExpertItem:()=>{if(l.value.length>4){c("\u6761\u4EF6\u592A\u591A\u4E86");return}l.value.push(a())},removeExpertItem:s=>{l.value.splice(s,1)},cascaderChange:(s,o)=>{t("casChange",s[0]),r.value=n.fieldList.find(i=>i.value===s[0]).children,l.value.length>1&&(e(),l.value[0].field=s)},resetSearch:e,saveSearch:p,validSearch:u}}};var x=function(){var t=this,a=t._self._c;return a("div",{staticClass:"advanced_search"},t._l(t.expertFormList,function(l,r){return a("div",{key:r,staticClass:"form-item flex-center-align"},[a("div",{staticClass:"relation-item margin-right-medium"},[r!==0?a("CustomSelect",{attrs:{size:"medium","popper-append-to-body":!1},model:{value:l.relation,callback:function(e){t.$set(l,"relation",e)},expression:"item.relation"}},t._l(t.relationSelList,function(e){return a("el-option",{key:e.value,attrs:{value:e.value,label:e.label}})}),1):t._e()],1),a("div",{staticClass:"type-item margin-right-medium"},[t.selectType==="select"?a("CustomSelect",{staticClass:"chart-type",attrs:{size:"medium","popper-append-to-body":!1},model:{value:l.field,callback:function(e){t.$set(l,"field",e)},expression:"item.field"}},[a("el-option-group",{attrs:{label:t.optionsLabel}},t._l(t.fieldList,function(e){return a("el-option",{key:e.value,attrs:{value:e.value,label:e.label}})}),1)],1):t.selectType==="cascader"&&r===0?a("CustomCascader",{staticClass:"chart-type",attrs:{size:"medium",options:t.fieldList,"show-all-levels":!1,props:{expandTrigger:"hover"},"append-to-body":!1},on:{change:e=>t.cascaderChange(e,0)},model:{value:l.field,callback:function(e){t.$set(l,"field",e)},expression:"item.field"}}):a("CustomSelect",{attrs:{placeholder:"\u8BF7\u9009\u62E9","popper-append-to-body":!1},model:{value:l.field,callback:function(e){t.$set(l,"field",e)},expression:"item.field"}},t._l(t.otherFieldList,function(e){return a("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})}),1)],1),a("div",{staticClass:"keyword-item margin-right-medium"},[a("el-input",{attrs:{maxlength:40,size:"medium"},model:{value:l.keyword,callback:function(e){t.$set(l,"keyword",typeof e=="string"?e.trim():e)},expression:"item.keyword"}})],1),a("div",{staticClass:"rule-item margin-right-medium"},[a("CustomSelect",{staticClass:"search-type",attrs:{size:"medium","popper-append-to-body":!1},model:{value:l.match,callback:function(e){t.$set(l,"match",e)},expression:"item.match"}},t._l(t.searchRuleList,function(e){return a("el-option",{key:e.value,attrs:{value:e.value,label:e.label}})}),1)],1),a("div",{staticClass:"searchBtnItem"},[a("el-button",{attrs:{disabled:r+1!==t.expertFormList.length,type:"primary",size:"medium"},on:{click:t.addExpertItem}},[t._v("\u65B0\u589E")]),a("el-button",{style:{visibility:r===0?"hidden":""},attrs:{type:"primary",size:"medium"},on:{click:function(e){return t.removeExpertItem(r)}}},[t._v("\u5220\u9664")])],1)])}),0)},C=[],k=h(g,x,C,!1,null,"766ffe32",null,null);const E=k.exports;export{E as A};
