<template>
	<!-- 专员 -->
	<div class="container" style="margin:10px;">
		<el-form :inline="true" :model="model" class="demo-form-inline">
			<el-form-item label="推广专员ID">
				<el-input v-model="model.UserId" placeholder="推广专员ID"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="onSubmit">查询</el-button>
			</el-form-item>
		</el-form>
		<el-table style="margin-top: 5px;" v-loading="listLoading" :data="userlist" element-loading-text="Loading"
			border fit highlight-current-row>
			<el-table-column label="用户ID" width="120" align="center">
				<template slot-scope="scope">
					{{scope.row.id}}
				</template>
			</el-table-column>
			<el-table-column label="用户微信名" align="center">
				<template slot-scope="scope">
					<span>{{ scope.row.username }}</span>
				</template>
			</el-table-column>
			<el-table-column label="用户角色" align="center">
				<template slot-scope="scope">
					<el-tag :key="scope.row.type" type="warning" effect="dark">
						{{scope.row.type==1?'管理员':scope.row.type==2?'普通用户':scope.row.type==3?'销售专员':scope.row.type==4?'销售经理':'未知'}}
					</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="备注" align="center">
				<template slot-scope="scope">
					<span>{{ scope.row.remark }}</span>
				</template>
			</el-table-column>
			<el-table-column label="用户电话" align="center">
				<template slot-scope="scope">
					<span>{{ scope.row.phone }}</span>
				</template>
			</el-table-column>
			<el-table-column fixed="right" label="操作" width="160">
				<template slot-scope="scope">
					<!-- <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
					<el-button type="text" size="small" @click="showUpdate(scope.row.id)" v-show="false">编辑
					</el-button>
					<el-button type="text" size="small" @click="deleteInfo(scope.row.id)">删除
					</el-button>
				</template>
			</el-table-column>
		</el-table>
	<!-- 	<el-pagination
		  background
		  layout="prev, pager, next"
		  :total="total"  style="text-align: right;margin-top: 10px;">
		</el-pagination> -->
	</div>
</template>

<script>
	import {
		GetUserCustomerView,
		DeleteUser,
		Save,
	} from '../../api/user.js'
	export default {
		data() {
			return {
				userlist: [],
				listLoading: true,
				model: {
					UserId: 0
				},
			}
		},
		created() {
			this.ShowCustomer()
		},
		methods: {
		
			ShowCustomer() {
				GetUserCustomerView(this.model).then(res => {
					console.log('数据', res)
					if (res.code == 200) {
						this.userlist = res.data
						this.listLoading=false
					}
				})
			},
			onSubmit(){
				if(this.model.UserId==0){
					this.$message.error('请输入专员ID')
				}else{
					this.ShowCustomer()
				}
			},
			deleteInfo(id){
				DeleteUser({
					ids:id
				}).then(res=>{
					console.log('res',res)
					if(res.code==200){
						this.$message.success('删除成功')
						this.ShowCustomer()
					}else{
						this.$message.error('删除失败')
					}
				})
			}
		}

	}
</script>

<style>
</style>
