

<script>
/* eslint-disable */
// sd-skip-auto-import
import util from"./util";import components from"./_import-components/sd-display-expr-import";var _render=function e(){var t=this,a=t._self._c;return a("div",{class:t.$style.wrapper},[a("a-select",{class:t.$style.fieldSelect,attrs:{"allow-clear":"",options:t.selectListFields},on:{change:t.changeLeftValue},model:{value:t.leftValue,callback:function(e){t.leftValue=e},expression:"leftValue"}}),t.leftValue?a("a-select",{class:t.$style.operatorSelect,model:{value:t.evaluator,callback:function(e){t.evaluator=e},expression:"evaluator"}},[a("a-select-option",{attrs:{value:"=="}},[t._v(" 是 ")]),a("a-select-option",{attrs:{value:"!="}},[t._v(" 不是 ")])],1):t._e(),t.leftValue?a("a-select",{class:t.$style.valueSelect,attrs:{options:t.conditionFieldList},model:{value:t.rightValue,callback:function(e){t.rightValue=e},expression:"rightValue"}}):t._e()],1)};var staticRenderFns=[];_render._withStripped=true;export default{name:"SdDisplayExpr",components:components,mixins:[util.mixin],model:{prop:"value",event:"change"},props:{value:{type:String,default:void 0}},data(){return{leftValue:void 0,rightValue:void 0,evaluator:"=="}},computed:{selectListFields(){return this.componentInstances.filter((e=>"selectlist"===e.dataType&&"true"!==e.attr.multiple)).map((e=>({label:e.caption,value:e.name,key:e.name})))},conditionFieldList(){return this.componentInstances.find((e=>e.name===this.leftValue))?.attr.selectListItem}},watch:{value:{immediate:true,handler(){const e=this.getDisplayExpr(this.value);this.leftValue=e.leftValue;this.rightValue=e.rightValue;this.evaluator=e.evaluator}},rightValue(){this.updateValue()},evaluator(){this.updateValue()}},methods:{updateValue(){const e=this.leftValue;if(!e){this.$emit("change",void 0);return}const t=this.rightValue??"";const a=this.evaluator??"";this.$emit("change",`#bean.${e} ${a} ${JSON.stringify(t)}`)},getDisplayExpr(e){if(!e)return{evaluator:"=="};const t=["==","!="];let a="";let l;let i;t.some((t=>{const s=e.indexOf(t);if(-1!==s){i=t;a=e.substring(0,s).trim().replace("#bean.","");l=JSON.parse(e.substring(s+t.length).trim());return true}else return false}));return{leftValue:a,rightValue:l,evaluator:i}},changeLeftValue(e){if(!e||this.conditionFieldList[0].value===this.rightValue){this.updateValue();return}this.rightValue=this.conditionFieldList[0].value}},render:_render,staticRenderFns:staticRenderFns};</script>

<style module lang="scss">
@use '@/common/design' as *;
.wrapper {
  display: flex;
  .field-select,
  .value-select {
    flex: auto;
  }
  .operator-select {
    flex: none;
    width: auto;
    min-width: 4em;
  }
}
</style>
