selectCustomer.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <view class="container">
  3. <Step :step="currentStep" :stepsData="currentText" />
  4. <scroll-view class="content" scroll-y>
  5. <!-- 搜索栏 -->
  6. <view class="search-section">
  7. <view class="search-input-wrapper">
  8. <image class="search-icon" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_search.png"></image>
  9. <input class="search-input" type="text" placeholder="输入客户名称" v-model="searchKeyword"
  10. @input="handleSearch" />
  11. <image class="clear-icon" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_clear.png" v-if="searchKeyword"
  12. @click="clearSearch"></image>
  13. </view>
  14. <view class="section-title">已选择 {{ selectedCustomers.length||'0' }} 人:</view>
  15. <view class="selected-tags">
  16. <view class="selected-tag" v-for="(customer, index) in selectedCustomers" :key="customer.id">
  17. <text class="tag-name">{{ customer.doctorName||'-' }}</text>
  18. <text class="tag-remove" @click="removeCustomer(customer.id)">×</text>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 已选择客户 -->
  23. <view class="selected-section">
  24. </view>
  25. <!-- 客户列表 -->
  26. <view class="customer-list">
  27. <view class="customer-item" :class="{ active: isSelected(customer.id) }"
  28. v-for="(customer, index) in filteredCustomers" :key="customer.id" @click="toggleCustomer(customer)">
  29. <view class="left">
  30. <image class="head" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/my_heads_icon.png"></image>
  31. <view class="customer-info">
  32. <view class="customer-header">
  33. <view class="customer-name">{{ customer.doctorName ||'-'}}</view>
  34. <view class="customer-level" v-if="customer.jobTitle">{{ customer.jobTitle }}</view>
  35. </view>
  36. <view class="customer-details">
  37. <view class="customer-hospital">{{ customer.cityName||'-' }}</view>
  38. <view class="customer-department">{{ customer.department ||'-'}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <checkbox :value="customer.id" :checked="isSelected(customer.id)" @click.stop="toggleCustomer(customer)"
  43. color="#388BFF" />
  44. </view>
  45. </view>
  46. </scroll-view>
  47. <!-- 底部操作栏 -->
  48. <view class="bottom-bar">
  49. <view class="del-box" @click="deleteSelected">
  50. <image class="w40 h40" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_delete.png"></image>
  51. <text>删除</text>
  52. </view>
  53. <view class="action-buttons">
  54. <view class="btn btn-cancel" @click="handlePrev">上一步</view>
  55. <view class="btn btn-submit" @click="handleNext">下一步</view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import { getAppliedList } from '@/api/task.js'
  62. import Step from '@/pages_task/components/step.vue'
  63. import { speakerList } from '@/api/speaker.js'
  64. export default {
  65. components: {
  66. Step
  67. },
  68. data() {
  69. return {
  70. currentText: [{
  71. id: 1,
  72. stepNumber: 1,
  73. title: '填写任务'
  74. },
  75. {
  76. id: 2,
  77. stepNumber: 2,
  78. title: '选择客户'
  79. },
  80. {
  81. id: 3,
  82. stepNumber: 3,
  83. title: '积分设置'
  84. }
  85. ],
  86. currentStep: 2,
  87. searchKeyword: '',
  88. selectedCustomers: [],
  89. customerList: [],
  90. loading: false,
  91. debounceTimer: null
  92. }
  93. },
  94. onLoad() {
  95. this.loadCustomerData()
  96. },
  97. computed: {
  98. filteredCustomers() {
  99. if (!this.searchKeyword.trim()) {
  100. return this.customerList
  101. }
  102. const keyword = this.searchKeyword.toLowerCase()
  103. return this.customerList.filter(customer =>
  104. (customer.doctorName && customer.doctorName.toLowerCase().includes(keyword)) ||
  105. (customer.cityName && customer.cityName.toLowerCase().includes(keyword)) ||
  106. (customer.department && customer.department.toLowerCase().includes(keyword))
  107. )
  108. }
  109. },
  110. methods: {
  111. async loadCustomerData() {
  112. try {
  113. this.loading = true
  114. let companyId=uni.getStorageSync('userInfo').companyId
  115. // getAppliedList 查询到 定义审核通过了的医生
  116. const res = await getAppliedList(companyId)
  117. if (res.code === 200 && res.rows) {
  118. // 将接口返回的数据映射为页面需要的格式
  119. this.customerList = res.rows;
  120. }
  121. } catch (error) {
  122. console.error('获取客户数据失败:', error)
  123. uni.showToast({
  124. icon: 'none',
  125. title: '获取客户数据失败'
  126. })
  127. } finally {
  128. this.loading = false
  129. }
  130. },
  131. handleSearch() {
  132. // 清除之前的定时器
  133. if (this.debounceTimer) {
  134. clearTimeout(this.debounceTimer)
  135. }
  136. // 设置新的定时器,500毫秒后执行搜索
  137. this.debounceTimer = setTimeout(() => {
  138. // 搜索逻辑已经在computed中处理,这里可以添加额外的搜索逻辑
  139. console.log('执行搜索:', this.searchKeyword)
  140. }, 500)
  141. },
  142. clearSearch() {
  143. this.searchKeyword = ''
  144. },
  145. isSelected(customerId) {
  146. return this.selectedCustomers.some(customer => customer.id === customerId)
  147. },
  148. toggleCustomer(customer) {
  149. const index = this.selectedCustomers.findIndex(item => item.id === customer.id)
  150. if (index > -1) {
  151. // 已选中,移除
  152. this.selectedCustomers.splice(index, 1)
  153. } else {
  154. // 未选中,添加
  155. this.selectedCustomers.push(customer)
  156. }
  157. },
  158. removeCustomer(customerId) {
  159. const index = this.selectedCustomers.findIndex(item => item.id === customerId)
  160. if (index > -1) {
  161. this.selectedCustomers.splice(index, 1)
  162. }
  163. },
  164. deleteSelected() {
  165. if (this.selectedCustomers.length === 0) {
  166. uni.showToast({
  167. icon: 'none',
  168. title: '请先选择要删除的客户'
  169. })
  170. return
  171. }
  172. // 这里可以添加删除逻辑,比如从列表中移除已选中的客户
  173. uni.showModal({
  174. title: '提示',
  175. content: `确定要删除选中的 ${this.selectedCustomers.length} 个客户吗?`,
  176. success: (res) => {
  177. if (res.confirm) {
  178. // 从客户列表中移除已选中的客户
  179. const selectedIds = this.selectedCustomers.map(item => item.id)
  180. this.customerList = this.customerList.filter(
  181. customer => !selectedIds.includes(customer.id)
  182. )
  183. // 清空已选中的客户
  184. this.selectedCustomers = []
  185. uni.showToast({
  186. title: '删除成功'
  187. })
  188. }
  189. }
  190. })
  191. },
  192. handlePrev() {
  193. uni.navigateBack()
  194. },
  195. handleNext() {
  196. if (this.selectedCustomers.length === 0) {
  197. uni.showToast({
  198. icon: 'none',
  199. title: '请至少选择一个客户'
  200. })
  201. return
  202. }
  203. // 保存选中的客户到本地存储,以便pointsSettings.vue获取
  204. const enhanced = this.selectedCustomers.map(item => ({
  205. ...item,
  206. mobile: item.mobile||''
  207. }))
  208. uni.setStorageSync('selectedCustomers', JSON.stringify(enhanced))
  209. // 跳转到下一步(积分设置)
  210. uni.navigateTo({
  211. url: '/pages_task/pointsSettings'
  212. })
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .container {
  219. min-height: 100vh;
  220. background: #F7F8FA;
  221. display: flex;
  222. flex-direction: column;
  223. &::before {
  224. content: '';
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. right: 0;
  229. width: 100%;
  230. height: 544rpx;
  231. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  232. }
  233. }
  234. .step-container {
  235. display: flex;
  236. align-items: center;
  237. justify-content: center;
  238. background: #fff;
  239. padding: 32rpx 0;
  240. margin-bottom: 20rpx;
  241. .step-item {
  242. display: flex;
  243. flex-direction: column;
  244. align-items: center;
  245. position: relative;
  246. .step-number {
  247. width: 48rpx;
  248. height: 48rpx;
  249. border-radius: 50%;
  250. background: #F2F3F5;
  251. color: #C8C9CC;
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. font-size: 28rpx;
  256. font-weight: 500;
  257. margin-bottom: 8rpx;
  258. transition: all 0.3s;
  259. &.active {
  260. background: #388BFF;
  261. color: #fff;
  262. }
  263. }
  264. .step-text {
  265. font-size: 28rpx;
  266. color: #C8C9CC;
  267. transition: all 0.3s;
  268. &.active {
  269. color: #388BFF;
  270. font-weight: 500;
  271. }
  272. }
  273. &.active {
  274. .step-number {
  275. background: #388BFF;
  276. color: #fff;
  277. }
  278. .step-text {
  279. color: #388BFF;
  280. font-weight: 500;
  281. }
  282. }
  283. }
  284. .step-divider {
  285. width: 80rpx;
  286. height: 2rpx;
  287. background: #EBEDF0;
  288. margin: 0 20rpx;
  289. }
  290. }
  291. .content {
  292. flex: 1;
  293. padding: 24rpx;
  294. box-sizing: border-box;
  295. padding-bottom: 200rpx;
  296. }
  297. .search-section {
  298. background-color: #ffffff;
  299. border-radius: 24rpx 24rpx 24rpx 24rpx;
  300. padding: 24rpx;
  301. margin-bottom: 24rpx;
  302. .section-title {
  303. font-size: 24rpx;
  304. color: #999999;
  305. margin-bottom: 24rpx;
  306. }
  307. .selected-tags {
  308. display: flex;
  309. flex-wrap: wrap;
  310. gap: 16rpx;
  311. .selected-tag {
  312. display: flex;
  313. align-items: center;
  314. border-radius: 76rpx 76rpx 76rpx 76rpx;
  315. border: 2rpx solid #F5F5F5;
  316. padding: 12rpx 24rpx;
  317. font-size: 28rpx;
  318. .tag-name {
  319. color: #333;
  320. margin-right: 8rpx;
  321. }
  322. .tag-remove {
  323. color: #C8C9CC;
  324. font-size: 36rpx;
  325. line-height: 1;
  326. cursor: pointer;
  327. }
  328. }
  329. }
  330. .search-input-wrapper {
  331. background: #F7F8FA;
  332. border-radius: 38rpx 38rpx 38rpx 38rpx;
  333. position: relative;
  334. display: flex;
  335. align-items: center;
  336. padding: 0 28rpx;
  337. height: 72rpx;
  338. margin-bottom: 24rpx;
  339. .search-icon {
  340. width: 36rpx;
  341. height: 36rpx;
  342. margin-right: 16rpx;
  343. }
  344. .search-input {
  345. flex: 1;
  346. height: 100%;
  347. font-size: 28rpx;
  348. color: #333;
  349. }
  350. .clear-icon {
  351. width: 32rpx;
  352. height: 32rpx;
  353. margin-left: 16rpx;
  354. }
  355. }
  356. }
  357. .customer-list {
  358. .customer-item {
  359. border-radius: 24rpx 24rpx 24rpx 24rpx;
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. padding: 32rpx;
  364. margin-bottom: 12rpx;
  365. background-color: #ffffff;
  366. cursor: pointer;
  367. transition: all 0.3s;
  368. &.active {
  369. background: rgba(56,139,255,0.06);
  370. }
  371. &:last-child {
  372. margin-bottom: 0;
  373. }
  374. .left {
  375. display: flex;
  376. align-items: center;
  377. .head {
  378. width: 88rpx;
  379. height: 88rpx;
  380. border-radius: 50%;
  381. margin-right: 24rpx;
  382. }
  383. .customer-info {
  384. flex: 1;
  385. .customer-header {
  386. display: flex;
  387. align-items: center;
  388. margin-bottom: 12rpx;
  389. .customer-name {
  390. font-weight: 500;
  391. font-size: 32rpx;
  392. color: #333333;
  393. margin-right: 16rpx;
  394. }
  395. .customer-level {
  396. font-size: 24rpx;
  397. color: #C89743;
  398. background: #FFF6E5;
  399. border-radius: 8rpx;
  400. padding: 4rpx 12rpx;
  401. }
  402. }
  403. .customer-details {
  404. display: flex;
  405. align-items: center;
  406. .customer-hospital {
  407. font-size: 28rpx;
  408. color: #666;
  409. margin-right: 24rpx;
  410. border-right: 2rpx solid #EAEBEE;
  411. padding-right: 24rpx;
  412. }
  413. .customer-department {
  414. font-size: 28rpx;
  415. color: #666;
  416. }
  417. }
  418. }
  419. }
  420. }
  421. }
  422. .bottom-bar {
  423. position: fixed;
  424. bottom: 0;
  425. left: 0;
  426. right: 0;
  427. background: #fff;
  428. padding: 24rpx 32rpx;
  429. border-top: 1rpx solid #F2F3F5;
  430. z-index: 100;
  431. display: flex;
  432. align-items: center;
  433. .del-box {
  434. display: flex;
  435. flex-direction: column;
  436. align-items: center;
  437. font-size: 24rpx;
  438. color: #666666;
  439. margin-right: 32rpx;
  440. cursor: pointer;
  441. }
  442. .action-buttons {
  443. display: flex;
  444. flex: 1;
  445. justify-content: space-between;
  446. .btn {
  447. width: 292rpx;
  448. height: 88rpx;
  449. display: flex;
  450. align-items: center;
  451. justify-content: center;
  452. font-size: 32rpx;
  453. font-weight: 500;
  454. border-radius: 200rpx 200rpx 200rpx 200rpx;
  455. cursor: pointer;
  456. &.btn-cancel {
  457. background: #fff;
  458. border: 2rpx solid #388BFF;
  459. color: #388BFF;
  460. }
  461. &.btn-submit {
  462. background: #388BFF;
  463. color: #fff;
  464. }
  465. }
  466. }
  467. }
  468. </style>