<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>妹子图</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/css/oksub.css}">
    <link rel="stylesheet" th:href="@{/lib/iview/styles/iview.css}">
</head>
<body>
<div id="app" class="ok-body" v-cloak>
    <!--模糊搜索区域-->
    <template>
        <div style="margin-bottom: 8px;margin-top: 8px;">
            <i-input placeholder="输入内容"  v-model="image.description"  style="width: 200px"></i-input>
            <i-button type="primary"  icon="ios-search" @click="load()">搜索</i-button>
            <i-button type="primary"  icon="ios-redo" @click="reload()" >重置</i-button>
            <i-button type="primary" icon="ios-hammer" @click="removeAll(1)" >恢复</i-button>
            <i-button type="primary" icon="md-trash" @click="removeAll(0)" >删除</i-button>
            <i-button type="primary" style="float:right" icon="md-add" @click="add()" >新增</i-button>
        </div>
    </template>
    <template>
        <i-table size="small" :columns="tableTitle"  :data="tableData">
        </i-table>
        <br>
        <Page  style="float: right;" :current="image.pageNumber" :total="tableSize" :page-size="image.pageSize"  @on-change="changePage" @on-page-size-change="changePageSize" show-elevator show-sizer show-total></Page>
    </template>
</div>
<!--js逻辑-->
<script type="text/javascript" th:src="@{/lib/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/lib/vue/vue.min.js}" ></script>
<script type="text/javascript" th:src="@{/lib/iview/iview.min.js}"></script>
<script th:inline="none">
layui.use(["okUtils", "okLayer"], function () {
    var okUtils = layui.okUtils;
    var okLayer = layui.okLayer;
    var vm = new Vue({
        el: '#app',
        data: function(){
        var _this = this;
		return {
            tableTitle : [{
                title: '序号',
                minWidth : 80,
                render: function(h, params) {
                    return h('span', params.index + (_this.image.pageNumber- 1) * _this.image.pageSize + 1);
                }
            },{
                key : "ossUrl",
                title : "路径",
                minWidth:400
            },{
                key : "gmtCreate",
                title : "创建时间",
                minWidth:150
            },{
                key : "status",
                title : "状态",
                minWidth:80,
                render : function(h, params) {
                    var status = params.row.status==0?"删除":"正常";
                    return h('div', status);
                }
            },{
                title : '操作',
                key : 'action',
                minWidth : 300,
                align : 'center',
                render : function(h, params) {
                    var functionList = [];
                    var show = params.row.status==1?"删除":"恢复"
                    var status = params.row.status==1?0:1;
                    var resume = h('Button', {
                        props : {
                            type : 'primary',
                            size : 'small',
                            icon : 'md-trash'
                        },
                        style : {
                            marginRight : '8px'
                        },
                        on : {
                            click : function() {
                                vm.resume(status,params.row.id);
                            }
                        }
                    }, show);
                    functionList.push(resume);
                    return h('div', functionList);
                }
            } ],
            tableData : [],
            image  : {
                pageSize : 10,
                pageNumber : 1,
                description:'',
            },
            tableSize : 50,
          }
        },
        methods: {
            load : function() {
               var _this = this;
               okUtils.ajax("/sys/girl/list", "post", this.image, false).done(function (response) {
                    _this.tableData = response.msg.pageData;
                    _this.tableSize = response.msg.totalCount;
                }).fail(function (error) {
                    console.log(error)
                });
            },
            reload : function(){
                this.image.pageNumber=1;
                this.image.pageSize=10;
                this.image.pornStatus=null;
                this.load();
            },
            changePage : function(pageNumber) {
                vm.image.pageNumber = pageNumber;
                vm.load();
            },
            changePageSize : function(pageSize) {
                vm.image.pageSize = pageSize;
                vm.load();
            },
            remove : function(image) {
                okUtils.ajaxCloud({
                    url:"/sys/girl/delete",
                    param : {id:image.id},
                    success : function(result) {
                         okLayer.msg.greenTick(result.msg, function () {
                              vm.load();
                         })
                    }
                });
            },
            removeAll:function(status){
                okLayer.confirm("确定要执行此操作吗？", function () {
                    okUtils.ajaxCloud({
                        url:"/sys/girl/removeAll",
                        param : {status:status},
                        success : function(result) {
                            okLayer.msg.greenTick(result.msg, function () {
                                  vm.load();
                            })
                        }
                    });
                 })
            },
            resume:function(status,id){
                okLayer.confirm("确定要执行此操作吗？", function () {
                    okUtils.ajaxCloud({
                        url:"/sys/girl/resume",
                        param : {status:status,id:id},
                        success : function(result) {
                            okLayer.msg.greenTick(result.msg, function () {
                                  vm.load();
                            })
                        }
                    });
                 })
            }
        },
        created: function() {
            this.load()
        }
    })
  });
</script>
</body>
</html>