<template>
    <div id="tabfunction-wrapper">
        <div v-bind:style="contentStyle" @touchstart.stop="handleTouchOutside">
            <div v-if="enabledModuleGroups.length === 0" style="padding-top: 20px;padding-left: 20px;">
                未开通窗口浏览权限，请联系相关管理员开通。
            </div>
            <div v-for="(group, idx) in enabledModuleGroups" :key="idx">
                <div class="funclist_title">{{group.groupname}}</div>
                <mu-row style="clear: both">
                    <mu-col
                        v-for="(module,index) in group.modules"
                        :key="index"
                        span="3"
                        style="text-align: center;margin-top: 10px;margin-bottom: 10px;"
                        @touchstart.stop="handleTouchStartModules($event, module)"
                        @touchmove.stop="handleTouchMoveModules($event, module)"
                        @touchend.stop="handleTouchEndModules($event, module, group.groupname)"
                    >
                        <template v-if="!module.actions">
                            <div class="funclist_icon"
                                :style="{backgroundColor: getIconColor(module,index),fontSize:module.ifReport === true?'40px':'25px'}">
                                <!-- <van-badge> -->
                                    <svg class="icon" aria-hidden="true">
                                        <use :xlink:href="'#'+module.icon "></use>
                                    </svg>
                                    <!-- <template #content v-if="module.tag">
                                        {{ module.tag.text }}
                                    </template>
                                </van-badge> -->
                                <van-tag v-if="module.tag && module.tag.text" class="funclist_tag" round :type="module.tag.type">{{ module.tag.text }}</van-tag>
                            </div>
                            <div class="funclist_text">{{module.name}}</div>
                        </template>
                        <van-popover
                            v-else
                            v-model="module.showPopover"
                            :actions="module.actions"
                            :placement="isPopoverPlacement"
                            :close-on-click-outside="false"
                            get-container="#tabfunction-wrapper"
                            @closed="autoPopoverClosed"
                            @select="handlePopoverSelected"
                        >
                            <div slot="reference" :class="{'longpress': module.longPress}">
                                <div class="funclist_icon" :class="{'longpressend': module.showPopover}"
                                    :style="{backgroundColor: getIconColor(module,index),fontSize:module.ifReport === true?'40px':'25px'}">
                                    <svg class="icon" aria-hidden="true">
                                        <use :xlink:href="'#'+module.icon "></use>
                                    </svg>

                                    <div class="showing_cls">
                                        <div class="ball-scale-multiple" v-if="module.showPopover">
                                            <div></div>
                                            <div></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="funclist_text">{{module.name}}</div>
                            </div>
                        </van-popover>
                    </mu-col>
                </mu-row>
            </div>
        </div>
        <!-- 报表弹窗 -->
        <lj-dialog :title="reportName" ref="rpDialog">
            <div slot="content">
                <template v-for="(report,index) in reportList" >
                    <div class="report_list_item" :key="index">
                        <div class="report_list_item_icon" style="background-color: #ff6f61;"
                            @click="handleReportClick(report)">
                            <i :class="getIconClassReport(report)" style="font-size:18px"></i>
                        </div>
                        <div class="report_list_item_text report_list_item_border">
                            <div class="report_list_item_name" @click="handleReportClick(report)">
                                {{report.name}}</div>
                            <div class="report_list_item_right">
                                <mu-checkbox v-model="selects" :value="report.winName"
                                    uncheck-icon=":iconfont icon-xing"
                                    checked-icon=":iconfont icon-xing lj-color-orange" @change="handleStar(report)">
                                </mu-checkbox>
                            </div>
                        </div>
                    </div>
                </template>
            </div>
        </lj-dialog>
    </div>
</template>

