<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('报修维修单详细')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal" th:object="${amsRepairOrder}">
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">报修单号：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{repairNo}"></p>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">单据状态：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext">
                                <span class="label label-primary" th:if="*{orderStatus == 'DRAFT'}">草稿</span>
                                <span class="label label-warning" th:if="*{orderStatus == 'PENDING_CONFIRM'}">待受理</span>
                                <span class="label label-danger" th:if="*{orderStatus == 'REJECTED'}">已驳回</span>
                                <span class="label label-info" th:if="*{orderStatus == 'WAIT_REPAIR'}">待维修</span>
                                <span class="label label-info" th:if="*{orderStatus == 'REPAIRING'}">维修中</span>
                                <span class="label label-success" th:if="*{orderStatus == 'REPAIR_DONE'}">维修完成</span>
                            </p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">资产编码：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{assetCode}"></p>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">资产名称：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{assetName}"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">资产类别：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{categoryName}"></p>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">规格型号：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{specModel ?: '-'}"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">品牌：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{brand ?: '-'}"></p>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">报修前资产状态：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext">
                                <span th:if="*{beforeAssetStatus == 'IN_STOCK'}" class="label label-primary">在库</span>
                                <span th:if="*{beforeAssetStatus == 'IN_USE'}" class="label label-info">在用</span>
                                <span th:if="*{beforeAssetStatus == null}">-</span>
                            </p>
                        </div>
                    </div>
                </div>
            </div>

            <h4 class="form-header h4">故障及申报信息</h4>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">报修人：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{reportUserName}"></p>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">报修时间：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{#dates.format(reportTime, 'yyyy-MM-dd HH:mm:ss')}"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">预计完成日期：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext" th:text="*{#dates.format(expectedFinishTime, 'yyyy-MM-dd')}"></p>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6" th:if="*{orderStatus == 'REJECTED'}">
                    <div class="form-group">
                        <label class="col-sm-4 control-label text-danger">驳回原因：</label>
                        <div class="col-sm-8">
                            <p class="form-control-plaintext text-danger" th:text="*{rejectReason}"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">故障描述：</label>
                        <div class="col-sm-10">
                            <p class="form-control-plaintext" style="white-space: pre-wrap;" th:text="*{faultDesc}"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注：</label>
                        <div class="col-sm-10">
                            <p class="form-control-plaintext" th:text="*{remark ?: '-'}"></p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 仅在进入维修环节后展示 -->
            <div th:if="*{orderStatus == 'REPAIRING' || orderStatus == 'REPAIR_DONE'}">
                <h4 class="form-header h4">维修过程及结果</h4>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">维修方类型：</label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{repairerType == 'INTERNAL' ? '内部维修' : '外部维修'}"></p>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label" th:text="*{repairerType == 'INTERNAL' ? '维修人：' : '外部维修单位：'}"></label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{repairerType == 'INTERNAL' ? repairUserName : repairOrgName}"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-6" th:if="*{repairerType == 'EXTERNAL' && repairUserName != null && repairUserName != ''}">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">维修联系人：</label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{repairUserName}"></p>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">联系电话：</label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{repairContactPhone ?: '-'}"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">维修开始时间：</label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{#dates.format(repairStartTime, 'yyyy-MM-dd HH:mm:ss')}"></p>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6" th:if="*{orderStatus == 'REPAIR_DONE'}">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">维修完成时间：</label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{#dates.format(repairFinishTime, 'yyyy-MM-dd HH:mm:ss')}"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row" th:if="*{orderStatus == 'REPAIR_DONE'}">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">维修费用：</label>
                            <div class="col-sm-8">
                                <p class="form-control-plaintext" th:text="*{'￥' + #numbers.formatDecimal(repairCost, 1, 2)}"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row" th:if="*{orderStatus == 'REPAIR_DONE'}">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">维修结果：</label>
                            <div class="col-sm-10">
                                <p class="form-control-plaintext" style="white-space: pre-wrap;" th:text="*{repairResult}"></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
</body>
</html>
