copy-search-form.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <wd-popup
  3. v-model="visible"
  4. position="top"
  5. custom-style="border-radius: 0 0 24rpx 24rpx;"
  6. safe-area-inset-top
  7. @close="visible = false"
  8. >
  9. <view class="p-32rpx">
  10. <view class="mb-24rpx text-32rpx text-[#333] font-semibold">
  11. 搜索流程
  12. </view>
  13. <view class="mb-24rpx">
  14. <view class="mb-12rpx text-28rpx text-[#666]">
  15. 流程名称
  16. </view>
  17. <wd-input
  18. v-model="formData.processInstanceName"
  19. placeholder="请输入流程名称"
  20. clearable
  21. />
  22. </view>
  23. <view class="mb-32rpx">
  24. <view class="mb-12rpx text-28rpx text-[#666]">
  25. 抄送时间
  26. </view>
  27. <view class="flex items-center gap-16rpx">
  28. <view class="flex-1" @click="showStartPicker = true">
  29. <view
  30. class="h-72rpx flex items-center justify-center rounded-8rpx bg-[#f5f5f5] px-24rpx text-28rpx"
  31. >
  32. {{ formatDate(formData.createTime?.[0]) || '开始日期' }}
  33. </view>
  34. </view>
  35. <text class="text-28rpx text-[#999]">至</text>
  36. <view class="flex-1" @click="showEndPicker = true">
  37. <view
  38. class="h-72rpx flex items-center justify-center rounded-8rpx bg-[#f5f5f5] px-24rpx text-28rpx"
  39. >
  40. {{ formatDate(formData.createTime?.[1]) || '结束日期' }}
  41. </view>
  42. </view>
  43. </view>
  44. <wd-datetime-picker-view
  45. v-if="showStartPicker"
  46. v-model="tempCreateTime[0]"
  47. type="date"
  48. :columns-height="200"
  49. />
  50. <view v-if="showStartPicker" class="mt-16rpx flex justify-end gap-16rpx">
  51. <wd-button size="small" plain @click="handleStartCancel">
  52. 取消
  53. </wd-button>
  54. <wd-button size="small" type="primary" @click="handleStartConfirm">
  55. 确定
  56. </wd-button>
  57. </view>
  58. <wd-datetime-picker-view
  59. v-if="showEndPicker"
  60. v-model="tempCreateTime[1]"
  61. type="date"
  62. :columns-height="200"
  63. />
  64. <view v-if="showEndPicker" class="mt-16rpx flex justify-end gap-16rpx">
  65. <wd-button size="small" plain @click="handleEndCancel">
  66. 取消
  67. </wd-button>
  68. <wd-button size="small" type="primary" @click="handleEndConfirm">
  69. 确定
  70. </wd-button>
  71. </view>
  72. </view>
  73. <view class="w-full flex justify-center gap-24rpx">
  74. <wd-button class="flex-1" plain @click="handleReset">
  75. 重置
  76. </wd-button>
  77. <wd-button class="flex-1" type="primary" @click="handleSearch">
  78. 搜索
  79. </wd-button>
  80. </view>
  81. </view>
  82. </wd-popup>
  83. </template>
  84. <script lang="ts" setup>
  85. import { computed, reactive, ref, watch } from 'vue'
  86. import { formatDate } from '@/utils/date'
  87. /** 搜索表单数据 */
  88. export interface CopySearchFormData {
  89. processInstanceName?: string
  90. createTime?: [number | undefined, number | undefined]
  91. }
  92. const props = defineProps<{
  93. modelValue: boolean
  94. searchParams?: Partial<CopySearchFormData>
  95. }>()
  96. const emit = defineEmits<{
  97. 'update:modelValue': [value: boolean]
  98. 'search': [data: CopySearchFormData]
  99. 'reset': []
  100. }>()
  101. const visible = computed({
  102. get: () => props.modelValue,
  103. set: (val: boolean) => emit('update:modelValue', val),
  104. })
  105. const formData = reactive<CopySearchFormData>({
  106. processInstanceName: undefined,
  107. createTime: [undefined, undefined],
  108. })
  109. // 时间选择器状态
  110. const showStartPicker = ref(false)
  111. const showEndPicker = ref(false)
  112. const tempCreateTime = ref<[number, number]>([Date.now(), Date.now()])
  113. /** 开始时间确认 */
  114. function handleStartConfirm() {
  115. formData.createTime = [tempCreateTime.value[0], formData.createTime?.[1]]
  116. showStartPicker.value = false
  117. }
  118. /** 开始时间取消 */
  119. function handleStartCancel() {
  120. showStartPicker.value = false
  121. }
  122. /** 结束时间确认 */
  123. function handleEndConfirm() {
  124. formData.createTime = [formData.createTime?.[0], tempCreateTime.value[1]]
  125. showEndPicker.value = false
  126. }
  127. /** 结束时间取消 */
  128. function handleEndCancel() {
  129. showEndPicker.value = false
  130. }
  131. /** 监听弹窗打开,同步外部参数 */
  132. watch(() => props.modelValue, (val) => {
  133. if (val && props.searchParams) {
  134. formData.processInstanceName = props.searchParams.processInstanceName
  135. formData.createTime = props.searchParams.createTime ?? [undefined, undefined]
  136. }
  137. })
  138. /** 搜索 */
  139. function handleSearch() {
  140. visible.value = false
  141. emit('search', { ...formData })
  142. }
  143. /** 重置 */
  144. function handleReset() {
  145. formData.processInstanceName = undefined
  146. formData.createTime = [undefined, undefined]
  147. visible.value = false
  148. emit('reset')
  149. }
  150. </script>