<template>
    <div class="loginUser">
        <div class="search-wrapper">
            <el-form :inline="true" :model="searchForm" class="search_form" style="text-align: left">
                <el-form-item label="uid">
                    <el-input v-model="searchForm.uid" placeholder="请输入用户uid" @keyup.enter.native="onSubmit"></el-input>
                </el-form-item>
                <el-form-item label="电话号码">
                    <el-input v-model="searchForm.mobile" placeholder="请输入电话号码" @keyup.enter.native="onSubmit">
                    </el-input>
                </el-form-item>
                <el-form-item label="企业登录名">
                    <el-input v-model="searchForm.enterpriseNumber" placeholder="请输入企业登录名"
                        @keyup.enter.native="onSubmit">
                    </el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="table-wrapper">
            <table-template :tableData="tableData" :tableColumns="tableColumns" :loading="loading"
                :pagination="pagination" @Jump="jumpPage">
                <el-table-column fixed="right" label="操作" width="150" align="center">
                    <template slot-scope="scope">
                        <el-button type="danger" size="mini" round @click="del(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </table-template>
        </div>
    </div>
</template>

<script>
import TableTemplate from "@/components/Table";
import { changeList } from "@/utils";
import { queryListPreUser } from '@/api/currency/loginUser.js'
export default {
    components: { TableTemplate },

    data() {
        return {
            searchForm: {
                uid: '',
                mobile: '',
                enterpriseNumber: ''
            },
            loading: false,
            tableColumns: [
                {
                    key: "uid",
                    label: "用户id",
                }, {
                    key: "userName",
                    label: "用户名称",
                }, {
                    key: "mobile",
                    label: "电话",
                }, {
                    key: "regip",
                    label: "注册ip",
                }, {
                    key: "enterpriseNumber",
                    label: "企业登录名",
                }, {
                    key: "enterpriseName",
                    label: "企业名称",
                },
            ],
            tableData: [],
            pagination: {
                total: 0,
                pageSize: 10,
                currentPage: 1,
            },
        }
    },
    methods: {
        init() {
            this.loading = true;
            let params = {
                uid: this.searchForm.uid,
                mobile: this.searchForm.mobile,
                enterpriseNumber: this.searchForm.enterpriseNumber,
                pageNum: this.pagination.currentPage,
                pageSize: this.pagination.pageSize,
            }
            queryListPreUser(params).then((res) => {
                this.loading = false;
                console.log(res);
                if (res.success) {
                    this.pagination.total = res.data.total;
                    if (res.data.total != 0) {
                        this.tableData = res.data.list;
                        if (localStorage.getItem('userName') == 'admin') {
                            this.tableData = changeList(this.tableData)
                        }
                    } else {
                        this.tableData = []
                    }
                }
            })
        },
        jumpPage() {
            this.init();
        },
        onSubmit() {
            this.pagination.currentPage = 1;
            this.init();
        },
        del(val) {
            console.log(val)
        }
    },
    created() {
        this.init()
    },
}
</script>

<style lang="stylus" scoped>
@import '~@/stylus/common';

</style>