<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('音乐人标签列表')"/>
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <style>
        .layui-layer-btn0 {
            padding: 0;
        }
        #addClassify {
            display: none;
            width: 540px;
            padding: 20px;
        }
        #addClassify .selectClassify {
            display: flex;
            align-items: center;
        }
        #addClassify .selectClassify label {
            display: flex;
            margin-right: 20px;
            align-items: center;
        }
        #addClassify .selectClassify label input {
            margin: 0;
            margin-right: 2px;
        }
        .shadeCss,.layui-layer-shade {
            background-color: rgb(0, 0, 0, 0.5) !important;
        }
        .select-list ul {
            display: flex;
            justify-content: space-between;
        }

        .selectClassifyOne span {
            width: 45px;
        }
        .tagStore .fixed-table-toolbar {
            display: flex;
        }
        .tagStore .fixed-table-toolbar .bs-bars {
            flex: 1;
        }
        .tagStore .fixed-table-toolbar .bs-bars .btn-group-sm {
            display: flex;
            justify-content: space-between;
        }
        .leftSearchBox {
            display: flex;
            align-items: center;
        }
        .leftSearchBox input, .leftSearchBox select {
            width: 200px;
            height: 34px;
            margin-right: 12px;
        }
        .ibox-content {
            border-style: none;
            padding: 0;
        }
        .kv-hidden {
            display: none !important;
        }
        .layui-layer-btn0, .layui-layer-btn1 {
            font-size: 12px;
            font-weight: normal;
            margin: 0 3px;
            margin-right: 7px;
            margin-left: 7px;
            padding: 0 15px;
            color: #fff;
            border: 1px solid #0064b6;
            background: #0071ce;
            border-radius: 3px;
            display: inline-block;
            height: 30px;
            line-height: 30px;
            text-align: center;
            vertical-align: middle;
            background-repeat: no-repeat;
            text-decoration: none;
            outline: none;
            -moz-box-sizing: content-box;
            -webkit-box-sizing: content-box;
            box-sizing: content-box;
        }
        .layui-layer-btn1 {
            color: #404a58;
            border: 1px solid #c0c4cd;
            background: #fff;
            border-radius: 3px;
            margin-left: 0;
        }
        .layui-layer-btn0:hover {
            color: #fff;
        }
        #addClassify {
            padding: 0;
            display: none;
            width: 540px;
            padding-top: 20px;
        }
        #addClassify .selectClassify {
            display: flex;
            align-items: center;
            padding: 0 20px;
        }
        #addClassify .selectClassify label {
            display: flex;
            margin-right: 20px;
            align-items: center;
        }
        #addClassify .selectClassify label input {
            margin: 0;
            margin-right: 2px;
        }
        .shadeCss,.layui-layer-shade {
            background-color: rgb(0, 0, 0, 0.5) !important;
        }
        .select-list ul {
            display: flex;
            justify-content: space-between;
        }
        .selectClassifyOne {
            display: flex;
            align-items: center;
            margin: 12px 0;
            padding: 0 20px;
        }
        .tagStore .fixed-table-toolbar {
            display: flex;
        }
        .tagStore .fixed-table-toolbar .bs-bars {
            flex: 1;
        }
        .tagStore .fixed-table-toolbar .bs-bars .btn-group-sm {
            display: flex;
            justify-content: space-between;
        }
        .leftSearchBox {
            display: flex;
            align-items: center;
        }
        .leftSearchBox input, .leftSearchBox select {
            width: 200px;
            height: 34px;
            margin-right: 12px;
        }
        .ibox-content {
            border-style: none;
            padding: 0;
        }
        .kv-hidden {
            display: none !important;
        }
        .bottomBtn {
            text-align: right;
            padding: 10px 15px 12px;
            background: #f0f4f7;
            border-top: 1px #c7c7c7 solid;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            名称：<input type="text" name="tagName"/>
                        </li>
                        <li>
                            类型：<select name="tagType" th:with="type=${@dict.getType('zhengzai_self_extag_type')}">
                            <option value="">全部</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" id="button-open-10" shiro:hasPermission="goblin:extag:add">
                <i class="fa fa-plus"></i> 新增
            </a>
<!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">-->
<!--                <i class="fa fa-remove"></i> 删除-->
<!--            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="goblin:extag:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
        <div id="addClassify">
            <div class="selectClassify">
                <span>LOGO：</span>
                <img id="viewImg" src="" alt="" style="max-height:150px;">
                <div class="ibox-content">
                    <div class="form-group">
                        <div class="file-loading">
                            <input id="fileinput" type="file" name="file" data-browse-on-zone-click="true" data-theme="fas">
                        </div>
                    </div>
                </div>
            </div>
            <div class="selectClassifyOne">
                <span>昵称：</span>
                <input class="form-control" id="musicName" type="text">
            </div>
            <div class="selectClassify" style="margin-bottom: 20px;">
                <span>类别：</span>
                <label>
                    <input type="radio" checked value="1" id="optionsRadios1" name="optionsRadios"><span>音乐人</span></label>
                <label>
                    <input type="radio" value="2" id="optionsRadios2" name="optionsRadios"><span>艺术家</span></label>
                <label>
                    <input type="radio" value="3" id="optionsRadios3" name="optionsRadios"><span>品牌方</span></label>
                <label>
                    <input type="radio" value="4" id="optionsRadios4" name="optionsRadios"><span>厂牌</span></label>
                <label>
                    <input type="radio" value="5" id="optionsRadios5" name="optionsRadios"><span>AR</span></label>
            </div>
            <div class="bottomBtn">
                <a href="javascript:;" class="layui-layer-btn0" onclick="yes()">确定</a>
                <a class="layui-layer-btn1 layui-layer-btn1" onclick="closeModal()">取消</a>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js" />
<script th:inline="javascript">
    var dicSelfExtagType = [[${@dict.getType('zhengzai_self_extag_type')}]];
    var rmvFlg = [[${@permission.hasPermi('goblin:extag:rmv')}]];
    var prefix = ctx + "goblin/extag";
    var platformUrl = [[${platformUrl}]];
    let type = '1';
    let id = '';
    $(function () {
        $("#fileinput").fileinput({
            'theme': 'explorer-fas',
            // 'uploadUrl': 'https://devplatform.zhengzai.tv/platform/basicServices/alOss/upload',
            'uploadUrl': platformUrl + '/platform/basicServices/alOss/upload',
            "uploadExtraData": {
                "pathName" : "banner",
                "buckType" : 1
            },
            autoReplace: true,
            showCaption: false,
            showPreview: false,
            showRemove: false,
            showUpload: false,
            showCancel: false,
            showClose: false,
            autoReplace: true,
            dropZoneTitle: "请上传文件",
            maxFileCount: 1
        }).on("filebatchselected", function (event, files) {         //默认上传
            $(this).fileinput("upload");
        })
        .on("fileuploaded", function (event, data) {       //上传回调事件
            showPicture = 'https://img.zhengzai.tv/' + data.response.data.ossPath;
            $("#viewImg").attr('src', showPicture)
        })
        var options = {
            url: prefix + "/list",
            removeUrl: prefix + "/rmv/{id}",
            exportUrl: prefix + "/export",
            sortName: "mid desc",
            modalName: "音乐人标签库",
            columns: [{
                checkbox: true
            },
                {
                    field: 'tagPic',
                    title: '头像',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'tagName',
                    title: '名称'
                },
                {
                    field: 'tagType',
                    title: '类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(dicSelfExtagType, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + rmvFlg + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tagId + '\')"><i class="fa fa-trash"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    $("input[name=optionsRadios]").on('change',function(e){
        type = e.target.value;
    })
    $("#button-open-10").click(function(){
        layer.open({
            type: 1,
            shade: true,
            title: '创建分类', //不显示标题
            content: $('#addClassify'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            success: function () {
                $(".layui-layer-shade").addClass('shadeCss')
            },
            cancel: function(res){
                reset()
                // layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
            }
        });
    })
    function reset() {
        id = '';
        $("#musicName").val('');
        $("#viewImg").attr('src', '');
    }
    $("#button-open-11").click(function(){
        $("button[name=refresh]").click()
    })
    function onCheck (row, $element) {
    }
    function yes(index, layero) {
        let data = {
            tagName: $("#musicName").val(),
            tagPic: $("#viewImg").attr('src'),
            tagType: type
        }
        $.ajax({
            type: 'post',
            url: '/goblin/extag/addSave',
            data: data,
            success: function(res) {
                if (res.code == 0) {
                    closeModal();
                    reset()
                    $("button[name=refresh]").click()
                } else {
                    layer.msg(res.msg)
                }
            }
        })
    }
    function closeModal () {
        reset()
        $(".layui-layer-close1").click();
    }
</script>
</body>
</html>