index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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">(最多6张)</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 < 6" @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. uni.showToast({ title: err.message || err.msg || '请求失败', icon: 'none' });
  141. }
  142. },
  143. navBack() {
  144. uni.navigateBack({ delta: 1 });
  145. },
  146. onServiceChange(e) {
  147. this.serviceIndex = e.detail.value;
  148. const selectedService = this.serviceOptions[this.serviceIndex];
  149. // 当选择服务时,自动填充其默认的履约佣金,并转化为元显示
  150. if (selectedService && selectedService.fulfillmentCommission != null) {
  151. this.fulfillmentCommissionYuan = (selectedService.fulfillmentCommission / 100).toFixed(2);
  152. } else {
  153. this.fulfillmentCommissionYuan = '';
  154. }
  155. },
  156. chooseImage() {
  157. uni.chooseImage({
  158. count: 6 - this.imageList.length,
  159. sizeType: ['compressed'],
  160. sourceType: ['album', 'camera'],
  161. success: async (res) => {
  162. for (const path of res.tempFilePaths) {
  163. this.imageList.push(path);
  164. try {
  165. uni.showLoading({ title: '正在上传...', mask: true });
  166. const uploadRes = await uploadFile(path);
  167. if (uploadRes && uploadRes.data && uploadRes.data.ossId) {
  168. this.imageOssIds.push(uploadRes.data.ossId);
  169. }
  170. uni.hideLoading();
  171. } catch (err) {
  172. uni.hideLoading();
  173. console.error('上传凭证失败:', err);
  174. uni.showToast({ title: err.message || err.msg || '请求失败', icon: 'none' });
  175. }
  176. }
  177. }
  178. });
  179. },
  180. deleteImage(index) {
  181. this.imageList.splice(index, 1);
  182. this.imageOssIds.splice(index, 1);
  183. },
  184. previewImage(index) {
  185. uni.previewImage({
  186. urls: this.imageList,
  187. current: index
  188. });
  189. },
  190. async submitAppeal() {
  191. // 再次检查校验条件
  192. if (!this.isReady) {
  193. if (this.serviceIndex === -1) {
  194. uni.showToast({ title: '请先选择服务项', icon: 'none' });
  195. } else if (this.fulfillmentCommissionYuan === '') {
  196. uni.showToast({ title: '请输入履约佣金', icon: 'none' });
  197. } else if (this.imageList.length === 0) {
  198. uni.showToast({ title: '请上传至少一张凭证', icon: 'none' });
  199. }
  200. return;
  201. }
  202. uni.showLoading({ title: '提交中...', mask: true });
  203. try {
  204. const selectedService = this.serviceOptions[this.serviceIndex];
  205. const nowStr = this.formatNow();
  206. // 构造完整 JSON 入参
  207. const cents = Math.round(parseFloat(this.fulfillmentCommissionYuan) * 100) || 0;
  208. const data = {
  209. "orderId": this.orderId, // 保留原始类型(通常为 string 或 number)
  210. "service": selectedService.id,
  211. "photos": this.imageOssIds.join(','),
  212. "fulfillmentCommission": cents,
  213. "reason": this.description || '无详细备注',
  214. "createDept": 0,
  215. "createBy": 0,
  216. "createTime": nowStr,
  217. "updateBy": 0,
  218. "updateTime": nowStr,
  219. "params": {}
  220. };
  221. console.log('即将发起 API 请求:', data);
  222. const res = await addSubOrderAppeal(data);
  223. uni.hideLoading();
  224. if (res.code === 200 || res.msg === '操作成功') {
  225. uni.showToast({ title: '提交成功,请等待后续处理', icon: 'none', duration: 2000 });
  226. setTimeout(() => {
  227. uni.navigateBack({ delta: 1 });
  228. }, 2000);
  229. } else {
  230. uni.showToast({ title: res.msg || '提交异常,请稍后重试', icon: 'none', duration: 2000 });
  231. }
  232. } catch (err) {
  233. uni.hideLoading();
  234. console.error('提交失败详情:', err);
  235. uni.showToast({ title: err.message || err.msg || '请求失败', icon: 'none', duration: 2000 });
  236. }
  237. }
  238. }
  239. }
  240. </script>
  241. <style scoped>
  242. page {
  243. background-color: #F8F9FB;
  244. }
  245. .appeal-container {
  246. min-height: 100vh;
  247. padding-bottom: 180rpx;
  248. }
  249. /* 导航栏样式 */
  250. .custom-header {
  251. position: fixed;
  252. top: 0;
  253. left: 0;
  254. width: 100%;
  255. height: 88rpx;
  256. padding-top: var(--status-bar-height);
  257. background-color: #fff;
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. padding-left: 30rpx;
  262. padding-right: 30rpx;
  263. box-sizing: content-box;
  264. z-index: 100;
  265. }
  266. .header-placeholder {
  267. height: calc(88rpx + var(--status-bar-height));
  268. }
  269. .back-icon {
  270. width: 44rpx;
  271. height: 44rpx;
  272. }
  273. .header-title {
  274. font-size: 32rpx;
  275. font-weight: bold;
  276. color: #333;
  277. }
  278. .header-right {
  279. width: 44rpx;
  280. }
  281. /* Banner 提示 */
  282. .banner-tip {
  283. background: linear-gradient(135deg, #FF9800 0%, #FF5722 100%);
  284. margin: 30rpx;
  285. border-radius: 20rpx;
  286. padding: 30rpx;
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: center;
  290. box-shadow: 0 10rpx 20rpx rgba(255, 87, 34, 0.2);
  291. }
  292. .tip-content {
  293. flex: 1;
  294. }
  295. .tip-title {
  296. color: #fff;
  297. font-size: 32rpx;
  298. font-weight: bold;
  299. display: block;
  300. margin-bottom: 10rpx;
  301. }
  302. .tip-desc {
  303. color: rgba(255, 255, 255, 0.9);
  304. font-size: 24rpx;
  305. }
  306. .banner-img {
  307. width: 100rpx;
  308. height: 100rpx;
  309. opacity: 0.8;
  310. }
  311. /* 表单容器 */
  312. .form-wrapper {
  313. margin: 0 30rpx;
  314. }
  315. .form-section {
  316. background-color: #fff;
  317. border-radius: 20rpx;
  318. padding: 30rpx;
  319. margin-bottom: 24rpx;
  320. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.02);
  321. }
  322. .section-label {
  323. display: flex;
  324. align-items: center;
  325. margin-bottom: 24rpx;
  326. }
  327. .label-text {
  328. font-size: 30rpx;
  329. font-weight: bold;
  330. color: #333;
  331. }
  332. .required {
  333. color: #FF5722;
  334. margin-left: 6rpx;
  335. }
  336. .label-sub {
  337. font-size: 24rpx;
  338. color: #999;
  339. margin-left: 10rpx;
  340. }
  341. /* 下拉选择框 */
  342. .picker-box {
  343. background-color: #F8F9FA;
  344. height: 96rpx;
  345. padding: 0 30rpx;
  346. border-radius: 12rpx;
  347. display: flex;
  348. align-items: center;
  349. justify-content: space-between;
  350. border: 1px solid #EEEEEE;
  351. }
  352. .picker-value {
  353. font-size: 28rpx;
  354. color: #333;
  355. }
  356. .picker-value.placeholder {
  357. color: #999;
  358. }
  359. .arrow-icon {
  360. width: 24rpx;
  361. height: 24rpx;
  362. opacity: 0.3;
  363. }
  364. /* 输入框 */
  365. .input-box {
  366. background-color: #F8F9FA;
  367. height: 96rpx;
  368. padding: 0 30rpx;
  369. border-radius: 12rpx;
  370. display: flex;
  371. align-items: center;
  372. border: 1px solid #EEEEEE;
  373. }
  374. .content-input {
  375. width: 100%;
  376. font-size: 28rpx;
  377. color: #333;
  378. }
  379. /* 图片上传网格 */
  380. .upload-grid {
  381. display: flex;
  382. flex-wrap: wrap;
  383. gap: 18rpx;
  384. }
  385. .upload-item, .upload-btn {
  386. width: calc((100% - 36rpx) / 3);
  387. height: 200rpx;
  388. border-radius: 12rpx;
  389. overflow: hidden;
  390. position: relative;
  391. }
  392. .uploaded-img {
  393. width: 100%;
  394. height: 100%;
  395. }
  396. .delete-btn {
  397. position: absolute;
  398. top: 10rpx;
  399. right: 10rpx;
  400. background-color: rgba(0, 0, 0, 0.5);
  401. color: #fff;
  402. width: 36rpx;
  403. height: 36rpx;
  404. border-radius: 50%;
  405. display: flex;
  406. align-items: center;
  407. justify-content: center;
  408. font-size: 24rpx;
  409. }
  410. .upload-btn {
  411. background-color: #F8F9FA;
  412. border: 2rpx dashed #E0E0E0;
  413. display: flex;
  414. flex-direction: column;
  415. align-items: center;
  416. justify-content: center;
  417. }
  418. .plus {
  419. font-size: 60rpx;
  420. color: #CCCCCC;
  421. line-height: 1;
  422. }
  423. .upload-text {
  424. font-size: 22rpx;
  425. color: #999;
  426. margin-top: 8rpx;
  427. }
  428. /* 文本域 */
  429. .textarea-box {
  430. background-color: #F8F9FA;
  431. border-radius: 12rpx;
  432. padding: 24rpx;
  433. border: 1px solid #EEEEEE;
  434. }
  435. .content-textarea {
  436. width: 100%;
  437. min-height: 200rpx;
  438. font-size: 28rpx;
  439. color: #333;
  440. line-height: 1.5;
  441. }
  442. .word-count {
  443. text-align: right;
  444. display: block;
  445. font-size: 22rpx;
  446. color: #BBB;
  447. margin-top: 10rpx;
  448. }
  449. /* 底部按钮 */
  450. .bottom-action {
  451. position: fixed;
  452. bottom: 0;
  453. left: 0;
  454. right: 0;
  455. background-color: #fff;
  456. padding: 30rpx 40rpx;
  457. padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
  458. box-shadow: 0 -10rpx 30rpx rgba(0, 0, 0, 0.05);
  459. z-index: 99;
  460. }
  461. .confirm-btn {
  462. background: linear-gradient(90deg, #FF9800 0%, #FF5722 100%);
  463. color: #fff;
  464. height: 88rpx;
  465. line-height: 88rpx;
  466. border-radius: 44rpx;
  467. font-size: 32rpx;
  468. font-weight: bold;
  469. box-shadow: 0 8rpx 20rpx rgba(255, 87, 34, 0.3);
  470. }
  471. .confirm-btn.disabled {
  472. background: #E0E0E0;
  473. box-shadow: none;
  474. color: #fff;
  475. }
  476. </style>