<template>
  <lt-a-table ref="refTable" :url="url" :remoteQueryMode="remoteQueryMode" :pageSize="10" size="small"
    :columnFilter="columnFilter" style="border: 0px" :showToolBar="false" :showEditInDialog="false" :columns="columns"
    :searchBox="false" :dataName="dataName" @row-dblclick="handleDblclick" @row-click="handleClick"
    @selection-change="handleSelectionChange" @loadSuccess="loadSuccess" bordered :highlight-current-row="true"
    :queryParams="queryParams" row-key="ModelId">

  </lt-a-table>
</template>
<script setup lang="ts">

import { ref, reactive, getCurrentInstance, computed, PropType } from "vue"
import { formatCols } from "../../commonMethods/commonMethods"
import { ColStruct } from "@/components/lt-graph/src/hooks/type";
const props = defineProps({
  receipModelFilter: {
    type: Array,
    default() {
      return [];
    },
  },
  receipModelCols: {
    type: Array as PropType<ColStruct[]>,
    default() {
      return [];
    },
  },
})

const url = "FormularService/LoadFileDescription"
const remoteQueryMode = 3
const columnFilter = computed(() => {
  return props.receipModelFilter
})
const columns = computed(() => {
  return formatCols(props.receipModelCols).filter((item) => {
    return item.Visible == true
  })
})

const emits = defineEmits(["update:selectionData", "update:selectRowData", "row-dblclick"])

const loading = ref(false)  //是否加载
const queryParams = reactive({
  Request: {
    Conditions: [
      { "Key": "IsParent", "Value": true, "MatchCase": "Equal" }
    ],

  },
})
const dataName = "Datas"
//公共方法
const currentInstance = getCurrentInstance()
const reload = function () {
  //清空选中项
  emits("update:selectionData", []);
  emits("update:selectRowData", null);
  // currentInstance.refs.refTable.reload()
}
const handleDblclick = function (row: any, dataIndex: number, event: any) {
  emits("row-dblclick", row);
}
const handleClick = function (row: any) {
  emits("update:selectRowData", row);
}
const handleSelectionChange = function (val: any) {
  emits("update:selectionData", val);
}
const loadSuccess = function (data: any, index: number) {
  emits("update:selectRowData", data[0]);
}

// onMounted(()=>{

// })

</script>
