<template>
    <div>
        <div style="display: flex;align-items: center;justify-content: space-between;">
            <div>
                <a-input-search v-model:value="value" placeholder="请输入商品名" style="width: 200px;margin-left: 20px;"
                    @search="onSearch" />
                <!-- <a-space direction="vertical">
                    <a-select v-model:value="value1" :size="size" style="width: 200px;margin-left: 20px;" :options="options"></a-select>
                </a-space> -->
            </div>
            <div>
                <a-button type="primary" block @click="onCreatePay">新建支付项</a-button>
            </div>
        </div>
        <div style="margin-top: 10px;" v-if="isShow">
            <a-table :dataSource="list" :columns="columns">
                <template #bodyCell="{ column, record }">
                    <div v-if="column.key == 'picurl'">
                        <div style="display:flex;align-items: center;">
                            <a-image :width="100" :src="record.picurl" />
                            <div>{{ record.subject }}
                            </div>
                        </div>
                    </div>
                    <div v-else-if="column.key == 'status'">
                        <div v-if="record.status == 0" style="color: rgb(12, 191, 33);">
                            正常
                        </div>
                        <div v-else-if="record.status == 1" style="color: #e6a23c;">
                           预警额度
                        </div>
                        <div v-else style="color: #f56c6c;">
                           风控
                        </div>
                    </div>

                    <div v-if="column.key == 'tags'">
                        <a-button type="primary" @click="onEdit">编辑</a-button>
                        <a-button type="primary" style="margin-left: 20px;">支付链接</a-button>
                        <a-button type="primary" style="margin-left: 20px;">统计</a-button>
                        <a-button type="primary" style="margin-left: 20px;">删除</a-button>
                    </div>
                </template>
            </a-table>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref, defineExpose, onMounted } from 'vue';
import type { SelectProps } from 'ant-design-vue';
import { getUid } from '@/utils/userInfo'
import { onSelectGoods, onfindby } from '@/api/index'
const popupScroll = () => {
    console.log('popupScroll');
};
const value = ref<string>('');
const optionss = ref<Array<Object>>([])
const options = [...Array(25)].map((_, i) => ({ value: (i + 10).toString(36) + (i + 1) }))
let list = ref()
let isShow = ref(true)
const columns = [
    {
        title: '支付项目名称',
        dataIndex: 'picurl',
        key: 'picurl',
    },
    {
        title: '绑定商品编号',
        dataIndex: 'goodsid',
        key: 'goodsid',
    },
    {
        title: '支付金额',
        dataIndex: 'price',
        key: 'price',
    },
    {
        title: '状态',
        dataIndex: 'status',
        key: 'status',
    },
    {
        title: '创始人',
        dataIndex: 'userid',
        key: 'userid',
    },
    {
        title: '备注',
        dataIndex: 'body',
        key: 'body',
    },
    {
        title: '操作',
        dataIndex: 'tags',
        key: 'tags',
    },
]
const onEdit = (e: any) => {
    console.log(e);
}
const onSearch = async () => {
    const params = {
        status: "0",
        name: value.value,
        uid: getUid()
    }
    const data = await onfindby(params)
    list.value = data.data
    console.log(list, 'list');

};
const onCreatePay = async()=>{
isShow.value = !isShow.value
}
onMounted(async () => {
    onSearch()
})
defineExpose({
    size: ref<SelectProps['size']>('middle'),
    value1: ref('a1'),
    options,
    value,
    isShow,
    onSearch,
    columns,
    onEdit,
    optionss,
    onCreatePay
})
</script>
<style lang="less" scoped>
</style>