<template>
    <view class="">
        <view class="head">
            <text>
                门店审核
            </text>
            <text>
                共{{ total }}个
            </text>
        </view>
        <My_listbox ref="List" @getlist="getList" bottomHeight="30">
            <store-list check ref="storeList" :list="list" @onClick="onClick" @onHandle="onHandle" />
        </My_listbox>
    </view>
</template>

<script>
import storeList from "../team/modules/storeList.vue"
export default {
    components: { storeList },
    data() {
        return {
            "content": {
                "where": {
                    "condition": ""
                }
            },
            total: 0,
            list: [],
            uninitialized: true
        }
    },
    onLoad() {
        this.getList()
        uni.setNavigationBarTitle({
            title: '门店信息审核'
        });
    },
    methods: {
        getList(init = false) {
            if (this.paging(this.content, init)) return;
            this.$Http.basic({
                "id": "20240411141602",
                content: this.content
            }).then(res => {
                console.log("待审核门店列表", res)
                this.$refs.List.RefreshToComplete()
                if (this.cutoff(res.msg)) return;
                this.uninitialized = false;
                this.$refs.List.setHeight()
                res.data = this.$refs.storeList.handleList(res.data)
                this.total = res.total;
                this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data), this.colors;
                this.content = this.$refs.List.paging(this.content, res)
            })
        },

        updateList() {
            if (this.content.pageNumber && this.content.pageNumber >= 2) {
                let content = this.paging(this.content, true, true)
                this.$Http.basic({
                    "id": "20240411141602",
                    content
                }).then(res => {
                    console.log("更新待审核门店列表", res)
                    if (this.cutoff(res.msg)) return;
                    this.$refs.List.setHeight()
                    this.list = this.$refs.storeList.handleList(res.data);
                    this.total = res.total;
                    this.$refs.List.paging(content, res, true)
                })
            }
        },
        onClick(item) {
            this.onInsert();
            uni.navigateTo({
                url: '/store/center/detail?id=' + item.sa_storeid,
            });
        },
        onHandle(item, funname) {
            console.log(item, funname)
            let id = '',
                that = this;
            switch (funname) {
                case "退回":
                    id = 20240410135402;
                    break;
                case "审核":
                    id = 20240410141002;
                    break;
                case "反审核":
                    id = 20240410141402;
                    break;
            }
            uni.showModal({
                title: '提醒',
                content: `确定对“${item.storename}”执行“${funname}”操作吗？`,
                confirmText: funname,
                success: ({
                    confirm
                }) => {
                    if (confirm) that.$Http.basic({
                        id,
                        "content": {
                            "sa_storeid": item.sa_storeid
                        }
                    }).then(res => {
                        console.log(`${funname}门店`, res)
                        if (that.cutoff(res.msg, `门店“${funname}”成功`)) return;
                        that.updateList()
                    })
                },
            })


        },
        onInsert() {
            this.$Http.uploadStoreList = function () {
                if (this.content.pageNumber && this.content.pageNumber >= 2) {
                    let content = this.paging(this.content, true, true)
                    this.$Http.basic({
                        "id": "20240411141602",
                        content
                    }).then(res => {
                        console.log("待审核门店列表", res)
                        if (this.cutoff(res.msg)) return;
                        this.$refs.List.setHeight()
                        this.list = this.$refs.storeList.handleList(res.data);
                        this.$refs.List.paging(content, res, true)
                    })
                }
            }.bind(this)
        }
    },
}
</script>

<style lang="scss" scoped>
.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 37px;
    padding: 0 10px;
    box-sizing: border-box;
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-size: 12px;
    color: #666666;
}
</style>