com-search.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <style>
  2. .com-search .tabs {
  3. margin-top: 20px;
  4. }
  5. .com-search .label {
  6. margin-right: 10px;
  7. }
  8. .com-search .item-box {
  9. margin-bottom: 10px;
  10. margin-right: 15px;
  11. }
  12. .com-search .clear-where {
  13. color: #419EFB;
  14. cursor: pointer;
  15. }
  16. </style>
  17. <template id="com-search">
  18. <div class="com-search">
  19. <div flex="wrap:wrap cross:center">
  20. <div style="height: 32px;">{{dateLabel}}:</div>
  21. <el-date-picker
  22. class="item-box"
  23. size="small"
  24. @change="changeTime"
  25. v-model="search.time"
  26. type="datetimerange"
  27. value-format="yyyy-MM-dd HH:mm:ss"
  28. range-separator="至"
  29. start-placeholder="开始日期"
  30. end-placeholder="结束日期">
  31. </el-date-picker>
  32. <div class="item-box" flex="dir:left cross:center">
  33. <div class="label">选择门店</div>
  34. <el-select size="small" style="width: 120px" v-model="search.store_id" @change="toSearch">
  35. <el-option label="全部" value="-99"></el-option>
  36. <el-option v-for="item in storeList" :key="item.id" :label="item.name"
  37. :value="item.id">
  38. </el-option>
  39. </el-select>
  40. </div>
  41. <div class="item-box" class="label">
  42. <el-input style="width: 350px" size="small" v-model="search.keyword" placeholder="请输入搜索内容" clearable
  43. @clear="toSearch"
  44. @keyup.enter.native="toSearch">
  45. <el-select style="width: 120px" slot="prepend" v-model="search.keyword_1">
  46. <el-option v-for="item in selectList" :key="item.value"
  47. :label="item.name"
  48. :value="item.value">
  49. </el-option>
  50. </el-select>
  51. </el-input>
  52. </div>
  53. <div class="item-box" flex="cross:center">
  54. <div v-if="isShowClear" @click="clearWhere" class="div-box clear-where">清空筛选条件</div>
  55. </div>
  56. </div>
  57. <div class="tabs">
  58. <el-tabs v-model="newActiveName" @tab-click="handleClick">
  59. <el-tab-pane v-for="(item, index) in tabs" :key="index" :label="item.name"
  60. :name="item.value"></el-tab-pane>
  61. </el-tabs>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. Vue.component('com-search', {
  67. template: '#com-search',
  68. props: {
  69. selectList: {
  70. type: Array,
  71. default: function () {
  72. return [
  73. {value: '1', name: '订单号'},
  74. {value: '9', name: '商户单号'},
  75. {value: '2', name: '用户名'},
  76. {value: '4', name: '用户ID'},
  77. {value: '5', name: '商品名称'},
  78. {value: '3', name: '收件人'},
  79. {value: '6', name: '收件人电话'},
  80. {value: '7', name: '门店名称'}
  81. ]
  82. }
  83. },
  84. tabs: {
  85. type: Array,
  86. default: function () {
  87. return [
  88. {value: '-1', name: '全部'},
  89. {value: '0', name: '未付款'},
  90. {value: '1', name: '待发货'},
  91. {value: '2', name: '待收货'},
  92. {value: '3', name: '已完成'},
  93. {value: '4', name: '待处理'},
  94. {value: '5', name: '已取消'},
  95. {value: '7', name: '回收站'},
  96. ]
  97. }
  98. },
  99. activeName: {
  100. type: String,
  101. default: '-1',
  102. },
  103. plugins: {
  104. type: Array,
  105. default: function () {
  106. return [
  107. {
  108. name: '全部订单',
  109. sign: 'all',
  110. }
  111. ];
  112. }
  113. },
  114. isShowOrderType: {
  115. type: Boolean,
  116. default: true
  117. },
  118. isShowOrderPlugin: {
  119. type: Boolean,
  120. default: false
  121. },
  122. newSearch: {
  123. type: Object,
  124. default: function () {
  125. return {
  126. time: null,
  127. keyword: '',
  128. keyword_1: '1',
  129. date_start: '',
  130. date_end: '',
  131. platform: '',
  132. status: '',
  133. plugin: 'all',
  134. send_type: -1,
  135. }
  136. }
  137. },
  138. dateLabel: {
  139. type: String,
  140. default: '下单时间'
  141. }
  142. },
  143. data() {
  144. return {
  145. search: {},
  146. newActiveName: null,
  147. isShowClear: false,
  148. storeList: []
  149. }
  150. },
  151. methods: {
  152. getStoreList() {
  153. request({
  154. params: {
  155. r: 'plugin/o2o_store/mall/store/index',
  156. status: 1
  157. },
  158. }).then(e => {
  159. if (e.data.code === 0) {
  160. this.storeList = e.data.data.list;
  161. }
  162. })
  163. },
  164. // 日期搜索
  165. changeTime() {
  166. if (this.search.time) {
  167. this.search.date_start = this.search.time[0];
  168. this.search.date_end = this.search.time[1];
  169. } else {
  170. this.search.date_start = null;
  171. this.search.date_end = null;
  172. }
  173. this.toSearch();
  174. },
  175. toSearch() {
  176. this.search.page = 1;
  177. this.$emit('search', this.search);
  178. this.checkSearch();
  179. },
  180. handleClick(res) {
  181. this.search.status = this.newActiveName;
  182. this.toSearch();
  183. },
  184. clearWhere() {
  185. this.search.keyword = '';
  186. this.search.date_start = null;
  187. this.search.date_end = null;
  188. this.search.time = null;
  189. this.search.platform = '';
  190. this.search.send_type = -1;
  191. this.search.plugin = 'all';
  192. this.toSearch();
  193. },
  194. checkSearch() {
  195. if (this.search.keyword || (this.search.date_start && this.search.date_end)
  196. || this.search.plugin != 'all' || this.search.send_type != -1
  197. || this.search.platform) {
  198. this.isShowClear = true;
  199. } else {
  200. this.isShowClear = false;
  201. }
  202. }
  203. },
  204. created() {
  205. this.search = this.newSearch;
  206. this.newActiveName = this.activeName;
  207. this.checkSearch();
  208. this.getStoreList();
  209. }
  210. })
  211. </script>