pointsSettings.vue 16 KB

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