weight-modify.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="container">
  3. <u--form ref="formRef" :model="form" :rules="rules" label-width="165px" label-position="top"
  4. :labelStyle="{ fontSize: '32rpx' }" errorType="toast">
  5. <!-- 物流单号输入 -->
  6. <u-form-item label="" prop="packageCode">
  7. <u-input :placeholderStyle="placeholderStyle" :customStyle="customStyle" v-model="form.packageCode"
  8. placeholder="扫描/输入物流单号" border="surround" name="packageCode" />
  9. </u-form-item>
  10. <!-- 重量输入 -->
  11. <u-form-item label="重量(kg)" prop="actualWeight">
  12. <u-input :placeholderStyle="placeholderStyle" :customStyle="customStyle" v-model="form.actualWeight"
  13. placeholder="请输入重量" border="surround" name="actualWeight" type="number" />
  14. </u-form-item>
  15. <!-- 图片上传 -->
  16. <u-form-item label="上传图片" prop="imgUrlList">
  17. <cy-upload v-model:filename="form.imgUrlList" name="imgUrlList" :limit="10" :max-size="1024 * 1024">
  18. </cy-upload>
  19. </u-form-item>
  20. </u--form>
  21. <!-- 底部按钮 -->
  22. <view class="fixed-bottom">
  23. <u-button size="large" type="warning" @click="scanCode" text="扫码" class="scan-button" />
  24. <u-button size="large" v-permission="'app:express:changeWeight:confirm'" type="success" @click="submitForm"
  25. text="提交" class="submit-button" />
  26. </view>
  27. </view>
  28. </template>
  29. <script setup>
  30. import {
  31. ref,
  32. reactive,
  33. onUnmounted
  34. } from 'vue';
  35. import {
  36. onLoad,
  37. onShow
  38. } from '@dcloudio/uni-app'
  39. import cyUpload from '@/components/cy-upload/index.vue'
  40. const placeholderStyle = "font-size:32rpx"
  41. const customStyle = reactive({
  42. height: '90rpx'
  43. })
  44. const formRef = ref(null);
  45. const selectedWarehouse = ref('');
  46. const showSelector = ref(false);
  47. const form = ref({
  48. "packageCode": "",
  49. "batchNum": "",
  50. "godownId": '',
  51. "godownName": '',
  52. "otherInfo": "",
  53. "actualWeight": '',
  54. "imgUrlList": []
  55. });
  56. const rules = {
  57. packageCode: [{
  58. required: true,
  59. message: '请输入物流单号',
  60. trigger: 'blur'
  61. }],
  62. actualWeight: [{
  63. required: true,
  64. message: '请输入重量',
  65. trigger: 'blur'
  66. }],
  67. godownId: [{
  68. required: true,
  69. message: '请选择仓库',
  70. trigger: 'blur'
  71. }]
  72. };
  73. //获取用户绑定的仓库
  74. function getUserBindWarehouse() {
  75. uni.$u.http.get('/app/appUser/getUserBindGodown').then(res => {
  76. if (res.code == 200) {
  77. selectedWarehouse.value = res.data?.godownName || ''
  78. form.value.godownId = res.data?.id || ''
  79. form.value.godownName = res.data?.godownName || ''
  80. }
  81. })
  82. }
  83. function scanCode() {
  84. uni.scanCode({
  85. success: (res) => {
  86. form.value.packageCode = res.result;
  87. },
  88. fail: (err) => {
  89. uni.$u.toast('扫码失败')
  90. }
  91. });
  92. }
  93. function submitForm() {
  94. formRef.value.validate().then((valid) => {
  95. if (valid) {
  96. uni.$u.http.post('/app/ordersign/changeWeight', form.value).then(res => {
  97. if (res.code == 200) {
  98. uni.$u.toast('重量修改成功')
  99. let text = form.value.packageCode + '已提交审核'
  100. uni.$u.ttsModule.speak(text)
  101. } else {
  102. let text = form.value.packageCode + '订单不存在'
  103. uni.$u.ttsModule.speak(text)
  104. }
  105. })
  106. }
  107. });
  108. }
  109. // #ifdef APP-PLUS
  110. const { unregister } = uni.$u.useEventListener((e) => {
  111. form.value.packageCode = e.barcode
  112. });
  113. // #endif
  114. onLoad(() => {
  115. getUserBindWarehouse()
  116. })
  117. onUnmounted(() => {
  118. // #ifdef APP-PLUS
  119. unregister();
  120. // #endif
  121. });
  122. </script>
  123. <style>
  124. page {
  125. background-color: #ffffff;
  126. }
  127. </style>
  128. <style scoped>
  129. .container {
  130. display: flex;
  131. flex-direction: column;
  132. padding: 20px;
  133. }
  134. .input-group {
  135. display: flex;
  136. gap: 10px;
  137. margin-bottom: 30rpx;
  138. }
  139. .input-group :deep(.u-button) {
  140. width: 160rpx
  141. }
  142. .input-group .u-input {
  143. background-color: #fff;
  144. }
  145. .fixed-bottom {
  146. position: fixed;
  147. bottom: 0;
  148. left: 0;
  149. right: 0;
  150. display: flex;
  151. gap: 20rpx;
  152. padding: 20rpx;
  153. background-color: white;
  154. border-top: 1px solid #eee;
  155. }
  156. .scan-button {
  157. flex: 1;
  158. background-color: #ff9500 !important;
  159. border-color: #ff9500 !important;
  160. }
  161. .submit-button {
  162. flex: 1;
  163. background-color: #52c41a !important;
  164. border-color: #52c41a !important;
  165. }
  166. </style>