<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>报修管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../layuiadmin/style/formSelects-v4.css"/>
    <style type="text/css">
        .baoxiu-li {
            margin: 10px
        }

        img {
            width: 40%;
            height: 30%;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>

<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        <li class="layui-this">报修详情</li>
        <li>操作记录</li>
    </ul>
    <div class="layui-tab-content" style="background-color: #fff;">
        <div id="order_detail" class="layui-tab-item layui-show"></div>
        <div id="order_record" class="layui-tab-item"></div>

        <script id="order_detail_demo" type="text/html">
            <div class="layui-tab-item layui-show">
                <ui>
                    <li class="baoxiu-li">
                        <h3>报销单号：{{ d.no }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>地点：{{ d.device_address }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>问题描述：{{ d.fault_des }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>报修类型：{{ d.repair_type }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>报修人：{{ d.name }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>报修电话：{{ d.tel }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>报修时间：{{ d.create_time }}</h3>
                    </li>
                    <li class="baoxiu-li">
                        <h3>报修状态：{{ d.status_text }}</h3>
                    </li>
                    {{# layui.each(d.images, function(index, item){ }}
                    <li>
                        <img class="layui-upload-img" src={{ item.picture }}>
                    </li>
                    {{# }); }}
                </ui>
            </div>
        </script>
        <script id="order_record_demo" type="text/html">
            <div class="layui-tab-item layui-show">
                <ul class="layui-timeline">
                    {{# layui.each(d, function(index, item){ }}
                    <li class="layui-timeline-item">
                        <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                        <div class="layui-timeline-content layui-text">
                            <h3 class="layui-timeline-title">{{ item.status_text }}</h3>
                            <p>
                                {{ item.desc }}
                            </p>
                            <p>
                                时间：{{ item.operation_time }}
                            </p>
                            <!-- 完工-->
                            {{# if(item.status == 6){ }}
                            <p>
                                故障原因：{{ item.fault_cause }}
                            </p>
                            <p>
                                完工描述：{{ item.content }}
                            </p>
                            {{# } }}

                            {{# layui.each(item.images, function(index, img){ }}
                    <li>
                        <img class="layui-upload-img" src={{ img.url }}>
                    </li>
                    {{# }); }}
                    <!-- 评价-->
                    <div id="pingfen"></div>
            </div>
            </li>
            {{# }); }}

            </ul>
            </div>
        </script>
    </div>
</div>


<script src="../../layuiadmin/layui/layui.js"></script>

<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index',
        formSelects: 'formSelects-v4'
    }).use(['index', 'form', 'utils', 'laytpl', 'rate'], function () {
        var $ = layui.$
            , admin = layui.admin
            , laytpl = layui.laytpl
            , rate = layui.rate
            , form = layui.form;
        var data = JSON.parse(JSON.stringify(parent.layui.table.editdata)); // 框架有Bug所以这么转换
        let baoxiu_imgs_node = $('#baoxiu_imgs');
        for (let i in data.imgs) {
            baoxiu_imgs_node.append("<img style='width: 150px; height: auto; margin: 10px' src=" + data.imgs[i].url + ">");
        }
        var getTpl = order_detail_demo.innerHTML
            , order_detail = document.getElementById('order_detail');
        laytpl(getTpl).render(data, function (html) {
            order_detail.innerHTML = html;
        });

        admin.req({
            url: '/tenant/repair_order/get_repair_order_record/'
            , data: {order_id: data.id}
            , type: 'get'
            , done: function (res) {
                var getTpl2 = order_record_demo.innerHTML
                    , order_record = document.getElementById('order_record');
                laytpl(getTpl2).render(res.data, function (html) {
                    order_record.innerHTML = html;
                });

                for (var i in res.data) {
                    if (res.data[i].status == 7) {
                        rate.render({
                            elem: '#pingfen'
                            , value: res.data[i].start
                            , readonly: true
                            , text: true
                        });
                    }
                }

            }
        });
    })
    ;
</script>
</body>
</html>
