pointsSettings.vue 16 KB

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