MySearch.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <u-popup lock-scroll :show="show" closeOnClickOverlay mode="top" @close="close" @open="open">
  3. <view class="container">
  4. <u--form ref="form" labelPosition="left" :model="formData" labelWidth="180" labelAlign="left">
  5. <block v-for="(item, index) in formItems" :key="index">
  6. <!-- <slot name='slot'></slot> -->
  7. <u-form-item :label="item.label" :prop="item.prop">
  8. <component :is="item.component" v-model="formData[item.prop]" v-bind="item.props"
  9. v-on="item.events" :ref="item.prop" />
  10. </u-form-item>
  11. </block>
  12. </u--form>
  13. <view class="action">
  14. <u-button text="重置" shape="circle" style="color: #000;" @click="reset"></u-button>
  15. <u-button type="primary" text="确定" shape="circle" @click="search"></u-button>
  16. </view>
  17. <!-- <u--input ref="kk" placeholder="请输入内容" border="surround" clearable focus></u--input> -->
  18. <!-- <slot name="picker"></slot> -->
  19. </view>
  20. </u-popup>
  21. </template>
  22. <script>
  23. import MyInput from '@/uni_modules/uview-ui/components/u--input/u--input.vue'
  24. import MyPicker from '@/uni_modules/uview-ui/components/u-picker/u-picker.vue'
  25. import MyDateRange from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
  26. import MySelect from '@/uni_modules/zxz-uni-data-select/components/zxz-uni-data-select/zxz-uni-data-select.vue'
  27. // <zxz-uni-data-select :localdata="option.dimension" v-model="form.dimension" dataValue='type'
  28. // dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  29. export default {
  30. name: "MySearch",
  31. components: {
  32. MyInput,
  33. MyPicker,
  34. MyDateRange,
  35. MySelect
  36. },
  37. props: {
  38. show: {
  39. type: Boolean,
  40. default: false
  41. },
  42. formItems: {
  43. type: Array,
  44. default: () => []
  45. },
  46. initialData: {
  47. type: Object,
  48. default: () => ({})
  49. }
  50. },
  51. data() {
  52. return {
  53. formData: {},
  54. };
  55. },
  56. watch: {
  57. initialData: {
  58. handler(newVal) {
  59. console.log(newVal);
  60. this.formData = {
  61. ...newVal
  62. };
  63. },
  64. deep: true
  65. }
  66. },
  67. methods: {
  68. open() {
  69. console.log(this.formData);
  70. console.log(this.formItems);
  71. },
  72. close() {
  73. this.$emit('update:show', false)
  74. },
  75. maskClick(e) {
  76. console.log('maskClick事件:', e);
  77. },
  78. reset() {
  79. // this.form = {
  80. // ...this.initialData
  81. // }
  82. this.formData = {}
  83. console.log(this.formData);
  84. },
  85. search() {
  86. this.close()
  87. this.$emit('search', this.formData)
  88. }
  89. },
  90. created() {
  91. console.log(this);
  92. },
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .container {
  97. padding: 20rpx;
  98. }
  99. /deep/.u-form-item__body {
  100. padding: 16rpx 0
  101. }
  102. /deep/.uni-date__icon-clear {
  103. border: none !important;
  104. transform: translateY(25%);
  105. }
  106. .action {
  107. padding: 20rpx;
  108. display: flex;
  109. }
  110. /deep/.u-button {
  111. width: 40%;
  112. }
  113. .form-button-container {
  114. display: flex;
  115. justify-content: space-around;
  116. margin-top: 20px;
  117. }
  118. /deep/.uni-stat__select {
  119. background-color: #fff;
  120. }
  121. </style>