pointsSettings.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  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="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/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="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/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="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/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 userInfoStr = uni.getStorageSync('userInfo')
  212. const userInfo = userInfoStr ? JSON.parse(userInfoStr) : {}
  213. // 获取当前时间
  214. const now = new Date()
  215. const applyTime = now.toISOString().slice(0, 19).replace('T', ' ')
  216. // 构建提交数据
  217. const taskData = {
  218. // 任务基本信息
  219. // taskName: taskFormData.taskName || '',
  220. deptId: taskFormData.deptId || 0,
  221. projectId: taskFormData.projectId || 0,
  222. costShareId: taskFormData.costShareId || 0,
  223. taskType: taskFormData.taskType || 0,
  224. taskIntegral: this.totalIntegral || 0,
  225. taskUnit: taskFormData.taskUnit || 0,
  226. productId: taskFormData.productId || 0,
  227. planStartTime: taskFormData.planStartTime || '',
  228. planEndTime: taskFormData.planEndTime || '',
  229. // applyTime: applyTime,
  230. belongType: taskFormData.belongType || 0,
  231. companyId: userInfo.companyId || 0,
  232. companyUserId: userInfo.id || 0,
  233. remark: taskFormData.remark || '',
  234. // 构建doctorIds数组
  235. // doctorIds: this.customerList.map(customer => parseInt(customer.id) || 0),
  236. // 构建doctorTaskList数组
  237. doctorTaskList: this.customerList.map(customer => ({
  238. doctorId: parseInt(customer.id) || 0,
  239. taskIntegral: parseInt(customer.integral) || 0
  240. }))
  241. }
  242. console.log('提交的任务数据:', taskData)
  243. // 调用addInfo接口提交表单
  244. uni.showLoading({
  245. title: '提交中...'
  246. })
  247. addInfo(taskData).then(res => {
  248. uni.hideLoading()
  249. if (res.code === 200) {
  250. // 清除本地存储的数据
  251. uni.removeStorageSync('taskFormData')
  252. uni.removeStorageSync('selectedCustomers')
  253. // 显示提交成功提示
  254. uni.showToast({
  255. title: '任务创建成功',
  256. success: () => {
  257. // 延迟跳转,让用户看到成功提示
  258. setTimeout(() => {
  259. uni.navigateTo({
  260. url: '/pages_task/taskList'
  261. })
  262. }, 1500)
  263. }
  264. })
  265. } else {
  266. uni.showToast({
  267. icon: 'none',
  268. title: res.message || '提交失败'
  269. })
  270. }
  271. }).catch(err => {
  272. uni.hideLoading()
  273. uni.showToast({
  274. icon: 'none',
  275. title: '网络错误,请重试'
  276. })
  277. })
  278. },
  279. deleteSelected() {
  280. // 删除所有客户数据
  281. uni.showModal({
  282. title: '提示',
  283. content: '确定要删除所有客户数据吗?删除后不可恢复。',
  284. success: (res) => {
  285. if (res.confirm) {
  286. // 清空所有客户的积分数据
  287. this.customerList.forEach(customer => {
  288. this.$set(customer, 'integral', '')
  289. })
  290. uni.showToast({
  291. title: '已清空所有客户积分',
  292. icon: 'success'
  293. })
  294. }
  295. }
  296. })
  297. }
  298. }
  299. }
  300. </script>
  301. <style lang="scss" scoped>
  302. .container {
  303. min-height: 100vh;
  304. background: #F7F8FA;
  305. display: flex;
  306. flex-direction: column;
  307. &::before {
  308. content: '';
  309. position: absolute;
  310. top: 0;
  311. left: 0;
  312. right: 0;
  313. width: 100%;
  314. height: 544rpx;
  315. background: linear-gradient(180deg, #E4EFFE 0%, rgba(228, 239, 254, 0) 100%);
  316. }
  317. }
  318. .content {
  319. flex: 1;
  320. padding: 24rpx;
  321. box-sizing: border-box;
  322. padding-bottom: 200rpx;
  323. position: relative;
  324. }
  325. .integral-section {
  326. background-color: #ffffff;
  327. border-radius: 24rpx;
  328. padding: 32rpx 24rpx;
  329. margin-bottom: 24rpx;
  330. .section-header {
  331. display: flex;
  332. justify-content: space-between;
  333. align-items: center;
  334. margin-bottom: 32rpx;
  335. padding: 32rpx 0;
  336. background: #F5F9FF;
  337. border-radius: 16rpx;
  338. font-size: 28rpx;
  339. color: #666666;
  340. text-align: center;
  341. font-weight: 600;
  342. .section-title {
  343. flex: 1;
  344. }
  345. .section-subtitle {
  346. flex: 1;
  347. }
  348. }
  349. .integral-list {
  350. .integral-item {
  351. display: flex;
  352. justify-content: space-between;
  353. align-items: center;
  354. padding: 32rpx 0;
  355. border-bottom: 1rpx solid #F2F3F5;
  356. &:last-child {
  357. border-bottom: none;
  358. }
  359. .customer-info {
  360. flex: 1;
  361. text-align: center;
  362. .customer-name {
  363. font-size: 32rpx;
  364. font-weight: 500;
  365. color: #333333;
  366. }
  367. }
  368. .integral-input-wrapper {
  369. flex: 1;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. position: relative;
  374. .integral-input {
  375. width: 100%;
  376. font-size: 32rpx;
  377. color: #333333;
  378. text-align: center;
  379. padding: 12rpx 60rpx 12rpx 16rpx;
  380. background: #F7F8FA;
  381. border-radius: 8rpx;
  382. &::placeholder {
  383. color: #C8C9CC;
  384. font-size: 28rpx;
  385. text-align: center;
  386. }
  387. &:disabled {
  388. background: transparent;
  389. opacity: 0.8;
  390. }
  391. }
  392. .clear-icon-wrapper {
  393. position: absolute;
  394. right: 8rpx;
  395. width: 48rpx;
  396. height: 48rpx;
  397. display: flex;
  398. align-items: center;
  399. justify-content: center;
  400. z-index: 10;
  401. cursor: pointer;
  402. &:active {
  403. opacity: 0.6;
  404. }
  405. .clear-icon {
  406. width: 28rpx;
  407. height: 28rpx;
  408. }
  409. }
  410. }
  411. }
  412. }
  413. }
  414. .suspension {
  415. position: fixed;
  416. text-align: center;
  417. line-height: 96rpx;
  418. right: 36rpx;
  419. top: 70%;
  420. width: 96rpx;
  421. height: 96rpx;
  422. background: linear-gradient(0deg, #388BFF 0%, #388BFF 100%);
  423. box-shadow: inset 0rpx 4rpx 8rpx 0rpx rgba(255, 255, 255, 0.25),
  424. inset 0rpx -6rpx 8rpx 0rpx rgba(255, 255, 255, 0.25),
  425. 4rpx 8rpx 12rpx 0rpx rgba(88, 144, 239, 0.29);
  426. border-radius: 110rpx;
  427. font-size: 28rpx;
  428. color: #FFFFFF;
  429. z-index: 999;
  430. cursor: pointer;
  431. &:active {
  432. opacity: 0.8;
  433. }
  434. }
  435. /* 概览弹窗样式 */
  436. .overview-popup {
  437. background-color: #fff;
  438. border-radius: 32rpx 32rpx 0 0;
  439. max-height: 80vh;
  440. overflow-y: auto;
  441. padding-bottom: env(safe-area-inset-bottom);
  442. }
  443. .popup-header {
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. padding: 32rpx 40rpx;
  448. .popup-title {
  449. font-weight: 500;
  450. font-size: 32rpx;
  451. color: #333333;
  452. }
  453. .close-btn {
  454. width: 48rpx;
  455. height: 48rpx;
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. cursor: pointer;
  460. position: absolute;
  461. right: 0;
  462. .close-icon {
  463. width: 44rpx;
  464. height: 44rpx;
  465. margin-right: 32rpx;
  466. flex-shrink: 0;
  467. }
  468. &:active {
  469. opacity: 0.6;
  470. }
  471. }
  472. }
  473. .overview-section {
  474. padding: 32rpx 40rpx;
  475. .row {
  476. display: flex;
  477. align-items: center;
  478. margin-bottom: 24rpx;
  479. &:last-child {
  480. border-bottom: none;
  481. }
  482. .line {
  483. width: 6rpx;
  484. height: 32rpx;
  485. background: #388BFF;
  486. border-radius: 36rpx;
  487. margin-right: 20rpx;
  488. }
  489. .section-title {
  490. font-size: 28rpx;
  491. font-weight: 600;
  492. color: #333333;
  493. }
  494. }
  495. .info-list {
  496. .info-item {
  497. display: flex;
  498. margin-bottom: 16rpx;
  499. align-items: flex-start;
  500. font-size: 28rpx;
  501. &:last-child {
  502. margin-bottom: 0;
  503. }
  504. .info-label {
  505. color: #999999;
  506. flex-shrink: 0;
  507. width: 140rpx;
  508. }
  509. .info-value {
  510. color: #333333;
  511. flex: 1;
  512. line-height: 1.4;
  513. }
  514. }
  515. }
  516. .customer-table {
  517. .table-header {
  518. display: flex;
  519. background: #F5F9FF;
  520. border-radius: 8rpx;
  521. padding: 20rpx 16rpx;
  522. margin-bottom: 8rpx;
  523. .table-cell {
  524. font-size: 24rpx;
  525. font-weight: 600;
  526. color: #666666;
  527. text-align: center;
  528. }
  529. }
  530. .table-body {
  531. .table-row {
  532. display: flex;
  533. padding: 20rpx 16rpx;
  534. border-bottom: 1rpx solid #F2F3F5;
  535. &:last-child {
  536. border-bottom: none;
  537. }
  538. .table-cell {
  539. font-size: 28rpx;
  540. color: #333333;
  541. text-align: center;
  542. &:first-child {
  543. font-weight: 500;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. }
  550. .total-section {
  551. padding: 32rpx 40rpx;
  552. background: #F5F9FF;
  553. border-radius: 16rpx;
  554. margin: 24rpx 40rpx 40rpx;
  555. .total-item {
  556. display: flex;
  557. justify-content: space-between;
  558. align-items: center;
  559. margin-bottom: 16rpx;
  560. &:last-child {
  561. margin-bottom: 0;
  562. }
  563. .total-label {
  564. font-size: 28rpx;
  565. color: #666666;
  566. }
  567. .total-value {
  568. font-size: 28rpx;
  569. font-weight: 600;
  570. color: #388BFF;
  571. }
  572. }
  573. }
  574. .safe-area {
  575. height: env(safe-area-inset-bottom);
  576. }
  577. .bottom-bar {
  578. position: fixed;
  579. bottom: 0;
  580. left: 0;
  581. right: 0;
  582. background: #fff;
  583. padding: 24rpx 32rpx;
  584. border-top: 1rpx solid #F2F3F5;
  585. z-index: 100;
  586. display: flex;
  587. align-items: center;
  588. .del-box {
  589. display: flex;
  590. flex-direction: column;
  591. align-items: center;
  592. font-size: 24rpx;
  593. color: #666666;
  594. margin-right: 32rpx;
  595. cursor: pointer;
  596. &:active {
  597. opacity: 0.6;
  598. }
  599. }
  600. .action-buttons {
  601. display: flex;
  602. flex: 1;
  603. justify-content: space-between;
  604. .btn {
  605. width: 292rpx;
  606. height: 88rpx;
  607. display: flex;
  608. align-items: center;
  609. justify-content: center;
  610. font-size: 32rpx;
  611. font-weight: 500;
  612. border-radius: 200rpx 200rpx 200rpx 200rpx;
  613. cursor: pointer;
  614. &.btn-cancel {
  615. background: #fff;
  616. border: 2rpx solid #388BFF;
  617. color: #388BFF;
  618. }
  619. &.btn-submit {
  620. background: #388BFF;
  621. color: #fff;
  622. }
  623. }
  624. }
  625. }
  626. .w40 {
  627. width: 40rpx;
  628. }
  629. .h40 {
  630. height: 40rpx;
  631. }
  632. </style>