admin-add.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>添加管理员</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  8. <!-- 所有的 css & js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/jquery.min.js"></script>
  14. <script src="../../static/kj/layer/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. <script src="../../static/kj/upload-util.js"></script>
  17. </head>
  18. <body>
  19. <div class="vue-box" style="display: none;" :style="'display: block;'">
  20. <!-- 参数栏 -->
  21. <div class="c-panel">
  22. <h4 class="c-title">添加用户</h4>
  23. <el-form>
  24. <!-- 防止密码框被填充 -->
  25. <div style="height: 0px; overflow: hidden;">
  26. <el-input></el-input>
  27. <el-input type="password"></el-input>
  28. </div>
  29. <sa-item type="text" name="账号" v-model="m.name" br need></sa-item>
  30. <sa-item type="text" name="姓名" v-model="m.nickname" br need></sa-item>
  31. <sa-item style="display: inline;" type="text" name="手机号" v-model="m.phone" br need></sa-item>
  32. <div class="c-item">
  33. <label class="c-label"><span style="color: red;">*</span>所属单位:</label>
  34. <el-select v-model="m.departmentId">
  35. <el-option label="请选择" v-for="(item,index) in deptList" :key="item.id" :label="item.name"
  36. :value="item.id">
  37. </el-option>
  38. </el-select>
  39. </div>
  40. <sa-item type="password" name="密码" v-model="m.password" br need></sa-item>
  41. <sa-item name="角色" br>
  42. <el-select v-model="m.roleId">
  43. <el-option label="请选择" :value="0" disabled></el-option>
  44. <el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id">
  45. </el-option>
  46. </el-select>
  47. </sa-item>
  48. <sa-item name="" br>
  49. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  50. </sa-item>
  51. </el-form>
  52. </div>
  53. </div>
  54. <script>
  55. var app = new Vue({
  56. components: {
  57. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  58. },
  59. el: '.vue-box',
  60. data: {
  61. sa: sa, // 超级对象
  62. m: {
  63. id: 0,
  64. name: '',
  65. departmentId: '',
  66. avatar: '',
  67. password: '',
  68. roleId: 0
  69. },
  70. roleList: [],
  71. deptList: [],
  72. currentUser: sa.$sys.getCurrUser(),
  73. deptIds: [],
  74. },
  75. methods: {
  76. getDeptList() {
  77. sa.ajax('/TbDepartment/getList', {
  78. pageNo: 1,
  79. pageSize: 100
  80. }, function(resp) {
  81. this.deptList = resp.data;
  82. }.bind(this))
  83. },
  84. // 修改
  85. ok: function() {
  86. // 表单校验
  87. let m = this.m;
  88. sa.checkNull(m.name, '请输入账号');
  89. sa.checkNull(m.nickname, '请输入姓名');
  90. let phone = m.phone;
  91. if (!sa.isPhone(phone)) {
  92. sa.error('请输入正确的手机号');
  93. return;
  94. }
  95. sa.checkNull(m.departmentId, '请选择单位');
  96. sa.checkNull(m.password, '请输入密码');
  97. sa.checkNull(m.roleId, '请选择角色');
  98. // 添加
  99. sa.ajax('/admin/add', m, function(res) {
  100. sa.alert('增加成功', this.clean);
  101. parent.app.f5(); // 刷新父页面列表
  102. sa.closeCurrIframe();
  103. }.bind(this));
  104. },
  105. getRoleList() {
  106. sa.ajax('/role/getList', function(res) {
  107. this.roleList = res.data; // 数据
  108. }.bind(this), {
  109. msg: null
  110. });
  111. }
  112. },
  113. mounted: function() {
  114. // 加载角色
  115. this.getRoleList();
  116. this.getDeptList();
  117. }
  118. })
  119. </script>
  120. </body>
  121. </html>