editSelectCustomer.vue 17 KB

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