customer-admin-add.html 3.9 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="../../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/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/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. <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. <!-- 表单 -->
  30. <sa-item type="text" name="用户名" v-model="m.name" placeholder="请输入用户名" br></sa-item>
  31. <sa-item type="password" name="密码" v-model="m.password" placeholder="请输入密码" br></sa-item>
  32. <sa-item type="password" name="再输一次" v-model="m.againPassword" placeholder="请再输一次密码" br></sa-item>
  33. <div class="c-item">
  34. <label class="c-label"><span style="color: red;">*</span>角色:</label>
  35. <el-select v-model="m.roleIds" multiple>
  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"></el-option>
  38. </el-select>
  39. </div>
  40. <sa-item name="" br>
  41. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  42. </sa-item>
  43. </el-form>
  44. </div>
  45. </div>
  46. <script>
  47. var app = new Vue({
  48. components: {
  49. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  50. },
  51. el: '.vue-box',
  52. data: {
  53. sa: sa, // 超级对象
  54. m: {
  55. id: 0,
  56. customerId: sa.p('customerId', ''),
  57. name: '',
  58. avatar: '',
  59. password: '',
  60. againPassword: '',
  61. roleIds: []
  62. },
  63. roleList: []
  64. },
  65. methods: {
  66. // 修改
  67. ok: function () {
  68. // 表单校验
  69. let m = this.m;
  70. sa.checkNull(m.name, '请输入用户名');
  71. sa.checkNull(m.password, '请输入密码');
  72. if (m.password !== m.againPassword) {
  73. sa.error('两次输入密码不一致');
  74. return;
  75. }
  76. if (m.roleIds.length == 0) {
  77. sa.error('请选择角色');
  78. return;
  79. }
  80. m.roleId = m.roleIds.join(',')
  81. // 添加
  82. sa.ajax('/admin/addCustomerAdmin', m, function (res) {
  83. sa.alert('增加成功', this.clean);
  84. }.bind(this));
  85. },
  86. clean() {
  87. parent.app.f5(); // 刷新父页面列表
  88. sa.closeCurrIframe(); // 关闭本页
  89. }
  90. },
  91. mounted: function () {
  92. // 加载角色
  93. sa.ajax('/role/getCustomerRoleList', {customerId: this.m.customerId}, function (res) {
  94. this.roleList = res.data; // 数据
  95. }.bind(this), {msg: null});
  96. }
  97. })
  98. </script>
  99. </body>
  100. </html>