user-search.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <ArtSearchBar
  3. ref="searchBarRef"
  4. v-model="formData"
  5. :items="formItems"
  6. :rules="rules"
  7. :showExpand="false"
  8. :isExpand="true"
  9. @reset="handleReset"
  10. @search="handleSearch"
  11. >
  12. </ArtSearchBar>
  13. </template>
  14. <script setup lang="ts">
  15. import { ref, computed, onMounted, h } from 'vue'
  16. interface Props {
  17. modelValue: Record<string, any>
  18. schoolList: Api.Common.SelectRelationInfo[]
  19. companyList: Api.Common.SelectInfo[],
  20. userList: Api.Common.SelectInfo[]
  21. }
  22. interface Emits {
  23. (e: 'update:modelValue', value: Record<string, any>): void
  24. (e: 'search', params: Record<string, any>): void
  25. (e: 'reset'): void
  26. }
  27. const props = defineProps<Props>()
  28. const emit = defineEmits<Emits>()
  29. // 表单数据双向绑定
  30. const searchBarRef = ref()
  31. const formData = computed({
  32. get: () => props.modelValue,
  33. set: (val) => emit('update:modelValue', val)
  34. })
  35. // 校验规则
  36. const rules = {
  37. // name: [{ required: true, message: '请输入用户名', trigger: 'blur' }]
  38. }
  39. const props1 = {
  40. checkStrictly: true
  41. }
  42. // 表单配置
  43. const formItems = computed(() => [
  44. {
  45. label: '食堂名称',
  46. key: 'name',
  47. type: 'input',
  48. placeholder: '请输入食堂名称',
  49. clearable: true
  50. },
  51. {
  52. label: '餐饮公司',
  53. key: 'company_id',
  54. type: 'select',
  55. filterable: true,
  56. props: {
  57. options: props.companyList.map((item) => ({
  58. label: item.name,
  59. value: item.id
  60. }))
  61. }
  62. },
  63. {
  64. label: '学校',
  65. key: 'school_id',
  66. type: 'select',
  67. props: {
  68. filterable: true,
  69. placeholder: '可搜索',
  70. clearable: true,
  71. options: props.schoolList.map((item) => ({
  72. label: item.name,
  73. value: item.id
  74. }))
  75. }
  76. },
  77. {
  78. label: '是否直营',
  79. key: 'is_direct',
  80. type: 'select',
  81. filterable: true,
  82. props: {
  83. options: [
  84. { label: '全部', value: -1 },
  85. { label: '直营', value: 1 },
  86. { label: '非直营', value: 0 }
  87. ]
  88. }
  89. },
  90. {
  91. label: '手机号',
  92. key: 'phone',
  93. type: 'input',
  94. placeholder: '请输入手机号',
  95. clearable: true
  96. },
  97. {
  98. label: '最后跟进人',
  99. key: 'last_user_id',
  100. type: 'select',
  101. labelWidth: '90px',
  102. span:6,
  103. filterable: true,
  104. props: {
  105. emptyValues:[0],
  106. valueOnClear:0,
  107. options: props.userList.map((item) => ({
  108. label: item.name,
  109. value: item.id
  110. })),
  111. },
  112. },
  113. {
  114. label: '最后跟进时间',
  115. key: 'last_date',
  116. span:8,
  117. labelWidth: '100px',
  118. type: 'datetimerange',
  119. filterable: true,
  120. props: {
  121. type: 'datetimerange',
  122. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  123. rangeSeparator: '至',
  124. startPlaceholder: '开始日期时间',
  125. endPlaceholder: '结束日期时间'
  126. }
  127. },
  128. ])
  129. // 事件
  130. function handleReset() {
  131. emit('reset')
  132. }
  133. async function handleSearch() {
  134. await searchBarRef.value.validate()
  135. emit('search', formData.value)
  136. }
  137. </script>