<?php /*a:4:{s:85:"E:\phpstudy_pro\WWW\data\hkcms\template\admin\adminlte\routine\attachment\select.html";i:1715617489;s:74:"E:\phpstudy_pro\WWW\data\hkcms\template\admin\adminlte\common\default.html";i:1715617489;s:71:"E:\phpstudy_pro\WWW\data\hkcms\template\admin\adminlte\common\meta.html";i:1715617489;s:73:"E:\phpstudy_pro\WWW\data\hkcms\template\admin\adminlte\common\script.html";i:1715617489;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta name="csrf-token" content="<?php echo token(); ?>">

    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="never">
<meta name="renderer" content="webkit">
<title><?php echo $site['title']; ?> - <?php echo lang("Backstage panel"); ?></title>

<link rel="Shortcut Icon" href="<?php echo $site['favicon']; ?>?v=<?php echo env('APP_DEBUG')?time():$site['version']; ?>" type="image/x-icon" />

<!-- Font Awesome 5.13.0 字体图标库 -->
<link rel="stylesheet" href="/static/libs/fontawesome-free/css/all.min.css">
<!-- AdminLTE v3.2.0 | Bootstrap v4.6.0 CSS框架 -->
<link rel="stylesheet" href="/static/module/admin/adminlte/css/adminlte.css?v=<?php echo env('APP_DEBUG')?time():$site['version']; ?>">
<link rel="stylesheet" href="/static/module/admin/adminlte/css/common.css?v=<?php echo env('APP_DEBUG')?time():$site['version']; ?>">

<script type="text/javascript">
    window.Config = <?php echo json_encode($site); ?>;
    window.Lang = <?php echo json_encode($tempLang); ?>;
    window.Tpl = <?php echo json_encode($Tpl); ?>;
</script>

    <style>
        html,body,.wrapper {
            height: 100% !important;
        }
        .content {
            min-height: 100%;
            height: auto;
            padding-bottom: 20px;
            background-color: #f2f3f5;
        }
        .operatePage .card-footer {
            width: 100%;
            position: fixed;
            bottom: 0;
            z-index: 99;
        }
    </style>

    {__STYLE__}

</head>
<body class="sidebar-mini layout-top-nav overlayScrollbars" >

    <?php if(empty($popup)): ?>
    <!-- 子页 -->
    <div class="wrapper">
        <div class="content">
            <div class="container-fluid" style="padding-top: 16px">
                <div class="card card-primary">
    <div class="card-body">

        <!--筛选-->
        <div class="filter-panel d-none">
            <form action="" method="get" class="frm-filter">
                <div class="row">
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang("Title"); ?></label>
                            <input type="text" class="form-control" name="title" placeholder="<?php echo lang("Title"); ?>" data-op="like %...%">
                        </div>
                    </div>
                    <?php if($mimetype!='' && (isset($mimetype[-1]) && $mimetype[-1] != '/') && stristr($mimetype, '/')!==false): ?>
                    <input type="hidden" name="mime_type" value="<?php echo $mimetype; ?>" data-op="in">
                    <?php elseif(($mimetype!='' && isset($mimetype[-1]) && $mimetype[-1]=='/')): ?>
                    <input type="hidden" name="mime_type" value="<?php echo $mimetype; ?>" data-op="like ...%">
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang('Suffix'); ?></label>
                            <select name="ext" class="form-control">
                                <option value=""><?php echo lang('All'); ?></option>
                                <?php if(is_array($ext) || $ext instanceof \think\Collection || $ext instanceof \think\Paginator): $i = 0; $__LIST__ = $ext;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo; ?>"><?php echo $vo; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <?php $mimetype = $mimetype."*"; elseif(($mimetype=='')): ?>
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang('Suffix'); ?></label>
                            <select name="ext" class="form-control">
                                <option value=""><?php echo lang('All'); ?></option>
                                <?php if(is_array($ext) || $ext instanceof \think\Collection || $ext instanceof \think\Paginator): $i = 0; $__LIST__ = $ext;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo; ?>"><?php echo $vo; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <?php else: ?>
                    <input type="hidden" name="ext" value="<?php echo str_replace('.','',$mimetype); ?>" data-op="in">
                    <?php endif; if(!empty($size)): ?>
                    <input type="hidden" name="size" value="<?php echo $size; ?>" data-op="<">
                    <?php else: ?>
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang('Size'); ?></label>
                            <input type="hidden" name="size" data-op="BETWEEN">
                            <div class="row ml-0">
                                <div class="col-6 pr-0">
                                    <input type="number" class="form-control" id="size_start" placeholder="<?php echo lang('Unit byte'); ?>">
                                </div>
                                <div class="col-6">
                                    <input type="number" class="form-control" id="size_end" placeholder="<?php echo lang('Unit byte'); ?>">
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>
                    <div class="col-lg-2 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group text-center">
                            <input type="submit" class="btn btn-primary" value="<?php echo lang('Search'); ?>">
                            <input type="reset" class="btn btn-default ml-2" value="<?php echo lang('Reset'); ?>">
                        </div>
                    </div>
                </div>
            </form>
            <hr>
        </div>

        <div id="toolbar" class="toolbar">
            <?php if(has_rule('common/upload')): ?>
            <div class="file-upload-group">
                <button type="button" class="btn btn-primary btn-uploads"
                        data-multiple="<?php echo $multiple; ?>"
                        data-mimetype="<?php echo (isset($mimetype) && ($mimetype !== '')?$mimetype:'*'); ?>"
                        data-size="<?php echo !empty($size) ? $size :  site('file_size'); ?>">
                    <i class="fas fa-arrow-alt-circle-up"></i> <?php echo lang('Upload'); ?>
                </button>
            </div>

            <button type="button" class="btn btn-default btn-remote" data-toggle="tooltip"><i class="fas fa-download"></i> <?php echo __('Remote download'); ?></button>
            <?php endif; if(has_rule('del')): ?>
            <button type="button" class="btn btn-disabled btn-danger disabled btn-del " data-url="<?php echo url('/routine.attachment/del'); ?>"><i class="fas fa-trash-alt"></i>
                <?php echo lang('Delete'); ?></button>
            <?php endif; ?>
            <button type="button" class="btn btn-success btn-img-select btn-disabled disabled" data-field="<?php echo (isset($field) && ($field !== '')?$field:''); ?>" data-multiple="<?php echo $multiple; ?>" data-file-num="<?php echo (isset($fileNum) && ($fileNum !== '')?$fileNum:'10'); ?>"><i class="fas fa-check-circle"></i>
                <?php echo lang('Select'); ?></button>

        </div>
        <table id="table"
               data-del="<?php if(has_rule('del')): ?><?php echo url('/routine.attachment/del'); ?><?php endif; ?>"
               data-edit="<?php if(has_rule('edit')): ?><?php echo url('/routine.attachment/edit'); ?><?php endif; ?>"
        ></table>
    </div>
</div>

{block:script}
<script>
    require(['admin','table'], function (admin, Table) {
        $(function () {
            var table = Table.init({
                url: "<?php echo url('/routine.attachment/select'); ?>",
                showToggle: false,
                search: false,
                pagination: true,
                escape: false,
                customFilter: true,
                sortName: 'update_time',
                sortOrder: 'desc',
                singleSelect: !("<?php echo $multiple; ?>"=="true" || "<?php echo $multiple; ?>"=='1'),
                columns: [{
                    field: 'state',
                    checkbox: true,
                },{
                    field: 'user_id',
                    title: '<?php echo lang("User ID"); ?>',
                    visible: false
                },{
                    field: 'user_name',
                    title: '<?php echo lang("Username"); ?>',
                },{
                    field: 'title',
                    title: '<?php echo lang("Title"); ?>',
                    formatter: function (value, row, index, field) {
                        if (value.length>20) {
                            return '<span title="'+value+'">'+(value.substring(0,20)+'...')+'</span>'
                        }
                        return value;
                    }
                },{
                    field: 'cdn_url',
                    title: '<?php echo lang("Preview"); ?>',
                    formatter: Table.formatter.image,
                    events: Table.events.image
                },{
                    field: 'path',
                    title: '<?php echo lang("Path"); ?>',
                    visible: false
                },{
                    field: 'storage',
                    title: '<?php echo lang("Storage"); ?>',
                },{
                    field: 'size_text',
                    title: '<?php echo lang("Size (kb)"); ?>',
                },{
                    field: 'ext',
                    title: '<?php echo lang("Suffix"); ?>',
                },{
                    field: 'mime_type',
                    title: '<?php echo lang("Mime type"); ?>',
                    visible: false
                },{
                    field: 'remark',
                    title: '<?php echo lang("Remark"); ?>',
                    visible: false
                },{
                    field: 'create_time',
                    title: '<?php echo lang("Create time"); ?>',
                },{
                    field: 'update_time',
                    title: '<?php echo lang("Update time"); ?>',
                    visible: false
                },{
                    field: 'operate',
                    title: '<?php echo lang("operate"); ?>',
                    formatter: Table.formatter.operate,
                    events: Table.events.operate
                }]});

            // 远程下载
            $('.btn-remote').click(function (e) {
                layer.prompt({title: '<?php echo __("Please enter the remote attachment address"); ?>', formType: 2}, function(url, index){
                    var ind = layer.load(1);
                    $.post('<?php echo url("/routine.attachment/download"); ?>',{ url:url },function (e) {
                        layer.close(ind);
                        if (e.code==200) {
                            layer.msg(e.msg,{time:1000},function () {
                                table.bootstrapTable('refresh');
                                layer.close(index);
                            })
                        } else {
                            layer.alert(e.msg);
                        }
                    });
                });
            });

            // 文件选择事件
            $(document).on('click', '.btn-img-select', function (e) {
                let data = table.bootstrapTable('getSelections');
                if (data.length===0) {
                    layer.msg(lang('Please select a record line'),{time:4000,icon:2});
                    return false;
                }
                let arr = [];
                $.each(data, function(key, value) {
                    arr.push(value.path);
                });

                // 判断文件最大选择数
                let fileNum = $(this).data('file-num') || 10;
                if (arr.length>fileNum) {
                    layer.msg(lang('Only %s file can be uploaded at a time!',[fileNum]),{time:4000,icon:2});
                    return false;
                }

                let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

                // 判断是否有回调
                var toCallback = parent.$("#layui-layer" + index).data("callback");
                if (toCallback && typeof toCallback === "function") {
                    if (false===toCallback(arr)) {
                        return false;
                    }
                } else {
                    // let field = $(this).data('field');
                    // if (field) {
                    //     var multiple = $(this).data('multiple');
                    //     if (multiple=='multiple' || multiple==1) {
                    //         var oldfiles = $(parent.document).find('#'+field).val();
                    //         if (oldfiles.length==0) {
                    //             $(parent.document).find('#'+field).val(arr.join(','))
                    //         } else {
                    //             oldfiles = oldfiles.split(',');
                    //             if (oldfiles.length+arr.length>fileNum) {
                    //                 layer.msg(lang('Only %s file can be uploaded at a time!',[fileNum]),{time: 4000,icon:2})
                    //                 return false;
                    //             }
                    //             $(parent.document).find('#'+field).val($(parent.document).find('#'+field).val()+','+(arr.join(',')));
                    //         }
                    //     } else {
                    //         $(parent.document).find('#'+field).val(arr.join(','))
                    //     }
                    //
                    //
                    //     // 触发change事件
                    //     let $obj = parent.$;
                    //     $obj('#'+field).trigger('change');
                    // }
                }
                parent.layer.close(index);
            });
        })
    })
</script>
{/block:script}
            </div>
        </div>
    </div>

    <?php else: ?>
    <div class="operatePage">
        <div class="card card-primary">
    <div class="card-body">

        <!--筛选-->
        <div class="filter-panel d-none">
            <form action="" method="get" class="frm-filter">
                <div class="row">
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang("Title"); ?></label>
                            <input type="text" class="form-control" name="title" placeholder="<?php echo lang("Title"); ?>" data-op="like %...%">
                        </div>
                    </div>
                    <?php if($mimetype!='' && (isset($mimetype[-1]) && $mimetype[-1] != '/') && stristr($mimetype, '/')!==false): ?>
                    <input type="hidden" name="mime_type" value="<?php echo $mimetype; ?>" data-op="in">
                    <?php elseif(($mimetype!='' && isset($mimetype[-1]) && $mimetype[-1]=='/')): ?>
                    <input type="hidden" name="mime_type" value="<?php echo $mimetype; ?>" data-op="like ...%">
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang('Suffix'); ?></label>
                            <select name="ext" class="form-control">
                                <option value=""><?php echo lang('All'); ?></option>
                                <?php if(is_array($ext) || $ext instanceof \think\Collection || $ext instanceof \think\Paginator): $i = 0; $__LIST__ = $ext;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo; ?>"><?php echo $vo; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <?php $mimetype = $mimetype."*"; elseif(($mimetype=='')): ?>
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang('Suffix'); ?></label>
                            <select name="ext" class="form-control">
                                <option value=""><?php echo lang('All'); ?></option>
                                <?php if(is_array($ext) || $ext instanceof \think\Collection || $ext instanceof \think\Paginator): $i = 0; $__LIST__ = $ext;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo; ?>"><?php echo $vo; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <?php else: ?>
                    <input type="hidden" name="ext" value="<?php echo str_replace('.','',$mimetype); ?>" data-op="in">
                    <?php endif; if(!empty($size)): ?>
                    <input type="hidden" name="size" value="<?php echo $size; ?>" data-op="<">
                    <?php else: ?>
                    <div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="row-form-label"><?php echo lang('Size'); ?></label>
                            <input type="hidden" name="size" data-op="BETWEEN">
                            <div class="row ml-0">
                                <div class="col-6 pr-0">
                                    <input type="number" class="form-control" id="size_start" placeholder="<?php echo lang('Unit byte'); ?>">
                                </div>
                                <div class="col-6">
                                    <input type="number" class="form-control" id="size_end" placeholder="<?php echo lang('Unit byte'); ?>">
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>
                    <div class="col-lg-2 col-md-4 col-sm-6 col-xs-12">
                        <div class="form-group text-center">
                            <input type="submit" class="btn btn-primary" value="<?php echo lang('Search'); ?>">
                            <input type="reset" class="btn btn-default ml-2" value="<?php echo lang('Reset'); ?>">
                        </div>
                    </div>
                </div>
            </form>
            <hr>
        </div>

        <div id="toolbar" class="toolbar">
            <?php if(has_rule('common/upload')): ?>
            <div class="file-upload-group">
                <button type="button" class="btn btn-primary btn-uploads"
                        data-multiple="<?php echo $multiple; ?>"
                        data-mimetype="<?php echo (isset($mimetype) && ($mimetype !== '')?$mimetype:'*'); ?>"
                        data-size="<?php echo !empty($size) ? $size :  site('file_size'); ?>">
                    <i class="fas fa-arrow-alt-circle-up"></i> <?php echo lang('Upload'); ?>
                </button>
            </div>

            <button type="button" class="btn btn-default btn-remote" data-toggle="tooltip"><i class="fas fa-download"></i> <?php echo __('Remote download'); ?></button>
            <?php endif; if(has_rule('del')): ?>
            <button type="button" class="btn btn-disabled btn-danger disabled btn-del " data-url="<?php echo url('/routine.attachment/del'); ?>"><i class="fas fa-trash-alt"></i>
                <?php echo lang('Delete'); ?></button>
            <?php endif; ?>
            <button type="button" class="btn btn-success btn-img-select btn-disabled disabled" data-field="<?php echo (isset($field) && ($field !== '')?$field:''); ?>" data-multiple="<?php echo $multiple; ?>" data-file-num="<?php echo (isset($fileNum) && ($fileNum !== '')?$fileNum:'10'); ?>"><i class="fas fa-check-circle"></i>
                <?php echo lang('Select'); ?></button>

        </div>
        <table id="table"
               data-del="<?php if(has_rule('del')): ?><?php echo url('/routine.attachment/del'); ?><?php endif; ?>"
               data-edit="<?php if(has_rule('edit')): ?><?php echo url('/routine.attachment/edit'); ?><?php endif; ?>"
        ></table>
    </div>
</div>

{block:script}
<script>
    require(['admin','table'], function (admin, Table) {
        $(function () {
            var table = Table.init({
                url: "<?php echo url('/routine.attachment/select'); ?>",
                showToggle: false,
                search: false,
                pagination: true,
                escape: false,
                customFilter: true,
                sortName: 'update_time',
                sortOrder: 'desc',
                singleSelect: !("<?php echo $multiple; ?>"=="true" || "<?php echo $multiple; ?>"=='1'),
                columns: [{
                    field: 'state',
                    checkbox: true,
                },{
                    field: 'user_id',
                    title: '<?php echo lang("User ID"); ?>',
                    visible: false
                },{
                    field: 'user_name',
                    title: '<?php echo lang("Username"); ?>',
                },{
                    field: 'title',
                    title: '<?php echo lang("Title"); ?>',
                    formatter: function (value, row, index, field) {
                        if (value.length>20) {
                            return '<span title="'+value+'">'+(value.substring(0,20)+'...')+'</span>'
                        }
                        return value;
                    }
                },{
                    field: 'cdn_url',
                    title: '<?php echo lang("Preview"); ?>',
                    formatter: Table.formatter.image,
                    events: Table.events.image
                },{
                    field: 'path',
                    title: '<?php echo lang("Path"); ?>',
                    visible: false
                },{
                    field: 'storage',
                    title: '<?php echo lang("Storage"); ?>',
                },{
                    field: 'size_text',
                    title: '<?php echo lang("Size (kb)"); ?>',
                },{
                    field: 'ext',
                    title: '<?php echo lang("Suffix"); ?>',
                },{
                    field: 'mime_type',
                    title: '<?php echo lang("Mime type"); ?>',
                    visible: false
                },{
                    field: 'remark',
                    title: '<?php echo lang("Remark"); ?>',
                    visible: false
                },{
                    field: 'create_time',
                    title: '<?php echo lang("Create time"); ?>',
                },{
                    field: 'update_time',
                    title: '<?php echo lang("Update time"); ?>',
                    visible: false
                },{
                    field: 'operate',
                    title: '<?php echo lang("operate"); ?>',
                    formatter: Table.formatter.operate,
                    events: Table.events.operate
                }]});

            // 远程下载
            $('.btn-remote').click(function (e) {
                layer.prompt({title: '<?php echo __("Please enter the remote attachment address"); ?>', formType: 2}, function(url, index){
                    var ind = layer.load(1);
                    $.post('<?php echo url("/routine.attachment/download"); ?>',{ url:url },function (e) {
                        layer.close(ind);
                        if (e.code==200) {
                            layer.msg(e.msg,{time:1000},function () {
                                table.bootstrapTable('refresh');
                                layer.close(index);
                            })
                        } else {
                            layer.alert(e.msg);
                        }
                    });
                });
            });

            // 文件选择事件
            $(document).on('click', '.btn-img-select', function (e) {
                let data = table.bootstrapTable('getSelections');
                if (data.length===0) {
                    layer.msg(lang('Please select a record line'),{time:4000,icon:2});
                    return false;
                }
                let arr = [];
                $.each(data, function(key, value) {
                    arr.push(value.path);
                });

                // 判断文件最大选择数
                let fileNum = $(this).data('file-num') || 10;
                if (arr.length>fileNum) {
                    layer.msg(lang('Only %s file can be uploaded at a time!',[fileNum]),{time:4000,icon:2});
                    return false;
                }

                let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

                // 判断是否有回调
                var toCallback = parent.$("#layui-layer" + index).data("callback");
                if (toCallback && typeof toCallback === "function") {
                    if (false===toCallback(arr)) {
                        return false;
                    }
                } else {
                    // let field = $(this).data('field');
                    // if (field) {
                    //     var multiple = $(this).data('multiple');
                    //     if (multiple=='multiple' || multiple==1) {
                    //         var oldfiles = $(parent.document).find('#'+field).val();
                    //         if (oldfiles.length==0) {
                    //             $(parent.document).find('#'+field).val(arr.join(','))
                    //         } else {
                    //             oldfiles = oldfiles.split(',');
                    //             if (oldfiles.length+arr.length>fileNum) {
                    //                 layer.msg(lang('Only %s file can be uploaded at a time!',[fileNum]),{time: 4000,icon:2})
                    //                 return false;
                    //             }
                    //             $(parent.document).find('#'+field).val($(parent.document).find('#'+field).val()+','+(arr.join(',')));
                    //         }
                    //     } else {
                    //         $(parent.document).find('#'+field).val(arr.join(','))
                    //     }
                    //
                    //
                    //     // 触发change事件
                    //     let $obj = parent.$;
                    //     $obj('#'+field).trigger('change');
                    // }
                }
                parent.layer.close(index);
            });
        })
    })
</script>
{/block:script}
    </div>
    <?php endif; ?>

    <script src="/static/libs/require/require.js"></script>
<script src="/static/module/admin/adminlte/js/main.js?v=<?php echo env('APP_DEBUG')?time():$site['version']; ?>"></script>

<!-- // 加载插件JS-->
<?php echo load_js(); ?>



    {__SCRIPT__}
    
</body>
</html>