salesmanSelect.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div class="salesmanSelect">
  3. <div class="search">
  4. <el-input v-model="searchValue" prefix-icon="Search" placeholder="请输入负责人姓名,工号,手机号查找" clearable></el-input>
  5. <el-button class="btn" link type="primary" @click="handleSearch">搜索</el-button>
  6. </div>
  7. <div class="salesman">
  8. <div class="salesman-item" :class="{'active': item.checked}" v-for="(item, index) in newList" @click="handleSelect(item, index)">
  9. <div class="content">
  10. <div class="name">
  11. <span>{{ item.name }}</span>
  12. <span>{{ item.mobile }}</span>
  13. </div>
  14. <div class="depart">
  15. {{ item.deptName }}
  16. </div>
  17. </div>
  18. <el-icon v-show="item.checked"><Check /></el-icon>
  19. </div>
  20. </div>
  21. <el-divider style="width: 100%"></el-divider>
  22. <div class="footer">
  23. <el-button plain @click="handleCancel">取消</el-button>
  24. <el-button type="primary" @click="handleConfirm">确定</el-button>
  25. </div>
  26. </div>
  27. </template>
  28. <script setup lang="ts">
  29. import {ElMessage} from "element-plus";
  30. import api from "@/api";
  31. const emits = defineEmits(['close'])
  32. let searchValue = ref('')
  33. let list = ref([])
  34. let newList = ref([])
  35. const handleSearch = () => {
  36. newList.value = list.value.filter(a => a.name.includes(searchValue.value))
  37. }
  38. // 选择
  39. let checkedItem = ref(null)
  40. const handleSelect = (item, index) => {
  41. let list = newList.value.filter(a => a.name != item.name)
  42. list.forEach(a => a.checked = false)
  43. item.checked = !item.checked
  44. checkedItem.value = item
  45. }
  46. // 取消
  47. const handleCancel = () => {
  48. emits('close', checkedItem.value)
  49. }
  50. // 确定
  51. const handleConfirm = () => {
  52. if(checkedItem.value) {
  53. emits('close', checkedItem.value)
  54. } else {
  55. ElMessage({
  56. message: '请选择业务员!',
  57. type: 'warning'
  58. })
  59. }
  60. }
  61. // 初始化
  62. const initData = () => {
  63. api.operationApi.operationList({
  64. isMember: 2,
  65. }).then((res: any) => {
  66. if(res.code == 200) {
  67. if(res.data.records) {
  68. res.data.records.forEach(item => {
  69. item.checked = false
  70. })
  71. }
  72. list.value = res.data.records
  73. newList.value = list.value
  74. } else {
  75. ElMessage({
  76. message: res.msg,
  77. type: 'error'
  78. })
  79. }
  80. })
  81. }
  82. // 编辑回显
  83. const initEditData = (data) => {
  84. }
  85. defineExpose({
  86. initEditData
  87. })
  88. onMounted(() => {
  89. initData()
  90. })
  91. </script>
  92. <style scoped lang="scss">
  93. .salesmanSelect{
  94. .search{
  95. width: 100%;
  96. position: relative;
  97. .btn{
  98. position: absolute;
  99. top: 6px;
  100. right: 10px;
  101. }
  102. }
  103. .salesman{
  104. max-height: 400px;
  105. overflow-y: auto;
  106. margin: 8px 0;
  107. .salesman-item{
  108. height: 64px;
  109. padding: 8px 12px;
  110. font-size: 14px;
  111. color: #333333;
  112. display: flex;
  113. align-items: center;
  114. justify-content: space-between;
  115. .name{
  116. display: flex;
  117. align-items: center;
  118. justify-content: flex-start;
  119. margin-bottom: 8px;
  120. span:nth-child(1) {
  121. font-size: 16px;
  122. color: black;
  123. width: 60px;
  124. }
  125. }
  126. &:hover{
  127. background: #F4FAFF;
  128. border-radius: 4px;
  129. }
  130. }
  131. .active{
  132. background: #F4FAFF;
  133. border-radius: 4px;
  134. }
  135. }
  136. .footer{
  137. display: flex;
  138. align-items: center;
  139. justify-content: center;
  140. }
  141. }
  142. </style>