index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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" style="margin-top:16px;float:right" @click="onCancel">取 消</el-button>
  36. <el-button size="mini" type="primary" style="margin-top:16px;float:right;margin-right:10px" @click="onSelect">确 定</el-button>
  37. <div style="margin-top:16px;text-align:left">
  38. <el-pagination
  39. background
  40. small
  41. @size-change="handleSizeChange"
  42. @current-change="handleCurrentChange"
  43. :current-page="currentPage"
  44. :page-size="param.content.pageSize"
  45. layout="total, prev, pager, next"
  46. :total="total">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. export default {
  53. props:['param','radio','checked','implement','justsaler'],
  54. data () {
  55. return {
  56. search:'',
  57. tableData: [],
  58. total:0,
  59. currentPage:0,
  60. selected:[]
  61. }
  62. },
  63. components:{
  64. },
  65. methods:{
  66. async listData () {
  67. this.param.content.where.justsaler = this.justsaler
  68. this.param.content.where.condition = this.search
  69. console.log(this.param,"查询团队")
  70. const res = await this.$api.requested(this.param)
  71. if (!this.radio) {
  72. res.data = res.data.filter(e=>{
  73. if (e.isteamleader !== 1 && e.userid !== this.implement)
  74. return e
  75. })
  76. }
  77. this.tableData = res.data
  78. console.log(this.implement)
  79. if (this.implement !== undefined && this.implement !== ''){
  80. this.total = res.total -1
  81. }else {
  82. this.total = res.total
  83. }
  84. this.currentPage = res.pageNumber
  85. },
  86. handleSizeChange(val) {
  87. // console.log(`每页 ${val} 条`);
  88. this.param.content.pageSize = val
  89. this.listData()
  90. },
  91. handleCurrentChange(val) {
  92. // console.log(`当前页: ${val}`);
  93. this.param.content.pageNumber = val
  94. this.listData()
  95. },
  96. clickMenber (item) {
  97. if (this.radio) {
  98. this.selected = []
  99. }
  100. let _isSame = this.selected.some(m=>item.userid === m.userid)
  101. if (!_isSame) {
  102. this.selected.push(item)
  103. } else {
  104. this.selected = this.selected.filter(e=>{
  105. return e.userid !== item.userid
  106. })
  107. }
  108. },
  109. showSelelctIcon (item) {
  110. let _isSame = this.selected.some(m=>item.userid === m.userid)
  111. return _isSame
  112. },
  113. onSelect () {
  114. this.$emit('onSelect',this.selected)
  115. },
  116. closeTag (item) {
  117. this.selected = this.selected.filter(e=>{
  118. return e.userid !== item.userid
  119. })
  120. },
  121. onCancel () {
  122. this.$emit('onCancel')
  123. }
  124. },
  125. mounted () {
  126. this.listData()
  127. }
  128. }
  129. </script>
  130. <style>
  131. </style>
  132. <style scoped>
  133. .search_input{
  134. display: flex;
  135. align-items: center;
  136. flex-wrap: wrap;
  137. padding: 8px 8px 0 8px;
  138. border: 1px solid #f1f2f3;
  139. border-radius: 5px;
  140. }
  141. .input_panel{
  142. flex: 1;
  143. min-width: 100px;
  144. border:none;
  145. outline: none;
  146. margin-bottom: 8px;
  147. color:#666
  148. }
  149. .menber__item{
  150. width: calc(100% - 20px);
  151. padding:5px 10px;
  152. border-radius: 5px;
  153. cursor: pointer;
  154. color:#666;
  155. margin-bottom: 5px;
  156. transition: .2s linear;
  157. }
  158. .menber__item:hover{
  159. background: #b5e4ff6e;
  160. }
  161. .active_menber__item{
  162. background: #b5e4ff6e;
  163. }
  164. .menber__panel {
  165. max-height: 300px;
  166. overflow-y:scroll ;
  167. }
  168. .avatar{
  169. position: relative;
  170. height:30px;
  171. width: 30px;
  172. border-radius: 100%;
  173. text-align: center;
  174. line-height: 30px;
  175. color:#fff;
  176. font-weight: 500;
  177. background: #3874F6;
  178. cursor: pointer;
  179. overflow: hidden;
  180. }
  181. .avatar__image{
  182. height: 100%;
  183. width: 100%;
  184. }
  185. .avatar-mini{
  186. position: relative;
  187. height:20px;
  188. width: 20px;
  189. line-height: 20px;
  190. text-align: center;
  191. margin-right: 5px;
  192. color:#fff;
  193. font-size: 12px;
  194. font-weight: 500;
  195. border-radius: 100%;
  196. background: #3874F6;
  197. }
  198. .iconCheck{
  199. font-weight: bold;
  200. color:#3874F6
  201. }
  202. .tag{
  203. font-size: 12px;
  204. color:#666;
  205. padding: 5px;
  206. border-radius: 3px;
  207. margin:0 5px 8px 0;
  208. background: #b5e4ff6e;
  209. cursor: pointer;
  210. }
  211. </style>