<template>
    <view class="container">
        <MBCard>
            <uni-forms ref="baseForm" :modelValue="queryParams">
                <uni-forms-item label="大区">
                    <LargeArea v-model="queryParams.bigAreaId" @change="handleQuery"/>
                </uni-forms-item>
                <uni-forms-item label="地域">
                    <Area v-model="queryParams.deptId" @change="handleQuery"/>
                </uni-forms-item>
                <uni-forms-item label="商业公司">
                    <BusinessCompany
                        v-model="queryParams.businessName"
                        @change="handleQuery"
                    />
                </uni-forms-item>
            </uni-forms>
        </MBCard>

        <uni-table ref="table" :loading="loading" emptyText="暂无更多数据" stripe>
            <uni-tr>
                <uni-th align="center" width="50">序号</uni-th>
                <uni-th align="left" width="200">公司名称</uni-th>
                <uni-th align="left" width="50">地域</uni-th>
                <uni-th width="100">账期终审</uni-th>
                <uni-th width="100">额度终审</uni-th>
                <uni-th width="100">价格终审</uni-th>
            </uni-tr>
            <uni-tr v-for="(item, index) in tableData" :key="index">
                <uni-td align="center">{{ index + 1 }}</uni-td>
                <uni-td>{{ item.userName }}</uni-td>
                <uni-td>{{ item.areaName }}</uni-td>
                <uni-td>
                    <view v-if="item.creditPeriod > 0">
                        <button class="uni-button" size="mini" type="submit">编辑</button>
                    </view>
                </uni-td>
                <uni-td>
                    <view v-if="item.creditLimit > 0">
                        <button class="uni-button" size="mini" type="submit">编辑</button>
                    </view>
                </uni-td>
                <uni-td>
                    <view v-if="item.price > 0">
                        <button class="uni-button" size="mini" type="submit">编辑</button>
                    </view>
                </uni-td>
            </uni-tr>
        </uni-table>

    </view>
</template>

<script setup>
import {defineOptions, onMounted, ref} from "vue"
import Area from "../../../components/Area.vue";
import MBCard from "../../../components/MB/MBCard.vue";
import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";
import BusinessCompany from "../../../components/BusinessCompany.vue";
import UniForms from "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
import LargeArea from "../../../components/LargeArea/LargeArea.vue";
import {getPriceFinallReviewList} from "../../../api/AccountPriceFinallReview";

defineOptions({
    name: "AccountPriceFinallReview"
})


const loading = ref(true)
const queryParams = ref({})
const tableData = ref([])
const total = ref(0)
const paging = ref({
    pageNum: 1,
    pageSize: 100,
})

const handleQuery = async () => {
    const data = await getPriceFinallReviewList(queryParams.value, paging.value)
    tableData.value = data.rows
    total.value = data.total
    loading.value = false
}

onMounted(async () => {
    await handleQuery()
})
</script>