contacts.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div class="normal-panel scroll-panel" style="width: calc((100vh - 400px) / 2)">
  3. <div class="container" style="border-bottom:1px solid #f1f2f3;padding: 16px 16px 6px 16px">
  4. <!-- <el-form class="myform" size="small" inline label-position="right" :label-width="tool.onlyZh('50px')">
  5. <el-form-item :label="$t(`搜索`)">-->
  6. <!-- <el-input v-model="condition" prefix-icon="el-icon-search" :placeholder="$t(`联系人,手机号(全称)`)" @keyup.native.enter="search" @clear="clearSearch" clearable></el-input>-->
  7. <div class="inline-16 mt-10" >
  8. <span style="font-size: 14px;color: #606266;" class="inline-16">{{$t('搜索')}}</span>
  9. <el-input style="width:200px;" :placeholder="$t(`联系人,手机号`)" :suffix-icon="condition?condition.length > 0?'':'':'el-icon-search'" v-model="condition" @keyup.native.enter="search" @clear="clearSearch" size="small" class="input-with-select inline-16 layout_search__panel" clearable>
  10. </el-input>
  11. </div>
  12. <div class="inline-16 mt-10" >
  13. <span style="font-size: 14px;color: #606266;" class="inline-16" >{{$t('标签')}}</span>
  14. <el-select v-model="tag" :placeholder="$t('请选择标签')" size="small" @change="search" clearable @clear="clearSearch" filterable class="inline-16" multiple>
  15. <el-option
  16. v-for="item in tags"
  17. :key="item.index"
  18. :label="$t(item)"
  19. :value="item">
  20. </el-option>
  21. </el-select>
  22. </div>
  23. <div class="inline-16 mt-10">
  24. <el-button type="primary" size="small" @click="onReset" >{{$t('重置')}}</el-button>
  25. </div>
  26. <!-- </el-form-item>
  27. </el-form>-->
  28. </div>
  29. <div style="overflow: auto;height: calc(100vh - 260px);" v-if="data.length > 0" >
  30. <ul >
  31. <li @click="clickContacts(item)" :class="active === item.index?'act':''" class="container" v-for="item in data" :key="item.index">
  32. <div class="flex-align-stretch">
  33. <div class="avatar">
  34. {{item.name.substr(0, 1)}}
  35. </div>
  36. <div class="r-panel">
  37. <p>{{item.name}} <el-tag v-for="tag in item.tag1" :key="tag.index" :type="tag==='支持者'?'warning':tag==='反对者'?'danger':''" size="mini" style="margin:0 5px">{{$t(tag)}}</el-tag></p>
  38. <small class="color-grey"><i class="el-icon-mobile"></i>&nbsp;{{item.phonenumber}}&emsp;<i class="el-icon-collection-tag"></i>&nbsp;{{$t(item.groupname)}}</small>
  39. </div>
  40. </div>
  41. </li>
  42. </ul>
  43. </div>
  44. <!-- <div class="flex-align-center" v-if="data.phonebook && data.phonebook.length === 0">
  45. <el-empty :image-size="200" :description="$t(`暂无联系人`)"></el-empty>
  46. </div>-->
  47. <div class="flex-align-center" v-else>
  48. <el-empty :image-size="200" :description="$t(`暂无联系人`)"></el-empty>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. export default {
  54. props:['data','tags','editIndex','activeContactsData'],
  55. data () {
  56. return {
  57. active:0,
  58. condition:'',
  59. tag:[]
  60. }
  61. },
  62. watch: {
  63. data (val) {
  64. if (this.data.length > 0) {
  65. if (this.editIndex !== ''){
  66. this.active = this.editIndex
  67. let indexN = ''
  68. this.data.forEach((item,index)=>{
  69. if (item.index === this.editIndex){
  70. indexN = index
  71. return
  72. }
  73. })
  74. this.$emit('clickContacts',this.data[indexN])
  75. }else {
  76. this.active = this.data[0].index
  77. this.$emit('clickContacts',this.data[0])
  78. }
  79. }else {
  80. this.$emit('clickContacts','')
  81. }
  82. }
  83. },
  84. methods:{
  85. clickContacts (item) {
  86. this.active = item.index
  87. this.$emit('clickContacts',item)
  88. },
  89. search () {
  90. if (!this.tag){
  91. this.tag = []
  92. }
  93. var reg=/^\d{1,}$/
  94. var pattern = new RegExp(reg);
  95. if (this.condition){
  96. if (pattern.test(this.condition)) {
  97. this.$emit('filtetContacts','phonenumber',this.condition,this.tag)
  98. } else {
  99. this.$emit('filtetContacts','name',this.condition,this.tag)
  100. }
  101. }else {
  102. this.$emit('filtetContacts','close',this.condition,this.tag)
  103. }
  104. },
  105. clearSearch () {
  106. var reg=/^\d{1,}$/
  107. var pattern = new RegExp(reg);
  108. if (this.condition){
  109. if (pattern.test(this.condition)) {
  110. this.$emit('filtetContacts','phonenumber',this.condition,this.tag)
  111. } else {
  112. this.$emit('filtetContacts','name',this.condition,this.tag)
  113. }
  114. }else {
  115. this.$emit('filtetContacts','close',this.condition,this.tag)
  116. }
  117. /* this.$emit('filtetContacts','close',this.condition,this.tag)*/
  118. },
  119. onChange() {
  120. if (this.condition === '')
  121. return this.$emit('filtetContacts','close',this.condition,this.tag)
  122. },
  123. onReset(){
  124. this.condition = ''
  125. this.tag = []
  126. this.$emit('filtetContacts','reset',this.condition,this.tag)
  127. }
  128. },
  129. mounted () {
  130. }
  131. }
  132. </script>
  133. <style>
  134. .myform .el-form-item{
  135. margin-bottom: 0 !important;
  136. }
  137. </style>
  138. <style scoped>
  139. .scroll-panel{
  140. height: calc(100vh - 182px);
  141. overflow-y: scroll;
  142. }
  143. .scroll-panel::-webkit-scrollbar{
  144. display:none !important;
  145. }
  146. .normal-panel {
  147. border-right:1px solid #f1f2f3
  148. }
  149. .r-panel{
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: space-between;
  153. font-size: 14px;
  154. margin-left: 10px;
  155. }
  156. .color-grey{
  157. color:#999
  158. }
  159. li{
  160. transition: .2s linear all;
  161. cursor: pointer;
  162. }
  163. .act{
  164. background: #f1f2f3;
  165. }
  166. li:hover{
  167. background: #f1f2f3;
  168. }
  169. .flex-align-center{
  170. height: 100%;
  171. justify-content: space-around;
  172. }
  173. .avatar{
  174. width: 50px;
  175. height: 50px;
  176. text-align: center;
  177. line-height: 50px;
  178. font-size: 1.5rem;
  179. color:#fff;
  180. border-radius: 100%;
  181. background: #3874F6;
  182. }
  183. </style>