pointsSettings.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <template>
  2. <view class="container">
  3. <Step :step="currentStep" :stepsData="currentText" />
  4. <scroll-view class="content" scroll-y>
  5. <!-- 客户积分设置列表 -->
  6. <view class="integral-section">
  7. <view class="section-header">
  8. <view class="section-title">客户姓名</view>
  9. <view class="section-subtitle">积分数值</view>
  10. </view>
  11. <view class="integral-list">
  12. <view class="integral-item" v-for="(customer, index) in customerList" :key="customer.id">
  13. <view class="customer-info">
  14. <view class="customer-name">{{ customer.name }}</view>
  15. </view>
  16. <view class="integral-input-wrapper">
  17. <input class="integral-input" type="number" :placeholder="customer.placeholder"
  18. v-model="customer.integral" :disabled="customer.disabled"
  19. @input="onIntegralInput(customer)" />
  20. <view v-if="customer.integral" class="clear-icon-wrapper"
  21. @click.stop="clearIntegral(customer)">
  22. <image class="clear-icon" src="/static/image/icon_clear.png"></image>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. <!-- 概览悬浮按钮 -->
  30. <view class="suspension" @click="showOverviewPopup">概览</view>
  31. <!-- 概览弹窗 -->
  32. <!-- :show="showOverview" -->
  33. <u-popup :show="showOverview" mode="bottom" @close="closeOverviewPopup" round="20" :safeAreaInsetBottom="true">
  34. <view class="overview-popup">
  35. <!-- 弹窗头部 -->
  36. <view class="popup-header">
  37. <text class="popup-title">概览</text>
  38. <view class="close-btn" @click="closeOverviewPopup">
  39. <image class="close-icon" src="/static/image/icon_close.png"></image>
  40. </view>
  41. </view>
  42. <!-- 任务信息 -->
  43. <view class="overview-section">
  44. <view class="row">
  45. <text class="line"></text>
  46. <view class="section-title">任务信息</view>
  47. </view>
  48. <view class="info-list">
  49. <view class="info-item">
  50. <view class="info-label">项目归属:</view>
  51. <view class="info-value">湖南省药学服务公司</view>
  52. </view>
  53. <view class="info-item">
  54. <view class="info-label">项目任务:</view>
  55. <view class="info-value">科普文章</view>
  56. </view>
  57. <view class="info-item">
  58. <view class="info-label">项目时间:</view>
  59. <view class="info-value">2025/11/19 14:12~2025/11/19 14:12</view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 客户信息 -->
  64. <view class="overview-section">
  65. <view class="row">
  66. <text class="line"></text>
  67. <view class="section-title">客户信息</view>
  68. </view>
  69. <view class="customer-table">
  70. <!-- 表头 -->
  71. <view class="table-header">
  72. <view class="table-cell" style="flex: 1.5;">姓名</view>
  73. <view class="table-cell" style="flex: 1;">级别</view>
  74. <view class="table-cell" style="flex: 1;">积分</view>
  75. <view class="table-cell" style="flex: 2;">联系方式</view>
  76. </view>
  77. <!-- 表格内容 -->
  78. <view class="table-body">
  79. <view class="table-row" v-for="(customer, index) in customerList" :key="customer.id">
  80. <view class="table-cell" style="flex: 1.5;">{{ customer.name }}</view>
  81. <view class="table-cell" style="flex: 1;">一级</view>
  82. <view class="table-cell" style="flex: 1;">{{ customer.integral || '0' }}</view>
  83. <view class="table-cell" style="flex: 2;">177****4235</view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 安全区域占位 -->
  89. <view class="safe-area"></view>
  90. </view>
  91. </u-popup>
  92. <!-- 底部操作栏 -->
  93. <view class="bottom-bar">
  94. <view class="del-box" @click="deleteSelected">
  95. <image class="w40 h40" src="/static/image/icon_delete.png"></image>
  96. <text>删除</text>
  97. </view>
  98. <view class="action-buttons">
  99. <view class="btn btn-cancel" @click="handlePrev">上一步</view>
  100. <view class="btn btn-submit" @click="submit">提交</view>
  101. </view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import Step from '@/pages_task/components/step.vue'
  107. import { addInfo} from '@/api/task.js';
  108. export default {
  109. components: {
  110. Step
  111. },
  112. data() {
  113. return {
  114. currentText: [{
  115. id: 1,
  116. stepNumber: 1,
  117. title: '填写任务'
  118. },
  119. {
  120. id: 2,
  121. stepNumber: 2,
  122. title: '选择客户'
  123. },
  124. {
  125. id: 3,
  126. stepNumber: 3,
  127. title: '积分设置'
  128. }
  129. ],
  130. currentStep: 3,
  131. showOverview: false, // 控制概览弹窗显示
  132. customerList: []
  133. }
  134. },
  135. onLoad() {
  136. // 从本地存储中获取选中的客户数据
  137. const selectedCustomersStr = uni.getStorageSync('selectedCustomers')
  138. if (selectedCustomersStr) {
  139. const selectedCustomers = JSON.parse(selectedCustomersStr)
  140. // 将选中的客户数据转换为积分设置需要的格式
  141. this.customerList = selectedCustomers.map(customer => ({
  142. id: customer.id,
  143. name: customer.doctorName || '未知姓名',
  144. doctorName: customer.doctorName || '未知姓名',
  145. integral: '',
  146. placeholder: '请输入积分',
  147. disabled: false
  148. }))
  149. }
  150. },
  151. computed: {
  152. totalIntegral() {
  153. let total = 0
  154. this.customerList.forEach(customer => {
  155. const integral = parseInt(customer.integral) || 0
  156. total += integral
  157. })
  158. return total
  159. }
  160. },
  161. methods: {
  162. // 显示概览弹窗
  163. showOverviewPopup() {
  164. this.showOverview = true
  165. },
  166. // 关闭概览弹窗
  167. closeOverviewPopup() {
  168. this.showOverview = false
  169. },
  170. clearIntegral(customer) {
  171. // 使用 $set 确保响应式更新
  172. this.$set(customer, 'integral', '')
  173. },
  174. onIntegralInput(customer) {
  175. // 积分输入验证
  176. if (customer.integral && parseInt(customer.integral) < 0) {
  177. this.$set(customer, 'integral', '0')
  178. }
  179. },
  180. handlePrev() {
  181. uni.navigateBack()
  182. },
  183. submit() {
  184. // 验证所有客户积分是否已填写
  185. const emptyCustomers = this.customerList.filter(customer => !customer.integral || customer.integral === '')
  186. if (emptyCustomers.length > 0) {
  187. uni.showToast({
  188. icon: 'none',
  189. title: '请为所有客户设置积分'
  190. })
  191. return
  192. }
  193. // 验证积分是否为数字
  194. const invalidCustomers = this.customerList.filter(customer => {
  195. const integral = parseInt(customer.integral)
  196. return isNaN(integral) || integral < 0
  197. })
  198. if (invalidCustomers.length > 0) {
  199. uni.showToast({
  200. icon: 'none',
  201. title: '请输入有效的积分数值'
  202. })
  203. return
  204. }
  205. // 获取所有三个页面的数据
  206. const taskFormDataStr = uni.getStorageSync('taskFormData')
  207. const selectedCustomersStr = uni.getStorageSync('selectedCustomers')
  208. const taskFormData = taskFormDataStr ? JSON.parse(taskFormDataStr) : {}
  209. const selectedCustomers = selectedCustomersStr ? JSON.parse(selectedCustomersStr) : []
  210. // 构建提交数据
  211. const taskData = {
  212. // 任务基本信息
  213. ...taskFormData,
  214. // 客户信息和积分
  215. customers: this.customerList.map(customer => ({
  216. id: customer.id,
  217. name: customer.name,
  218. doctorName: customer.doctorName,
  219. integral: parseInt(customer.integral)
  220. })),
  221. // 总积分
  222. totalIntegral: this.totalIntegral,
  223. // 选中的原始客户数据
  224. selectedCustomers: selectedCustomers
  225. }
  226. console.log('提交的任务数据:', taskData)
  227. // 调用addInfo接口提交表单
  228. uni.showLoading({
  229. title: '提交中...'
  230. })
  231. addInfo(taskData).then(res => {
  232. uni.hideLoading()
  233. if (res.code === 200) {
  234. // 清除本地存储的数据
  235. uni.removeStorageSync('taskFormData')
  236. uni.removeStorageSync('selectedCustomers')
  237. // 显示提交成功提示
  238. uni.showToast({
  239. title: '任务创建成功',
  240. success: () => {
  241. // 延迟跳转,让用户看到成功提示
  242. setTimeout(() => {
  243. uni.navigateTo({
  244. url: '/pages_task/taskList'
  245. })
  246. }, 1500)
  247. }
  248. })
  249. } else {
  250. uni.showToast({
  251. icon: 'none',
  252. title: res.message || '提交失败'
  253. })
  254. }
  255. }).catch(err => {
  256. uni.hideLoading()
  257. uni.showToast({
  258. icon: 'none',
  259. title: '网络错误,请重试'
  260. })
  261. })
  262. },
  263. deleteSelected() {
  264. // 删除所有客户数据
  265. uni.showModal({
  266. title: '提示',
  267. content: '确定要删除所有客户数据吗?删除后不可恢复。',
  268. success: (res) => {
  269. if (res.confirm) {
  270. // 清空所有客户的积分数据
  271. this.customerList.forEach(customer => {
  272. this.$set(customer, 'integral', '')
  273. })
  274. uni.showToast({
  275. title: '已清空所有客户积分',
  276. icon: 'success'
  277. })
  278. }
  279. }
  280. })
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. .container {
  287. min-height: 100vh;
  288. background: #F7F8FA;
  289. display: flex;
  290. flex-direction: column;
  291. &::before {
  292. content: '';
  293. position: absolute;
  294. top: 0;
  295. left: 0;
  296. right: 0;
  297. width: 100%;
  298. height: 544rpx;
  299. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  300. }
  301. }
  302. .content {
  303. flex: 1;
  304. padding: 24rpx;
  305. box-sizing: border-box;
  306. padding-bottom: 200rpx;
  307. position: relative;
  308. }
  309. .integral-section {
  310. background-color: #ffffff;
  311. border-radius: 24rpx;
  312. padding: 32rpx 24rpx;
  313. margin-bottom: 24rpx;
  314. .section-header {
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. margin-bottom: 32rpx;
  319. padding: 32rpx 0;
  320. background: #F5F9FF;
  321. border-radius: 16rpx;
  322. font-size: 28rpx;
  323. color: #666666;
  324. text-align: center;
  325. font-weight: 600;
  326. .section-title {
  327. flex: 1;
  328. }
  329. .section-subtitle {
  330. flex: 1;
  331. }
  332. }
  333. .integral-list {
  334. .integral-item {
  335. display: flex;
  336. justify-content: space-between;
  337. align-items: center;
  338. padding: 32rpx 0;
  339. border-bottom: 1rpx solid #F2F3F5;
  340. &:last-child {
  341. border-bottom: none;
  342. }
  343. .customer-info {
  344. flex: 1;
  345. text-align: center;
  346. .customer-name {
  347. font-size: 32rpx;
  348. font-weight: 500;
  349. color: #333333;
  350. }
  351. }
  352. .integral-input-wrapper {
  353. flex: 1;
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. position: relative;
  358. .integral-input {
  359. width: 100%;
  360. font-size: 32rpx;
  361. color: #333333;
  362. text-align: center;
  363. padding: 12rpx 60rpx 12rpx 16rpx;
  364. background: #F7F8FA;
  365. border-radius: 8rpx;
  366. &::placeholder {
  367. color: #C8C9CC;
  368. font-size: 28rpx;
  369. text-align: center;
  370. }
  371. &:disabled {
  372. background: transparent;
  373. opacity: 0.8;
  374. }
  375. }
  376. .clear-icon-wrapper {
  377. position: absolute;
  378. right: 8rpx;
  379. width: 48rpx;
  380. height: 48rpx;
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. z-index: 10;
  385. cursor: pointer;
  386. &:active {
  387. opacity: 0.6;
  388. }
  389. .clear-icon {
  390. width: 28rpx;
  391. height: 28rpx;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .suspension {
  399. position: fixed;
  400. text-align: center;
  401. line-height: 96rpx;
  402. right: 36rpx;
  403. top: 70%;
  404. width: 96rpx;
  405. height: 96rpx;
  406. background: linear-gradient(0deg, #388BFF 0%, #388BFF 100%);
  407. box-shadow: inset 0rpx 4rpx 8rpx 0rpx rgba(255, 255, 255, 0.25),
  408. inset 0rpx -6rpx 8rpx 0rpx rgba(255, 255, 255, 0.25),
  409. 4rpx 8rpx 12rpx 0rpx rgba(88, 144, 239, 0.29);
  410. border-radius: 110rpx;
  411. font-size: 28rpx;
  412. color: #FFFFFF;
  413. z-index: 999;
  414. cursor: pointer;
  415. &:active {
  416. opacity: 0.8;
  417. }
  418. }
  419. /* 概览弹窗样式 */
  420. .overview-popup {
  421. background-color: #fff;
  422. border-radius: 32rpx 32rpx 0 0;
  423. max-height: 80vh;
  424. overflow-y: auto;
  425. padding-bottom: env(safe-area-inset-bottom);
  426. }
  427. .popup-header {
  428. display: flex;
  429. justify-content: center;
  430. align-items: center;
  431. padding: 32rpx 40rpx;
  432. .popup-title {
  433. font-weight: 500;
  434. font-size: 32rpx;
  435. color: #333333;
  436. }
  437. .close-btn {
  438. width: 48rpx;
  439. height: 48rpx;
  440. display: flex;
  441. align-items: center;
  442. justify-content: center;
  443. cursor: pointer;
  444. position: absolute;
  445. right: 0;
  446. .close-icon {
  447. width: 44rpx;
  448. height: 44rpx;
  449. margin-right: 32rpx;
  450. flex-shrink: 0;
  451. }
  452. &:active {
  453. opacity: 0.6;
  454. }
  455. }
  456. }
  457. .overview-section {
  458. padding: 32rpx 40rpx;
  459. .row {
  460. display: flex;
  461. align-items: center;
  462. margin-bottom: 24rpx;
  463. &:last-child {
  464. border-bottom: none;
  465. }
  466. .line {
  467. width: 6rpx;
  468. height: 32rpx;
  469. background: #388BFF;
  470. border-radius: 36rpx;
  471. margin-right: 20rpx;
  472. }
  473. .section-title {
  474. font-size: 28rpx;
  475. font-weight: 600;
  476. color: #333333;
  477. }
  478. }
  479. .info-list {
  480. .info-item {
  481. display: flex;
  482. margin-bottom: 16rpx;
  483. align-items: flex-start;
  484. font-size: 28rpx;
  485. &:last-child {
  486. margin-bottom: 0;
  487. }
  488. .info-label {
  489. color: #999999;
  490. flex-shrink: 0;
  491. width: 140rpx;
  492. }
  493. .info-value {
  494. color: #333333;
  495. flex: 1;
  496. line-height: 1.4;
  497. }
  498. }
  499. }
  500. .customer-table {
  501. .table-header {
  502. display: flex;
  503. background: #F5F9FF;
  504. border-radius: 8rpx;
  505. padding: 20rpx 16rpx;
  506. margin-bottom: 8rpx;
  507. .table-cell {
  508. font-size: 24rpx;
  509. font-weight: 600;
  510. color: #666666;
  511. text-align: center;
  512. }
  513. }
  514. .table-body {
  515. .table-row {
  516. display: flex;
  517. padding: 20rpx 16rpx;
  518. border-bottom: 1rpx solid #F2F3F5;
  519. &:last-child {
  520. border-bottom: none;
  521. }
  522. .table-cell {
  523. font-size: 28rpx;
  524. color: #333333;
  525. text-align: center;
  526. &:first-child {
  527. font-weight: 500;
  528. }
  529. }
  530. }
  531. }
  532. }
  533. }
  534. .total-section {
  535. padding: 32rpx 40rpx;
  536. background: #F5F9FF;
  537. border-radius: 16rpx;
  538. margin: 24rpx 40rpx 40rpx;
  539. .total-item {
  540. display: flex;
  541. justify-content: space-between;
  542. align-items: center;
  543. margin-bottom: 16rpx;
  544. &:last-child {
  545. margin-bottom: 0;
  546. }
  547. .total-label {
  548. font-size: 28rpx;
  549. color: #666666;
  550. }
  551. .total-value {
  552. font-size: 28rpx;
  553. font-weight: 600;
  554. color: #388BFF;
  555. }
  556. }
  557. }
  558. .safe-area {
  559. height: env(safe-area-inset-bottom);
  560. }
  561. .bottom-bar {
  562. position: fixed;
  563. bottom: 0;
  564. left: 0;
  565. right: 0;
  566. background: #fff;
  567. padding: 24rpx 32rpx;
  568. border-top: 1rpx solid #F2F3F5;
  569. z-index: 100;
  570. display: flex;
  571. align-items: center;
  572. .del-box {
  573. display: flex;
  574. flex-direction: column;
  575. align-items: center;
  576. font-size: 24rpx;
  577. color: #666666;
  578. margin-right: 32rpx;
  579. cursor: pointer;
  580. &:active {
  581. opacity: 0.6;
  582. }
  583. }
  584. .action-buttons {
  585. display: flex;
  586. flex: 1;
  587. justify-content: space-between;
  588. .btn {
  589. width: 292rpx;
  590. height: 88rpx;
  591. display: flex;
  592. align-items: center;
  593. justify-content: center;
  594. font-size: 32rpx;
  595. font-weight: 500;
  596. border-radius: 200rpx 200rpx 200rpx 200rpx;
  597. cursor: pointer;
  598. &.btn-cancel {
  599. background: #fff;
  600. border: 2rpx solid #388BFF;
  601. color: #388BFF;
  602. }
  603. &.btn-submit {
  604. background: #388BFF;
  605. color: #fff;
  606. }
  607. }
  608. }
  609. }
  610. .w40 {
  611. width: 40rpx;
  612. }
  613. .h40 {
  614. height: 40rpx;
  615. }
  616. </style>