Page({
    data: {
        active: "",
        page: null,
        ops: [],
        unfolds: [],
    },
    onLoad(options) {
        getApp().globalData.Language.getLanguagePackage(this, '360°画像');
        const ops = wx.getStorageSync('auth').wportrayal.options.filter(v => ["Client", "Project", "Contacts", "Sales"].includes(v))
        this.setData({
            active: ops[0],
            unfolds: [ops[0]]

        })
        this.setData({
            ops: ops.map(v => {
                return {
                    name: v,
                    title: {
                        "Client": "客户",
                        "Project": "项目",
                        "Contacts": "联系人",
                        "Sales": "业务员"
                    } [v]
                }
            }),
        })
    },
    onChange(event) {
        const active = event.detail.name;
        if (!this.data.unfolds.includes(active)) {
            this.data.unfolds.push(active);
        }
        this.setData({
            active,
            unfolds: this.data.unfolds
        });
        this.getList({
            detail: active
        });
    },
    getList({
        detail
    }) {
        if (detail && this.data.active == "") return setTimeout(() => {
            this.getList({
                detail: detail
            })
        })
        if (detail && this.data.active != detail) return;
        const page = this.selectComponent("#" + this.data.active);
        if (page) {
            if (page.data.total == null) page.getList();
            this.data.page = page;
        }
    },
    changeSearchShow() {
        this.data.page.changeSearchShow();
    },
    openFiltrate() {
        this.data.page.setData({
            showFiltrate: true
        });
    }
})