<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
	<jsp:include page="head.jsp"/>
	<title>com.izouma.awesomeadmin.frame</title>
</head>
<body>
<jsp:include page="contentBefore.jsp"/>
<template>
	<el-form ref="form" :model="row_info" label-width="80px">
		<el-form-item label="username">
			<el-input v-model="row_info.username"></el-input>
		</el-form-item>
		<el-form-item label="nickname">
			<el-input v-model="row_info.nickname"></el-input>
		</el-form-item>
		<el-form-item label="icon">
			<el-input v-model="row_info.icon"></el-input>
		</el-form-item>
		<el-form-item label="age">
			<el-input v-model="row_info.age"></el-input>
		</el-form-item>
		<el-form-item label="sex">
			<el-input v-model="row_info.sex"></el-input>
		</el-form-item>
		<el-form-item label="openId">
			<el-input v-model="row_info.openId"></el-input>
		</el-form-item>
		<el-form-item label="unionId">
			<el-input v-model="row_info.unionId"></el-input>
		</el-form-item>
		<el-form-item label="phone">
			<el-input v-model="row_info.phone"></el-input>
		</el-form-item>
		<el-form-item label="mail">
			<el-input v-model="row_info.mail"></el-input>
		</el-form-item>
		<el-form-item label="focusArea">
			<el-input v-model="row_info.focusArea"></el-input>
		</el-form-item>
		<el-form-item label="investmentQuota">
			<el-input v-model="row_info.investmentQuota"></el-input>
		</el-form-item>
		<el-form-item label="investmentArea">
			<el-input v-model="row_info.investmentArea"></el-input>
		</el-form-item>
		<el-form-item label="createTime">
			<el-input v-model="row_info.createTime"></el-input>
		</el-form-item>
		<el-form-item label="delFlag">
			<el-input v-model="row_info.delFlag"></el-input>
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="onSubmit">{{edit?'保存':'立即创建'}}</el-button>
			<el-button>取消</el-button>
	</el-form-item>
	</el-form>
</template>
<jsp:include page="contentAfter.jsp"/>
</body>
<script>
	function getQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return unescape(r[2]);
		return null;
	}
	new Vue({
		el: '#app',
		created: function () {
			var id = getQueryString('id');
			if (id) {
				$.get({
					url: '../userInfo/getUserInfo',
					data: {
						id: id
					}
				}).then(function (res) {
					if (res.success) {
						this.edit = true;
						this.row_info = res.data;
					}
				}.bind(this));
			}
		},
		data: function () {
			return {
				menu: '0-0',
				user: {
					id: '',

					username: 'admin',
					avatar: ''
				},
				loading: false,
				edit: false,
				tab: 1,
				row_info : {},
			};
		},
		methods: {
			logout: function () {
				this.$confirm('确定要注销吗?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'info'
				}).then(function () {
					localStorage.removeItem('user');
					this.$router.push({path: '/login'});
				}.bind(this)).catch(function (e) {

				});
			},
			onSubmit: function () {
				var data = JSON.parse(JSON.stringify(this.row_info));
				$.post({
					url: this.edit ? '../userInfo/update' : '../userInfo/save',
					data: data
				}).then(function (res) {
					if (res.success) {
						if (!this.edit) {
							this.row_info.id = res.data;
						}
						this.edit = true;
						this.$message.success(this.edit ? '保存成功' : '创建成功');
					} else {
						this.$message.error(this.edit ? '保存失败' : '创建失败');
					}
				}.bind(this))
			},
		}
	})
</script>
</html>

