weight-modify.vue 3.3 KB

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