pointsSettings.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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. export default {
  108. components: {
  109. Step
  110. },
  111. data() {
  112. return {currentText: [{
  113. id: 1,
  114. stepNumber: 1,
  115. title: '填写任务'
  116. },
  117. {
  118. id: 2,
  119. stepNumber: 2,
  120. title: '选择客户'
  121. },
  122. {
  123. id: 3,
  124. stepNumber: 3,
  125. title: '积分设置'
  126. }
  127. ],
  128. currentStep: 3,
  129. showOverview: false, // 控制概览弹窗显示
  130. customerList: [{
  131. id: 1,
  132. name: '王小明',
  133. integral: '30',
  134. placeholder: '请输入积分',
  135. disabled: false
  136. },
  137. {
  138. id: 2,
  139. name: '李洋',
  140. integral: '',
  141. placeholder: '请输入积分',
  142. disabled: false
  143. },
  144. {
  145. id: 3,
  146. name: '钱小燕',
  147. integral: '',
  148. placeholder: '请输入积分',
  149. disabled: false
  150. }
  151. ]
  152. }
  153. },
  154. computed: {
  155. totalIntegral() {
  156. let total = 0
  157. this.customerList.forEach(customer => {
  158. const integral = parseInt(customer.integral) || 0
  159. total += integral
  160. })
  161. return total
  162. }
  163. },
  164. methods: {
  165. // 显示概览弹窗
  166. showOverviewPopup() {
  167. this.showOverview = true
  168. },
  169. // 关闭概览弹窗
  170. closeOverviewPopup() {
  171. this.showOverview = false
  172. },
  173. clearIntegral(customer) {
  174. // 使用 $set 确保响应式更新
  175. this.$set(customer, 'integral', '')
  176. },
  177. onIntegralInput(customer) {
  178. // 积分输入验证
  179. if (customer.integral && parseInt(customer.integral) < 0) {
  180. this.$set(customer, 'integral', '0')
  181. }
  182. },
  183. handlePrev() {
  184. uni.navigateBack()
  185. },
  186. submit() {
  187. // 重命名方法为 submit 以匹配模板
  188. this.handleSubmit();
  189. uni.navigateTo({
  190. url: '/pages_task/success'
  191. })
  192. },
  193. handleSubmit() {
  194. // 验证所有客户积分是否已填写
  195. const emptyCustomers = this.customerList.filter(customer => !customer.integral || customer.integral === '')
  196. if (emptyCustomers.length > 0) {
  197. uni.showToast({
  198. icon: 'none',
  199. title: '请为所有客户设置积分'
  200. })
  201. return
  202. }
  203. // 验证积分是否为数字
  204. const invalidCustomers = this.customerList.filter(customer => {
  205. const integral = parseInt(customer.integral)
  206. return isNaN(integral) || integral < 0
  207. })
  208. if (invalidCustomers.length > 0) {
  209. uni.showToast({
  210. icon: 'none',
  211. title: '请输入有效的积分数值'
  212. })
  213. return
  214. }
  215. // 提交数据
  216. const taskData = {
  217. customers: this.customerList.map(customer => ({
  218. id: customer.id,
  219. name: customer.name,
  220. integral: parseInt(customer.integral)
  221. })),
  222. totalIntegral: this.totalIntegral
  223. }
  224. console.log('提交的任务数据:', taskData)
  225. // 显示提交成功提示
  226. uni.showToast({
  227. title: '任务创建成功',
  228. success: () => {
  229. // 延迟跳转,让用户看到成功提示
  230. setTimeout(() => {
  231. uni.navigateTo({
  232. url: '/pages_task/taskList'
  233. })
  234. }, 1500)
  235. }
  236. })
  237. },
  238. deleteSelected() {
  239. // 删除所有客户数据
  240. uni.showModal({
  241. title: '提示',
  242. content: '确定要删除所有客户数据吗?删除后不可恢复。',
  243. success: (res) => {
  244. if (res.confirm) {
  245. // 清空所有客户的积分数据
  246. this.customerList.forEach(customer => {
  247. this.$set(customer, 'integral', '')
  248. })
  249. uni.showToast({
  250. title: '已清空所有客户积分',
  251. icon: 'success'
  252. })
  253. }
  254. }
  255. })
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. .container {
  262. min-height: 100vh;
  263. background: #F7F8FA;
  264. display: flex;
  265. flex-direction: column;
  266. &::before {
  267. content: '';
  268. position: absolute;
  269. top: 0;
  270. left: 0;
  271. right: 0;
  272. width: 100%;
  273. height: 544rpx;
  274. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  275. }
  276. }
  277. .content {
  278. flex: 1;
  279. padding: 24rpx;
  280. box-sizing: border-box;
  281. padding-bottom: 200rpx;
  282. position: relative;
  283. }
  284. .integral-section {
  285. background-color: #ffffff;
  286. border-radius: 24rpx;
  287. padding: 32rpx 24rpx;
  288. margin-bottom: 24rpx;
  289. .section-header {
  290. display: flex;
  291. justify-content: space-between;
  292. align-items: center;
  293. margin-bottom: 32rpx;
  294. padding: 32rpx 0;
  295. background: #F5F9FF;
  296. border-radius: 16rpx;
  297. font-size: 28rpx;
  298. color: #666666;
  299. text-align: center;
  300. font-weight: 600;
  301. .section-title {
  302. flex: 1;
  303. }
  304. .section-subtitle {
  305. flex: 1;
  306. }
  307. }
  308. .integral-list {
  309. .integral-item {
  310. display: flex;
  311. justify-content: space-between;
  312. align-items: center;
  313. padding: 32rpx 0;
  314. border-bottom: 1rpx solid #F2F3F5;
  315. &:last-child {
  316. border-bottom: none;
  317. }
  318. .customer-info {
  319. flex: 1;
  320. text-align: center;
  321. .customer-name {
  322. font-size: 32rpx;
  323. font-weight: 500;
  324. color: #333333;
  325. }
  326. }
  327. .integral-input-wrapper {
  328. flex: 1;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. position: relative;
  333. .integral-input {
  334. width: 100%;
  335. font-size: 32rpx;
  336. color: #333333;
  337. text-align: center;
  338. padding: 12rpx 60rpx 12rpx 16rpx;
  339. background: #F7F8FA;
  340. border-radius: 8rpx;
  341. &::placeholder {
  342. color: #C8C9CC;
  343. font-size: 28rpx;
  344. text-align: center;
  345. }
  346. &:disabled {
  347. background: transparent;
  348. opacity: 0.8;
  349. }
  350. }
  351. .clear-icon-wrapper {
  352. position: absolute;
  353. right: 8rpx;
  354. width: 48rpx;
  355. height: 48rpx;
  356. display: flex;
  357. align-items: center;
  358. justify-content: center;
  359. z-index: 10;
  360. cursor: pointer;
  361. &:active {
  362. opacity: 0.6;
  363. }
  364. .clear-icon {
  365. width: 28rpx;
  366. height: 28rpx;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. }
  373. .suspension {
  374. position: fixed;
  375. text-align: center;
  376. line-height: 96rpx;
  377. right: 36rpx;
  378. top: 70%;
  379. width: 96rpx;
  380. height: 96rpx;
  381. background: linear-gradient(0deg, #388BFF 0%, #388BFF 100%);
  382. box-shadow: inset 0rpx 4rpx 8rpx 0rpx rgba(255, 255, 255, 0.25),
  383. inset 0rpx -6rpx 8rpx 0rpx rgba(255, 255, 255, 0.25),
  384. 4rpx 8rpx 12rpx 0rpx rgba(88, 144, 239, 0.29);
  385. border-radius: 110rpx;
  386. font-size: 28rpx;
  387. color: #FFFFFF;
  388. z-index: 999;
  389. cursor: pointer;
  390. &:active {
  391. opacity: 0.8;
  392. }
  393. }
  394. /* 概览弹窗样式 */
  395. .overview-popup {
  396. background-color: #fff;
  397. border-radius: 32rpx 32rpx 0 0;
  398. max-height: 80vh;
  399. overflow-y: auto;
  400. padding-bottom: env(safe-area-inset-bottom);
  401. }
  402. .popup-header {
  403. display: flex;
  404. justify-content: center;
  405. align-items: center;
  406. padding: 32rpx 40rpx;
  407. .popup-title {
  408. font-weight: 500;
  409. font-size: 32rpx;
  410. color: #333333;
  411. }
  412. .close-btn {
  413. width: 48rpx;
  414. height: 48rpx;
  415. display: flex;
  416. align-items: center;
  417. justify-content: center;
  418. cursor: pointer;
  419. position: absolute;
  420. right: 0;
  421. .close-icon {
  422. width: 44rpx;
  423. height: 44rpx;
  424. margin-right: 32rpx;
  425. flex-shrink: 0;
  426. }
  427. &:active {
  428. opacity: 0.6;
  429. }
  430. }
  431. }
  432. .overview-section {
  433. padding: 32rpx 40rpx;
  434. .row {
  435. display: flex;
  436. align-items: center;
  437. margin-bottom: 24rpx;
  438. &:last-child {
  439. border-bottom: none;
  440. }
  441. .line {
  442. width: 6rpx;
  443. height: 32rpx;
  444. background: #388BFF;
  445. border-radius: 36rpx;
  446. margin-right: 20rpx;
  447. }
  448. .section-title {
  449. font-size: 28rpx;
  450. font-weight: 600;
  451. color: #333333;
  452. }
  453. }
  454. .info-list {
  455. .info-item {
  456. display: flex;
  457. margin-bottom: 16rpx;
  458. align-items: flex-start;
  459. font-size: 28rpx;
  460. &:last-child {
  461. margin-bottom: 0;
  462. }
  463. .info-label {
  464. color: #999999;
  465. flex-shrink: 0;
  466. width: 140rpx;
  467. }
  468. .info-value {
  469. color: #333333;
  470. flex: 1;
  471. line-height: 1.4;
  472. }
  473. }
  474. }
  475. .customer-table {
  476. .table-header {
  477. display: flex;
  478. background: #F5F9FF;
  479. border-radius: 8rpx;
  480. padding: 20rpx 16rpx;
  481. margin-bottom: 8rpx;
  482. .table-cell {
  483. font-size: 24rpx;
  484. font-weight: 600;
  485. color: #666666;
  486. text-align: center;
  487. }
  488. }
  489. .table-body {
  490. .table-row {
  491. display: flex;
  492. padding: 20rpx 16rpx;
  493. border-bottom: 1rpx solid #F2F3F5;
  494. &:last-child {
  495. border-bottom: none;
  496. }
  497. .table-cell {
  498. font-size: 28rpx;
  499. color: #333333;
  500. text-align: center;
  501. &:first-child {
  502. font-weight: 500;
  503. }
  504. }
  505. }
  506. }
  507. }
  508. }
  509. .total-section {
  510. padding: 32rpx 40rpx;
  511. background: #F5F9FF;
  512. border-radius: 16rpx;
  513. margin: 24rpx 40rpx 40rpx;
  514. .total-item {
  515. display: flex;
  516. justify-content: space-between;
  517. align-items: center;
  518. margin-bottom: 16rpx;
  519. &:last-child {
  520. margin-bottom: 0;
  521. }
  522. .total-label {
  523. font-size: 28rpx;
  524. color: #666666;
  525. }
  526. .total-value {
  527. font-size: 28rpx;
  528. font-weight: 600;
  529. color: #388BFF;
  530. }
  531. }
  532. }
  533. .safe-area {
  534. height: env(safe-area-inset-bottom);
  535. }
  536. .bottom-bar {
  537. position: fixed;
  538. bottom: 0;
  539. left: 0;
  540. right: 0;
  541. background: #fff;
  542. padding: 24rpx 32rpx;
  543. border-top: 1rpx solid #F2F3F5;
  544. z-index: 100;
  545. display: flex;
  546. align-items: center;
  547. .del-box {
  548. display: flex;
  549. flex-direction: column;
  550. align-items: center;
  551. font-size: 24rpx;
  552. color: #666666;
  553. margin-right: 32rpx;
  554. cursor: pointer;
  555. &:active {
  556. opacity: 0.6;
  557. }
  558. }
  559. .action-buttons {
  560. display: flex;
  561. flex: 1;
  562. justify-content: space-between;
  563. .btn {
  564. width: 292rpx;
  565. height: 88rpx;
  566. display: flex;
  567. align-items: center;
  568. justify-content: center;
  569. font-size: 32rpx;
  570. font-weight: 500;
  571. border-radius: 200rpx 200rpx 200rpx 200rpx;
  572. cursor: pointer;
  573. &.btn-cancel {
  574. background: #fff;
  575. border: 2rpx solid #388BFF;
  576. color: #388BFF;
  577. }
  578. &.btn-submit {
  579. background: #388BFF;
  580. color: #fff;
  581. }
  582. }
  583. }
  584. }
  585. .w40 {
  586. width: 40rpx;
  587. }
  588. .h40 {
  589. height: 40rpx;
  590. }
  591. </style>