serviceOrderDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <view class="container">
  3. <!-- 内容区域 -->
  4. <scroll-view class="content" scroll-y>
  5. <view class="detail-section">
  6. <!-- 服务单标题和已确认标识 -->
  7. <view class="order-header">
  8. <view class="order-title-text">服务单</view>
  9. <image class="w144 h144" v-if="serviceOrder.doctorConfirm === 1" src="@/static/image/img_confirmed.png" mode=""></image>
  10. </view>
  11. <!-- 服务内容 -->
  12. <view class="service-content">
  13. <view class="content-title">尊敬的用户: 本次劳务内容:</view>
  14. <!-- 服务表格 -->
  15. <view class="service-table">
  16. <view class="table-header">
  17. <view class="table-cell">具体实施项目</view>
  18. <view class="table-cell">单场金额</view>
  19. <view class="table-cell">完成时间</view>
  20. <view class="table-cell">单位</view>
  21. <view class="table-cell">数量</view>
  22. <view class="table-cell">总金额</view>
  23. </view>
  24. <view class="table-row" v-for="(item, index) in orderDetail.serviceItems" :key="index">
  25. <view class="table-cell x-c">{{ item.projectName }}</view>
  26. <view class="table-cell x-c">{{ item.taskIntegral}}</view>
  27. <view class="table-cell x-c">{{ formatDate(item.planEndTime) }}</view>
  28. <view class="table-cell x-c">{{ item.taskUnit}}</view>
  29. <view class="table-cell x-c">{{ item.taskCount }}</view>
  30. <view class="table-cell x-c">{{ totalAmount }}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 协议内容 -->
  35. <view class="agreement-content">
  36. <view class="agreement-text">
  37. 甲乙双方已签订《服务协议》,乙方实际向甲方提供上述服务,现双方确认该工作已全部完成。乙方确认该笔收入为自己的合理劳动所得,并同意依法纳税,乙方提供银行卡、身份证信息给甲方用于报税,甲方承诺为乙方个人信息保密。
  38. </view>
  39. <view class="payment-info">
  40. <view class="payment-text">
  41. 我司将向您支付人民币[{{ totalAmount || 0 }}]元(大写:{{ convertToChineseAmount(totalAmount) || '-' }})作为此次劳务报酬(该服务报酬为我司代扣代缴相关税款后的金额),款项将汇入如下账户:
  42. </view>
  43. <view class="account-info">
  44. <view class="account-item">
  45. <text class="account-label">姓名:</text>
  46. <text class="account-value">{{ serviceOrder.initiatorName || '王小明' }}</text>
  47. </view>
  48. <view class="account-item">
  49. <text class="account-label">开户行:</text>
  50. <text class="account-value">{{ orderDetail.bankName || '中国农业银行' }}</text>
  51. </view>
  52. <view class="account-item">
  53. <text class="account-label">账号:</text>
  54. <text class="account-value">{{ orderDetail.bankCardNo || '6524012536580258' }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. <view class="confirm-box" v-if="serviceOrder.doctorConfirm === 0">
  62. <!-- 确认选项(仅待确认状态显示) -->
  63. <view class="confirm-options">
  64. <view class="option-item">
  65. <checkbox-group @change="onOptionChange">
  66. <label class="option-label">
  67. <checkbox value="promise" :checked="confirmOptions.promise" color="#388BFF" />
  68. <text class="option-text">承诺上述服务已真实发生;</text>
  69. </label>
  70. </checkbox-group>
  71. </view>
  72. <view class="option-item">
  73. <checkbox-group @change="onOptionChange">
  74. <label class="option-label">
  75. <checkbox value="lecture" :checked="confirmOptions.lecture" color="#388BFF" />
  76. <text class="option-text">【适用于提供讲课服务的情形】在提供本次服务之前,已充分悉知和了解讲课内容的材料。</text>
  77. </label>
  78. </checkbox-group>
  79. </view>
  80. </view>
  81. <!-- 底部按钮(仅待确认状态显示) -->
  82. <view class="bottom-bar" v-if="orderDetail.status === 0">
  83. <view class="btn btn-cancel" @click="goBack">返回</view>
  84. <view class="btn btn-confirm" @click="handleConfirm">确认</view>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import { getServiceOrderDetail, confirmServiceOrder } from '@/api/serviceOrder'
  91. import utils from '@/utils/common.js'
  92. export default {
  93. data() {
  94. return {
  95. serviceOrderId:null,
  96. serviceOrder:{},
  97. totalAmount:0,
  98. orderDetail: {
  99. status: 0,
  100. totalAmount: '1534',
  101. amountInWords: '壹仟伍佰叁拾肆元整',
  102. accountName: '王小明',
  103. bankName: '中国农业银行',
  104. accountNumber: '6524012536580258',
  105. serviceItems: []
  106. },
  107. confirmOptions: {
  108. promise: false,
  109. lecture: false
  110. },
  111. user:{},
  112. utils: utils // 将 utils 挂载到 data 中,以便在模板中使用
  113. }
  114. },
  115. onLoad(options) {
  116. if (options.id) {
  117. this.serviceOrderId = options.id
  118. }
  119. this.loadOrderDetail()
  120. },
  121. methods: {
  122. async loadOrderDetail() {
  123. try {
  124. uni.showLoading({ title: '加载中...' })
  125. const res = await getServiceOrderDetail({ serviceOrderId: this.serviceOrderId })
  126. uni.hideLoading()
  127. if (res.code === 200 && res.data) {
  128. this.orderDetail = { ...this.orderDetail, ...res.data }
  129. if (res.data.serviceOrderInfoVO) {
  130. this.orderDetail.serviceItems = res.data.serviceOrderInfoVO.taskInfos
  131. this.serviceOrder = res.data.serviceOrderInfoVO.serviceOrder
  132. this.totalAmount = this.serviceOrder.totalAmount
  133. }
  134. } else {
  135. uni.hideLoading();
  136. uni.showToast({
  137. icon:'none',
  138. title: res.msg,
  139. });
  140. }
  141. } catch (e) {
  142. uni.hideLoading()
  143. console.error('加载服务单详情失败', e)
  144. }
  145. },
  146. onOptionChange(e) {
  147. const values = e.detail.value
  148. this.confirmOptions.promise = values.includes('promise')
  149. this.confirmOptions.lecture = values.includes('lecture')
  150. },
  151. // 格式化日期字符串为年月日格式
  152. formatDate(dateStr) {
  153. if (!dateStr) return ''
  154. // 处理 "2026-02-05" 格式的日期字符串
  155. if (typeof dateStr === 'string' && dateStr.includes('-')) {
  156. // 将 "2026-02-05" 转换为 Date 对象
  157. const date = new Date(dateStr.replace(/-/g, '/'))
  158. // 使用 utils.timeFormat 格式化
  159. return utils.timeFormat(date.getTime(), 'yyyy年mm月dd日')
  160. }
  161. // 如果是时间戳,直接使用
  162. return utils.timeFormat(dateStr, 'yyyy年mm月dd日')
  163. },
  164. // 将数字金额转换为中文大写
  165. convertToChineseAmount(amount) {
  166. if (!amount && amount !== 0) return ''
  167. // 转换为数字
  168. const num = Number(amount)
  169. if (isNaN(num) || num < 0) return ''
  170. // 中文数字
  171. const chineseNums = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
  172. // 单位
  173. const units = ['', '拾', '佰', '仟']
  174. const bigUnits = ['', '万', '亿']
  175. // 处理小数部分
  176. const parts = num.toString().split('.')
  177. const integerPart = Math.floor(num)
  178. const decimalPart = parts[1] ? parts[1].substring(0, 2) : '' // 最多两位小数
  179. // 转换整数部分
  180. let integerStr = integerPart.toString()
  181. let result = ''
  182. if (integerPart === 0) {
  183. result = '零'
  184. } else {
  185. // 每4位一组处理
  186. const groups = []
  187. while (integerStr.length > 0) {
  188. groups.unshift(integerStr.slice(-4))
  189. integerStr = integerStr.slice(0, -4)
  190. }
  191. groups.forEach((group, groupIndex) => {
  192. const groupNum = parseInt(group)
  193. if (groupNum === 0) {
  194. // 如果这一组是0,且不是最后一组,添加"零"
  195. if (groupIndex < groups.length - 1) {
  196. result += '零'
  197. }
  198. return
  199. }
  200. let groupStr = ''
  201. for (let i = 0; i < group.length; i++) {
  202. const digit = parseInt(group[i])
  203. const pos = group.length - 1 - i
  204. if (digit === 0) {
  205. // 如果当前位是0,且下一位不是0,添加"零"
  206. if (i < group.length - 1 && parseInt(group[i + 1]) !== 0) {
  207. groupStr += '零'
  208. }
  209. } else {
  210. groupStr += chineseNums[digit] + units[pos]
  211. }
  212. }
  213. result += groupStr
  214. // 添加大单位(万、亿)
  215. if (groupIndex < groups.length - 1) {
  216. const bigUnitIndex = groups.length - 1 - groupIndex - 1
  217. if (bigUnitIndex < bigUnits.length) {
  218. result += bigUnits[bigUnitIndex]
  219. }
  220. }
  221. })
  222. }
  223. result += '元'
  224. // 处理小数部分
  225. if (decimalPart) {
  226. if (decimalPart.length === 1) {
  227. const d1 = parseInt(decimalPart[0])
  228. if (d1 !== 0) {
  229. result += chineseNums[d1] + '角'
  230. }
  231. } else if (decimalPart.length === 2) {
  232. const d1 = parseInt(decimalPart[0])
  233. const d2 = parseInt(decimalPart[1])
  234. if (d1 !== 0) {
  235. result += chineseNums[d1] + '角'
  236. }
  237. if (d2 !== 0) {
  238. result += chineseNums[d2] + '分'
  239. }
  240. }
  241. } else {
  242. result += '整'
  243. }
  244. return result
  245. },
  246. goBack() {
  247. uni.navigateBack()
  248. },
  249. async handleConfirm() {
  250. var user = JSON.parse(uni.getStorageSync('userInfo'))
  251. // 验证至少选中一个选项(二选一)
  252. if (!this.confirmOptions.promise && !this.confirmOptions.lecture) {
  253. uni.showToast({
  254. icon: 'none',
  255. title: '请至少选择一个确认选项'
  256. })
  257. return
  258. }
  259. try {
  260. uni.showLoading({ title: '确认中...' })
  261. const res = await confirmServiceOrder({
  262. serviceOrderId: this.serviceOrderId,
  263. totalAmount:this.totalAmount,
  264. userId:user.id
  265. })
  266. uni.hideLoading()
  267. if (res.code === 200) {
  268. uni.showToast({
  269. icon: 'success',
  270. title: '确认成功'
  271. })
  272. setTimeout(() => {
  273. uni.navigateBack()
  274. }, 1000)
  275. } else {
  276. uni.showToast({
  277. icon: 'none',
  278. title: res.msg || '确认失败'
  279. })
  280. }
  281. } catch (e) {
  282. uni.hideLoading()
  283. uni.showToast({
  284. icon: 'none',
  285. title: '确认失败'
  286. })
  287. }
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="scss" scoped>
  293. .container {
  294. min-height: 100vh;
  295. background: #fff;
  296. display: flex;
  297. flex-direction: column;
  298. }
  299. .navbar {
  300. display: flex;
  301. align-items: center;
  302. justify-content: space-between;
  303. padding: 20rpx 24rpx;
  304. background: #fff;
  305. border-bottom: 1rpx solid #f0f0f0;
  306. .nav-left {
  307. width: 60rpx;
  308. .back-icon {
  309. font-size: 36rpx;
  310. color: #333;
  311. font-weight: bold;
  312. }
  313. }
  314. .nav-title {
  315. flex: 1;
  316. text-align: center;
  317. font-size: 36rpx;
  318. font-weight: bold;
  319. color: #333;
  320. }
  321. .nav-right {
  322. display: flex;
  323. align-items: center;
  324. gap: 24rpx;
  325. width: 60rpx;
  326. justify-content: flex-end;
  327. .more-icon {
  328. font-size: 32rpx;
  329. color: #333;
  330. }
  331. .eye-icon {
  332. font-size: 32rpx;
  333. color: #333;
  334. }
  335. }
  336. }
  337. .content {
  338. flex: 1;
  339. padding-bottom: 400rpx;
  340. }
  341. .detail-section {
  342. background: #fff;
  343. // margin: 24rpx;
  344. // border-radius: 16rpx;
  345. padding: 32rpx;
  346. }
  347. .order-header {
  348. position: relative;
  349. text-align: center;
  350. margin-bottom: 32rpx;
  351. image{
  352. position: absolute;
  353. right: 0;
  354. top: 0;
  355. }
  356. .order-title-text {
  357. font-size: 36rpx;
  358. font-weight: bold;
  359. color: #333;
  360. }
  361. .confirmed-stamp {
  362. position: absolute;
  363. right: 0;
  364. top: 50%;
  365. transform: translateY(-50%) rotate(-15deg);
  366. width: 120rpx;
  367. height: 120rpx;
  368. border: 4rpx solid rgba(0, 0, 0, 0.1);
  369. border-radius: 50%;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. font-size: 24rpx;
  374. color: rgba(0, 0, 0, 0.4);
  375. background: rgba(255, 255, 255, 0.8);
  376. }
  377. }
  378. .service-content {
  379. margin-bottom: 32rpx;
  380. .content-title {
  381. font-size: 28rpx;
  382. color: #333;
  383. margin-bottom: 24rpx;
  384. }
  385. .service-table {
  386. border: 1rpx solid #EBEDF0;
  387. border-radius: 8rpx;
  388. overflow: hidden;
  389. width: 100%;
  390. .table-header,
  391. .table-row {
  392. display: flex;
  393. width: 100%;
  394. .table-cell {
  395. flex: 1;
  396. padding: 16rpx 8rpx;
  397. font-size: 22rpx;
  398. text-align: center;
  399. border-right: 1rpx solid #EBEDF0;
  400. word-break: break-all;
  401. box-sizing: border-box;
  402. &:last-child {
  403. border-right: none;
  404. }
  405. }
  406. }
  407. .table-header {
  408. background: #f5f5f5;
  409. .table-cell {
  410. font-weight: 500;
  411. color: #333;
  412. }
  413. }
  414. .table-row {
  415. border-top: 1rpx solid #EBEDF0;
  416. .table-cell {
  417. color: #666;
  418. }
  419. }
  420. }
  421. }
  422. .agreement-content {
  423. .agreement-text,
  424. .payment-text {
  425. font-size: 26rpx;
  426. color: #666;
  427. line-height: 1.8;
  428. margin-bottom: 24rpx;
  429. }
  430. .account-info {
  431. margin-top: 24rpx;
  432. .account-item {
  433. margin-bottom: 16rpx;
  434. font-size: 26rpx;
  435. .account-label {
  436. color: #666;
  437. }
  438. .account-value {
  439. color: #333;
  440. margin-left: 8rpx;
  441. }
  442. }
  443. }
  444. }
  445. .confirm-box{
  446. position: fixed;
  447. bottom: 0;
  448. left: 0;
  449. right: 0;
  450. background: #fff;
  451. // padding: 24rpx;
  452. border-top: 1rpx solid #f0f0f0;
  453. z-index: 100;
  454. box-shadow: 0rpx -4rpx 16rpx 0rpx rgba(0,0,0,0.04);
  455. }
  456. .confirm-options {
  457. background: #fff;
  458. border-radius: 16rpx;
  459. padding: 32rpx;
  460. .option-item {
  461. margin-bottom: 24rpx;
  462. &:last-child {
  463. margin-bottom: 0;
  464. }
  465. .option-label {
  466. display: flex;
  467. align-items: flex-start;
  468. .option-text {
  469. flex: 1;
  470. margin-left: 8rpx;
  471. font-size: 26rpx;
  472. color: #333;
  473. line-height: 1.8;
  474. }
  475. }
  476. }
  477. }
  478. .bottom-bar {
  479. padding:24rpx 32rpx;
  480. display: flex;
  481. gap: 24rpx;
  482. margin-bottom: 40rpx;
  483. .btn {
  484. flex: 1;
  485. height: 88rpx;
  486. display: flex;
  487. align-items: center;
  488. justify-content: center;
  489. border-radius: 44rpx;
  490. font-size: 32rpx;
  491. font-weight: 500;
  492. &.btn-cancel {
  493. background: #fff;
  494. border: 2rpx solid #388BFF;
  495. color: #388BFF;
  496. }
  497. &.btn-confirm {
  498. background: #388BFF;
  499. color: #fff;
  500. }
  501. }
  502. }
  503. </style>