com-search.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. $mchId = Yii::$app->admin->identity->mch_id;
  3. Yii::$app->loadComponentView('goods/com-add-cat');
  4. ?>
  5. <style>
  6. .com-search .search-box {
  7. margin-bottom: 10px;
  8. }
  9. .com-search .div-box {
  10. margin-right: 10px;
  11. }
  12. .com-search .input-item {
  13. display: inline-block;
  14. width: 250px;
  15. }
  16. .com-search .input-item .el-input__inner {
  17. border-right: 0;
  18. }
  19. .com-search .input-item .el-input__inner:hover {
  20. border: 1px solid #dcdfe6;
  21. border-right: 0;
  22. outline: 0;
  23. }
  24. .com-search .input-item .el-input__inner:focus {
  25. border: 1px solid #dcdfe6;
  26. border-right: 0;
  27. outline: 0;
  28. }
  29. .com-search .input-item .el-input-group__append {
  30. background-color: #fff;
  31. border-left: 0;
  32. width: 10%;
  33. padding: 0;
  34. }
  35. .com-search .input-item .el-input-group__append .el-button {
  36. padding: 0;
  37. }
  38. .com-search .input-item .el-input-group__append .el-button {
  39. margin: 0;
  40. }
  41. .com-search .clear-where {
  42. color: #419EFB;
  43. cursor: pointer;
  44. }
  45. </style>
  46. <template id="com-search">
  47. <div class="com-search">
  48. <div class="search-box" flex="dir:left cross-center">
  49. <div v-if="isShowCat" class="div-box">
  50. <!-- <el-button size="small" @click="$refs.cats.openDialog()">分类筛选</el-button>-->
  51. <el-button size="small" v-if="search.cats && search.cats.length > 0" type="danger" @click="clearCat">清除分类</el-button>
  52. </div>
  53. <div class="div-box" flex="dir:left">
  54. <div flex="cross:center" style="height: 32px;">添加时间:</div>
  55. <el-date-picker
  56. size="small"
  57. @change="changeTime"
  58. v-model="datetime"
  59. type="datetimerange"
  60. value-format="yyyy-MM-dd HH:mm:ss"
  61. range-separator="至"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期">
  64. </el-date-picker>
  65. </div>
  66. <div v-if="isShowSearch" class="input-item div-box" flex="cross-center">
  67. <div>
  68. <el-input @keyup.enter.native="toSearch" size="small" placeholder="请输入商品ID或名称搜索"
  69. v-model="search.keyword" clearable
  70. @clear="toSearch">
  71. <el-button slot="append" icon="el-icon-search" @click="toSearch"></el-button>
  72. </el-input>
  73. </div>
  74. </div>
  75. <div v-if="isShowSearch" class="input-item div-box" flex="cross-center">
  76. <div>
  77. <el-input @keyup.enter.native="toSearch" size="small" placeholder="请输入门店名称搜索"
  78. v-model="search.store_name" clearable
  79. @clear="toSearch">
  80. <el-button slot="append" icon="el-icon-search" @click="toSearch"></el-button>
  81. </el-input>
  82. </div>
  83. </div>
  84. <div v-if="isShowClear" @click="clearWhere" class="div-box clear-where" flex="cross:center">清空筛选条件</div>
  85. </div>
  86. <com-add-cat ref="cats" :new-cats="newSearch.cats" @select="selectCat" :mch_id="mch_id"></com-add-cat>
  87. </div>
  88. </template>
  89. <script>
  90. Vue.component('com-search', {
  91. template: '#com-search',
  92. props: {
  93. newSearch: {
  94. type: Object,
  95. default: function () {
  96. return {
  97. keyword: '',
  98. store_name: '',
  99. status: '-1',
  100. sort_prop: '',
  101. sort_type: '',
  102. cats: [],
  103. date_start: null,
  104. date_end: null,
  105. }
  106. }
  107. },
  108. isShowCat: {
  109. type: Boolean,
  110. default: true
  111. },
  112. isShowSearch: {
  113. type: Boolean,
  114. default: true
  115. },
  116. newActiveName: {
  117. type: String,
  118. default: '-1'
  119. }
  120. },
  121. data() {
  122. return {
  123. activeName: '-1',
  124. dialogVisible: false,
  125. dialogLoading: false,
  126. options: [],
  127. cats: [],
  128. children: [],
  129. third: [],
  130. datetime: [],
  131. mch_id: <?= $mchId ?>,
  132. isShowClear: false,
  133. }
  134. },
  135. methods: {
  136. handleClick(res) {
  137. this.search.status = this.activeName;
  138. this.getList();
  139. },
  140. toSearch() {
  141. this.dialogVisible = false;
  142. this.getList();
  143. },
  144. clearCat() {
  145. this.search.cats = [];
  146. this.getList();
  147. },
  148. changeTime() {
  149. if (this.datetime) {
  150. this.search.date_start = this.datetime[0];
  151. this.search.date_end = this.datetime[1];
  152. } else {
  153. this.search.date_start = null;
  154. this.search.date_end = null;
  155. }
  156. this.getList();
  157. },
  158. getList() {
  159. this.$emit('to-search', this.search);
  160. this.checkClear();
  161. },
  162. clearWhere() {
  163. this.search.cats = [];
  164. this.search.keyword = '';
  165. this.search.store_name = '';
  166. this.search.date_start = null;
  167. this.search.date_end = null;
  168. this.datetime = [];
  169. this.getList();
  170. },
  171. checkClear() {
  172. if (this.search.keyword || this.search.store_name || (this.search.cats && this.search.cats.length > 0)
  173. || (this.search.date_start && this.search.date_end)) {
  174. this.isShowClear = true;
  175. } else {
  176. this.isShowClear = false;
  177. }
  178. },
  179. selectCat(cats) {
  180. this.cats = cats;
  181. let arr = [];
  182. cats.map(v => {
  183. arr.push(v.value);
  184. });
  185. this.search.cats = arr;
  186. this.getList();
  187. },
  188. },
  189. created() {
  190. this.search = this.newSearch;
  191. if (this.search.date_start && this.search.date_end) {
  192. this.datetime = [this.search.date_start, this.search.date_end];
  193. }
  194. this.activeName = this.newActiveName;
  195. this.checkClear();
  196. }
  197. })
  198. </script>