weight-modify.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. } from 'vue';
  34. import {
  35. onLoad,
  36. onShow,
  37. onUnload
  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 form = ref({
  46. "packageCode": "",
  47. "batchNum": "",
  48. "godownId": '',
  49. "otherInfo": "",
  50. "actualWeight": '',
  51. "imgUrlList": []
  52. });
  53. const rules = {
  54. packageCode: [{
  55. required: true,
  56. message: '请输入物流单号',
  57. trigger: 'blur'
  58. }],
  59. actualWeight: [{
  60. required: true,
  61. message: '请输入重量',
  62. trigger: 'blur'
  63. }]
  64. };
  65. function scanCode() {
  66. uni.scanCode({
  67. success: (res) => {
  68. form.value.packageCode = res.result;
  69. },
  70. fail: (err) => {
  71. uni.$u.toast('扫码失败')
  72. }
  73. });
  74. }
  75. function submitForm() {
  76. formRef.value.validate().then((valid) => {
  77. if (valid) {
  78. uni.$u.http.post('/app/ordersign/changeWeight', form.value).then(res => {
  79. if (res.code == 200) {
  80. uni.$u.toast('重量修改成功')
  81. let text = code + '已提交审核'
  82. uni.$u.ttsModule.speak(text)
  83. } else {
  84. let text = code + '订单不存在'
  85. uni.$u.ttsModule.speak(text)
  86. }
  87. })
  88. }
  89. });
  90. }
  91. onLoad(() => {
  92. // #ifdef APP-PLUS
  93. uni.$u.useGlobalEvent((e) => {
  94. form.value.packageCode = e.barcode
  95. })
  96. // #endif
  97. })
  98. onShow(() => {
  99. uni.$u.updateActivePageOnShow()
  100. })
  101. onUnload(() => {
  102. uni.$u.cleanupOnPageUnload();
  103. });
  104. </script>
  105. <style>
  106. page {
  107. background-color: #ffffff;
  108. }
  109. </style>
  110. <style scoped>
  111. .container {
  112. display: flex;
  113. flex-direction: column;
  114. padding: 20px;
  115. }
  116. </style>