salesmanSelect.vue 3.6 KB

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