detail.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <mobile-frame>
  3. <view class="info">
  4. <view class="one">
  5. <uni-forms ref="form" :modelValue="form" :rules="rules" label-width="auto">
  6. <uni-forms-item label="快递类型查询" name="transport_type">
  7. <uni-easyinput type="text" @change="searchOther" v-model="form.transport_type" placeholder="请输入快递类型" />
  8. </uni-forms-item>
  9. <uni-forms-item label="快递类型" name="customer_transport_type">
  10. <picker class="picker" mode="selector" :range="typeList" @change="typeChange" range-key="label">
  11. <view>{{form.type_name||'请选择快递类型'}}</view>
  12. </picker>
  13. </uni-forms-item>
  14. <uni-forms-item label="维护快递单号" name="customer_transport_no">
  15. <uni-easyinput type="text" v-model="form.customer_transport_no" placeholder="请输入快递单号" />
  16. </uni-forms-item>
  17. </uni-forms>
  18. <view class="btn">
  19. <button type="primary" @click="onSubmit('form')" size="small">提交</button>
  20. </view>
  21. </view>
  22. </view>
  23. </mobile-frame>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. id: '',
  30. form: {},
  31. rules: {
  32. customer_transport_type: {
  33. rules: [{
  34. required: true,
  35. errorMessage: '请输入快递类型',
  36. }]
  37. },
  38. customer_transport_no: {
  39. rules: [{
  40. required: true,
  41. errorMessage: '请输入快递单号',
  42. }]
  43. }
  44. },
  45. typeList: [],
  46. };
  47. },
  48. onLoad: function(e) {
  49. const that = this;
  50. that.$set(that, `id`, e.id || '');
  51. that.watchLogin();
  52. },
  53. methods: {
  54. watchLogin() {
  55. const that = this;
  56. uni.getStorage({
  57. key: 'token',
  58. success: async (res) => {},
  59. fail: (err) => {
  60. uni.navigateTo({
  61. url: `/pages/login/index`
  62. })
  63. }
  64. })
  65. },
  66. typeChange(e) {
  67. const that = this;
  68. let data = that.typeList[e.detail.value];
  69. that.$set(that.form, `customer_transport_type`, data.value);
  70. that.$set(that.form, `type_name`, data.label);
  71. },
  72. // 提交保存
  73. async onSubmit(ref) {
  74. const that = this;
  75. that.$refs[ref].validate().then(async params => {
  76. let form = that.form;
  77. let transport = {};
  78. transport.customer_transport_no = params.customer_transport_no;
  79. transport.customer_transport_type = params.customer_transport_type;
  80. form.transport = transport;
  81. const arr = await that.$api(`/afterSale/${that.id}`, 'POST', form);
  82. if (arr.errcode == '0') {
  83. uni.showToast({
  84. title: `维护信息成功`,
  85. icon: 'success',
  86. });
  87. uni.navigateBack({
  88. detail: 1
  89. })
  90. } else {
  91. uni.showToast({
  92. title: arr.errmsg,
  93. icon: 'none',
  94. })
  95. }
  96. })
  97. },
  98. // 查询其他信息
  99. async searchOther(e) {
  100. const that = this;
  101. let res = await that.$api(`/dictData`, 'GET', {
  102. code: "transport_type",
  103. label: e
  104. });
  105. if (res.errcode == '0') {
  106. that.$set(that, `typeList`, res.data);
  107. }
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. .info {
  114. display: flex;
  115. flex-direction: column;
  116. width: 100vw;
  117. height: 100vh;
  118. .one {
  119. padding: 2vw;
  120. .uni-input {
  121. border: #f1f1ff 1px solid;
  122. padding: 2vw 2vw;
  123. border-radius: 1vw;
  124. }
  125. .picker {
  126. border: 1px solid #3333;
  127. border-radius: 5px;
  128. padding: 2vw;
  129. }
  130. .btn {
  131. text-align: center;
  132. button {
  133. margin: 0 2vw 2vw 2vw;
  134. background-color: var(--ff0Color);
  135. color: var(--fffColor);
  136. }
  137. .name {
  138. color: var(--f85Color);
  139. font-size: var(--font14Size);
  140. }
  141. }
  142. }
  143. }
  144. .uni-forms-item {
  145. margin-bottom: 6vw !important;
  146. display: flex;
  147. flex-direction: row;
  148. }
  149. </style>