index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div>
  3. <!-- <el-input class="normal-margin" type="text" v-model="search" @keyup.native.enter="listData" suffix-icon="el-icon-search" size="small" placeholder="输入成员名称">
  4. <div slot="prepend">
  5. <el-tag type="info" size="mini" closable v-for="item in selected" :key="item.index">{{item.name}}</el-tag>
  6. </div>
  7. </el-input> -->
  8. <div class="search_input normal-margin">
  9. <div class="tag flex-align-center" type="primary" size="mini" closable v-for="item in selected" :key="item.index">
  10. <div class="avatar-mini">
  11. <img class="avatar__image" v-if="item.headpic" :src="item.headpic" alt="">
  12. <p v-else>{{item.name.substr(0, 1)}}</p>
  13. </div>
  14. <p class="inline-16">{{item.name}}</p>
  15. <b><i class="el-icon-close" @click="closeTag(item)"></i></b>
  16. </div>
  17. <input class="input_panel" type="text" v-model="search" @keyup.enter="listData" placeholder="输入搜索内容">
  18. </div>
  19. <div class="flex-align-stretch menber__panel">
  20. <div class="flex-align-center menber__item flex-between" :class="showSelelctIcon(item)?'active_menber__item':''" style="flex:1 0 auto" v-for="item in tableData" :key="item.index" @click="clickMenber(item)">
  21. <div class="flex-align-center">
  22. <div class="avatar inline-16">
  23. <img class="avatar__image" v-if="item.headpic" :src="item.headpic" alt="">
  24. <p v-else>{{item.name.substr(0, 1)}}</p>
  25. </div>
  26. <div>
  27. <p>{{ item.name }} &nbsp;<small style="color:#999999ad">{{item.username}}</small></p>
  28. <small style="color:#999999ad;margin-top:10px">部门:{{ item.depname?item.depname:"未知部门" }}&emsp;职位:{{ item.position?item.position:"未知部门" }}</small>
  29. </div>
  30. </div>
  31. <i class="el-icon-check iconCheck" v-if="showSelelctIcon(item)"></i>
  32. </div>
  33. </div>
  34. <el-empty v-if="tableData.length === 0" description="暂无数据" :image-size="40"></el-empty>
  35. <el-button size="mini" type="primary" style="margin-top:16px;float:right" @click="onSelect">确 定</el-button>
  36. <div style="margin-top:16px;text-align:left">
  37. <el-pagination
  38. background
  39. small
  40. @size-change="handleSizeChange"
  41. @current-change="handleCurrentChange"
  42. :current-page="currentPage"
  43. :page-size="param.content.pageSize"
  44. layout="total, prev, pager, next"
  45. :total="total">
  46. </el-pagination>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. export default {
  52. props:['param','radio','checked'],
  53. data () {
  54. return {
  55. search:'',
  56. tableData: [],
  57. total:0,
  58. currentPage:0,
  59. selected:[]
  60. }
  61. },
  62. components:{
  63. },
  64. methods:{
  65. async listData () {
  66. this.param.content.where.condition = this.search
  67. const res = await this.$api.requested(this.param)
  68. this.tableData = res.data
  69. this.total = res.total
  70. this.currentPage = res.pageNumber
  71. },
  72. handleSizeChange(val) {
  73. // console.log(`每页 ${val} 条`);
  74. this.param.content.pageSize = val
  75. this.listData()
  76. },
  77. handleCurrentChange(val) {
  78. // console.log(`当前页: ${val}`);
  79. this.param.content.pageNumber = val
  80. this.listData()
  81. },
  82. clickMenber (item) {
  83. if (this.radio) {
  84. this.selected = []
  85. }
  86. let _isSame = this.selected.some(m=>item.userid === m.userid)
  87. if (!_isSame) {
  88. this.selected.push(item)
  89. } else {
  90. this.selected = this.selected.filter(e=>{
  91. return e.userid !== item.userid
  92. })
  93. }
  94. },
  95. showSelelctIcon (item) {
  96. let _isSame = this.selected.some(m=>item.userid === m.userid)
  97. return _isSame
  98. },
  99. onSelect () {
  100. this.$emit('onSelect',this.selected)
  101. },
  102. closeTag (item) {
  103. this.selected = this.selected.filter(e=>{
  104. return e.userid !== item.userid
  105. })
  106. }
  107. },
  108. mounted () {
  109. this.listData()
  110. }
  111. }
  112. </script>
  113. <style>
  114. </style>
  115. <style scoped>
  116. .search_input{
  117. display: flex;
  118. align-items: center;
  119. flex-wrap: wrap;
  120. padding: 8px 8px 0 8px;
  121. border: 1px solid #f1f2f3;
  122. border-radius: 5px;
  123. }
  124. .input_panel{
  125. flex: 1;
  126. min-width: 100px;
  127. border:none;
  128. outline: none;
  129. margin-bottom: 8px;
  130. color:#666
  131. }
  132. .menber__item{
  133. width: calc(100% - 20px);
  134. padding:5px 10px;
  135. border-radius: 5px;
  136. cursor: pointer;
  137. color:#666;
  138. margin-bottom: 5px;
  139. transition: .2s linear;
  140. }
  141. .menber__item:hover{
  142. background: #b5e4ff6e;
  143. }
  144. .active_menber__item{
  145. background: #b5e4ff6e;
  146. }
  147. .menber__panel {
  148. max-height: 300px;
  149. overflow-y:scroll ;
  150. }
  151. .avatar{
  152. position: relative;
  153. height:30px;
  154. width: 30px;
  155. border-radius: 100%;
  156. text-align: center;
  157. line-height: 30px;
  158. color:#fff;
  159. font-weight: 500;
  160. background: #3874F6;
  161. cursor: pointer;
  162. overflow: hidden;
  163. }
  164. .avatar__image{
  165. height: 100%;
  166. width: 100%;
  167. }
  168. .avatar-mini{
  169. position: relative;
  170. height:20px;
  171. width: 20px;
  172. line-height: 20px;
  173. text-align: center;
  174. margin-right: 5px;
  175. color:#fff;
  176. font-size: 12px;
  177. font-weight: 500;
  178. border-radius: 100%;
  179. background: #3874F6;
  180. }
  181. .iconCheck{
  182. font-weight: bold;
  183. color:#3874F6
  184. }
  185. .tag{
  186. font-size: 12px;
  187. color:#666;
  188. padding: 5px;
  189. border-radius: 3px;
  190. margin:0 5px 8px 0;
  191. background: #b5e4ff6e;
  192. cursor: pointer;
  193. }
  194. </style>