index.vue 10 KB

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