<template>
	<NavBar />
	<view class="container">
		<view class="title">
			<PageTitle :title="$t('ib.fundSetting')" />
		</view>
		<view class="content">
			<view class="tableSection">
				<uni-table :emptyText="$t('common.noData')" v-if="!tableLoading">
					<uni-tr class="tableTh">
						<uni-th align="left" class="columnItem">{{ $t('fundSetting.rebateRule') }}</uni-th>
					</uni-tr>
					<uni-tr v-for="row in rebateRuleList" :key="row.rowKey ?? row.id" @click="handleRowClick(row)" >
						<uni-td class="columnItem">
							<view style="width: 100%;display: flex;justify-content: space-between;">
								<view>{{ row?.['rebate_name'] ?? '-' }}</view>
								<view><uni-icons type="right" size="40upx"></uni-icons></view>
							</view>
						</uni-td>
					</uni-tr>
				</uni-table>
				<Spin v-show="tableLoading" />
			</view>
		</view>
	</view>
	<view>
		
	</view>
</template>

<script>
import { queryRebate } from '@/services/partner/myClient.ts';
import { useUserStore } from '@/stores/user';

export default {
	data() {
		return {
			tableLoading: false,
			rebateRuleList: []
		}
	},
	created() {
		this.loadData()
	},
	methods: {
		async loadData() {
			this.tableLoading = true
			const resp = await queryRebate()
			this.tableLoading = false
			this.rebateRuleList = resp.data
		},
		handleRowClick(currentRow) {
			const userStore = useUserStore();
			userStore.setCurrentRow(currentRow)
			uni.navigateTo({
				url: "/pages/partner/rebateSetting/tree"
			})
		}
	}
}
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>