<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/head :: head(link)"/>
<body>
<div id="app" class="ok-body" v-cloak>
    <template>
        <div style="margin-bottom: 8px;margin-top: 8px;">
            <i-input placeholder="输入内容"  v-model="log.description"  style="width: 300px"></i-input>
            <i-button type="primary"  icon="ios-search" @click="load()">搜索</i-button>
            <i-button type="primary"  icon="ios-redo" @click="reload()" >重置</i-button>
        </div>
    </template>
    <template>
        <i-table size="small" :columns="tableTitle"  :data="tableData">
        </i-table>
        <br>
        <Page  style="float: right;" :current="log.pageNo" :total="tableSize" :page-size="log.pageSize"  @on-change="changePage" @on-page-size-change="changePageSize" show-elevator show-sizer show-total></Page>
    </template>
</div>
<div th:replace="common/foot :: foot(script)"></div>
<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 that = this;
		return {
            tableTitle : [{
                title: '序号',
                width : 70,
                render: function(h, params) {
                    return h('span', params.index + (that.log.pageNo- 1) * that.log.pageSize + 1);
                }
            },{
                key : "username",
                title : "用户名",
                width:200
            },{
                key : "address",
                title : "地址",
                minWidth:100
            },{
                key : "gmtCreate",
                title : "创建时间",
                minWidth:150
            },{
                key : "status",
                title : "状态",
                width:100,
                render : function(h, params) {
                    var type = params.row.status==1?"成功":"失败";
                    return h('div', type);
                }
            },{
                title : '操作',
                key : 'action',
                width : 100,
                align : 'center',
                render : function(h, params) {
                    var functionList = [];
                    var remove = h('Button', {
                        props : {
                            type : 'primary',
                            size : 'small',
                            icon : 'md-trash'
                        },
                        style : {
                            marginRight : '8px'
                        },
                        on : {
                            click : function() {
                                vm.remove(params.row);
                            }
                        }
                    }, '删除');
                    functionList.push(remove);
                    return h('div', functionList);
                }
            } ],
            tableData : [],
            log : {
                pageSize : 10,
                pageNo : 1,
                description:''
            },
            tableSize : 50,
          }
        },
        methods: {
            load : function() {
                var that = this;
                okUtils.ajaxCloud({
                    url:"/app/ding/log",
                    param : that.log,
                    success : function(result) {
                         that.tableData = result.msg.pageData;
                         that.tableSize = result.msg.totalCount;
                    }
                });
            },
            reload : function(){
                vm.log.pageSize = 10;
                vm.log.pageNo = 1;
                vm.log.description = '';
                this.load();
            },
            changePage : function(pageNo) {
                vm.log.pageNo = pageNo;
                vm.load();
            },
            changePageSize : function(pageSize) {
                vm.log.pageSize = pageSize;
                vm.load();
            },
            remove:function(log) {
                 okLayer.confirm("确定要删除吗？", function () {
                    okUtils.ajaxCloud({
                        url:"/app/ding/log/delete",
                        param : {logId: log.logId},
                        success : function(result) {
                            okLayer.msg.greenTick(result.msg, function () {
                                  vm.load();
                            });
                        }
                    });
                 })
            }
        },
        created: function() {
            this.load()
        }
    })
  });
</script>
</body>
</html>
