75 lines
2.6 KiB
Plaintext
75 lines
2.6 KiB
Plaintext
<div id="user_index">
|
|
<fieldset>
|
|
<legend>用户查询</legend>
|
|
<label>登录名:<input type="text" v-model="userName" /></label>
|
|
<label>用户名:<input type="text" v-model="name" /></label>
|
|
<input type="button" v-on:click="userSearch" value="查询" />
|
|
<input type="button" v-on:click="clear" value="清空" />
|
|
<input type="button" v-on:click="addNew" value="新增" />
|
|
</fieldset>
|
|
<table class="table" v-if="tableShow">
|
|
<thead>
|
|
<tr>
|
|
<th>用户编号</th>
|
|
<th>用户登录名</th>
|
|
<th>用户姓名</th>
|
|
<th>状态</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="(u,index) in users">
|
|
<td>{{u.Id}}</td>
|
|
<td>{{u.UserName}}</td>
|
|
<td>{{u.Name}}</td>
|
|
<td>{{u.Status}}</td>
|
|
<td><input type="button" value="删除" v-on:click="removeUser(u.Id,index)" /></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var userIndex = new Vue({
|
|
el: "#user_index",
|
|
data: {
|
|
userName: "",
|
|
name: "",
|
|
tableShow: false,
|
|
users: [],
|
|
ticket: myJs.getTicket(),
|
|
},
|
|
methods: {
|
|
userSearch() {
|
|
myJs.get(myJs.url.user.GetUsers, { userName: this.userName, name: this.name, }, function (d) {
|
|
userIndex.users = d;
|
|
userIndex.tableShow = true;
|
|
}, function (s, i, m) {
|
|
myJs.msg(m);
|
|
});
|
|
},
|
|
clear() {
|
|
this.userName = "";
|
|
this.name = "";
|
|
this.tableShow = false;
|
|
this.users = [];
|
|
},
|
|
addNew() {
|
|
debugger;
|
|
myJs.post(myJs.url.user.AddNewUser, {
|
|
adminTicket: this.ticket,
|
|
userName: this.userName,
|
|
name: this.name,
|
|
password: this.userName,
|
|
}, function (d) {
|
|
userIndex.users.push(d);
|
|
userIndex.tableShow = true;
|
|
});
|
|
},
|
|
removeUser(id, index) {
|
|
myJs.post(myJs.url.user.RemoveUser, { adminTicket: this.ticket, id: id }, function (d) {
|
|
userIndex.users.splice(index, 1);
|
|
});
|
|
},
|
|
}
|
|
});
|
|
</script> |