selectCustomer.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. uni.setStorageSync('selectedCustomers', JSON.stringify(this.selectedCustomers))
  205. // 跳转到下一步(积分设置)
  206. uni.navigateTo({
  207. url: '/pages_task/pointsSettings'
  208. })
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .container {
  215. min-height: 100vh;
  216. background: #F7F8FA;
  217. display: flex;
  218. flex-direction: column;
  219. &::before {
  220. content: '';
  221. position: absolute;
  222. top: 0;
  223. left: 0;
  224. right: 0;
  225. width: 100%;
  226. height: 544rpx;
  227. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  228. }
  229. }
  230. .step-container {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. background: #fff;
  235. padding: 32rpx 0;
  236. margin-bottom: 20rpx;
  237. .step-item {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. position: relative;
  242. .step-number {
  243. width: 48rpx;
  244. height: 48rpx;
  245. border-radius: 50%;
  246. background: #F2F3F5;
  247. color: #C8C9CC;
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. font-size: 28rpx;
  252. font-weight: 500;
  253. margin-bottom: 8rpx;
  254. transition: all 0.3s;
  255. &.active {
  256. background: #388BFF;
  257. color: #fff;
  258. }
  259. }
  260. .step-text {
  261. font-size: 28rpx;
  262. color: #C8C9CC;
  263. transition: all 0.3s;
  264. &.active {
  265. color: #388BFF;
  266. font-weight: 500;
  267. }
  268. }
  269. &.active {
  270. .step-number {
  271. background: #388BFF;
  272. color: #fff;
  273. }
  274. .step-text {
  275. color: #388BFF;
  276. font-weight: 500;
  277. }
  278. }
  279. }
  280. .step-divider {
  281. width: 80rpx;
  282. height: 2rpx;
  283. background: #EBEDF0;
  284. margin: 0 20rpx;
  285. }
  286. }
  287. .content {
  288. flex: 1;
  289. padding: 24rpx;
  290. box-sizing: border-box;
  291. padding-bottom: 200rpx;
  292. }
  293. .search-section {
  294. background-color: #ffffff;
  295. border-radius: 24rpx 24rpx 24rpx 24rpx;
  296. padding: 24rpx;
  297. margin-bottom: 24rpx;
  298. .section-title {
  299. font-size: 24rpx;
  300. color: #999999;
  301. margin-bottom: 24rpx;
  302. }
  303. .selected-tags {
  304. display: flex;
  305. flex-wrap: wrap;
  306. gap: 16rpx;
  307. .selected-tag {
  308. display: flex;
  309. align-items: center;
  310. border-radius: 76rpx 76rpx 76rpx 76rpx;
  311. border: 2rpx solid #F5F5F5;
  312. padding: 12rpx 24rpx;
  313. font-size: 28rpx;
  314. .tag-name {
  315. color: #333;
  316. margin-right: 8rpx;
  317. }
  318. .tag-remove {
  319. color: #C8C9CC;
  320. font-size: 36rpx;
  321. line-height: 1;
  322. cursor: pointer;
  323. }
  324. }
  325. }
  326. .search-input-wrapper {
  327. background: #F7F8FA;
  328. border-radius: 38rpx 38rpx 38rpx 38rpx;
  329. position: relative;
  330. display: flex;
  331. align-items: center;
  332. padding: 0 28rpx;
  333. height: 72rpx;
  334. margin-bottom: 24rpx;
  335. .search-icon {
  336. width: 36rpx;
  337. height: 36rpx;
  338. margin-right: 16rpx;
  339. }
  340. .search-input {
  341. flex: 1;
  342. height: 100%;
  343. font-size: 28rpx;
  344. color: #333;
  345. }
  346. .clear-icon {
  347. width: 32rpx;
  348. height: 32rpx;
  349. margin-left: 16rpx;
  350. }
  351. }
  352. }
  353. .customer-list {
  354. .customer-item {
  355. border-radius: 24rpx 24rpx 24rpx 24rpx;
  356. display: flex;
  357. align-items: center;
  358. justify-content: space-between;
  359. padding: 32rpx;
  360. margin-bottom: 12rpx;
  361. background-color: #ffffff;
  362. cursor: pointer;
  363. transition: all 0.3s;
  364. &.active {
  365. background: rgba(56,139,255,0.06);
  366. }
  367. &:last-child {
  368. margin-bottom: 0;
  369. }
  370. .left {
  371. display: flex;
  372. align-items: center;
  373. .head {
  374. width: 88rpx;
  375. height: 88rpx;
  376. border-radius: 50%;
  377. margin-right: 24rpx;
  378. }
  379. .customer-info {
  380. flex: 1;
  381. .customer-header {
  382. display: flex;
  383. align-items: center;
  384. margin-bottom: 12rpx;
  385. .customer-name {
  386. font-weight: 500;
  387. font-size: 32rpx;
  388. color: #333333;
  389. margin-right: 16rpx;
  390. }
  391. .customer-level {
  392. font-size: 24rpx;
  393. color: #C89743;
  394. background: #FFF6E5;
  395. border-radius: 8rpx;
  396. padding: 4rpx 12rpx;
  397. }
  398. }
  399. .customer-details {
  400. display: flex;
  401. align-items: center;
  402. .customer-hospital {
  403. font-size: 28rpx;
  404. color: #666;
  405. margin-right: 24rpx;
  406. border-right: 2rpx solid #EAEBEE;
  407. padding-right: 24rpx;
  408. }
  409. .customer-department {
  410. font-size: 28rpx;
  411. color: #666;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. }
  418. .bottom-bar {
  419. position: fixed;
  420. bottom: 0;
  421. left: 0;
  422. right: 0;
  423. background: #fff;
  424. padding: 24rpx 32rpx;
  425. border-top: 1rpx solid #F2F3F5;
  426. z-index: 100;
  427. display: flex;
  428. align-items: center;
  429. .del-box {
  430. display: flex;
  431. flex-direction: column;
  432. align-items: center;
  433. font-size: 24rpx;
  434. color: #666666;
  435. margin-right: 32rpx;
  436. cursor: pointer;
  437. }
  438. .action-buttons {
  439. display: flex;
  440. flex: 1;
  441. justify-content: space-between;
  442. .btn {
  443. width: 292rpx;
  444. height: 88rpx;
  445. display: flex;
  446. align-items: center;
  447. justify-content: center;
  448. font-size: 32rpx;
  449. font-weight: 500;
  450. border-radius: 200rpx 200rpx 200rpx 200rpx;
  451. cursor: pointer;
  452. &.btn-cancel {
  453. background: #fff;
  454. border: 2rpx solid #388BFF;
  455. color: #388BFF;
  456. }
  457. &.btn-submit {
  458. background: #388BFF;
  459. color: #fff;
  460. }
  461. }
  462. }
  463. }
  464. </style>