index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view class="appeal-container">
  3. <!-- 自定义头部 -->
  4. <view class="custom-header">
  5. <view class="header-left" @click="navBack">
  6. <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);"></image>
  7. </view>
  8. <text class="header-title">增改服务项</text>
  9. <view class="header-right"></view>
  10. </view>
  11. <view class="header-placeholder"></view>
  12. <!-- 顶部提示 -->
  13. <view class="banner-tip">
  14. <view class="tip-content">
  15. <text class="tip-title">服务变更申请</text>
  16. <text class="tip-desc">如需在服务过程中增加或修改服务内容,请在此提交申请并上传相关凭证。</text>
  17. </view>
  18. <image class="banner-img" src="/static/icons/service-classification.svg"></image>
  19. </view>
  20. <view class="form-wrapper">
  21. <!-- 选择服务项 -->
  22. <view class="form-section">
  23. <view class="section-label">
  24. <text class="label-text">变更服务项</text>
  25. <text class="required">*</text>
  26. </view>
  27. <picker @change="onServiceChange" :value="serviceIndex" :range="serviceOptions" range-key="name">
  28. <view class="picker-box">
  29. <text class="picker-value" :class="{ 'placeholder': serviceIndex === -1 }">
  30. {{ serviceIndex === -1 ? '请选择需要变更的服务项' : serviceOptions[serviceIndex].name }}
  31. </text>
  32. <image class="arrow-icon" src="/static/icons/nav_arrow.svg"></image>
  33. </view>
  34. </picker>
  35. </view>
  36. <!-- 履约佣金 -->
  37. <view class="form-section">
  38. <view class="section-label">
  39. <text class="label-text">履约佣金(元)</text>
  40. <text class="required">*</text>
  41. </view>
  42. <view class="input-box">
  43. <input
  44. class="content-input"
  45. type="digit"
  46. v-model="fulfillmentCommissionYuan"
  47. placeholder="请输入新的履约佣金..."
  48. />
  49. </view>
  50. </view>
  51. <!-- 上传凭证 -->
  52. <view class="form-section">
  53. <view class="section-label">
  54. <text class="label-text">图片凭证</text>
  55. <text class="required">*</text>
  56. <text class="label-sub">(最多9张)</text>
  57. </view>
  58. <view class="upload-grid">
  59. <view class="upload-item" v-for="(img, index) in imageList" :key="index" @click="previewImage(index)">
  60. <image :src="img" class="uploaded-img" mode="aspectFill"></image>
  61. <view class="delete-btn" @click.stop="deleteImage(index)">×</view>
  62. </view>
  63. <view class="upload-btn" v-if="imageList.length < 9" @click="chooseImage">
  64. <text class="plus">+</text>
  65. <text class="upload-text">上传凭证</text>
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 变更说明 -->
  70. <view class="form-section">
  71. <view class="section-label">
  72. <text class="label-text">变更说明</text>
  73. <text class="label-sub">(选填)</text>
  74. </view>
  75. <view class="textarea-box">
  76. <textarea
  77. class="content-textarea"
  78. v-model="description"
  79. placeholder="请详细描述具体的变更内容或原因..."
  80. maxlength="500"
  81. auto-height
  82. />
  83. <text class="word-count">{{ description.length }}/500</text>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 底部确认按钮 -->
  88. <view class="bottom-action">
  89. <button class="confirm-btn" :class="{ 'disabled': !isReady }" @click="submitAppeal">确认提交</button>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import { listAllService } from '@/api/service/list'
  95. import { uploadFile } from '@/api/fulfiller/app'
  96. import { addSubOrderAppeal } from '@/api/order/subOrderAppeal'
  97. export default {
  98. data() {
  99. return {
  100. orderId: '',
  101. serviceOptions: [],
  102. serviceIndex: -1,
  103. imageList: [],
  104. imageOssIds: [],
  105. description: '',
  106. fulfillmentCommissionYuan: ''
  107. }
  108. },
  109. computed: {
  110. isReady() {
  111. // 必须要选服务且上传了至少一张图片,并且填写了佣金
  112. return this.serviceIndex !== -1 && this.imageList.length > 0 && this.fulfillmentCommissionYuan !== '';
  113. }
  114. },
  115. async onLoad(options) {
  116. if (options.id) {
  117. this.orderId = options.id;
  118. }
  119. await this.fetchServices();
  120. },
  121. methods: {
  122. // 补齐一个简单的时间格式化工具
  123. formatNow() {
  124. const now = new Date();
  125. const pad = (n) => String(n).padStart(2, '0');
  126. const year = now.getFullYear();
  127. const month = pad(now.getMonth() + 1);
  128. const day = pad(now.getDate());
  129. const hours = pad(now.getHours());
  130. const minutes = pad(now.getMinutes());
  131. const seconds = pad(now.getSeconds());
  132. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  133. },
  134. async fetchServices() {
  135. try {
  136. const res = await listAllService();
  137. this.serviceOptions = res.data || [];
  138. } catch (err) {
  139. console.error('获取服务项失败:', err);
  140. }
  141. },
  142. navBack() {
  143. uni.navigateBack({ delta: 1 });
  144. },
  145. onServiceChange(e) {
  146. this.serviceIndex = e.detail.value;
  147. const selectedService = this.serviceOptions[this.serviceIndex];
  148. // 当选择服务时,自动填充其默认的履约佣金,并转化为元显示
  149. if (selectedService && selectedService.fulfillmentCommission != null) {
  150. this.fulfillmentCommissionYuan = (selectedService.fulfillmentCommission / 100).toFixed(2);
  151. } else {
  152. this.fulfillmentCommissionYuan = '';
  153. }
  154. },
  155. chooseImage() {
  156. uni.chooseImage({
  157. count: 9 - this.imageList.length,
  158. sizeType: ['compressed'],
  159. sourceType: ['album', 'camera'],
  160. success: async (res) => {
  161. for (const path of res.tempFilePaths) {
  162. this.imageList.push(path);
  163. try {
  164. uni.showLoading({ title: '正在上传...', mask: true });
  165. const uploadRes = await uploadFile(path);
  166. if (uploadRes && uploadRes.data && uploadRes.data.ossId) {
  167. this.imageOssIds.push(uploadRes.data.ossId);
  168. }
  169. uni.hideLoading();
  170. } catch (err) {
  171. uni.hideLoading();
  172. console.error('上传凭证失败:', err);
  173. uni.showToast({ title: '上传失败', icon: 'none' });
  174. }
  175. }
  176. }
  177. });
  178. },
  179. deleteImage(index) {
  180. this.imageList.splice(index, 1);
  181. this.imageOssIds.splice(index, 1);
  182. },
  183. previewImage(index) {
  184. uni.previewImage({
  185. urls: this.imageList,
  186. current: index
  187. });
  188. },
  189. async submitAppeal() {
  190. // 再次检查校验条件
  191. if (!this.isReady) {
  192. if (this.serviceIndex === -1) {
  193. uni.showToast({ title: '请先选择服务项', icon: 'none' });
  194. } else if (this.fulfillmentCommissionYuan === '') {
  195. uni.showToast({ title: '请输入履约佣金', icon: 'none' });
  196. } else if (this.imageList.length === 0) {
  197. uni.showToast({ title: '请上传至少一张凭证', icon: 'none' });
  198. }
  199. return;
  200. }
  201. uni.showLoading({ title: '提交中...', mask: true });
  202. try {
  203. const selectedService = this.serviceOptions[this.serviceIndex];
  204. const nowStr = this.formatNow();
  205. // 构造完整 JSON 入参
  206. const cents = Math.round(parseFloat(this.fulfillmentCommissionYuan) * 100) || 0;
  207. const data = {
  208. "orderId": this.orderId, // 保留原始类型(通常为 string 或 number)
  209. "service": selectedService.id,
  210. "photos": this.imageOssIds.join(','),
  211. "fulfillmentCommission": cents,
  212. "reason": this.description || '无详细备注',
  213. "createDept": 0,
  214. "createBy": 0,
  215. "createTime": nowStr,
  216. "updateBy": 0,
  217. "updateTime": nowStr,
  218. "params": {}
  219. };
  220. console.log('即将发起 API 请求:', data);
  221. const res = await addSubOrderAppeal(data);
  222. uni.hideLoading();
  223. if (res.code === 200 || res.msg === '操作成功') {
  224. uni.showToast({ title: '提交成功,请等待后续处理', icon: 'none', duration: 2000 });
  225. setTimeout(() => {
  226. uni.navigateBack({ delta: 1 });
  227. }, 2000);
  228. } else {
  229. uni.showToast({ title: res.msg || '提交异常,请稍后重试', icon: 'none', duration: 2000 });
  230. }
  231. } catch (err) {
  232. uni.hideLoading();
  233. console.error('提交失败详情:', err);
  234. uni.showToast({ title: '网络请求失败,请检查网络链接', icon: 'none', duration: 2000 });
  235. }
  236. }
  237. }
  238. }
  239. </script>
  240. <style scoped>
  241. page {
  242. background-color: #F8F9FB;
  243. }
  244. .appeal-container {
  245. min-height: 100vh;
  246. padding-bottom: 180rpx;
  247. }
  248. /* 导航栏样式 */
  249. .custom-header {
  250. position: fixed;
  251. top: 0;
  252. left: 0;
  253. width: 100%;
  254. height: 88rpx;
  255. padding-top: var(--status-bar-height);
  256. background-color: #fff;
  257. display: flex;
  258. align-items: center;
  259. justify-content: space-between;
  260. padding-left: 30rpx;
  261. padding-right: 30rpx;
  262. box-sizing: content-box;
  263. z-index: 100;
  264. }
  265. .header-placeholder {
  266. height: calc(88rpx + var(--status-bar-height));
  267. }
  268. .back-icon {
  269. width: 44rpx;
  270. height: 44rpx;
  271. }
  272. .header-title {
  273. font-size: 32rpx;
  274. font-weight: bold;
  275. color: #333;
  276. }
  277. .header-right {
  278. width: 44rpx;
  279. }
  280. /* Banner 提示 */
  281. .banner-tip {
  282. background: linear-gradient(135deg, #FF9800 0%, #FF5722 100%);
  283. margin: 30rpx;
  284. border-radius: 20rpx;
  285. padding: 30rpx;
  286. display: flex;
  287. justify-content: space-between;
  288. align-items: center;
  289. box-shadow: 0 10rpx 20rpx rgba(255, 87, 34, 0.2);
  290. }
  291. .tip-content {
  292. flex: 1;
  293. }
  294. .tip-title {
  295. color: #fff;
  296. font-size: 32rpx;
  297. font-weight: bold;
  298. display: block;
  299. margin-bottom: 10rpx;
  300. }
  301. .tip-desc {
  302. color: rgba(255, 255, 255, 0.9);
  303. font-size: 24rpx;
  304. }
  305. .banner-img {
  306. width: 100rpx;
  307. height: 100rpx;
  308. opacity: 0.8;
  309. }
  310. /* 表单容器 */
  311. .form-wrapper {
  312. margin: 0 30rpx;
  313. }
  314. .form-section {
  315. background-color: #fff;
  316. border-radius: 20rpx;
  317. padding: 30rpx;
  318. margin-bottom: 24rpx;
  319. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.02);
  320. }
  321. .section-label {
  322. display: flex;
  323. align-items: center;
  324. margin-bottom: 24rpx;
  325. }
  326. .label-text {
  327. font-size: 30rpx;
  328. font-weight: bold;
  329. color: #333;
  330. }
  331. .required {
  332. color: #FF5722;
  333. margin-left: 6rpx;
  334. }
  335. .label-sub {
  336. font-size: 24rpx;
  337. color: #999;
  338. margin-left: 10rpx;
  339. }
  340. /* 下拉选择框 */
  341. .picker-box {
  342. background-color: #F8F9FA;
  343. height: 96rpx;
  344. padding: 0 30rpx;
  345. border-radius: 12rpx;
  346. display: flex;
  347. align-items: center;
  348. justify-content: space-between;
  349. border: 1px solid #EEEEEE;
  350. }
  351. .picker-value {
  352. font-size: 28rpx;
  353. color: #333;
  354. }
  355. .picker-value.placeholder {
  356. color: #999;
  357. }
  358. .arrow-icon {
  359. width: 24rpx;
  360. height: 24rpx;
  361. opacity: 0.3;
  362. }
  363. /* 输入框 */
  364. .input-box {
  365. background-color: #F8F9FA;
  366. height: 96rpx;
  367. padding: 0 30rpx;
  368. border-radius: 12rpx;
  369. display: flex;
  370. align-items: center;
  371. border: 1px solid #EEEEEE;
  372. }
  373. .content-input {
  374. width: 100%;
  375. font-size: 28rpx;
  376. color: #333;
  377. }
  378. /* 图片上传网格 */
  379. .upload-grid {
  380. display: flex;
  381. flex-wrap: wrap;
  382. gap: 18rpx;
  383. }
  384. .upload-item, .upload-btn {
  385. width: calc((100% - 36rpx) / 3);
  386. height: 200rpx;
  387. border-radius: 12rpx;
  388. overflow: hidden;
  389. position: relative;
  390. }
  391. .uploaded-img {
  392. width: 100%;
  393. height: 100%;
  394. }
  395. .delete-btn {
  396. position: absolute;
  397. top: 10rpx;
  398. right: 10rpx;
  399. background-color: rgba(0, 0, 0, 0.5);
  400. color: #fff;
  401. width: 36rpx;
  402. height: 36rpx;
  403. border-radius: 50%;
  404. display: flex;
  405. align-items: center;
  406. justify-content: center;
  407. font-size: 24rpx;
  408. }
  409. .upload-btn {
  410. background-color: #F8F9FA;
  411. border: 2rpx dashed #E0E0E0;
  412. display: flex;
  413. flex-direction: column;
  414. align-items: center;
  415. justify-content: center;
  416. }
  417. .plus {
  418. font-size: 60rpx;
  419. color: #CCCCCC;
  420. line-height: 1;
  421. }
  422. .upload-text {
  423. font-size: 22rpx;
  424. color: #999;
  425. margin-top: 8rpx;
  426. }
  427. /* 文本域 */
  428. .textarea-box {
  429. background-color: #F8F9FA;
  430. border-radius: 12rpx;
  431. padding: 24rpx;
  432. border: 1px solid #EEEEEE;
  433. }
  434. .content-textarea {
  435. width: 100%;
  436. min-height: 200rpx;
  437. font-size: 28rpx;
  438. color: #333;
  439. line-height: 1.5;
  440. }
  441. .word-count {
  442. text-align: right;
  443. display: block;
  444. font-size: 22rpx;
  445. color: #BBB;
  446. margin-top: 10rpx;
  447. }
  448. /* 底部按钮 */
  449. .bottom-action {
  450. position: fixed;
  451. bottom: 0;
  452. left: 0;
  453. right: 0;
  454. background-color: #fff;
  455. padding: 30rpx 40rpx;
  456. padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
  457. box-shadow: 0 -10rpx 30rpx rgba(0, 0, 0, 0.05);
  458. z-index: 99;
  459. }
  460. .confirm-btn {
  461. background: linear-gradient(90deg, #FF9800 0%, #FF5722 100%);
  462. color: #fff;
  463. height: 88rpx;
  464. line-height: 88rpx;
  465. border-radius: 44rpx;
  466. font-size: 32rpx;
  467. font-weight: bold;
  468. box-shadow: 0 8rpx 20rpx rgba(255, 87, 34, 0.3);
  469. }
  470. .confirm-btn.disabled {
  471. background: #E0E0E0;
  472. box-shadow: none;
  473. color: #fff;
  474. }
  475. </style>