admin-add.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="https://unpkg.com/vue@2.6.10/dist/vue.min.js"></script>
  12. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  13. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  14. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
  15. <script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. <script src="../../static/kj/upload-util.js"></script>
  18. </head>
  19. <body>
  20. <div class="vue-box" style="display: none;" :style="'display: block;'">
  21. <!-- 参数栏 -->
  22. <div class="c-panel">
  23. <h4 class="c-title">添加用户</h4>
  24. <el-form>
  25. <!-- 防止密码框被填充 -->
  26. <div style="height: 0px; overflow: hidden;">
  27. <el-input></el-input>
  28. <el-input type="password"></el-input>
  29. </div>
  30. <sa-item type="text" name="账号" v-model="m.name" br need></sa-item>
  31. <sa-item type="text" name="姓名" v-model="m.nickname" br need></sa-item>
  32. <sa-item style="display: inline;" type="text" name="手机号" v-model="m.phone" br need></sa-item>
  33. <sa-item type="password" name="密码" v-model="m.password" br need></sa-item>
  34. <sa-item name="角色" br>
  35. <el-select v-model="m.roleId">
  36. <el-option label="请选择" :value="0" disabled></el-option>
  37. <el-option v-for="role in roleList" :key="role.id" :label="role.name" :value="role.id">
  38. </el-option>
  39. </el-select>
  40. </sa-item>
  41. <sa-item name="" br>
  42. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  43. </sa-item>
  44. </el-form>
  45. </div>
  46. </div>
  47. <script>
  48. var app = new Vue({
  49. components: {
  50. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  51. },
  52. el: '.vue-box',
  53. data: {
  54. sa: sa, // 超级对象
  55. m: {
  56. id: 0,
  57. name: '',
  58. customerId:sa.p('customerId',-2),
  59. superAdmin:0,
  60. avatar: '',
  61. password: '',
  62. roleId: 0
  63. },
  64. roleList: [],
  65. deptList: [],
  66. currentUser: sa.$sys.getCurrUser(),
  67. deptIds: [],
  68. },
  69. methods: {
  70. // 修改
  71. ok: function() {
  72. // 表单校验
  73. let m = this.m;
  74. sa.checkNull(m.name, '请输入账号');
  75. sa.checkNull(m.nickname, '请输入姓名');
  76. let phone = m.phone;
  77. if (!sa.isPhone(phone)) {
  78. sa.error('请输入正确的手机号');
  79. return;
  80. }
  81. sa.checkNull(m.password, '请输入密码');
  82. sa.checkNull(m.roleId, '请选择角色');
  83. // 添加
  84. sa.ajax('/admin/addCustomerAdmin', sa.removeNull(m), function(res) {
  85. sa.alert('增加成功', this.clean);
  86. parent.app.f5(); // 刷新父页面列表
  87. sa.closeCurrIframe();
  88. }.bind(this));
  89. },
  90. getRoleList() {
  91. sa.ajax('/role/getCustomerRoleList',{customerId:this.m.customerId}, function(res) {
  92. this.roleList = res.data; // 数据
  93. }.bind(this), {
  94. msg: null
  95. });
  96. }
  97. },
  98. mounted: function() {
  99. // 加载角色
  100. this.getRoleList();
  101. }
  102. })
  103. </script>
  104. </body>
  105. </html>