pointsSettings.vue 16 KB

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