<template>
<div>
    <common @asynCallBack="asynCallBack"></common>
    <top-header :pageTitle="pageTitle" :routeName="routeName"></top-header>
    <div class="mui-content">
        <div class="mui-content-padded">
            <ul class="mui-table-view vongi-jy-ul">

                <li class="mui-table-view-cell" v-for="(item,index) in recordList">
                    <a @click="goto(item)" class="mui-navigate-right">
                        {{item.deviceName}}
                        <span class="mui-pull-right">{{item.personId}}</span>
                    </a>
                </li>

            </ul>
        </div>
    </div>
    <NullList :remark="'暂无设备'" v-if="!recordList.length"></NullList>

    <loading :visible="isLoading"></loading>
</div>
</template>

<script>
import * as API_Device from "@/apis/Common/device";

import Common from "$project/components/Common.vue";
import Loading from "$project/components/Loading.vue";
import TopHeader from "$project/components/TopHeader.vue";
import isReachBottom from "$project/utils/isReachBottom";
import NullList from "$project/components/NullList.vue";

import {
    mapGetters,
    mapMutations
} from "vuex";
export default {
    name: "CommonDeviceLiveBindList",
    components: {
        Common,
        Loading,
        TopHeader,
        NullList,
    },
    data() {
        return {
            pageTitle: "设备维护",

            isLoading: false,

            listForm: {
                pageIndex: 1,
                pageSize: 20,
                totalPage: 1,
            },
            routeName: "Master",
            recordList: [],
        };
    },
    created() {},
    methods: {
        goto(mod) {
            if (mod.personId) {

                mui.toast("已设置，如需修改，联系中层以上人员重置");
                return;
            }
            //跳转首页
            this.$router.push({
                name: 'CommonDeviceLiveBindInfo',
                query: {
                    id: mod.id,
                    name: mod.deviceName,
                    onId: mod.deviceSerial,
                    personId: mod.personId,
                    routeName: 'CommonDeviceLiveBindList',
                }
            })
        },
        //获取列表
        getList() {
            this.isLoading = true;

            API_Device.livePageList(this.listForm)
                .then((response) => {
                    if (response) {
                        if (this.listForm.pageIndex == 1) {
                            this.recordList = response.data;
                            this.listForm.pageIndex = response.pageNumber;
                            this.listForm.totalPage = response.totalPage;
                        } else {
                            this.recordList = [...this.recordList, ...response.data];
                        }
                    }
                    this.listForm.pageIndex++;
                    this.isLoading = false;
                })
                .catch((error) => {
                    this.isLoading = false;
                    mui.toast(error);
                });
        },
        asynCallBack() {},
    },
    mounted() {
        //获取列表
        this.getList();
    },
    destroyed() {},
    computed: {
        ...mapGetters({
            openId: "wx_openid",
            token: "token",
            person_data: "person_data",
            person_popedom: "person_popedom",
        }),
    },
};
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
