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="https://unpkg.com/http-vue-loader@1.4.2/src/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">
  38. </el-option>
  39. </el-select>
  40. </div>
  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. customerId: sa.p('customerId', ''),
  58. name: '',
  59. avatar: '',
  60. password: '',
  61. againPassword: '',
  62. roleIds: []
  63. },
  64. roleList: []
  65. },
  66. methods: {
  67. // 修改
  68. ok: function () {
  69. console.log(this.m)
  70. // 表单校验
  71. let m = this.m;
  72. sa.checkNull(m.name, '请输入用户名');
  73. sa.checkNull(m.password, '请输入密码');
  74. if (m.password !== m.againPassword) {
  75. sa.error('两次输入密码不一致');
  76. return;
  77. }
  78. m.roleId = m.roleIds.join(',')
  79. // 添加
  80. sa.ajax('/admin/addPartnerAdmin', m, function (res) {
  81. sa.alert('增加成功', this.clean);
  82. }.bind(this));
  83. },
  84. clean() {
  85. parent.app.f5(); // 刷新父页面列表
  86. sa.closeCurrIframe(); // 关闭本页
  87. }
  88. },
  89. mounted: function () {
  90. // 加载角色
  91. sa.ajax('/role/getCustomerRoleList', {
  92. customerId: this.m.customerId
  93. }, function (res) {
  94. this.roleList = res.data; // 数据
  95. }.bind(this), {
  96. msg: null
  97. });
  98. }
  99. })
  100. </script>
  101. </body>
  102. </html>