index.vue 11 KB

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