<template>
<div ref="card" :id="config.name" style="padding:5px" >
    <div v-if="$slots.header">
        <slot name="header"></slot>
    </div>
    <Row v-else  type="flex" justify="start" :gutter="4"  v-show="!myConfig.readOnly">
      <Col v-show="showAddBtn">
        <Button icon="ios-add" size="small" @click="addRow" >{{addBtnName}}</Button>
       </Col>
       <Col v-show="showDelBatchBtn">
        <Button icon="ios-remove" size="small" @click="delBatchRow">{{delBatchBtnName}}</Button>
       </Col>
    </Row>
    <Row>
    <Table ref="table"  style="margin-top: 5px;"   :row-class-name="rowClassName" :loading="loading" :size="myConfig.tableSize"  :stripe="myConfig.showStripe" :border="myConfig.showBorder" :height="tableHeight" :maxHeight="tableMaxHeight" :show-header="myConfig.showHeader" @on-selection-change="OnSelectionChange" :columns="tableColumns"  :data="data" @on-column-width-resize="onColumnWidthResize" :show-summary="myConfig.showSummary"  :summary-method="handleSummary">
          <template  v-for="config in soltTableColumns" v-slot:[config.key]="{ index }" :key="'show_' + config.key">          
            <div @click="EditCell(index,config)">
                <ControlBox v-if="editIndex === index && editKey=== config.key"   :autofocus="true" :config="getCellConfig(index,config)"  :valueData="getCurRow(index)" @inputValue="input" :editIndex="index" @doAction="doAction"></ControlBox>
                <ShowText v-else :label="formatValue(index,config)"  :contentAlign="config.contentAlign"  :class="IsCellError(index,config)"></ShowText>
            </div>
         </template>
    </Table>
    <div  ref="page" v-if="myConfig.showPage" style="background:#eee;padding-top:5px;width:100%" >
        <Card :bordered="false" :padding="0" :dis-hover="true" style="border-radius:0px">
            <Row  type="flex" justify="end" style="padding:5px;padding-right:10px">
                <Page  :total="myConfig.pageConfig.total_results"  :size="myConfig.pageSize"  :current="myConfig.pageConfig.page_no" :page-size="myConfig.pageConfig.page_size" :page-size-opts="myConfig.pageConfig.pageSizeList"  @on-page-size-change="changePageSize" @on-change="changePage"  :show-total="myConfig.pageShowTotal" :show-elevator="myConfig.pageShowElevator" :show-sizer="myConfig.pageShowSizer"></Page>
            </Row>
        </Card>
    </div>
    </Row>
    <Modal v-if="!editRowFlag"  v-model="showEditRowForm"  width="90%" title="编辑" @on-ok="editRow">
        <div>
           <ExpandRow ref="rowForm"  :config="myConfig" :dictData="dictData"/>
        </div>
    </Modal>
</div>
</template>
<script>
import Base from './editgridbase.vue';
export default {
    name: 'editgrid',
    extends: Base,
    mounted() {
        if (this.$refs.card && this.$refs.card.$el) {
            this.$refs.card.$el.onmouseleave = () => {
                //this.handleOut();
            };
        }
    }
};
</script>
