AddManageUser.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="page">
  3. <div class="title">
  4. <el-tag type="danger" class="alert">
  5. <strong>注意:</strong>&nbsp;&nbsp;&nbsp;&nbsp;您添加的用户必须是已注册的用户,如果还还没有注册请先
  6. <a
  7. href="http://testuc.pacsonline.cn/#/reg"
  8. target="_black"
  9. >注册</a>
  10. </el-tag>
  11. </div>
  12. <div class="dataform" v-bind:class="{hidden:step!=1}">
  13. <el-tag class="alert">第一步:输入手机号/用户名查询用户</el-tag>
  14. <el-input v-model="search" placeholder="请输入手机号/用户名" size="small"></el-input>
  15. <div class="next">
  16. <el-button type="primary" @click="goBack" size="mini">取消</el-button>
  17. <el-button type="primary" @click="searchUser" size="mini">下一步</el-button>
  18. </div>
  19. </div>
  20. <div class="dataform" v-bind:class="{hidden:step!=2}">
  21. <el-tag class="alert">第二步:选择用户</el-tag>
  22. <el-table :data="items">
  23. <el-table-column label="选择">
  24. <template slot-scope="scope">
  25. <el-radio v-model="userid" :label="scope.row.userid">&nbsp</el-radio>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="用户名称" prop="name"></el-table-column>
  29. <el-table-column label="用户手机号" prop="phone"></el-table-column>
  30. <el-table-column label="身份证" prop="idcard"></el-table-column>
  31. </el-table>
  32. <div class="next">
  33. <el-button type="primary" @click="up" size="mini">上一步</el-button>
  34. <el-button type="primary" @click="save" size="mini">完成</el-button>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. step: 1,
  44. search: "",
  45. items: [],
  46. userid: false
  47. };
  48. },
  49. methods: {
  50. searchUser: function() {
  51. if (this.search.length == 0) {
  52. return;
  53. }
  54. this.$http.sarchUsers({ search: this.search }, this).then(res => {
  55. if (res.code === 0) {
  56. this.items = res.obj;
  57. this.step = this.step + 1;
  58. }
  59. });
  60. },
  61. goBack() {
  62. this.$router.back();
  63. },
  64. up: function() {
  65. this.step = this.step - 1;
  66. },
  67. save: function() {
  68. let that = this;
  69. if (this.userid) {
  70. this.items.forEach(it => {
  71. if (it.userid === this.userid) {
  72. var params = {
  73. uid: it.userid,
  74. uname: it.name,
  75. uphone: it.phone
  76. };
  77. this.$http.addMUser(params, this).then(res => {
  78. if (res.code === 0) {
  79. this.$message({
  80. message: "操作成功",
  81. type: "success",
  82. duration: 1000,
  83. onClose: function() {
  84. that.goBack();
  85. }
  86. });
  87. }
  88. });
  89. }
  90. });
  91. }
  92. }
  93. }
  94. };
  95. </script>
  96. <style scoped>
  97. .title {
  98. margin-bottom: 20px;
  99. }
  100. .alert {
  101. /* width: 500px; */
  102. }
  103. .hidden {
  104. display: none;
  105. }
  106. .next {
  107. text-align: center;
  108. margin-top: 20px;
  109. margin-bottom: 20px;
  110. }
  111. .page {
  112. height: 100%;
  113. width: 100%;
  114. display: flex;
  115. flex-direction: column;
  116. }
  117. .dataform {
  118. width: 100%;
  119. display: flex;
  120. flex-direction: column;
  121. }
  122. .dataform .alert {
  123. margin-bottom: 20px;
  124. width: 205px;
  125. }
  126. .dataform .el-input {
  127. width: 205px;
  128. }
  129. .dataform .next {
  130. width: 140px;
  131. }
  132. </style>