123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>添加管理员</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta name="viewport"
- content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <!-- 所有的 css & js 资源 -->
- <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
- <link rel="stylesheet" href="../../static/sa.css">
- <script src="../../static/kj/vue.min.js"></script>
- <script src="../../static/kj/element-ui/index.js"></script>
- <script src="../../static/kj/jquery.min.js"></script>
- <script src="../../static/kj/layer/layer.js"></script>
- <script src="../../static/sa.js"></script>
- <script src="../../static/kj/upload-util.js"></script>
- </head>
- <body>
- <div class="vue-box" style="display: none;" :style="'display: block;'">
- <!-- 参数栏 -->
- <div class="c-panel">
- <h4 class="c-title">添加用户</h4>
- <el-form>
- <!-- 防止密码框被填充 -->
- <div style="height: 0px; overflow: hidden;">
- <el-input></el-input>
- <el-input type="password"></el-input>
- </div>
- <sa-item type="text" name="账号" v-model="m.name" br need></sa-item>
- <sa-item type="text" name="姓名" v-model="m.nickname" br need></sa-item>
- <sa-item style="display: inline;" type="text" name="手机号" v-model="m.phone" br need></sa-item>
- <div class="c-item">
- <label class="c-label"><span style="color: red;">*</span>所属单位:</label>
- <el-select v-model="m.departmentId">
- <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id" :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </div>
- <sa-item type="password" name="密码" v-model="m.password" br need></sa-item>
- <sa-item name="角色" br>
- <el-select v-model="m.roleId">
- <el-option label="请选择" :value="0" disabled></el-option>
- <el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id">
- </el-option>
- </el-select>
- </sa-item>
- <sa-item name="" br>
- <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
- </sa-item>
- </el-form>
- </div>
- </div>
- <script>
- var app = new Vue({
- components: {
- "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
- },
- el: '.vue-box',
- data: {
- sa: sa, // 超级对象
- m: {
- id: 0,
- name: '',
- departmentId: '',
- avatar: '',
- password: '',
- roleId: 0
- },
- roleList: [],
- deptList: [],
- currentUser: sa.$sys.getCurrUser(),
- deptIds: [],
- },
- methods: {
- getDeptList() {
- sa.ajax('/TbDepartment/getList', {
- pageNo: 1,
- pageSize: 100
- }, function(resp) {
- this.deptList = resp.data;
- }.bind(this))
- },
- // 修改
- ok: function() {
- // 表单校验
- let m = this.m;
- sa.checkNull(m.name, '请输入账号');
- sa.checkNull(m.nickname, '请输入姓名');
- let phone = m.phone;
- if (!sa.isPhone(phone)) {
- sa.error('请输入正确的手机号');
- return;
- }
- sa.checkNull(m.departmentId, '请选择单位');
- sa.checkNull(m.password, '请输入密码');
- sa.checkNull(m.roleId, '请选择角色');
- // 添加
- sa.ajax('/admin/add', m, function(res) {
- sa.alert('增加成功', this.clean);
- parent.app.f5(); // 刷新父页面列表
- sa.closeCurrIframe();
- }.bind(this));
- },
- getRoleList() {
- sa.ajax('/role/getList', function(res) {
- this.roleList = res.data; // 数据
- }.bind(this), {
- msg: null
- });
- }
- },
- mounted: function() {
- // 加载角色
- this.getRoleList();
- this.getDeptList();
- }
- })
- </script>
- </body>
- </html>
|