detail.vue 3.7 KB

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