index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <van-popup
  3. v-model="popupShow"
  4. get-container="body"
  5. position="right"
  6. class="more-search-popup"
  7. :style="{ width: '80%' }"
  8. @close="close"
  9. >
  10. <van-nav-bar
  11. :title="title"
  12. fixed
  13. />
  14. <div class="ibps-fixed-navbar-toolbar ibps-fixed-top">
  15. <van-cell-group>
  16. <search-field
  17. ref="searchForm"
  18. :forms="searchForms.forms"
  19. :input-align="searchForms.inputAlign"
  20. >
  21. <!-- 默认只有 文本 下拉 日期 其余走插槽-->
  22. <div
  23. v-for="(form,i) in slotForms()"
  24. :key="form.slotName+i"
  25. :slot="form.slotName"
  26. >
  27. <slot :name="form.slotName" :item="form" />
  28. </div>
  29. </search-field>
  30. </van-cell-group>
  31. <!-- 操作按钮-->
  32. <slot name="toolbar">
  33. <ibps-toolbar
  34. v-if="actions && actions.length >0"
  35. ref="toolbar"
  36. :actions="actions"
  37. />
  38. </slot>
  39. </div>
  40. </van-popup>
  41. </template>
  42. <script>
  43. import IbpsToolbar from '@/components/ibps-toolbar'// 工具栏
  44. import searchField from './search-field'
  45. export default {
  46. name: 'ibps-more-search',
  47. components: {
  48. searchField,
  49. IbpsToolbar
  50. },
  51. props: {
  52. show: Boolean,
  53. searchForms: {
  54. type: Object,
  55. default: () => {}
  56. },
  57. title: {
  58. type: String,
  59. default: '高级搜索'
  60. }
  61. },
  62. data() {
  63. return {
  64. popupShow: this.show,
  65. actions: [
  66. {
  67. name: '取消',
  68. type: 'default',
  69. callback: this.cancel
  70. },
  71. {
  72. name: '重置',
  73. type: 'warning',
  74. callback: this.reset
  75. },
  76. {
  77. name: '确定',
  78. type: 'primary',
  79. callback: this.confirm
  80. }
  81. ]
  82. // slotNameForm: this.slotForms()
  83. }
  84. },
  85. watch: {
  86. show: {
  87. handler: function(val, oldVal) {
  88. this.popupShow = val
  89. },
  90. immediate: true
  91. }
  92. },
  93. methods: {
  94. slotForms() {
  95. const forms = this.searchForms ? this.searchForms.forms || [] : []
  96. return forms.filter((form) => form.slotName)
  97. },
  98. cancel() {
  99. this.close()
  100. },
  101. reset() {
  102. this.$refs['searchForm'].resetSearchForm()
  103. this.$emit('reset-form')
  104. },
  105. confirm() {
  106. const data = this.$refs['searchForm'].getData()
  107. this.close()
  108. this.$emit('callback', data)
  109. },
  110. close() {
  111. this.popupShow = false
  112. this.$emit('close', this.popupShow)
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. .more-search-popup {
  119. width: 60%;
  120. height: 100%;
  121. .ibps-search-field__label{
  122. padding: 10px 16px 0 16px;
  123. font-size: 12px;
  124. // color: #969799;
  125. }
  126. .ibps-checker{
  127. width: 100%;
  128. }
  129. }
  130. </style>