import { PageContainer } from "@ant-design/pro-components"
import { columns } from "./tableConfig"
import { useAjax } from "@/Hook/useAjax"
import { useState } from "react"
import { useModel } from "@umijs/max"
import { appList } from "@/services/distributor/appList"
import MyProTable from "@/components/MyProTable"

const Page: React.FC = () => {
    let { state, getEnum } = useModel("global")
    let [key, setKey] = useState<any>(1)
    let getList = useAjax((params) => appList(params), { type: 'table' })
    return <PageContainer
        tabList={getEnum("APP_TYPE", "arr")}
        tabProps={{
            type: 'card',
            hideAdd: true,
            onChange: (e) => setKey(e),
        }}
    >
        <MyProTable<any, any>
            headerTitle={"抖音小程序列表"}
            rowKey={(r) => r.id}
            search={{
                labelWidth: 120,
            }}
            scroll={{ x: "auto" }}
            params={{
                appType: key
            }}
            request={async (params) => {
                if (params.appType) {
                    return await getList.run(params)
                }
            }}
            columns={columns({ appType: key })}
        />
    </PageContainer>

}
export default Page