weight-modify.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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" type="success" @click="submitForm" text="提交" class="submit-button" />
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import {
  30. ref,
  31. reactive
  32. } from 'vue';
  33. import {
  34. onLoad
  35. } from '@dcloudio/uni-app'
  36. import cyUpload from '@/components/cy-upload/index.vue'
  37. const placeholderStyle = "font-size:32rpx"
  38. const customStyle = reactive({
  39. height: '90rpx'
  40. })
  41. const formRef = ref(null);
  42. const form = ref({
  43. "packageCode": "",
  44. "batchNum": "",
  45. "godownId": '',
  46. "otherInfo": "",
  47. "actualWeight": '',
  48. "imgUrlList": []
  49. });
  50. const rules = {
  51. packageCode: [{
  52. required: true,
  53. message: '请输入物流单号',
  54. trigger: 'blur'
  55. }],
  56. actualWeight: [{
  57. required: true,
  58. message: '请输入重量',
  59. trigger: 'blur'
  60. }]
  61. };
  62. function scanCode() {
  63. uni.scanCode({
  64. success: (res) => {
  65. form.value.packageCode = res.result;
  66. },
  67. fail: (err) => {
  68. uni.$u.toast('扫码失败')
  69. }
  70. });
  71. }
  72. function submitForm() {
  73. formRef.value.validate().then((valid) => {
  74. if (valid) {
  75. uni.$u.http.post('/app/ordersign/changeWeight', form.value).then(res => {
  76. if (res.code == 200) {
  77. uni.$u.toast('重量修改成功')
  78. let text = code + '已提交审核'
  79. uni.$u.ttsModule.speak(text)
  80. } else {
  81. let text = code + '订单不存在'
  82. uni.$u.ttsModule.speak(text)
  83. }
  84. })
  85. }
  86. });
  87. }
  88. onLoad(() => {
  89. // #ifdef APP-PLUS
  90. uni.$u.useGlobalEvent((e) => {
  91. form.value.packageCode = e.barcode
  92. })
  93. // #endif
  94. })
  95. </script>
  96. <style>
  97. page {
  98. background-color: #ffffff;
  99. }
  100. </style>
  101. <style scoped>
  102. .container {
  103. display: flex;
  104. flex-direction: column;
  105. padding: 20px;
  106. }
  107. </style>