<template>
<div style="display: flex;margin-bottom: 20px;">
  <a-input-search
      v-model:value="value"
      placeholder="请输入订单号"
      style="width: 200px"
      @search="onSearch"
    />
</div>

<a-table :columns="columns" :data-source="list">
  </a-table>
</template>
<script lang="ts" setup>
import { onMounted,ref ,defineExpose} from 'vue';
import {onFindPayInfo,onFindPayOrderid} from '@/api/index'
import { getUid } from '@/utils/userInfo'
let list = ref<any>([])
let page = ref<any>('1')
let size = ref<any>('10')
let value = ref<any>('')
const columns = [
  {
    title: '商品名',
    dataIndex: 'subject',
    key: 'subject',
  },
  {
    title: '订单数',
    dataIndex: 'amount',
    key: 'amount',
  },
  {
    title: '订单号',
    dataIndex: 'id',
    key: 'id',
  },
  {
    title: 'merchantorderid',
    key: 'merchantorderid',
    dataIndex: 'merchantorderid',
  },
  {
    title: '订单时间',
    dataIndex: 'updatetime',
    key: 'updatetime',
  },
];
const onSearch =async()=>{
  const prarms ={
   uid:getUid(),
   orderid:value.value
  }
 const data:any =  await onFindPayOrderid(prarms)
  if(data.state === 1){
    list.value=[data.data]
  }
 
}
onMounted(async()=>{
    const uid =getUid()
    const prarms:any = {  
        page:page.value,
        size:size.value,
        uid
    }
  const data:any =  await onFindPayInfo(prarms)
  if(data.state === 1){
    list.value=data.data
  }
})
defineExpose({
  columns
})
</script>