com-search.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <style>
  2. .com-search {
  3. padding: 15px;
  4. }
  5. .com-search div {
  6. margin-right: 5px;
  7. }
  8. .com-search .clean {
  9. color: #92959B;
  10. margin-left: 20px;
  11. cursor: pointer;
  12. font-size: 15px;
  13. }
  14. .com-search .input-item {
  15. display: inline-block;
  16. width: 250px;
  17. }
  18. .com-search .input-item .el-input__inner {
  19. border-right: 0;
  20. }
  21. .com-search .input-item .el-input__inner:hover {
  22. border: 1px solid #dcdfe6;
  23. border-right: 0;
  24. outline: 0;
  25. }
  26. .com-search .input-item .el-input__inner:focus {
  27. border: 1px solid #dcdfe6;
  28. border-right: 0;
  29. outline: 0;
  30. }
  31. .com-search .input-item .el-input-group__append {
  32. background-color: #fff;
  33. border-left: 0;
  34. width: 10%;
  35. padding: 0;
  36. }
  37. .com-search .input-item .el-input-group__append .el-button {
  38. padding: 0;
  39. }
  40. .com-search .input-item .el-input-group__append .el-button {
  41. margin: 0;
  42. }
  43. </style>
  44. <template id="com-search">
  45. <div class="com-search" flex="cross:center">
  46. <!-- <div v-if="isShowPayType">-->
  47. <!-- <el-select style="width: 150px;" size="small" v-model="search.pay_type" @change='getList'>-->
  48. <!-- <el-option key="all" label="全部支付方式" value=""></el-option>-->
  49. <!-- <el-option key="1" label="微信" value="wechat"></el-option>-->
  50. <!-- <el-option key="3" label="余额" value="balance"></el-option>-->
  51. <!-- </el-select>-->
  52. <!-- </div>-->
  53. <slot name="select"></slot>
  54. <!-- 时间选择框 -->
  55. <template v-if="isShowPicker">
  56. <div>
  57. <el-date-picker
  58. size="small"
  59. @change="changeTime"
  60. style="width: 350px"
  61. v-model="search.time"
  62. type="daterange"
  63. value-format="yyyy-MM-dd"
  64. range-separator="至"
  65. start-placeholder="开始日期"
  66. end-placeholder="结束日期">
  67. </el-date-picker>
  68. </div>
  69. <div>
  70. <el-tabs v-model="activeName" @tab-click="tabTotal">
  71. <el-tab-pane label="7日" name="week"></el-tab-pane>
  72. <el-tab-pane label="30日" name="month"></el-tab-pane>
  73. </el-tabs>
  74. </div>
  75. </template>
  76. <div v-if="isShowKeyword" class="input-item">
  77. <el-input
  78. @keyup.enter.native="getList"
  79. @clear="getList"
  80. clearable
  81. size="small"
  82. :placeholder="placeholder"
  83. v-model="search.name">
  84. <el-button slot="append" icon="el-icon-search" @click="getList"></el-button>
  85. </el-input>
  86. </div>
  87. <div>
  88. <el-button type="primary" class=" el-button el-button--mini" @click="primary">搜索</el-button>
  89. <button class="el-button el-button--mini" @click="clean">清空筛选</button>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. Vue.component('com-search', {
  95. template: '#com-search',
  96. props: {
  97. newSearch: {
  98. type: Object,
  99. default: function () {
  100. return {}
  101. }
  102. },
  103. dayData: {
  104. type: Object,
  105. default: function () {
  106. return {}
  107. }
  108. },
  109. isShowPlatform: {
  110. type: Boolean,
  111. default: true
  112. },
  113. isShowPayType: {
  114. type: Boolean,
  115. default: false
  116. },
  117. isShowKeyword: {
  118. type: Boolean,
  119. default: true
  120. },
  121. isShowPicker: {
  122. type: Boolean,
  123. default: true
  124. },
  125. placeholder: {
  126. type: String,
  127. default: '请输入搜索内容'
  128. }
  129. },
  130. data() {
  131. return {
  132. search: {},
  133. // 日期选中状态
  134. activeName: '',
  135. // 店铺列表
  136. mch_list: [],
  137. // 今天
  138. today: '',
  139. // 七天前
  140. weekDay: '',
  141. // 30天前
  142. monthDay: '',
  143. plugins_list: [],
  144. var1:false
  145. }
  146. },
  147. watch: {
  148. // isShowPayType: {
  149. // deep:true,
  150. //                 immediate: true,
  151. //                 handler(val) {
  152. // this.var1 = val
  153. // }
  154. // }
  155. },
  156. methods: {
  157. // 清空筛选
  158. clean() {
  159. this.search = {
  160. time: null,
  161. date_start: null,
  162. date_end: null,
  163. platform: '',
  164. pay_type: '',
  165. name: '',
  166. };
  167. this.activeName = null;
  168. this.getList();
  169. },
  170. primary(){
  171. this.getList();
  172. },
  173. // 选择时间区间
  174. tabTotal() {
  175. console.log(this.activeName);
  176. if (this.activeName == 'week') {
  177. this.search.time = [this.weekDay, this.today];
  178. }
  179. if (this.activeName == 'month') {
  180. this.search.time = [this.monthDay, this.today];
  181. }
  182. this.search.date_start = this.search.time[0];
  183. this.search.date_end = this.search.time[1];
  184. //this.getList()
  185. },
  186. // 自定义时间
  187. changeTime() {
  188. this.activeName = null;
  189. if (this.search.time) {
  190. this.search.date_start = this.search.time[0];
  191. this.search.date_end = this.search.time[1];
  192. } else {
  193. this.search.date_start = null;
  194. this.search.date_end = null;
  195. }
  196. //this.getList();
  197. },
  198. getList() {
  199. this.$emit('search', this.search)
  200. },
  201. // 废弃
  202. toSearch() {
  203. this.$emit('to-search', this.search)
  204. }
  205. },
  206. created() {
  207. this.search = this.newSearch;
  208. this.today = this.dayData.today;
  209. this.weekDay = this.dayData.weekDay;
  210. this.monthDay = this.dayData.monthDay;
  211. }
  212. })
  213. </script>