import { ref } from 'vue'
import { getSsHisImage } from '@/api/Sheshi'

const showHisImageCom = ref(false)
const sheshiData = ref()
// const ssId = ref<number | string>('')
export const useHisImage = () => {
  function showOrHideHisImage(data: TBaseNode) {
    sheshiData.value = data
    console.log(sheshiData, 'id')
    // const {id} = data
    showHisImageCom.value = !showHisImageCom.value
    // id && (sheshiData.value = data.id)
  }

  async function getHisImages(times: [string, string]) {
    const [timeBegin, timeEnd] = times
    const { code, data } = await getSsHisImage({
      sheShiId: sheshiData.value.id,
      timeBegin,
      timeEnd,
    })
    return code === '200' ? data : []
  }
  return { sheshiData, showHisImageCom, showOrHideHisImage, getHisImages }
}
