salesmanSelect.vue 3.9 KB

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