1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/*
* 管理员管理
* $Id: account_new_input.inc,v 1.1 2015/10/08 11:18:53 wanggb Exp $
* @author wanggb
* @access public
* @package manager.templates
*/
global $login;
global $password;
global $name;
global $contact;
global $comment;
global $account_role_list;
global $modules_list;
global $error_message;
global $account_role;
?>
<div id="change">
<p class="edit_title">新增账号</p>
<div class="edit_content">
<form id="form" method="post" action="account_new_result.php" enctype="multipart/form-data">
<input type="hidden" name="account_role"/>
<input type="hidden" name="organization"/>
<p>登陆帐号</p>
<el-input v-model="login" name="login" class="input_200"></el-input><br />
<p>登陆密码</p>
<el-input v-model="password" name="password" class="input_200"></el-input><br />
<p>账户名称</p>
<el-input v-model="name" name="name" class="input_200"></el-input><br />
<p>联系方式</p>
<el-input v-model="contact" name="contact" class="input_200"></el-input><br />
<p>用户角色 </p>
<el-select v-model="selected" size='medium' >
<el-option
v-for="item in account_role"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
<div v-if="isShow">
<p>机构选择 </p>
<el-select v-model="organization" size='medium' >
<div class="el-select-dropdown__item"><input v-model="searchVal" style="border-radius: 4px;background: url(images/search_icon.png) no-repeat 150px;"type="text" autocomplete="off"></div>
<el-option
v-for="item in new_org_list"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
</div>
<p>权限 <span style="color:#FF0000">※全不选即为超级管理员</span></p>
<template>
<el-checkbox-group v-model="checked">
<el-checkbox name="modules[]" style="display:block;" v-for="modules in modules_list" :label="modules.id" :key="modules.id" >{{modules.module}}</el-checkbox>
</el-checkbox-group>
</template>
<p>备注</p>
<el-input v-model="comment" name="comment" class="input_300"></el-input><br />
<br/><br/>
<el-button type="primary" class="edit_btn" @click="submitForm()">新增</el-button>
<el-button type="primary" class="edit_btn" @Click="window.location='./account_list.php'" />返回</el-button>
<br/><br/>
</form>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
var vm = new Vue({
el: '#form',
data: {
login: '<?=htmlspecialchars($login) ?>',
password:'<?=htmlspecialchars($password) ?>',
contact:'<?=htmlspecialchars($contact) ?>',
name:'<?=htmlspecialchars($name) ?>',
comment:'<?=htmlspecialchars($comment) ?>',
modules_list:<?=json_encode($modules_list)?>,
account_role:<?=json_encode($account_role_list)?>,
school_list:[{id:'1',title:"aa"},{id:'2',title:"bb"}],
government_list:<?=json_encode($government_list)?>,
selected:1,
checked:[],
isShow:true,
organization:'<?=$government_list[0]["id"]?>',
org_list:<?=json_encode($government_list)?>,
searchVal:''
},
watch:{
selected(val,oldval){
if(val > 8){
this.isShow = false;
}else{
this.isShow = true;
if(val >= 7){
this.org_list = this.school_list;
this.organization = '2';
}else{
this.org_list = this.government_list;
this.organization = '<?=$government_list[0]["id"]?>';
}
}
}
},
methods: {
submitForm() {
if(!this.login){
this.$message({
type: 'error',
message: '请输入登陆帐号。'
});
return;
}
if (!isAlpaNum(this.login)) {
this.$message({
type: 'error',
message: '登陆帐号只能使用半角英文或数字。'
});
return;
}
if (!this.password) {
this.$message({
type: 'error',
message: '请输入登陆密码。'
});
return;
}
if (!isAlpaNum(this.password)) {
this.$message({
type: 'error',
message: '登陆密码只能使用半角英文或数字。'
});
return;
}
if (!this.name) {
this.$message({
type: 'error',
message: '请输入账户名称。'
});
return;
}
$("input[name='account_role']").val(this.selected);
$("input[name='organization']").val(this.organization);
$('#form').submit();
}
},
computed: {
new_org_list() {
var _this = this;
var new_org_list = [];
_this.org_list.map(function(item) {
if (item.title.search(_this.searchVal) != -1) {
new_org_list.push(item);
}
});
if(new_org_list.length == 0){
new_org_list = _this.org_list;
}
return new_org_list;
}
}
})
if(<?=$error_message?1:0 ?>){
vm.$message({
type: 'error',
message: '<?=$error_message?>'
});
}
})
</script>