<template>
    <div class="filter-container">
        <el-card>
            <el-input v-model="tousercode" placeholder="请输入新负责人"  class="filter-item"></el-input>
            <el-input v-model="fromusercode" placeholder="请输入原负责人"  class="filter-item"></el-input>
            <el-button type="primary" @click="btn_search">搜索</el-button>
            <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
                <el-tab-pane label="全部" name="0"></el-tab-pane>
                <el-tab-pane label="未处理" name="1"></el-tab-pane>
                <el-tab-pane label="已处理" name="2"></el-tab-pane>
            </el-tabs>
             <el-table :data="dataLists" border stripe >
                <el-table-column type="selection" width="40"></el-table-column>
                <el-table-column prop="F_ToPerson" label="新负责人" align="center" fixed width=""></el-table-column>
                <el-table-column prop="F_NotifyPerson" label="原负责人" align="center" fixed width=""></el-table-column>
                <el-table-column prop="F_Notice" label="消息" align="center" fixed width=""></el-table-column>
                <el-table-column label="状态" align="center" fixed width="">
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.F_State == 0">未读</el-tag>
                        <el-tag v-else-if="scope.row.F_State == 1">已读但未处理</el-tag>
                        <el-tag v-else-if="scope.row.F_State == 2" type='success'>同意转移</el-tag>
                        <el-tag v-else type='danger'>拒绝</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="" align="center" class-name="oparate_btn" fixed="right">
                <template slot-scope="scope">
                    <el-button type="text" @click="btn_detail(scope.row.F_ID.toString())">详情</el-button>
                    <el-button type="text" @click="btn_handle(scope.row.F_ID.toString())" v-if="scope.row.F_State == 0 || scope.row.F_State==1">处理</el-button>
                    </template>
                </el-table-column>
             </el-table>
             <pagination
            v-show="pageParams.total > 0"
            :total="pageParams.total"
            :pageindex.sync="pageParams.pageindex"
            :pagesize.sync="pageParams.pagesize"
            class="pagination"
            @pagination="getList">
            </pagination>
        </el-card>
    </div>
</template>
<script>
import { getFileTranserLists } from '@/api/memberManagement/memberList'
import Pagination from '@/components/Pagination' // 对el-pagination 二次封装
import detail from './detail'
import handle from './handle'
export default {
    components: {
        Pagination,
    },
    data() {
        return {
            pageParams: {
                pageindex: 1, // 当前第几页
                pagesize: Number(this.$store.getters.serverConfig.PAGESIZE), // 每页几条数据
                total: 0 // 总共多少数据
            },
            activeName: 0 ,
            tousercode: '',//档案新负责人
            fromusercode: '',//档案原负责人
            dataLists:[],//列表数据
        }
    },
    created() {
        this.getList()
        document.onkeyup = (e) => {
            if (e.keyCode === 13) {
                this.getList()
            }
        }
    },
    methods: {
        getList() {
        return new Promise(resolve => {
            const params = {
            pageindex: this.pageParams.pageindex, // int 第几页
            pagesize: this.pageParams.pagesize, // int 每页几条信息
            state: this.activeName, //
            type: 1,//现在只有一个类型为销售档案转移，传值1
            tousercode: this.tousercode.trim(),//档案新负责人
            fromusercode: this.fromusercode.trim(),//档案原负责人
            }
            getFileTranserLists(params).then(response => {
            if (response.state.toLowerCase() === 'success') {
                this.pageParams.total = response.rows.Totals
                this.dataLists = response.rows.Rows
            }
            })
            resolve()
        })
        },
        btn_search() {
        this.pageParams.pageindex = 1
        this.getList()
        },
        btn_detail(editId) {
            this.$layer.iframe({
                content: {
                content: detail, // 传递的组件对象
                parent: this, // 当前的vue对象
                data: { 'rowid': editId }// props
                },
                area: ['80%', '90%'],
                title: '详情'
            })
        },
        btn_handle(handleId) {
            this.$layer.iframe({
                content: {
                content: handle, // 传递的组件对象
                parent: this, // 当前的vue对象
                data: { 'rowid': handleId }// props
                },
                area: ['30%', '30%'],
                title: '处理'
            })
        },
        handleClick(tab, event){
            console.log(tab, event);
            this.activeName=tab.name
            this.getList()
        }
    },
}
</script>
<style lang="scss" scoped>

</style>