<template>
    <view class="container">
        <MBCard>
            <uni-forms ref="baseForm" :modelValue="queryParams">
                <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="180">公司名称</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>{{ index + 1 }}</uni-td>
                <uni-td>{{ item.userName }}</uni-td>
                <uni-td>{{ item.areaName }}</uni-td>
                <uni-td>
                    <view v-if="item.zhangqi > 0">
                        <button class="uni-button" size="mini" type="submit">编辑</button>
                    </view>
                </uni-td>
                <uni-td>
                    <view v-if="item.edu > 0">
                        <button class="uni-button" size="mini" type="submit">编辑</button>
                    </view>
                </uni-td>
                <uni-td>
                    <view v-if="item.bg > 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 {getPricePreliminaryReviewList} from "../../../api/AccountPricePreliminaryRreview";

defineOptions({
    name: "AccountPricePreliminaryRreview"
})

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 getPricePreliminaryReviewList(queryParams.value, paging.value)
    tableData.value = data.rows
    total.value = data.total
    loading.value = false
}

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