<template>
	<div>
		<el-row>
			<el-col :span="24" class="first-row">
				<div class="tag">账号管理</div>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="24" class="second-row">
				<el-form :inline="true" :model="formInline" class="demo-form-inline">
					<el-form-item label="账号：" class="shuibiaoId">
						<el-input v-model="formInline.user" placeholder="请输入账号"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" @click="onSubmit">查找</el-button>
					</el-form-item>
				</el-form>
				<div class="btn-add">
					<el-button type="primary" icon="el-icon-add">添加</el-button>
				</div>
			</el-col>
		</el-row>
		<hr style="background-color: #CCCCCC;height: 1px;border: 0;">
		<el-row>
			<el-col :span="24" class="third-row">
				<el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
					@selection-change="handleSelectionChange" highlight-current-row>
					<el-table-column label="昵称" align="center">
						<template slot-scope="scope">{{ scope.row.id }}</template>
					</el-table-column>
					<el-table-column prop="account" label="账号" align="center"></el-table-column>
					<el-table-column prop="pass" label="密码" show-overflow-tooltip></el-table-column>
					<el-table-column label="操作" align="center" width="80">
						<el-button type="text" class="del-btn" slot-scope="scope"
							@click="handleDelete(scope.$index, scope.row)">删除
						</el-button>
					</el-table-column>
					<el-table-column width="130">
						<el-button type="text" slot-scope="scope" @click="handleEdit(scope.$index, scope.row)">编辑
						</el-button>
					</el-table-column>
				</el-table>
				<div style="margin-top: 20px" class="table-footer">
					<div class="pages">
						<el-pagination layout="prev, pager, next" :total="9000"></el-pagination>
					</div>
				</div>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="24" class="forth-row">
				<!-- 编辑对话框 -->
				<el-dialog title="编辑" :visible.sync="editdialogFormVisible" width="500px" top="0vh" class="my-dialog">
					<hr style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
					<el-form :model="form">
						<el-form-item label="昵称" :label-width="formLabelWidth">
							<el-input v-model="form.id" autocomplete="off"></el-input>
						</el-form-item>
						<el-form-item label="账号：" :label-width="formLabelWidth">
							<el-input v-model="form.account" autocomplete="off"></el-input>
						</el-form-item>
						<el-form-item label="密码：" :label-width="formLabelWidth">
							<el-input v-model="form.pass" autocomplete="off"></el-input>
						</el-form-item>
						<el-form-item label="确认密码：" :label-width="formLabelWidth">
							<el-input v-model="form.pass" autocomplete="off"></el-input>
						</el-form-item>
					</el-form>
					<div slot="footer" class="dialog-footer">
						<el-button @click="editdialogFormVisible = false">取 消</el-button>
						<el-button type="primary" @click="editdialogFormVisible = false">确 定</el-button>
					</div>
				</el-dialog>
				<!-- 删除对话框 -->
				<el-dialog :visible.sync="delDialogVisible" width="500px" center top="0vh" class="my-dialog">
					<div class="box-icon"></div>
					<span class="del-msg">确定删除该学生信息吗？</span>
					<span slot="footer" class="dialog-footer">
						<el-button @click="delDialogVisible = false">取 消</el-button>
						<el-button type="primary" @click="delDialogVisible = false">确 定</el-button>
					</span>
				</el-dialog>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				editdialogFormVisible: false,
				delDialogVisible: false,
				form: {
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},
				formLabelWidth: '120px',
				formInline: {
					user: '',
					options: [{
						value: '选项1',
						label: '全部'
					}, {
						value: '选项2',
						label: '黄金糕'
					}],
					value: '选项1'
				},
				tableData: [{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				},{
					id: '随风飘荡',
					account: 'admi123',
					pass: '*******'
				}],
				multipleSelection: []
			}
		},
		methods: {
			onSubmit() {
				console.log('submit!');
			},
			handleOpen(key, keyPath) {
				console.log(key, keyPath);
			},
			handleClose(key, keyPath) {
				console.log(key, keyPath);
			},
			toggleSelection(rows) {
				if (rows) {
					rows.forEach(row => {
						this.$refs.multipleTable.toggleRowSelection(row);
					});
				} else {
					this.$refs.multipleTable.clearSelection();
				}
			},
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			handleEdit(index, row) {
				this.editdialogFormVisible = true
				console.log(index, row);
			},
			handleDelete(index, row) {
				this.delDialogVisible = true
				console.log(index, row);
			}
		}
	}
</script>

<style scoped>
	@import url("zhanghaoguanli.css");
</style>
