<!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('短剧基础列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>视频名称：</label>
                            <input type="text" name="videoName"/>
                        </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" onclick="$.operate.add()" shiro:hasPermission="playlet:item:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="playlet:item:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="playlet:item:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="playlet:item: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>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('playlet:item:edit')}]];
    var removeFlag = [[${@permission.hasPermi('playlet:item:remove')}]];
    var prefix = ctx + "system/playlet/item";
    var typeDict = [[${@dict.getType('playlet_source_type')}]];
    var completeDict = [[${@dict.getType('playlet_complete_type')}]];
    var videoTypeDict = [[${@dict.getType('playlet_video_type')}]];
    var labelTypeDict = [[${@dict.getType('playlet_label_type')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "短剧基础",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'itemId',
                    title: '剧集ID'
                },
                {
                    field: 'taskId',
                    title: '任务ID'
                },
                {
                    visible: false,
                    field: 'itemTypeName',
                    title: '剧场'
                },
                {
                    field: 'producer',
                    title: '出品方'
                },
                {
                    field: 'tags',
                    title: '推荐标签'
                },
                {
                    title: '抖音',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return dyStatusTools(row);
                    }
                },
                {
                    title: '快手',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return ksStatusTools(row);
                    }
                },
                {
                    title: '视频',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return dspStatusTools(row);
                    }
                },
                {
                    field: 'videoName',
                    title: '短剧标题'
                },
                {
                    field: 'actorName',
                    title: '主角名'
                },
                {
                    field: 'completeNot',
                    title: '视频是否完结',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(completeDict, value);
                    }
                },
                {
                    field: 'coverPic',
                    title: '视频封面图',
                    formatter: function(value) {
                        if (value != null && value !== ''){return '<a target="_blank" href="' + value+ '" download="false">详情图片<a/>';}
                        else {return '<a>无<a/>'}
                    }
                },
                {
                    field: 'connectSite',
                    title: '网盘地址',
                    formatter: function(value) {
                        if (value != null && value !== ''){return '<a target="_blank" href="' + value+ '" download="false">详情图片<a/>';}
                        else {return '<a>无<a/>'}
                    }
                },
                {
                    field: 'upTime',
                    title: '上架时间'
                },
                {
                    field: 'specialItem',
                    title: '精品剧'
                },
                {
                    field: 'videoType',
                    title: '剧集类型'
                },
                {
                    field: 'labelType',
                    title: '剧集标签'
                },
                {
                    field: 'forUser',
                    title: '对标用户'
                },
                {
                    field: 'numberEpisode',
                    title: '总剧集'
                },
                {
                    field: 'numberCost',
                    title: '收费集数'
                },
                {
                    field: 'isDelete',
                    title: '是否删除 1 正常 0 删除',
                    visible: false
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'remark',
                    title: '短剧介绍',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function dyStatusTools(row) {
        if (row.dyStatus === '01') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enableDy(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disableDy(\'' + row.id + '\')"></i> ';
        }
    }

    function enableDy(id) {
        $.modal.confirm("确认要上架抖音平台吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "dyStatus": "02" });
        })
    }

    /* 上架抖音 */
    function disableDy(id) {
        $.modal.confirm("确认下架抖音平台吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "dyStatus": "01" });
        })
    }

    function ksStatusTools(row) {
        if (row.ksStatus === '01') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enableKs(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disableKs(\'' + row.id + '\')"></i> ';
        }
    }

    function enableKs(id) {
        $.modal.confirm("确认要上架快手平台吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "ksStatus": "02" });
        })
    }

    /* 上架快手 */
    function disableKs(id) {
        $.modal.confirm("确认下架快手平台吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "ksStatus": "01" });
        })
    }

    function dspStatusTools(row) {
        if (row.dspStatus === '01') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enableDsp(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disableDsp(\'' + row.id + '\')"></i> ';
        }
    }

    function enableDsp(id) {
        $.modal.confirm("确认要上架视频平台吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "dspStatus": "02" });
        })
    }

    /* 上架抖音 */
    function disableDsp(id) {
        $.modal.confirm("确认下架视频平台吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "dspStatus": "01" });
        })
    }

</script>
</body>
</html>