editSelectCustomer.vue 13 KB

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