<div class="panel-content">
    <div class="panel-title fluid">
        <div class="title-main">
            <h2>工具</h2>
        </div>
    </div>
    <div class="content-wrap">
        <div class="row">
            <% for (let tool of toolMenu) { %>
            <div class="col-xs-6 mb-30 ">
                <div class="c-body">
                    <h2><%= tool.title %>
                        <% if (tool.url === '/sysTools/api/clearJunkData' ) { %>
                        <a id="clearJunkBtn" href="javascript:void(0);" class="btn btn-primary pull-right">清除</a>
                        <% } else if (tool.url === '/sysTools/api/clearFakeData' ) { %>
                        <a id="clearFakeBtn" href="javascript:void(0);" class="btn btn-primary pull-right">清除</a>
                        <% } else if (tool.url === '/sysTools/api/uploadUserGuide' ) { %>
                        <a id="uploadUserGuide" href="javascript:void(0);" class="btn btn-primary pull-right">上传</a>
                        <% } else if (tool.url === '/sysTools/api/uploadUpgradeGuide' ) { %>
                        <a id="uploadUpgradeGuide" href="javascript:void(0);" class="btn btn-primary pull-right">上传</a>
                        <% } else { %>
                        <a id="<%= tool.controller %>" href="<%= tool.url %>" target="_blank" class="btn btn-primary pull-right">进入</a>
                        <% } %>
                    </h2>
                </div>
            </div>
            <% } %>
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>清单规则编辑器-->
            <!--<a id="stdBillsmain" href="/stdBillsmain" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>定额编辑器-->
            <!--<a id="rationRepository" href="/rationRepository/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>报表模板-->
            <!--<a id="rpt_tpl" href="/rpt_tpl" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>人材机库-->
            <!--<a id="stdGljRepository" href="/stdGljRepository/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>清单指引编辑器-->
            <!--<a id="billsGuidance" href="/billsGuidance/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>清除项目残留数据-->
            <!--<a id="clearJunkBtn" href="javascript:void(0);" class="btn btn-primary pull-right">清除</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>清单模板编辑器-->
            <!--<a id="billTemplate" href="/billsTemplate/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>列设置-->
            <!--<a id="mainTreeCol" href="/mainTreeCol/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>材料替换库-->
            <!--<a id="materialReplace" href="/materialReplace/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>工程特征库-->
            <!--<a id="projectFeature" href="/projectFeature/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>费率标准库-->
            <!--<a id="feeRate" href="/feeRate/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="col-xs-6 mb-30 ">-->
            <!--<div class="c-body">-->
            <!--<h2>计算程序模板库-->
            <!--<a id="calcProgram" href="/calcProgram/main" target="_blank" class="btn btn-primary pull-right">进入</a>-->
            <!--</h2>-->
            <!--</div>-->
            <!--</div>-->
        </div>
    </div>
</div>
<!--弹出 是否清除数据-->
<div class="modal fade" id="clearJunkModal" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">删除确认</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <div id="delete_showinfo">
                        <label>确认要清除数据库中项目残留数据吗？(每周日03:30自动清除)</label>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="justify-content: center">
                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="clearJunkY" >是</button>
                <button type="button" class="btn btn-primary"  data-dismiss="modal">否</button>
            </div>
        </div>
    </div>
</div>
<!--弹出 是否清除假删除数据-->
<div class="modal fade" id="clearFakeModal" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">删除确认</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <div>
                        <label>确认要清除数据库中项目假删除数据吗？(清单、定额)</label>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="justify-content: center">
                <button type="button" class="btn btn-primary"  data-dismiss="modal" id="clearFakeY" >是</button>
                <button type="button" class="btn btn-primary"  data-dismiss="modal">否</button>
            </div>
        </div>
    </div>
</div>
<!--上传pdf-->
<div class="modal fade" id="upload" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">上传</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label>请选择pdf格式文件</label>
                        <input id="upload-file" class="form-control-file" type="file" accept="application/pdf">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-primary" id="uploadConfirm">确定</a>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/public/web/common_ajax.js"></script>
<script type="text/javascript" src="/public/web/PerfectLoad.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
//        $('#billsLib').click(function () {
//            let href = '/stdBillsmain';
//            let newTab = window.open('about:blank');
//            CommonAjax.get(href, {}, function () {
//               newTab.location.href = href;
//            });
//        });
//
//        $('#rationLib').click(function () {
//            let href = '/rationRepository/main';
//            let newTab = window.open('about:blank');
//            CommonAjax.get(href, {}, function () {
//               newTab.location.href = href;
//            });
//        });
//
//        $('#rptTemplate').click(function () {
//            let href = '/rpt_tpl';
//            let newTab = window.open('about:blank');
//            CommonAjax.get(href, {}, function () {
//               newTab.location.href = href;
//            });
//        });
//
//        $('#gljLib').click(function () {
//            let href = '/stdGljRepository/main';
//            let newTab = window.open('about:blank');
//            CommonAjax.get(href, {}, function () {
//               newTab.location.href = href;
//            });
//        });
//
//        $('#billsGuidanceLib').click(function () {
//            let href = '/billsGuidance/main';
//            let newTab = window.open('about:blank');
//            CommonAjax.get(href, {}, function () {
//               newTab.location.href = href;
//            });
//        });

        $('#clearJunkBtn').click(function () {
            $('#clearJunkModal').modal('show');
        });
        $('#clearFakeBtn').click(function () {
            $('#clearFakeModal').modal('show');
        });
        $('#clearJunkY').click(function () {
            $.bootstrapLoading.start();
            CommonAjax.post('/sysTools/api/clearJunkData', '', function (rstData) {
                $.bootstrapLoading.end();
            }, function () {
                $.bootstrapLoading.end();
            })
        });
        $('#clearFakeY').click(function () {
            $.bootstrapLoading.start();
            CommonAjax.post('/sysTools/api/clearFakeData', '', function (rstData) {
                $.bootstrapLoading.end();
            }, function () {
                $.bootstrapLoading.end();
            })
        });
        let uploadType = {
                userGuide: 'userGuide',
                upgradeGuide: 'upgradeGuide'
            },
            curTrigger = null;
        //用户手册
        $('#uploadUserGuide').click(function () {
            curTrigger = uploadType.userGuide;
            $('#upload .modal-title').text('上传用户手册');
            $('#upload').modal('show');
        });
        //升级说明
        $('#uploadUpgradeGuide').click(function () {
            curTrigger = uploadType.upgradeGuide;
            $('#upload .modal-title').text('上传升级说明');
            $('#upload').modal('show');
        });
        $('#upload').on('hide.bs.modal', function () {
            $('#upload-file').val('');
        });
        $('#uploadConfirm').click(function () {
            let file = $('#upload-file')[0],
                pdf = file.files[0],
                trigger = curTrigger;
            if (!trigger) {
                alert('无效的操作！(触发器为空)');
                return;
            }
            if (!pdf) {
                alert('请选择pdf文件！');
                return;
            }
            let formData = new FormData();
            formData.append('file', pdf);
            formData.append('trigger', trigger);
            $.ajax({
                url: '/sysTools/api/uploadUserGuide',
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                beforeSend: function() {
                    $.bootstrapLoading.start();
                },
                success: function(response){
                    $.bootstrapLoading.end();
                    $('#upload').modal('hide');
                },
                error: function(){
                    alert('上传失败');
                    $.bootstrapLoading.end();
                }
            });
        });
    });
</script>