weight-modify.vue 3.3 KB

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