<template>
    <div class="app-container">
        <div>
            <el-form :inline="true" :model="formSearch" ref="ruleForm" class="demo-form-inline">
                <el-form-item label="时间:">
                    <el-date-picker
                        v-model="formSearch.time"
                        size="mini"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="废码单号:">
                    <el-input v-model="formSearch.number" size="mini" placeholder="请输入废码单号" clearable maxlength="50"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" size="mini" icon="el-icon-search" @click="search">查询</el-button>
                </el-form-item>
            </el-form>
        </div>
        <el-table :data="tableData" style="width: 100%" header-row-class-name="">
            <el-table-column prop="account" label="日期"></el-table-column>
            <el-table-column prop="name" label="摘要"></el-table-column>
            <el-table-column prop="phone" label="废码单号"></el-table-column>
            <el-table-column prop="enIdText" label="废码数"></el-table-column>
            <el-table-column prop="enIdText" label="废码状态"></el-table-column>
            <el-table-column label="操作" width="200">
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="confirm(scope.row.id)"><i class="el-icon-edit"></i>确认</el-button>
                    <el-button type="text" size="small" @click="showDetail">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            layout="total,  prev, pager, next, sizes, jumper"
            :total="total">
        </el-pagination>

    </div>
</template>
<script>
import {
    getUserList, getUserDetail
} from "@/api/user"
export default {
    name: "sendCancel",
    data() {

        return {
            formSearch: {//模糊搜索
                time: '',
                number: '',
            },
            currentPage: 1,                      //当前页
            pageSize: 10,                        //每页条数
            total: 0,                            //总条数
            tableData: [],                      //表格数据
        };
    },
    mounted() {
        this.initData()
    },
    methods: {
        //搜索查询
        search() {
            this.currentPage = 1
            this.initData()
        },
        //获取用户列表
        initData() {
            const params = {
                pageNum: this.currentPage,
                pageSize: this.pageSize,
                search:{
                },
                sort:''
            }
            getUserList(params).then(res => {
                this.tableData = res.data.list
                this.total = res.data.count
            })
        },
        confirm(){
            this.$confirm('此操作将废弃本防伪码, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$message({
                    type: 'success',
                    message: '废弃成功!'
                });
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消废弃'
                });          
            });
        },
        //防伪码作废详情
        showDetail() {
            
        },
        //每页条数变化
        handleSizeChange(val) {
            this.pageSize = val
            this.initData()
        },
        //当前页变化
        handleCurrentChange(val) {
            this.currentPage = val
            this.initData()
        }

    }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.input-with-select {
    float: left;
    top: 10px;
}

.el-input {
    width: 230px;
}
</style>
