orderSearch.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <!-- 订单中心 - 搜索弹窗 -->
  3. <div class="orderSearch flex-col">
  4. <van-popup v-model:show="sheetShow" round class="orderSearchPopup">
  5. <div class="content">
  6. <van-form @submit="onSubmit">
  7. <van-field v-model="userName" name="userName" :label="$t('orderCenter.userNameLabel')"
  8. :placeholder="$t('orderCenter.userNamePlaceholder')" />
  9. <van-field v-model="sn" name="sn" :label="$t('orderCenter.orderNo')"
  10. :placeholder="$t('orderCenter.orderNoPlaceholder')" />
  11. <van-field v-model="trxNo" name="trxNo" :label="$t('orderCenter.orderSerialNumberLabel')"
  12. :placeholder="$t('orderCenter.orderSerialNumberPlaceholder')" />
  13. <van-field v-model="clientId" name="clientId" :label="$t('orderCenter.equipmentNo')"
  14. :placeholder="$t('orderCenter.equipmentNoPlaceholder')" />
  15. <div class="van-cell van-field">
  16. <div class="van-cell__title van-field__label">
  17. <label id="van-field-4-label" for="van-field-4-input">{{ $t('orderCenter.orderDate') }}</label>
  18. </div>
  19. <div class="van-cell__value van-field__value">
  20. <div class="van-field__body">
  21. <input type="text" class="van-field__control" :placeholder="$t('orderCenter.startTime')"
  22. style="text-align: center; width: 50%;" v-model="startTime" @click="startTimeClick()" />
  23. <span>{{ $t('orderCenter.to') }}</span>
  24. <input type="text" class="van-field__control" :placeholder="$t('orderCenter.endTime')"
  25. style="text-align: center; width: 50%;" v-model="endTime" @click="endTimeClick()" />
  26. </div>
  27. </div>
  28. </div>
  29. <!-- 操作 -->
  30. <van-row justify="space-around" style="padding: 1em;">
  31. <van-button span="5" round type="primary" style="height: 2em; padding: 0 2em;" native-type="submit">
  32. {{ $t('orderCenter.clickSearch') }}
  33. </van-button>
  34. </van-row>
  35. </van-form>
  36. </div>
  37. </van-popup>
  38. <van-popup v-model:show="startDateShow" round position="bottom">
  39. <van-datetime-picker v-model="startDate" type="datetime" :title="$t('orderCenter.selectFullTime')"
  40. @confirm="startDateConFirm($event)" @cancel="startDateCancel()" :min-date="minDate" />
  41. </van-popup>
  42. <van-popup v-model:show="endDateShow" round position="bottom">
  43. <van-datetime-picker v-model="endDate" type="datetime" :title="$t('orderCenter.selectFullTime')"
  44. @confirm="endDateConFirm($event)" @cancel="endDateCancel()" :min-date="minDate" />
  45. </van-popup>
  46. </div>
  47. </template>
  48. <script>
  49. import { ref } from 'vue';
  50. import dateUtil from "@/utils/dateUtil";
  51. import { Toast } from 'vant';
  52. export default {
  53. name: 'orderSearch',
  54. setup(prop, context) {
  55. const sheetShow = ref(false);
  56. const startDateShow = ref(false);
  57. const endDateShow = ref(false);
  58. const minDate = new Date(2018, 1, 1);
  59. const userName = ref(''); // 用户名
  60. const sn = ref(''); // 订单编号
  61. const trxNo = ref(''); // 订单流水号
  62. const clientId = ref(''); // 设备唯一码_设备编号
  63. const startDate = ref(''); // 订单时间-起始时间
  64. const endDate = ref('');
  65. const startTime = ref('');
  66. const endTime = ref('');
  67. // 父组件页面触发展示及初始化
  68. const showSearch = () => { sheetShow.value = true; };
  69. const startTimeClick = () => { if (startDate.value === '') { startDate.value = new Date(); } startDateShow.value = true; }
  70. const startDateConFirm = (data) => {
  71. startDate.value = dateUtil.formateDate(data, "yyyy-MM-dd hh:mm:ss");
  72. startDateShow.value = false;
  73. startTime.value = startDate.value;
  74. }
  75. const startDateCancel = () => {
  76. // startDate.value = dateUtil.formateDate(new Date(startDate.value), "yyyy-MM-dd hh:mm:ss");
  77. startDateShow.value = false;
  78. // startTime.value = startDate.value;
  79. }
  80. const endTimeClick = () => { if (endDate.value === '') { endDate.value = new Date(); } endDateShow.value = true; }
  81. const endDateConFirm = (data) => {
  82. endDate.value = dateUtil.formateDate(data, "yyyy-MM-dd hh:mm:ss");
  83. endDateShow.value = false;
  84. endTime.value = endDate.value;
  85. }
  86. const endDateCancel = () => {
  87. // endDate.value = dateUtil.formateDate(new Date(endDate.value), "yyyy-MM-dd hh:mm:ss");
  88. endDateShow.value = false;
  89. // endTime.value = endDate.value;
  90. }
  91. // 提交搜索表单触发搜索
  92. const onSubmit = () => {
  93. console.log('startTime.value', startTime.value)
  94. if (userName.value == '' && sn.value == '' && trxNo.value == '' && clientId.value == '') {
  95. if (startTime.value != '' || endTime.value != '') {
  96. Toast("请输入正确时间");
  97. return;
  98. } else {
  99. Toast("请输入搜索条件");
  100. return;
  101. }
  102. }
  103. const searchParam = {
  104. userName: userName.value,
  105. sn: sn.value,
  106. trxNo: trxNo.value,
  107. clientId: clientId.value,
  108. startDate: startTime.value,
  109. endDate: endTime.value,
  110. };
  111. context.emit('search', searchParam);
  112. sheetShow.value = false;
  113. }
  114. return {
  115. sheetShow,
  116. startDateShow,
  117. startDateConFirm,
  118. startDateCancel,
  119. endDateShow,
  120. endDateConFirm,
  121. endDateCancel,
  122. minDate,
  123. userName,
  124. sn,
  125. trxNo,
  126. clientId,
  127. startDate,
  128. endDate,
  129. showSearch,
  130. startTimeClick,
  131. endTimeClick,
  132. onSubmit,
  133. startTime,
  134. endTime,
  135. };
  136. },
  137. components: {},
  138. };
  139. </script>
  140. <style lang="less" scoped>
  141. .orderSearch {
  142. width: 100%;
  143. :deep(.orderSearchPopup) {
  144. width: 90%;
  145. }
  146. .content {
  147. padding-top: 1em;
  148. }
  149. .field .van-field__label {
  150. width: auto;
  151. }
  152. }
  153. </style>