<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>应急维修</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" id="header">
        <a class="aui-pull-left aui-btn" onclick="closeFrame();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" data-i18n="900295"></div>
        <a class="aui-pull-right  " data-page="tpm_create" data-params="{}" data-i18n="[data-qr-title]900404" onclick="openQRcodetpm(this)" tapmod="">
            <img src="../image/qrcode.png" style="width: 20px;height: 20px;    margin-top:12px;" />
        </a>
    </header>
    <!-- <div class="container" id="list">
        <script id="DotTemplate" type="text/x-dot-template">
            {{~it.data:value:index}}
            <section class="aui-content-padded ">
                <ul class="aui-list aui-collapse aui-border">
                    <div class="aui-collapse-item">
                        <li class="aui-list-item aui-collapse-header" tapmode>
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-title">{{=lang(value.name)}}(<span style="{{ if(value.count>0 && value.status!=6){ }}color:#FF0000; {{ } }}">{{=value.count}}</span>)</div>
                                <div class="aui-list-item-right">
                                    <i class="aui-iconfont aui-icon-down aui-collapse-arrow"></i>
                                </div>
                            </div>
                        </li>
                        <div class="aui-collapse-content aui-padded-15 aui-border-b">
                            {{~value.repairlist:val:ind}}
                            <div class="aui-card-list open-win" win="tpm_yjwxdetail" param='{"repairid":"{{= val.repairid}}"}'>
                                <div class="aui-card-list-header aui-card-list-user">
                                    <div class="aui-card-list-user-name">
                                        <div class="aui-font-size-16">
                                            <b>{{= val.repairid}}</b> &nbsp;
                                            <b>{{= val.location}}</b> &nbsp;

                                            <span><img src="../image/{{ if(val.mutestatus==1){ }}noti{{ }else{ }}nonoti{{ } }}_dark.png" class="noti"></span></div>
                                    </div>

                                </div>
                                <div class="aui-card-list-content aui-border-t" style="margin-left: 1rem;">
                                    <ul class="aui-list aui-list-noborder" style="background:#fff;">
                                        <div class="aui-card-list-user-avatar dotcon" style="{{ if(val.markself!=1){ }} display:none; {{ } }}">
                                            <div class="dotflag"></div>
                                        </div>
                                        <div class="aui-list-item aui-padded-l-0">
                                            <div class="aui-list-item-inner">
                                                <div class="aui-list-item-title aui-font-size-14 ">
                                                    <div class="c-faultlist">{{= val.faultlist}}</div>
                                                    <div class="c-faultcontent">{{= val.faultcontent}}</div>
                                                    <div class="c-repairremark">{{= val.repairremark}}</div>

                                                </div>
                                                <div class="aui-list-item-title aui-font-size-12">
                                                    <div style="white-space:nowrap;word-space:nowrap;">{{= maskTime3(val.createtime)}}</div>
                                                    <div class="aui-text-danger goods-price" style="white-space:nowrap;word-space:nowrap;">{{= maskTime(val.offlinetime)}}</div>
                                                </div>
                                            </div>
                                        </div>

                                    </ul>
                                </div>
                            </div>
                            {{~}}
                        </div>

                    </div>
                </ul>
            </section>
            {{~}}
        </script>
    </div> -->
    <div class="container" id="test"></div>

</body>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/md5.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/swipe.js"></script>
<script type="text/javascript" src="../script/SHA1.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/remotedb.js"></script>
<script type="text/javascript" src="../script/list.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src="../script/aui-toast.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/CryptoJS/core.js"></script>
<script type="text/javascript" src="../script/CryptoJS/cipher-core.js"></script>
<script type="text/javascript" src="../script/CryptoJS/mode-ecb.js"></script>
<script type="text/javascript" src="../script/CryptoJS/aes.js"></script>
<script type="text/javascript" src="../script/aui-collapse.js"></script>

<script type="text/javascript" src="../script/i18next-12.0.0.min.js"></script>
<script type="text/javascript" src="../script/i18nextLocizeBackend.min.js"></script>
<script type="text/javascript" src="../script/jquery-i18next.min.js"></script>
<script type="text/javascript" src="../script/jquery.cookie.js"></script>
<script type="text/javascript" src="../script/i18n-app.js"></script>

<script type="text/javascript">
    var host, acd, lang, i18next;
    apiready = function() {
        fnReady();
        api.parseTapmode();
        ajaxsetup();
        // getHost();
        host = $api.getStorage('host');
        load_i18n(function(t, i18n) {
            lang = t;
            i18next = i18n;
            loading(lang('6660098'));
            getRepairList();
            if (api.pageParam) {
                acd = api.pageParam.acd;
            }
        });
        pullrefresh();
    };




    function getRepairList() {
        $.ajax({
            url: host + '/tpm/AppRepair/RepairList',
            data: JSON.stringify({
                "status": 0
            }),
            type: 'POST',
            success: function(result) {
                // console.log(JSON.stringify(result));
                if (result.ret == 1) {
                    // api.hideProgress();
                    // var testTemplate = doT.template($("#DotTemplate").text());
                    // $("#list").html(testTemplate(result));
                    renderCollapse(result.data);
                    var collapse = new auiCollapse({
                        autoHide: false //是否自动隐藏已经展开的容器
                    });
                    if (acd) {
                        openaccd(acd);
                    }

                    fnReadyOpenWin();

                } else {
                    customToast(lang(result.msg), 2000);
                }
                api.hideProgress();
            },
            error: function(ret) {
                console.log(JSON.stringify(ret));
            }
        })
    }

    function openaccd(acd) {
        $('.aui-collapse-header:eq(' + (acd - 1) + ')').click();
    }

    function pullrefresh() {

        api.setCustomRefreshHeaderInfo({
            // bgColor: '#000',
            bgColor: '#C0C0C0',

            image:
            {
                pull: 'widget://image/load1.png',
                transform: ['widget://image/load1.png',
                    'widget://image/load2.png',],
                load:
                    [
                        'widget://image/load1.png',
                        'widget://image/load2.png',
                        'widget://image/load3.png',
                        'widget://image/load4.png',
                        'widget://image/load5.png',
                        'widget://image/load6.png'
                    ],
            },
            // tips: {
            //     pull: '下拉刷新',
            //     threshold: '松开立即刷新',
            //     load: '正在刷新'
            // },
            switchTime: 0.05
        }, function () {
            //下拉刷新被触发，自动进入加载状态，使用 api.refreshHeaderLoadDone() 手动结束加载中状态
            //下拉刷新被触发，使用 api.refreshHeaderLoadDone() 结束加载中状态

            setTimeout(() => {
                api.refreshHeaderLoadDone();

                getRepairList();
            }, 1000)
            // api.refreshHeaderLoadDone()

        });
    }

    function renderCollapse(res = []) {
        let html = '';

        res.forEach((ele, i) => {
            //  if(res.count>0 && res.status!=6){ }}color:#FF0000; {{ }
            html += `<section class="aui-content-padded ">
                <ul class="aui-list aui-collapse aui-border">
                    <div class="aui-collapse-item">
                        <li class="aui-list-item aui-collapse-header" tapmode>
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-title">${lang(ele.name)}(<span style="${(ele.count > 0 && ele.status != 6) ? 'color:#FF0000' : ''}">${ele.count}</span>)</div>
                                <div class="aui-list-item-right">
                                    <i class="aui-iconfont aui-icon-down aui-collapse-arrow"></i>
                                </div>
                            </div>
                        </li>
                        <div class="aui-collapse-content aui-padded-15 aui-border-b">
                           ${ele.repairlist.length > 0 ? ele.repairlist.map(item => {
                return `<div class="aui-card-list open-win" win="tpm_yjwxdetail" param='{"repairid":"${item.repairid}"}'>
                                <div class="aui-card-list-header aui-card-list-user">
                                    <div class="aui-card-list-user-name">
                                        <div class="aui-font-size-16">
                                            <b>${item.repairid}</b> &nbsp;
                                            <b>${item.location.join('-')}</b> &nbsp;

                                            <span><img src="../image/${(item.mutestatus == 1) ? 'noti' : 'nonoti'}_dark.png" class="noti"></span></div>
                                    </div>
                                </div>
                                <div class="aui-card-list-content aui-border-t" style="margin-left: 1rem;">
                                    <ul class="aui-list aui-list-noborder" style="background:#fff;">
                                        <div class="aui-card-list-user-avatar dotcon" style="${item.markself != 1 ? 'display:none' : ''}">
                                            <div class="dotflag"></div>
                                        </div>
                                        <div class="aui-list-item aui-padded-l-0">
                                            <div class="aui-list-item-inner">
                                                <div class="aui-list-item-title aui-font-size-14 ">
                                                    <div class="c-faultlist">${item.faultlist}</div>
                                                    <div class="c-faultcontent">${item.faultcontent}</div>
                                                    <div class="c-repairremark">${item.repairremark.substr(0, 1) == ',' ? item.repairremark.substr(1) : item.repairremark}</div>

                                                </div>
                                                <div class="aui-list-item-title aui-font-size-12">
                                                    <div style="white-space:nowrap;word-space:nowrap;">${maskTime3(item.createtime)}</div>
                                                    <div class="aui-text-danger goods-price" style="white-space:nowrap;word-space:nowrap;">${maskTime(item.offlinetime)}</div>
                                                </div>
                                            </div>
                                        </div>

                                    </ul>
                                </div>
                            </div>` }) : ""}


                        </div>

                    </div>
                </ul>
            </section>`
        })
        $('#test').html(html)

    }




    var collapse = new auiCollapse({
        autoHide: false //是否自动隐藏已经展开的容器
    });


    var maskText = function(text) {
        var test = lang(text);
        return test;

    };


    function reloadMe() {
        console.log('reloadMe');
        location.reload();
        window.location.reload();
    }
</script>

</html>
