<template>
  <xc-combo-grid v-model="inputValue"
                 class="popup-main"
                 v-show="isShow"
                 @blur="isShow = false"
                 ref="gridRef"
                 :table-header="[]"
                 :query-data-func="getEmrTipsData"
                 @rowClick="rowClick">
    <el-table-column label="内容"
                     prop="content"
                     width="600"
                     show-overflow-tooltip/>
  </xc-combo-grid>
</template>

<script setup name='EmrPopup'>

import XcComboGrid from "@/components/xiao-chan/combo-grid/XcComboGrid.vue";
import {getEmrTipsData} from "@/api/zhu-yuan-yi-sheng/emr-patient";

const emit = defineEmits(['fillData'])

const coordinate = ref({
  x: '200px',
  y: '0px'
})

const isShow = ref(false)
const inputValue = ref()
const gridRef = ref()

const positionChange = (evt, view, position) => {
  position.x = position.x + 2 + 'px'
  position.y += 'px'
  coordinate.value = position
  open()
  gridRef.value.focus()
}

const rowClick = (row) => {
  emit('fillData', row)
}

const closed = () => {
  isShow.value = false
}

const open = () => {
  isShow.value = true
}

defineExpose({
  positionChange,
  closed,
  open
})


</script>

<style scoped lang="scss">
.popup-main {
  position: absolute;
  z-index: 99;

  //left: 0;
  //top: 0;
  left: v-bind('coordinate.x');
  top: v-bind('coordinate.y');
}
</style>