<script>
    import ljDialog from 'components/lj-dialog';
    export default {
        name: "tab-function",
        components: {
            ljDialog
        },
        props: {
            enabledFuncids: {
                type: Array
            },
            badgeFnList: {
                type: Array
            },
            badgeList: {
                type: Array
            }
        },
        data() {
            return {
                openReport: false,
                reportList: [],
                selects: [],
                reportName: "",
                contentStyle: {
                    //变量名不能改，继承会引用到
                    marginTop: "0px",
                    marginBottom: "0px",
                },
                rpstyle: {
                    height: ''
                },
                actionModule: {}, // 记录当前模块信息
                popDistance: { // 记录当前坐标
                    x: 0,
                    y: 0
                },
                checkAppTime: '', // 上次检测时间
                Loop: 0, // 计数器
                windowHeight: 0, // 屏幕高度
                windowWidth: 0, // 屏幕宽度
                moduleGroups: [{
                        groupname: "销售",
                        modules: [
                            {
                                funcid: 5229,
                                name: "销售订单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "saletask",
                            },
                            {
                                funcid: 5493,
                                name: "销售预测单",
                                icon: "icon-ribaotongji",
                                winName: "saletask-fore",
                            },
                            {
                                funcid: 5230,
                                name: "销售发货单",
                                icon: "icon-fahuo",
                                winName: "saletask-outware",
                                pageParam: {billtype: 1, thflag: 0, title: "销售发货单"}
                            },
                            {
                                funcid: 6859,
                                name: "出口销售出仓单",
                                icon: "icon-fahuo",
                                winName: "saletask-outware",
                                pageParam: {billtype: 2, thflag: 0, title: "出口销售出仓单"}
                            },
                            {
                                funcid: 460,
                                name: "产品浏览",
                                icon: "icon-shouhuo",
                                winName: "product-index"
                            },
                            {
                                funcid: 460,
                                name: "报价单",
                                icon: "icon-baojia",
                                winName: "quote-history"
                            },
                            {
                                funcid: 5902,
                                name: "销售价格表",
                                icon: "icon-baojia",
                                winName: "rp-saleprice"
                            },
                            {
                                funcid: 5903,
                                name: "产品价格对比",
                                icon: "icon-baojia",
                                winName: "rp-custprice"
                            },
                            {
                                funcid: 6565,
                                name: "销售报价单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "quote"
                            },
                            {
                                funcid: 6566,
                                name: "销售报价记录单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "quote-record"
                            },
                            {
                                funcid: 6860,
                                name: "出运单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "sale-out-cc",
                            },
                            {
                                funcid: 5459,
                                name: "报表",
                                icon: "icon-wenjianjiasuolvetu",
                                ifReport: true,
                                ReportList: [
                                    {
                                        funcid: 5460,
                                        name: "销售订单统计表",
                                        icon: "icon-xiaoshoudingdan",
                                        winName: "rp-saletask-new"
                                    },
                                    {
                                        funcid: 5461,
                                        name: "业务员销售排名统计表",
                                        icon: "icon-xiaozu-",
                                        winName: "rp-salerankinglist-outrep",
                                    },
                                    {
                                        funcid: 5462,
                                        name: "客户销售排名统计表",
                                        icon: "icon-chart-bar",
                                        winName: "rp-salerankinglist-cust",
                                    },
                                    {
                                        funcid: 5463,
                                        name: "产品型号销售排名统计表",
                                        icon: "icon-gongxuguanli2",
                                        winName: "rp-salerankinglist-model",
                                    },
                                    {
                                        funcid: 5751,
                                        name: "产品系列销售对比统计",
                                        icon: "icon-gongxuguanli2",
                                        winName: "rp-mtrlband",
                                    },
                                    {
                                        funcid: 5594,
                                        name: "销售订单粗产能分析",
                                        icon: "icon-yitihuachuxing",
                                        winName: "rp-saleability",
                                    },
                                    {
                                        funcid: 5804,
                                        name: "客诉统计表",
                                        icon: "icon-xiaoshoudingdan",
                                        winName: "rp-oppose-cust"
                                    },
                                    {
                                        funcid: 6243,
                                        name: "订单欠款统计表",
                                        icon: "icon-baojia",
                                        winName: "rp-saledebt"
                                    },
                                    {
                                        funcid: 6244,
                                        name: "订单毛利统计表",
                                        icon: "icon-baojia",
                                        winName: "rp-saleprofit"
                                    },
                                    {
                                        funcid: 6244,
                                        name: "订单利润列表",
                                        icon: "icon-baojia",
                                        winName: "rp-saledebt-mx"
                                    },
                                    {
                                        funcid: 6284,
                                        name: "预算利润统计分析",
                                        icon: "icon-baojia",
                                        winName: "rp-salerankinglist-profit"                 
                                    },
                                    {
                                        funcid: 6800,
                                        name: "经营看板",
                                        icon: "icon-baojia",
                                        winName: "rp-business-board"
                                    },
                                    {
                                        funcid: 7220,
                                        name: "客户&业务员销售排名统计表",
                                        icon: "icon-xiaoshoudingdan",
                                        winName: "rp-salerankinglist-cust-outrep"
                                    },
                                    {
                                        funcid: 6800,
                                        name: "经营看板(按分类统计)",
                                        icon: "icon-baojia",
                                        winName: "rp-business-board-mtrlkind"
                                    },
                                ]
                            }
                        ]
                    },
                    {
                        groupname: "仓库",
                        modules: [
                            {
                                funcid: 5231,
                                name: "库存表",
                                icon: "icon-soupcan",
                                winName: "mtrlware"
                            },
                            {
                                funcid: 5225,
                                name: "生产发料",
                                icon: "icon-wj-tzwj",
                                winName: "outware-scll-plan",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function(params) {
                                            if (!$lj.checkPower(5226)) {
                                                alert("没有[发料单建单]的权限");
                                                return;
                                            }
                                            $lj.openWin("outware-scll-plan-new");
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 5961,
                                name: "其他领料单",
                                icon: "icon-jiance1",
                                winName: "outware-scll-new",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function() {
                                            if (!$lj.checkPower(5962)) {
                                                alert("没有[其他领料单]新建的权限");
                                                return;
                                            }

                                            $lj.openWin('outware-scll-new-edit', {scll: {
                                                StorageID: 0,
                                                storagename: '',
                                                outtype: '',
                                                uselocation: '',
                                                part: '',
                                                relidname: '',
                                                empname: '',
                                                cusname: '',
                                                dscrp: ''
                                            }, winType: 0,hiscus: []})
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 7308,
                                name: "生产进仓单",
                                icon: "icon-jiance1",
                                winName:"inware-cp",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function() {
                                            if (!$lj.checkPower(7311)) {
                                                alert("没有[生产进仓单]新建的权限");
                                                return;
                                            }

                                            $lj.openWin('inware-cp-edit', {ware: {
                                                storageid:0,
                                                storagename: '',
                                                part: '',
                                                wrkGrpName: '',
                                                relid:0,
                                                sptname: '',
                                                dscrp: '',
                                                inrep: '',
                                            }, winType: 0})
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 7311,
                                name: "待进仓指令单",
                                icon: "icon-jiance1",
                                winName:"orderzl-noinware"
                            },
                            {
                                funcid: 7309,
                                name: "其他进仓单",
                                icon: "icon-jiance1",
                                winName:"inware-other",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function() {
                                            if (!$lj.checkPower(7314)) {
                                                alert("没有[其他进仓单]新建的权限");
                                                return;
                                            }

                                            $lj.openWin('inware-other-edit', {ware: {
                                                storageid:0,
                                                storagename: '',
                                                part: '',
                                                departmentname: '',
                                                sptname: '',
                                                dscrp: '',
                                                inrep: ''
                                            }, winType: 0})
                                        }
                                    },
                                ]
                            },
							{
                                funcid: 7310,
                                name: "其他出仓单",
                                icon: "icon-jiance1",
                                winName:"outware-other-production",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function() {
                                            if (!$lj.checkPower(7317)) {
                                                alert("没有[其他出仓单]新建的权限");
                                                return;
                                            }

                                            $lj.openWin('outware-other-edit', {ware: {
                                                storageid:0,
                                                storagename: '',
                                                part: '',
                                                departmentname: '',
                                                cusname: '',
                                                dscrp: '',
                                                outrep: ''
                                            }, winType: 0})
                                        }
                                    },
                                ]
                            },
							{
                                funcid: 6262,
                                name: "库存仓位调整",
                                icon: "icon-shenhe",
                                winName: "outware-pzcode-tran-bill-new",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function() {
                                            if (!$lj.checkPower(6263)) {
                                                alert("没有[库存仓位调整]新建的权限");
                                                return;
                                            }

                                            $lj.openWin('outware-pzcode-tran-bill-edit', {ware: {
                                                storageid: 0,
                                                storagename: '',
                                                outtype: '',
                                                uselocation: ''
                                            }, winType: 0})
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 6266,
                                name: "产品盘点单",
                                icon: "icon-shenhe",
                                winName: "ware-pd-bill-new",
                            },
                            {
                                funcid: 6368,
                                name: "生产领料单",
                                icon: "icon-shenhe",
                                winName: "outware-scll-bill",
                            },
                            {
                                funcid: 5231,
                                name: "库存表",
                                icon: "icon-soupcan",
                                winName: "mtrlware-test",
                                tag: {
                                    type: "danger",
                                    text: "测试"
                                }
                            },
                            {
                                funcid: 6837,
                                name: "物料监控",
                                icon: "icon-soupcan",
                                winName: "mtrl-will-rqqty",
                            },
                        ]
                    },
                    // {
                    //     groupname: "自制",
                    //     modules: [{
                    //             funcid: 5847,
                    //             name: "自制送检单",
                    //             icon: "icon-icon_xuqiu",
                    //             winName: "sptcheck-zz"
                    //         },
                    //         {
                    //             funcid: 5849,
                    //             name: "自制质检单",
                    //             icon: "icon-jiance1",
                    //             winName: "cpcheck-zz"
                    //         },
                    //     ],
                    // },
                    {
                        groupname: "生产",
                        modules: [{
                                funcid: 5472,
                                name: "车间指令单",
                                icon: "icon-zhiling1",
                                winName: "orderzllist"
                            },
                            {
                                funcid: 5224,
                                name: "发料通知",
                                icon: "icon-weiwaifaliao",
                                winName: "outware-scllplan"
                            },
                            {
                                funcid: 5968,
                                name: "已报工待质检完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-unfinish"
                            },
                            // {
                            //     funcid: 5968,
                            //     name: "已报工待质检完工(部件)",
                            //     icon: "icon-bill-status-finish",
                            //     winName: "sctask-unfinish-partbarcode"
                            // },
                            {
                                funcid: 5243,
                                name: "工序完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-finish"
                            },
                            {
                                funcid: 6784,
                                name: "批量工序完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-finish-same"
                            },
                            {
                                funcid: 5365,
                                name: "外协工序完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-finish-wfjg"
                            },
                            {
                                funcid: 5428,
                                name: "工序质检单",
                                icon: "icon-jiance1",
                                winName: "production-quality-list"
                            },
                            {
                                funcid: 5626,
                                name: "工段质检单",
                                icon: "icon-jiance1",
                                winName: "qualitycheck-workgroup-list"
                            },
                            {
                                funcid: 5626,
                                name: "品质异常反馈单",
                                icon: "icon-jiance1",
                                winName: "quality-feedback-list"
                            },
                            {
                                funcid: 5847,
                                name: "自制送检单",
                                icon: "icon-icon_xuqiu",
                                winName: "sptcheck-zz"
                            },
                            {
                                funcid: 5849,
                                name: "自制质检单",
                                icon: "icon-jiance1",
                                winName: "cpcheck-zz"
                            },
                            {
                                funcid: 6736,
                                name: "销售订单配置及相关计划配置变更单",
                                icon: "icon-jiance1",
                                winName: "saletaskmx-change"
                            },
                            {
                                funcid: 7035,
                                name: "车间工序待质检任务",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-notprechk"
                            },
                            {
                                funcid: 7109,
                                name: "工序完工单",
                                icon: "icon-bill-status-finish",
                                winName: "finish"
                            },
                            {
                                funcid: 7268,
                                name: "工序派工质检单",
                                icon: "icon-jiance1",
                                winName: "sctask-quality-list"
                            },
                            {
                                funcid: 7267,
                                name: "质检码完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-finish-qccode"
                            },
                            {
                                funcid: 7364,
                                name: "工序派工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-not-plan"
                            },
                            {
                                funcid: 7365,
                                name: "已派工待完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-plan"
                            },
                            {
                                funcid: 5469,
                                name: "报表",
                                icon: "icon-wenjianjiasuolvetu",
                                ifReport: true,
                                ReportList: [
                                    {
                                        funcid: 5470,
                                        name: "在进行订单异常统计表",
                                        icon: "icon-progress-running",
                                        winName: "rp-saletask-ea"
                                    },
                                    {
                                        funcid: 5471,
                                        name: "销售订单准交率",
                                        icon: "icon-write-text",
                                        winName: "rp-saletask-ontime"
                                    },
                                    {
                                        funcid: 5593,
                                        name: "车间产能分析",
                                        icon: "icon-yitihuachuxing",
                                        winName: "orderzl-analysis"
                                    },
                                    {
                                        funcid: 5700,
                                        name: "质检统计表",
                                        icon: "icon-jiance",
                                        winName: "rp-quality-check"
                                    },
                                    {
                                        funcid: 5803,
                                        name: "内部质量异常统计表",
                                        icon: "icon-jiance",
                                        winName: "rp-quality-wrong"
                                    },
                                    {
                                        funcid: 5952,
                                        name: "车间生产入库计划达成表",
                                        icon: "icon-jiance",
                                        winName: "rp-order-inware"
                                    },
                                    {
                                        funcid: 6547,
                                        name: "完工单明细统计表",
                                        icon: "icon-jiance",
                                        winName: "rp-finish-mxlist"
                                    },
                                    {
                                        funcid: 6744,
                                        name: "指令派工完工统计表",
                                        icon: "icon-progress-running",
                                        winName: "rp-orderml-sctask"
                                    },
                                    {
                                        funcid: 6840,
                                        name: "派工任务",
                                        icon: "icon-xiaoshoudingdan",
                                        winName: "sctask-work"
                                    },
                                    {
                                        funcid: 7290,
                                        name: "计划生产进度表",
                                        icon: "icon-xiaoshoudingdan",
                                        winName: "rp-production-schedule",
                                    },
                                    {
                                        funcid: 7289,
                                        name: "指令单工序进度统计表",
                                        icon: "icon-xiaoshoudingdan",
                                        winName: "rp-order-schedule",
                                    },
                                ]
                            },

                        ],
                    },
                    {
                        groupname: "采购",
                        modules: [
                            // {
                            //     funcid: 5219,
                            //     name: "送货预约",
                            //     icon: "icon-ic_event_available",
                            //     winName: "sptcheck"
                            // },
                            {
                                funcid: 5785,
                                name: "供应商现场质检单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "fxcheckbill"
                            },
                            {
                                funcid: 5492,
                                name: "采购订单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "buytask"
                            },
                            {
                                funcid: 7328,
                                name: "采购待送检",
                                icon: "icon-xiaoshoudingdan",
                                winName: "sptcheck-new-multi"
                            },
                            {
                                funcid: 5221,
                                name: "采购待检",
                                icon: "icon-jiance",
                                winName: "cpcheck-show",
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "扫描", icon: "scan", fnCallBack: function() {
                                            if (!$lj.checkPower(5220)) {
                                                alert("没有[采购送检单建单]的权限");
                                                return;
                                            }
                                            $lj.openScanner(function(ret) {
                                                var barcode = ret.content;
                                                if (barcode == "") {
                                                    alert("请先输入条码号!");
                                                    return;
                                                }
                                                $lj.postLJRequest(
                                                    "GetL1BuytaskmxbyCode", {
                                                        token: $lj.getStorage("token"),
                                                        taskcode: barcode,
                                                        savetype: 1
                                                    },
                                                    function(rsp) {
                                                        if (rsp.buytaskmxList.length > 0) {
                                                            $lj.openWin("sptcheck-new", {
                                                                    taskcodeType: rsp.taskcodeType,
                                                                    buytaskmxList: rsp.buytaskmxList,
                                                                    outwarecode: rsp.outwarecode
                                                                });
                                                        } else {
                                                            $lj.toast("未查询到条码【" + barcode + "】该单号的信息！");
                                                        }
                                                    }
                                                );
                                            });
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 7125,
                                name: "采购待收",
                                icon: "icon-icon_xuqiu",
                                winName: "inware-buy-sptcheck-nocheck",
                                tag: {
                                    type: "danger",
                                    text: "不质检"
                                },
                            },
                            {
                                funcid: 7203,
                                name: "采购确认收货",
                                icon: "icon-icon_xuqiu",
                                winName: "spt-outware",
                                tag: {
                                    type: "danger",
                                    text: "不质检"
                                },
                            },
                            {
                                funcid: 5221,
                                name: "来料质检记录",
                                icon: "icon-yan",
                                winName: "cpcheck-history"
                            },
                            {
                                funcid: 5285,
                                name: "特采初审",
                                icon: "icon-shenhe1",
                                winName: "cpcheck-buyer"
                            },
                            {
                                funcid: 5259,
                                name: "特采终审",
                                icon: "icon-shenhe",
                                winName: "cpcheck-special"
                            },
                            {
                                funcid: 5260,
                                name: "采购收货仓审",
                                icon: "icon-icon_xuqiu",
                                winName: "inware-buy-sptcheck"
                            },
                            {
                                funcid: 5669,
                                name: "采购待收货清单",
                                icon: "icon-renwu",
                                winName: "buytask-noinware"
                            },
                            {
                                funcid: 5669,
                                name: "采购收货单",
                                icon: "icon-shouhuo",
                                winName: "inware-buy"
                            },
                            {
                                funcid: 5669,
                                name: "采购允许退货清单",
                                icon: "icon-renwu",
                                winName: "buytask-allowth"
                            },
                            {
                                funcid: 5670,
                                name: "采购退货单",
                                icon: "icon-tuihuo",
                                winName: "buytask-th"
                            },
                            {
                                funcid: 325,
                                name: "供应商价格",
                                icon: "icon-baojia",
                                winName: "sptprice"
                            },
                            {
                                funcid: 5904,
                                name: "物料价格对比",
                                icon: "icon-baojia",
                                winName: "rp-sptprice"
                            },
                            {
                                funcid: 6567,
                                name: "材料申购单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "request-buy"
                            },
                            {
                                funcid: 6568,
                                name: "供应商费用单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "reissue-spt"
                            },
                            {
                                funcid: 7061,
                                name: "供应商询价单",
                                icon: "icon-xiaoshoudingdan",
                                winName: "spt-price-change"
                            },
                            {
                                funcid: 7057,
                                name: "采购收货明细待质检列表",
                                icon: "icon-xiaoshoudingdan",
                                winName: "inware-mx-nocheck"
                            },
                            {
                                funcid: 7081,
                                name: "采购收货质检单",
                                icon: "icon-jiance1",
                                winName: "inware-buy-cpcheck"
                            },
                            {
                                funcid: 5609,
                                name: "报表",
                                icon: "icon-wenjianjiasuolvetu",
                                ifReport: true,
                                ReportList: [
                                    {
                                        funcid: 5610,
                                        name: "采购收货统计表",
                                        icon: "icon-shouhuo",
                                        winName: "rp-inwarebuy"
                                    },
                                    {
                                        funcid: 5611,
                                        name: "供应商采购统计表",
                                        icon: "icon-gongyingshangguanli",
                                        winName: "rp-inwarebuy-spt"
                                    },
                                    {
                                        funcid: 5612,
                                        name: "物料采购统计表",
                                        icon: "icon-baogao",
                                        winName: "rp-inwarebuy-mtrl"
                                    },
                                    {
                                        funcid: 5802,
                                        name: "供应商异常统计表",
                                        icon: "icon-yitihuachuxing",
                                        winName: "rp-spt-error",
                                    },
                                    {
                                        funcid: 6996,
                                        name: "供应商质检批次统计表",
                                        icon: "icon-yitihuachuxing",
                                        winName: "rp-spt-check-batch",
                                    }
                                ]
                            }
                        ],
                    },
                    {
                        groupname: "外协",
                        modules: [
                            {
                                funcid: 5862,
                                name: "外协申请待订货清单",
                                icon: "icon-renwu",
                                winName: "request-wfjg-list"
                            },
                            {
                                funcid: 5862,
                                name: "外协订单",
                                icon: "icon-icon_xuqiu",
                                winName: "orderwfjg"
                            },
                            {
                                funcid: 5818,
                                name: "外协订单待发出清单",
                                icon: "icon-renwu",
                                winName: "outware-wfjg-list"
                            },
							{
                                funcid: 6245,
                                name: "外协工序派工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-wfjg-bill"
                            },
                            {
                                funcid: 5818,
                                name: "外协发出单",
                                icon: "icon-fahuo",
                                winName: "outware-wfjg"
                            },
                            {
                                funcid: 5819,
                                name: "外协订单待退回清单",
                                icon: "icon-renwu",
                                winName: "outware-wfjg-th-list"
                            },
                            {
                                funcid: 5819,
                                name: "外协退回单",
                                icon: "icon-tuihuo1",
                                winName: "outware-wfjg-th"
                            },
                            {
                                funcid: 5817,
                                name: "外协订单待收货清单",
                                icon: "icon-renwu",
                                winName: "orderwfjg-noinware-list"
                            },
                            {
                                funcid: 5817,
                                name: "外协收货单",
                                icon: "icon-shouhuo",
                                winName: "orderwfjg-inware"
                            },
                            {
                                funcid: 5820,
                                name: "外协订单允许返工清单",
                                icon: "icon-renwu",
                                winName: "inware-wfjg-redo-list"
                            },
                            {
                                funcid: 5820,
                                name: "外协返工单",
                                icon: "icon-fanli",
                                winName: "inware-wfjg-th"
                            },
                            {
                                funcid: 715,
                                name: "外协商库存表",
                                icon: "icon-soupcan",
                                winName: "mtrlware-spt"
                            },

                        ]
                    },
                    {
                        groupname: "委外",
                        modules: [
                            {
                                funcid: 6768,
                                name: "委外申请待订货清单",
                                icon: "icon-renwu",
                                winName: "outsourcing-orderzl-new-list"
                            },
                            {
                                funcid: 6746,
                                name: "委外指令单",
                                icon: "icon-icon_xuqiu",
                                winName: "outsourcing-orderzl-list"
                            },
                            {
                                funcid: 6769,
                                name: "委外订单待发出清单",
                                icon: "icon-renwu",
                                winName: "outsourcing-out-new-list"
                            },
                            {
                                funcid: 6747,
                                name: "委外发出单",
                                icon: "icon-fahuo",
                                winName: "outsourcing-out-list"
                            },
                            {
                                funcid: 6770,
                                name: "委外订单待退回清单",
                                icon: "icon-renwu",
                                winName: "outsourcing-out-th-new-list"
                            },
                            {
                                funcid: 6748,
                                name: "委外退回单",
                                icon: "icon-tuihuo1",
                                winName: "outsourcing-out-th-list"
                            },
                            {
                                funcid: 6771,
                                name: "委外订单待收货清单",
                                icon: "icon-renwu",
                                winName: "outsourcing-in-new-list"
                            },
                            {
                                funcid: 6749,
                                name: "委外收货单",
                                icon: "icon-shouhuo",
                                winName: "outsourcing-in-list"
                            },
                            {
                                funcid: 6772,
                                name: "委外订单允许返工清单",
                                icon: "icon-renwu",
                                winName: "outsourcing-in-th-new-list"
                            },
                            {
                                funcid: 6750,
                                name: "委外返工单",
                                icon: "icon-fanli",
                                winName: "outsourcing-in-th-list"
                            },
                            {
                                funcid: 6751,
                                name: "委外商库存",
                                icon: "icon-soupcan",
                                winName: "mtrlware-outsourcing"
                            },
                            {
                                funcid: 6841,
                                name: "委外质检单",
                                icon: "icon-jiance1",
                                winName: "cpcheck-ww"
                            },
                            {
                                funcid: 7052,
                                name: "委外收货明细待质检列表",
                                icon: "icon-jiance1",
                                winName: "inware-mx-wx-nocheck"
                            },
                            {
                                funcid: 7080,
                                name: "委外收货质检单",
                                icon: "icon-jiance1",
                                winName: "inware-wx-cpcheck"
                            },
                        ]
                    },
                    {
                        groupname: "仓库—PDA",
                        modules: []
                    },
                    {
                        groupname: "定制功能",
                        modules: [{
                                funcid: 5420,
                                name: "销售订单",
                                icon: "icon-cart",
                                winName: "saletask-qdz",
                                tag: {
                                    type: "danger",
                                    text: "定制"
                                }
                            },
                            {
                                funcid: 5421,
                                name: "工序完工",
                                icon: "icon-bill-status-finish",
                                winName: "sctask-finish-qdz",
                                tag: {
                                    type: "danger",
                                    text: "定制"
                                }
                            },
                            {
                                funcid: 4786, 
                                name: "产品盘点",
                                icon: "icon-xiaoshoudingdan",
                                winName: "ware-pd-zk",
                                tag: {
                                    type: "danger",
                                    text: "定制"
                                }
                            },
                            {
                                funcid: 4776, 
                                name: "仓库盘点",
                                icon: "icon-xiaoshoudingdan",
                                winName: "ware-check-zk",
                                tag: {
                                    type: "danger",
                                    text: "定制"
                                }
                            },
                            {
                                funcid: 4771, 
                                name: "采购收货",
                                icon: "icon-xiaoshoudingdan",
                                winName: "inwarebuy-bill-zk",
                                tag: {
                                    type: "danger",
                                    text: "定制"
                                }
                            },
                            {
                                funcid: 5225,
                                name: "生产发料",
                                icon: "icon-wj-tzwj",
                                winName: "outware-scll-plan",
                                tag: {
                                    type: "danger",
                                    text: "定制"
                                },
                                pageParam: {openType:"zk"},
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "新增", icon: "add-o", fnCallBack: function(params) {
                                            if (!$lj.checkPower(5226)) {
                                                alert("没有[发料单建单]的权限");
                                                return;
                                            }
                                            $lj.openWin("outware-scll-plan-new-zk");
                                        }
                                    },
                                ]
                            },
                        ]
                    },
                    {
                        groupname: "设备",
                        modules: [{
                                funcid: 5616,
                                name: "设备档案",
                                icon: "icon-cart",
                                winName: "equipment-list"
                            },
                            {
                                funcid: 5616,
                                name: "设备监视",
                                icon: "icon-grid",
                                winName: "equipment-watch"
                            },
                            {
                                funcid: 5616,
                                name: "故障设备",
                                icon: "icon-format-list-bulleted",
                                winName: "equipment-wrong"
                            },
                            {
                                funcid: 5616,
                                name: "设备列表",
                                icon: "icon-format-list-bulleted",
                                winName: "equipment-grid-list"
                            },
                            {
                                funcid: 5616,
                                name: "模具档案",
                                icon: "icon-cart",
                                winName: "mould-list"
                            },
                            {
                                funcid: 5459,//5940
                                name: "报表",
                                icon: "icon-wenjianjiasuolvetu",
                                ifReport: true,
                                ReportList: [{
                                        funcid: 5941,//
                                        name: "设备预防维护计划完成率",
                                        icon: "icon-jiance",
                                        winName: "rp-equip-workplan"
                                    },
                                    {
                                        funcid: 5942,//
                                        name: "重要设备故障累计时间",
                                        icon: "icon-jiance",
                                        winName: "rp-equip-repairt"
                                    },
                                    {
                                        funcid: 5943,//
                                        name: "重要设备故障累计时间-车间占比",
                                        icon: "icon-jiance",
                                        winName: "rp-equip-repairtwrk"
                                    },

                                ]
                            }
                        ]
                    },
                    {
                        groupname: "财务",
                        modules: [
                            {
                                funcid: 5300,
                                name: "其他收入支出单",
                                icon: "icon-shouzhiguanli",
                                winName: "income-expenses"
                            },
                            {
                                funcid: 5743,
                                option: 639,
                                modules: [
                                    {
                                        value: [0],
                                        name: "应收账",
                                        icon: "icon-web-icon-",
                                        winName: "musttake"
                                    },
                                    {
                                        value: [1],
                                        name: "应收账",
                                        icon: "icon-web-icon-",
                                        winName: "musttake-new",
                                        tag: {
                                            type: "danger",
                                            text: "新财务"
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 5744,
                                option: 639,
                                modules: [
                                    {
                                        value: [0],
                                        name: "应付账",
                                        icon: "icon-fukuandan",
                                        winName: "mustpay"
                                    },
                                    {
                                        value: [1],
                                        name: "应付账",
                                        icon: "icon-fukuandan",
                                        winName: "mustpay-new",
                                        tag: {
                                            type: "danger",
                                            text: "新财务"
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 6735,
                                option: 639,
                                modules: [
                                    {
                                        value: [1],
                                        name: "供应商收支单",
                                        icon: "icon-shouzhiguanli",
                                        winName: "bill-money",
                                        tag: {
                                            type: "danger",
                                            text: "新财务"
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 7033,
                                option: 639,
                                modules: [
                                    {
                                        value: [0],
                                        name: "客户收款单",
                                        icon: "icon-shouzhiguanli",
                                        winName: "cusamt"
                                    },
                                    {
                                        value: [1],
                                        name: "客户收支单",
                                        icon: "icon-shouzhiguanli",
                                        winName: "cust-inout",
                                        tag: {
                                            type: "danger",
                                            text: "新财务"
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 5464,
                                name: "报表",
                                icon: "icon-wenjianjiasuolvetu",
                                ifReport: true,
                                ReportList: [
                                    {
                                        funcid: 5465,
                                        name: "客户收款统计表",
                                        icon: "icon-baojia",
                                        winName: "rp-saletask-rec"
                                    },
                                    {
                                        funcid: 5466,
                                        name: "仓库周转率统计表",
                                        icon: "icon-jiaohuan",
                                        winName: "rp-warebalc"
                                    },
                                    {
                                        funcid: 5467,
                                        name: "产值统计表",
                                        icon: "icon-baobiao",
                                        winName: "rp-amt"
                                    },
                                    {
                                        funcid: 5468,
                                        name: "销售订单利润统计表",
                                        icon: "icon-20",
                                        winName: "rp-saletaskrealamt"
                                    },
                                    {
                                        funcid: 5775,
                                        name: "部门预算报销统计表",
                                        icon: "icon-20",
                                        winName: "rp-claim"
                                    },
                                    {
                                        funcid: 6488,
                                        name: "应付帐龄统计表",
                                        icon: "icon-20",
                                        winName: "rp-out"
                                    },
                                    {
                                        funcid: 6569,
                                        name: "应收帐龄统计表",
                                        icon: "icon-20",
                                        winName: "rp-in"
                                    },
                                    {
                                        funcid: 6842,
                                        name: "客户应收结余表",
                                        icon: "icon-baojia",
                                        winName: "cusbalc"
                                    },
                                    {
                                        funcid: 7017,
                                        name: "供应商应付结余表",
                                        icon: "icon-baojia",
                                        winName: "sptbalc"
                                    },
                                ]
                            }
                        ]
                    },
                    {
                        groupname: "行政",
                        modules: [
                            {
                                funcid: 6415,
                                name: "事件单",
                                icon: "icon-yuangongchengfachufachengfa",
                                winName: "event-list",
                                tag: {
                                    type: "danger",
                                    text: 0
                                },
                                actions: [
                                    { text: "查询", icon: "search" },
                                    { text: "报表", icon: "newspaper-o", fnCallBack: function() {
                                            if (!$lj.checkPower(6465)) {
                                                alert("没有[事件单报表]的权限");
                                                return;
                                            }
                                            $lj.openWin("rp-event");
                                        }
                                    },
                                ]
                            },
                            {
                                funcid: 6464,
                                name: "报表",
                                icon: "icon-wenjianjiasuolvetu",
                                ifReport: true,
                                ReportList: [{
                                        funcid: 6465,
                                        name: "事件单统计报表",
                                        icon: "icon-yuangongchengfachufachengfa",
                                        winName: "rp-event"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        groupname: "人事",
                        modules: [
                            // {
                            //     funcid: 6255,
                            //     name: "客户资料",
                            //     icon: "icon-yuangongchengfachufachengfa",
                            //     winName: "cust"
                            // }, 
                            {
                                funcid: 6861,
                                name: "客户档案",
                                icon: "icon-yuangongchengfachufachengfa",
                                winName: "customer-files"
                            },
                            {
                                funcid: 6862,
                                name: "商机管理",
                                icon: "icon-yuangongchengfachufachengfa",
                                winName: "business-chance"
                            }, 
                            {
                                funcid: 6255,
                                name: "人员列表",
                                icon: "icon-yuangongchengfachufachengfa",
                                winName: "empinfo-list"
                            },
                            {
                                funcid: 5489,
                                name: "考核单",
                                icon: "icon-yuangongchengfachufachengfa",
                                winName: "award-punish"
                            },
                            {
                                funcid: 5770,
                                name: "费用报销申请单",
                                icon: "icon-yusuanguanli",
                                winName: "claim"
                            },
                            {
                                funcid: 6741,
                                name: "个人其他计件单",
                                icon: "icon-yusuanguanli",
                                winName: "sctask-abnormity"
                            },
                            {
                                funcid: 6801,
                                name: "考勤日报表",
                                icon: "icon-yusuanguanli",
                                winName: "rp-dayattendance"
                            },
                            {
                                funcid: 6802,
                                name: "考勤月报表",
                                icon: "icon-yusuanguanli",
                                winName: "rp-monthattendance"
                            },
                        ]
                    },
                    {
                        groupname: "技术",
                        modules: [{
                                funcid: 5427,
                                name: "物料查询",
                                icon: "icon-soupcan",
                                winName: "mtrldef"
                            },
                            {
                                funcid: 5752,
                                name: "物料积压查询",
                                icon: "icon-soupcan",
                                winName: "mtrldef-jy"
                            },
                            {
                                funcid: 5427,//6792
                                name: "工序工艺路线",
                                icon: "icon-soupcan",
                                winName: "procode-route"
                            },
                            {
                                funcid: -1,
                                name: "蓝牙打印模板设置",
                                icon: "icon-soupcan",
                                winName: "print-template"
                            }
                        ]
                    },
                ],
                pdaModuleGroups: [
                    {
                        funcid: 4769,
                        option: [207, 306],
                        modules: [
                            {
                                value: [[0],[0,1]],
                                name: "生产进仓",
                                icon: "icon-ruku",
                                winName: "inware-frm",
                                pageParam: {intype: 3, draftName: "inwareScan", ifBigBar: true}
                            },
                            {
                                value: [[1,2], [-1]],
                                name: "生产进仓",
                                icon: "icon-ruku",
                                winName: "inware-bill",
								pageParam: {ifBigBar: true}
                            },
							{
                                value: [[0],[3]],
                                name: "生产进仓",
                                icon: "icon-ruku",
                                winName: "inwarecp-twoscan"
                            }
                        ]
                    },
                    {
                        funcid: 4770, 
                        name: "销售出仓",
                        icon: "icon-xiaoshoudingdan",
                        winName: "outware-salebill",
                        pageParam: {ifBigBar: true}
                    },
                    {
                        funcid: 4785, 
                        name: "销售退货",
                        icon: "icon-tuihuo1",
                        winName: "outware-salebill-th"
                    },
                    {
                        funcid: 6378, 
                        name: "出口销售出仓",
                        icon: "icon-xiaoshoudingdan",
                        winName: "outware-salebill-cc",
                        pageParam: {ifBigBar: true}
                    },
                    {
                        funcid: 4771,
                        option: 208,
                        modules: [
                            {
                                value: [0],
                                name: "采购收货",
                                icon: "icon-cart",
                                winName: "inwarebuy-scan",
                                pageParam: {intype: 0, draftName: "inwareBuyScanIN"}
                            },
                            {
                                value: [1],
                                name: "采购收货",
                                icon: "icon-cart",
                                winName: "inwarebuy-bill",
								pageParam: {thflag: 0}
                            },
                        ]
                    },
                    {
                        funcid: 4777, 
                        option: 208,
                        modules: [
                            {
                                value: [0],
                                name: "采购退货",
                                icon: "icon-tuihuo1",
                                winName: "inwarebuy-scan",
                                pageParam: {intype: 1, draftName: "inwareBuyScanOUT"}
                            },
                            {
                                value: [1],
                                name: "采购退货",
                                icon: "icon-tuihuo1",
                                winName: "inwarebuy-bill",
                                pageParam: {thflag: 1}
                            },
                        ]
                    },
                    {
                        funcid: 4774,
                        option: 204,
                        modules: [
                            {
                                value: [0],
                                name: "仓库调拨",
                                icon: "icon-kucun",
                                winName: "outware-other",
                                pageParam: {intype: 50, draftName: "outWareStorage"}
                            }
                        ]
                    },
                    {
                        funcid: 4774,
                        option: 204,
                        modules: [
                            {
                                value: [1],
                                name: "调拨进仓",
                                icon: "icon-kucun",
                                winName: "inware-move"
                            },
                        ]
                    },
                    {
                        funcid: 4774,
                        option: 204,
                        modules: [
                            {
                                value: [1],
                                name: "调拨出仓",
                                icon: "icon-kucun",
                                winName: "outware-move"
                            },
                        ]
                    },
                    {
                        funcid: 4772,
                        option: 205,
                        modules: [
                            {
                                value: [0],
                                name: "其他出仓",
                                icon: "icon-lingliaochuku",
                                winName: "outware-other",
                                pageParam: {intype: 8, draftName: "outWareOther"}
                            },
                            {
                                value: [1],
                                name: "其他出仓",
                                icon: "icon-lingliaochuku",
                                winName: "outware-otherbill"
                            },
                        ]
                    },
                    {
                        funcid: 4775,
                        option: 206,
                        modules: [
                            {
                                value: [0],
                                name: "其他进仓",
                                icon: "icon-ruku",
                                winName: "inware-frm",
                                pageParam: {intype: 8, draftName: "inWareOtherScan", ifBigBar: true}
                            },
                            {
                                value: [1],
                                name: "其他进仓",
                                icon: "icon-ruku",
                                winName: "inware-otherbill",
                            },
                        ]
                    },
                    {
                        funcid: 4776, 
                        name: "仓库盘点",
                        icon: "icon-shenhe",
                        winName: "ware-check",
                    },
					{
                        funcid: 4800,
                        name: "仓位调拨",
                        icon: "icon-shenhe",
                        winName: "outware-pzcode-tran",
                    },
					{
                        funcid: 4786,
                        name: "产品盘点单",
                        icon: "icon-shenhe",
                        winName: "ware-pd",
                    },
					{
                        funcid: 4801,
                        name: "仓位盘点",
                        icon: "icon-shenhe",
                        winName: "ware-check-location",
                    },
                    {
                        funcid: 4780,
                        name: "客户调货",
                        icon: "icon-shenhe",
                        winName: "mtrlware-trans",
                    },
                    {
                        funcid: 4789,
                        name: "派工单完工扫描",
                        icon: "icon-shenhe",
                        winName: "task-from",
                    },
                    {
                        funcid: 7115,
                        name: "派工单完工扫描(部件)",
                        icon: "icon-shenhe",
                        winName: "task-from-partbarcode",
                    },
                    {
                        funcid: 4779,
                        name: "最后工段完工扫描",
                        icon: "icon-shenhe",
                        winName: "lastorder-barcode",
                    },
                    {
                        funcid: 4778,
                        name: "工段交接",
                        icon: "icon-shenhe",
                        winName: "wkporder-barcode",
                    },
                    {
                        funcid: 4929,
                        name: "板件分包",
                        icon: "icon-shenhe",
                        winName: "barcode-packet",
                    },
                    {
                        funcid: 4788,
                        name: "工序派工确认",
                        icon: "icon-shenhe",
                        winName: "taskbeg-from",
                    },
					{
                        funcid: 4790,
                        name: "下载发货单已扫条码",
                        icon: "icon-shenhe",
                        winName: "outware-salenoscan",
                    },
                    {
                        funcid: 4802,
                        option: 637,
                        modules: [
                            {
                                value: [0],
                                name: "生产领料单",
                                icon: "icon-shenhe",
                                winName: "outware-scllbill",
                                pageParam: {ifBigBar: true}
                            },
                            {
                                value: [1],
                                name: "生产领料单",
                                icon: "icon-shenhe",
                                winName: "outware-scllfrm",
                                pageParam: {ifBigBar: true}
                            },
                        ]
                    },
                    {
                        funcid: 6514,
                        name: "超额发料单",
                        icon: "icon-shenhe",
                        winName: "outware-scllbill-bu",
                        pageParam: {ifBigBar: true}
                    },
                    {
                        funcid: 6563,
                        name: "生产补料单",
                        icon: "icon-shenhe",
                        winName: "outware-scllbill-backbu",
                        pageParam: {ifBigBar: true}
                    },
                    {
                        funcid: 4803,
                        option: 662,
                        modules: [
                            {
                                value: [0],
                                name: "生产退料单",
                                icon: "icon-shenhe",
                                winName: "outware-scllback",
                            },
                            {
                                value: [1],
                                name: "生产退料单",
                                icon: "icon-shenhe",
                                winName: "outware-scllbackfrm",
                            },
                        ]
                    },
                    {
                        funcid: 4792,
                        name: "GPR出仓",
                        icon: "icon-shenhe",
                        winName: "outware-gpr",
                    },
                    {
                        funcid: 4830,
                        name: "条码调整单",
                        icon: "icon-shenhe",
                        winName: "barcode-change",
                    },
					{
                        funcid: 5252,
                        name: "条码打包",
                        icon: "icon-shenhe",
                        winName: "bigbar-frm",
                    },
					{
                        funcid: [6228,6229,6239],
                        name: "外协集合单",
                        icon: "icon-shenhe",
                        winName: "outware-wfjgbill",
                    },
                    {
                        funcid: [7181,7182],
                        name: "委外集合单",
                        icon: "icon-shenhe",
                        winName: "outsourcing-bill",
                    },
					{
                        funcid: 4783, 
                        name: "条码查询",
                        icon: "icon-xiaoshoudingdan",
                        winName: "barcode-info"
                    },
					{
                        funcid: 5961,
                        name: "其他领料单",
                        icon: "icon-shenhe",
                        winName: "outware-scll-new-bill",
                    },
                    {
                        funcid: 5225,
                        name: "发料单",
                        icon: "icon-shenhe",
                        winName: "outware-scll-plan-bill",
                    },
                    {
                        funcid: 4830,
                        name: "条码变更单",
                        icon: "icon-shenhe",
                        winName: "barcode-modify",
                    },
                ]
            }
        },
        created() {
            this.initStyle();
            this.refreshCollect();

            this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
            this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeigh;
        },
        activated() {
            let reportAction = $lj.getStorage('reportAction')|| {};
            if (reportAction.ifaction) {
                this.refreshCollect();
                $lj.setStorage('reportAction', {
                    ifaction: false
                });
            }
            // this.fnGetDailyBusinessBadge(); // 更新微标数值
            $lj.sendEvent('refresh_dailyBadge');
        },
        methods: {
            // _fnCheckUpdateTime() {
            //     // 刷新记录检测时间
            //     let checkUpdateApp = $lj.getStorage('checkUpdateApp') || {};
            //     if (JSON.stringify(checkUpdateApp) != '{}') {
            //         let nowTime = new Date().getTime();
            //         console.log('nowTime :>> ', $lj.dateformat(new Date(nowTime)));
            //         console.log('checkUpdateApp.time :>> ', $lj.dateformat(new Date(checkUpdateApp.time)));
            //         console.log('nowTime > checkUpdateApp.time :>> ', nowTime > checkUpdateApp.time);
            //         if(nowTime > checkUpdateApp.time){
            //             console.log("功能页被动检测app，超时弹起");
            //             $lj.sendEvent('check_app', {msg: ""});
            //         }
            //     }
            // },
             /**创造PDA数据 */
            _fnGetPdaModule(list) {
                let arr = [];
                for (let i = 0; i < list.length; i++) {
                    let pdaModel = {};
                    if (!!list[i].modules) {
                        let hasOption = false;
                        let target;
                        if (Object.prototype.toString.call(list[i].option) == "[object Array]") {
                            let optionA = Number($lj.getOptionValue(list[i].option[0]));
                            let optionB = Number($lj.getOptionValue(list[i].option[1]));
                            for (let group of list[i].modules) {
                                if (
                                    group.value[0].indexOf(optionA) > -1 &&
                                    (group.value[1].indexOf(optionB) > -1 || group.value[1].indexOf(-1) > -1)
                                ) {
                                    target = group;
                                    hasOption = true;
                                    break;
                                }
                            }
                        } else {
                            let option = Number($lj.getOptionValue(list[i].option));
                            for (let group of list[i].modules) {
                                if (group.value.indexOf(option) > -1) {
                                    target = group;
                                    hasOption = true;
                                    break;
                                }
                            }
                        }
                        if (hasOption) {
                            pdaModel.name = target.name;
                            pdaModel.icon = target.icon;
                            pdaModel.winName = target.winName;
                            if (target.tag) {
                                pdaModel.tag = target.tag;
                            }
                            if (target.pageParam) {
                                pdaModel.pageParam = target.pageParam;
                            }
                            pdaModel.funcid = list[i].funcid;
                            if (list[i].pageParam) {
                                pdaModel.pageParam = list[i].pageParam;
                            }
                        }
                    } else {
                        pdaModel = list[i]
                    }
                    if (JSON.stringify(pdaModel) != "{}") {
                        arr.push(pdaModel);
                    }
                }
                return arr;
            },
            /**读取系统设置 */
            setPDAOptionValue() {
                for (let i = 0; i < this.moduleGroups.length; i++) {
                    if (this.moduleGroups[i].groupname == "仓库—PDA") {
                        this.moduleGroups[i].modules = this._fnGetPdaModule(this.pdaModuleGroups);
                    } else {
                        this.moduleGroups[i].modules = this._fnGetPdaModule(this.moduleGroups[i].modules);
                    }
                }
            },
            handleModuleClick(module, groupname) {
                if (module.winName || module.ifReport) {
                    if (module.ifReport === true) {
                        this.reportName = groupname + "报表";
                        let reportListTemp = [];
                        for (let i = 0; i < module.ReportList.length; i++) {
                            if (this.enabledFuncids.indexOf(module.ReportList[i].funcid) > -1) {
                                reportListTemp.push(module.ReportList[i]);
                            }
                        }
                        if (reportListTemp.length <= 0) {
                            $lj.toast("暂无 [" + this.reportName + "] 相关表权限", 2000);
                            return;
                        }
                        // this.openReport = true;
                        setTimeout(() => {
                            this.$refs.rpDialog.open();
                            this.reportList = reportListTemp;
                        }, 200);
                    } else {
                        $lj.openWin(module.winName, module.pageParam);
                    }
                } else {
                    alert("未定义窗口");
                }
            },
            // 点击外部关闭长按菜单
            handleTouchOutside() {
                if (this.actionModule.showPopover) {
                    this.actionModule.showPopover = false;
                }
            },
            // 获取功能微标
            fnGetDailyBusinessBadge() {
                if (!this.badgeFnList.length) {
                    return false;
                }
                for (let i = 0; i < this.badgeFnList.length; i++) {
                    for (let j = 0; j < this.enabledModuleGroups.length; j++) {
                        let ifmatch = false;
                        for (let k = 0; k < this.enabledModuleGroups[j].modules.length; k++) {
                            if (this.badgeFnList[i] == this.enabledModuleGroups[j].modules[k].funcid) {
                                let tagText = this.badgeList[i] > 99 ? "99+" : this.badgeList[i];
                                let tag = {
                                    type: "danger",
                                    text: tagText
                                }
                                this.enabledModuleGroups[j].modules[k].tag = tag;
                                ifmatch = true;
                                break;
                            }
                        }
                        if (ifmatch) break;
                    }
                }
            },
            // 触碰开始
            handleTouchStartModules(ev, module) {
                let self = this;
                //执行长按的内容
                if (this.actionModule.showPopover) {
                    this.actionModule.showPopover = false;
                }
                let nowTime = new Date().getTime();
                if (!this.checkAppTime || nowTime - this.checkAppTime > 3600000) {
                    // 超过一个小时才发起第二次检测
                    // this._fnCheckUpdateTime();
                    $lj.sendEvent('check_app', {msg: ""});
                    this.checkAppTime = nowTime;
                }
                module.longPress = true;
                self.Loop = setTimeout(function () {
                    if (self.Loop === 1) {
                        return false;
                    }
                    self.Loop = 0;
                    if (module.ifReport) {
                        return false;
                    }

                    if (module.actions) {
                        module.showPopover = true;
                        self.actionModule = module;
                        self.$nextTick(function () {
                            document.body.style.overflow = 'hidden'; // 锁定滚动
                            self.popDistance.x = ev.changedTouches[0].pageX;
                            self.popDistance.y = ev.changedTouches[0].pageY - document.body.scrollTop;
                            module.longPress = false;

                            api.notification({
                                vibrate:[50,50],
                            });
                        });
                    }
                }, 400);
                return false;
            },
            // 触碰移动
            handleTouchMoveModules(ev, module) {
                if (!module.showPopover) {
                    // 滑动中
                    clearTimeout(this.Loop);
                    this.Loop = 1;
                }
            },
            // 触碰结束
            handleTouchEndModules(ev, module, groupname) {
                clearTimeout(this.Loop);
                //这里click内容
                if ( this.Loop !== 1 && (module.ifReport || this.Loop !== 0 )) {
                    // 模拟点击效果
                    this.handleModuleClick(module, groupname);
                } else if (module.showPopover) {
                    // 当触碰移动到长按菜单上结束，触发点击
                    let x = ev.changedTouches[0].pageX;
                    let y = ev.changedTouches[0].pageY - document.body.scrollTop;
                    if (document.elementFromPoint(x,y)) {
                        let tmpName = document.elementFromPoint(x,y).className;
                        let tmpReg = new RegExp('van-popover', 'g');
                        if(tmpReg.test(tmpName)){
                            document.elementFromPoint(x,y).click();
                        }
                    }
                }
                return false;
            },
            autoPopoverClosed() {
                document.body.style.overflow = ''; // 解锁滚动条
            },
            // 长按菜单按钮类型
            handlePopoverSelected(action, index) {
                switch (action.icon) {
                    case "search":
                        // 查询
                        $lj.openWin(this.actionModule.winName, this.actionModule.pageParam);
                        break;
                    default: // 其他
                        action.fnCallBack();
                        break;
                }
            },
            initStyle() {
                // 兼容刘海屏
                let winHeight = 80;
                if (window.api) {
                    winHeight = api.winHeight;
                }
                let footerHeight = 61;
                if (api.systemType === "ios") {
                    footerHeight += api.safeArea.bottom
                }
                this.contentStyle.minHeight = (winHeight - footerHeight) + "px";
                this.contentStyle.marginTop = 15 + "px";
                this.contentStyle.marginBottom = 5 + "px";
            },
            getIconClass(module, index) {
                let result = ['iconfont', module.icon];
                return result;
            },
            getIconColor(module, index) {
                let result = "";
                if (module.ifReport === true) {
                    result = '';
                    return result;
                }
                switch (index % 4) {
                    case 0:
                        result = '#ff9800';
                        break;
                    case 1:
                        result = '#47cc47';
                        break;
                    case 2:
                        result = '#00aaee';
                        break;
                    case 3:
                        result = '#ff6f61';
                        break;
                }
                return result;
            },
            getIconClassReport(report) {
                let result = ['iconfont', report.icon];
                return result;
            },
            refreshCollect() {
                let self = this;
                let dataList = [];
                this.selects = [];
                let token = $lj.getStorage("token");
                let empid = $lj.getStorage('user').empid;
                console.log("-----------before post request-------------")
                $lj.postLJRequest("GetL1APPComReport", {
                    token: token,
                    empid: empid
                }, function (ret) {
                    if (ret) {
                        dataList = ret.comreportList;
                        for (let i = 0; i < dataList.length; i++) {
                            self.selects.push(dataList[i].value);
                        }
                    }
                })
            },
            handleStar(report) {
                let self = this;
                let token = $lj.getStorage("token");
                let empid = $lj.getStorage('user').empid;
                if (report.winName) {
                    if (self.selects.indexOf(report.winName) > -1) { //收藏报表
                        let requestBody = {
                            token: token,
                            empid: empid,
                            dwname: 'L1AppUserReport',
                            itemname: report.name,
                            itemvalue: report.winName,
                        };
                        $lj.postLJRequest(
                            "SetSysUserFileString", requestBody,
                            function (ret) {
                                if (!ret.ErrMsg) {
                                    $lj.setStorage('reportAction', {
                                        ifaction: true
                                    });
                                    $lj.toast("收藏成功", 2000);
                                }
                            }
                        );
                    } else { //取消收藏
                        let requestBody = {
                            token: token,
                            empid: empid,
                            itemname: report.name,
                        };
                        $lj.postLJRequest(
                            "DelL1APPComReport", requestBody,
                            function (ret) {
                                if (!ret.ErrMsg) {
                                    $lj.setStorage('reportAction', {
                                        ifaction: true
                                    });
                                    $lj.toast("取消收藏成功", 2000);
                                }
                            }
                        );
                    }
                } else {
                    alert("未定义窗口");
                }

            },
            handleReportClick(report) {
                if (report.winName) {
                    $lj.openWin(report.winName);
                } else {
                    alert("未定义窗口");
                }
            }
        },
        computed: {
            enabledModuleGroups() {
                let userInfo = $lj.getStorage("userInfo");
                if (!this.enabledFuncids || this.enabledFuncids.length === 0) {
                    return [];
                }
                let funcIdsStr = ",";
                for (let funcid of this.enabledFuncids) {
                    funcIdsStr += funcid + ",";
                }
                this.setPDAOptionValue();
                let result = [];
                for (let group of this.moduleGroups) {
                    let enabledGroup = {
                        groupname: group.groupname,
                        modules: []
                    };
                    for (let module of group.modules) {
                        this.$set(module,"showPopover", false);
                        this.$set(module,"longPress", false);
                        if(Object.prototype.toString.call(module.funcid) === "[object Array]"){
                            let backup = [];
                            for(let f of module.funcid){
                                if (funcIdsStr.indexOf("," + f + ",") >= 0) {
                                    backup.push(f);
                                }
                            }
                            this.$set(module,"pageParam",{funcid:backup})
                            if(backup.length > 0) enabledGroup.modules.push(module);
                        }else{
                            if (funcIdsStr.indexOf("," + module.funcid + ",") >= 0 || (module.funcid == -1 && userInfo.empid == 0)) {
                                enabledGroup.modules.push(module);
                            }
                        }
                    }
                    if (enabledGroup.modules.length > 0) {
                        result.push(enabledGroup);
                    }
                }
                return result;
            },
            // 判断弹窗弹出位置
            isPopoverPlacement() {
                let position = "";
                if (this.popDistance.y > 200) {
                    position = "top";
                } else {
                    position = "bottom";
                }
                position += "-"
                if (this.windowWidth / 2  > this.popDistance.x) {
                    position += "start";
                } else {
                    position += "end";
                }
                return position
            }
        },
        watch: {
            badgeList: {
                handler(val) {
                    this.fnGetDailyBusinessBadge();
                },
                deep: true
            }
        }
    }
</script>

<style lang="less">
    .report_list_item {
        display: flex;
        color: #606060;
        font-size: 15px;
        font-weight: bold;
        line-height: 50px;
        align-items: center;
    }

    .report_list_item_icon {
        flex: 0 0 35px;
        /* width: 35px;
    height: 35px; */
        font-size: 20px;
        line-height: 35px;

        color: #fff;
        border-radius: 50%;
        text-align: center;
    }

    /* .report_list_item_border {
    border-bottom: 1px solid #fff;
  } */

    .report_list_item_text {
        display: flex;
        width: 100%;
        margin: 0 5px 0 15px;
    }

    .report_list_item_name {
        flex: 0 0 90%
    }

    .report_list_item_right {
        color: #9b9b9b;
        font-size: 28px;
        /* position: absolute;
    right: 8%; */
    }

    .funclist_title {
        font-size: 16px;
        font-weight: bold;
        padding: 20px 0 0px 20px;
    }

    .funclist_icon {
        position: relative;
        width: 45px;
        font-size: 25px;
        line-height: 45px;
        color: #fff;
        border-radius: 50%;
        text-align: center;
        margin: 5px auto;

        &.longpressend {
            transition: all cubic-bezier(0.075, 0.82, 0.165, 1) 1s;
            animation: long-press 1s 0s linear;
        }
        .funclist_tag {
            position: absolute;
            top: 4px;
            right: 8px;
            transform: translate(50%, -50%) scale(0.9);
            font-size: 10px;
            white-space:nowrap;
            min-width: 16px;
            text-align: center;
        }
    }

    .funclist_text {
        font-size: 13px;
        color: #666;
        transition: all 0.2s ease-in-out;
    }

    .longpress {
        .funclist_icon {
            transform: scale(0.9);
            transition: all cubic-bezier(0.075, 0.82, 0.165, 1) 0.4s;
        }
        .funclist_text {
            transition: all cubic-bezier(0.075, 0.82, 0.165, 1) 0.4s;
        }
    }
    .showing_cls {
        position: absolute;
        right: 2px;
        bottom: 2px;
        width: 8px;
        height: 8px;
        border-radius: 100%;
        background-color: #2196f3;
        box-shadow: 0px 2px 5px 0px rgba(255, 255, 255, 0.1), 0px 0px 3px 0px rgba(255, 255, 255, 0.2);
    }
    .ball-scale-multiple {
        position: relative;
        width: 8px;
        height: 8px;
    }
    .ball-scale-multiple > div:nth-child(2) {
        -webkit-animation-delay: 0.4s;
                animation-delay: 0.4s; 
    }
    .ball-scale-multiple > div {
        background-color: rgba(33, 149, 243, 0.74);
        border-radius: 100%;
        -webkit-animation-fill-mode: both;
                animation-fill-mode: both;
        position: absolute;
        left: -8px;
        top: -8px;
        opacity: 0;
        margin: 0;
        width: 24px;
        height: 24px;
        -webkit-animation: ball-scale-multiple 2s 0s linear infinite;
                animation: ball-scale-multiple 2s 0s linear infinite; 
    }

    #tabfunction-wrapper {
        // padding: 15px 0;
        .van-overlay {
            background-color: transparent!important;
        }
        .van-popover__arrow {
            display: none;
        }
        .van-popup {
            border-radius: 8px;
            box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.06), 0px 0px 3px 0px rgba(0,0,0,0.1);
            .van-popover__action {
                width: auto;
            }
        }
    }
</style>