

<script>
/* eslint-disable */
// sd-skip-auto-import
import cloneDeep from"lodash.clonedeep";import components from"./_import-components/sd-header-config-import";var _render=function e(){var t=this,a=t._self._c;return a("span",[a("a-button",{on:{click:t.open}},[t._v("列表设置")]),a("a-modal",{attrs:{visible:t.visible,width:"900px","body-style":{overflow:"auto",height:"500px"},title:"设置展示列","destroy-on-close":""},on:{cancel:function(e){t.visible=false},ok:t.handleOk}},[a("a-button",{class:t.$style.add,attrs:{type:"link"},on:{click:()=>t.$refs.editor.addNode()}},[t._v(" 添加表头分组 ")]),a("a-transfer",{class:t.$style.transfer,attrs:{"list-style":{height:"450px",width:"400px"},"data-source":t._columns,"target-keys":t.targetKeys,render:e=>e.title},on:{change:t.handleChange},scopedSlots:t._u([{key:"children",fn:function({props:{direction:e}}){return["right"===e?a("sd-tree-editor",{ref:"editor",on:{change:t.updateTargetKeys},model:{value:t.treeData,callback:function(e){t.treeData=e},expression:"treeData"}}):t._e()]}}])})],1)],1)};var staticRenderFns=[];_render._withStripped=true;export default{name:"SdHeaderConfig",components:components,model:{prop:"value",event:"change"},props:{columns:{type:Array,default:()=>[]},value:{type:Array,default:()=>[]}},data(){return{targetKeys:[],treeData:[],visible:false}},computed:{_columns(){return this.columns.map((e=>{const{caption:t,name:a}=e;return{title:t,key:a}}))}},methods:{handleChange(e,t,a){if("right"===t)a.forEach((e=>{this.treeData.push(this._columns.find((t=>t.key===e)))}));this.targetKeys=e},updateTargetKeys(){this.$nextTick((()=>{const e=[];const t=a=>{a.forEach((a=>{if(!a.key?.startsWith("auto"))e.push(a.key);if(a.children)t(a.children)}))};t(this.treeData);this.targetKeys=e}))},open(){const e=cloneDeep(this.value);const t=e=>{e.forEach((e=>{e.key=e.dataIndex||e.name;e.title=e.caption||this._columns.find((t=>t.key===e.key))?.title;if(e.children)t(e.children)}))};t(e);this.treeData=e;this.updateTargetKeys();this.visible=true},handleOk(){this.visible=false;const e=t=>{t.forEach((t=>{if(t.children)e(t.children);t.caption=t.title;t.name=t.key}))};e(this.treeData);this.$emit("change",this.treeData)}},render:_render,staticRenderFns:staticRenderFns};</script>

<style module lang="scss">
@use '@/common/design' as *;
.transfer {
  > div:last-child {
    label {
      display: none;
    }
  }

  display: block;
}
.add {
  position: absolute;
  top: 84px;
  right: 34px;
  z-index: 1;
}
</style>
