index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div>
  3. <banner></banner>
  4. <div class="antibody_box" ref="tablePar">
  5. <!-- 搜索 -->
  6. <el-form :inline="true" :model="form" class="demo-form-inline">
  7. <el-form-item label="Antibody:">
  8. <el-input class="input-with-select" v-model="form.keyword" placeholder="">
  9. <!-- <el-button class="but_search" slot="append" icon="el-icon-search" @click="onSubmit"></el-button> -->
  10. </el-input>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="onSubmit">Search</el-button>
  14. <el-button type="danger" icon="el-icon-refresh" @click="reset">{{ $t("nav.reset") }}</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <!-- 列表 -->
  18. <table-list
  19. v-loading="tableLoading"
  20. :list="list"
  21. type="2"
  22. @my-sort-change="onSortFieldChange"
  23. />
  24. <!-- 加载更多 -->
  25. <div
  26. class="load_b"
  27. v-if="list.length > 0 && pageable.page + 1 !== moreParams.totalPages"
  28. @click="loadList"
  29. >
  30. <i v-if="loadShow" class="el-icon-loading"></i>
  31. <span class="load">{{ $t("table.load") }}</span>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import tableList from "@/components/tableList";
  38. import banner from "@/components/banner";
  39. let timer = null;
  40. export default {
  41. components: {
  42. tableList,
  43. banner
  44. },
  45. name: "antibody",
  46. data() {
  47. return {
  48. form: {
  49. keyword: "",
  50. sortKey: undefined,
  51. sortValue: undefined
  52. },
  53. pageable: {
  54. page: 0,
  55. size: 10
  56. },
  57. list: [],
  58. tableLoading: false,
  59. loadShow: false,
  60. moreParams: {},
  61. resultObj: {}
  62. };
  63. },
  64. methods: {
  65. // 重置
  66. reset() {
  67. this.form = {
  68. keyword: ""
  69. };
  70. this.pageable.page = 0;
  71. this.postlist();
  72. },
  73. // 查询
  74. onSubmit() {
  75. this.pageable.page = 0;
  76. this.postlist();
  77. },
  78. onSortFieldChange(params) {
  79. console.log(params);
  80. this.form.sortKey = params.field || undefined;
  81. this.form.sortValue = params.value || undefined;
  82. this.pageable.page = 0;
  83. this.postlist();
  84. },
  85. // 加载更多
  86. loadList() {
  87. this.loadShow = true;
  88. this.pageable.page++;
  89. this.postlist();
  90. },
  91. // 获取列表
  92. postlist() {
  93. let that = this;
  94. that.tableLoading = true;
  95. this.$api
  96. .post("basb/pageListProducts", {
  97. criteria: this.form,
  98. pageable: this.pageable
  99. })
  100. .then(res => {
  101. if (res.code === 0) {
  102. const resDataContent = (res.data.content || []).map(item => {
  103. return {
  104. ...item,
  105. skuDefault: item.skuList && item.skuList.length > 0 ? 0 : ""
  106. };
  107. });
  108. if (that.pageable.page === 0) {
  109. this.list = resDataContent;
  110. } else {
  111. this.list = this.list.concat(resDataContent);
  112. console.log(this.list);
  113. }
  114. this.moreParams = res.data.more_params;
  115. this.loadShow = false;
  116. }
  117. that.tableLoading = false;
  118. })
  119. .catch(() => {
  120. that.tableLoading = false;
  121. });
  122. },
  123. // 判断滚动条位置
  124. handleScroll() {
  125. if (timer) {
  126. clearTimeout(timer);
  127. }
  128. timer = setTimeout(() => {
  129. var scrollTop =
  130. window.pageYOffset ||
  131. document.documentElement.scrollTop ||
  132. document.body.scrollTop;
  133. var windowHeight =
  134. window.innerHeight ||
  135. document.documentElement.clientHeight ||
  136. document.body.clientHeight;
  137. var scrollHeight =
  138. document.documentElement.scrollHeight || document.body.scrollHeight;
  139. if (
  140. this.pageable.page + 1 == this.moreParams.totalPages ||
  141. this.list.length < 10
  142. ) {
  143. clearTimeout(timer);
  144. window.removeEventListener("scroll", this.handleScroll);
  145. return;
  146. }
  147. if (scrollTop + windowHeight >= scrollHeight && !this.loadShow) {
  148. // console.log('触底了')
  149. this.loadShow = true;
  150. this.pageable.page++;
  151. this.postlist();
  152. }
  153. }, 300);
  154. }
  155. },
  156. mounted() {
  157. this.postlist();
  158. // 监听滚动
  159. window.addEventListener("scroll", this.handleScroll);
  160. },
  161. created() {
  162. // this.getList()
  163. },
  164. beforeDestroy() {
  165. // 移除监听
  166. window.removeEventListener("scroll", this.handleScroll);
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. .antibody_box {
  172. display: block !important;
  173. width: 1200px;
  174. margin: auto ;
  175. .demo-form-inline{
  176. padding-top: 40px;
  177. position: sticky;
  178. top: 80px;
  179. background: #fff;
  180. z-index: 999;
  181. display: flex;
  182. align-self: center;
  183. }
  184. .input-with-select /deep/{
  185. width: 300px;
  186. border:1px solid #007BC4;
  187. border-radius: 4px;
  188. overflow: hidden;
  189. .el-input__inner{
  190. border: none!important;
  191. }
  192. // .el-input__inner{
  193. // border-color: #007BC4 !important;
  194. // border-right: none !important;
  195. // }
  196. // .el-input-group__append {
  197. // border-color: #007BC4 !important;
  198. // border-left: none !important;
  199. // }
  200. // .but_search {
  201. // background-color: #007BC4;
  202. // border: #007BC4;
  203. // color: #fff;
  204. // }
  205. }
  206. .clout_box {
  207. margin-bottom: 2rem;
  208. .title {
  209. word-wrap: break-word;
  210. word-break: normal;
  211. width: 100%;
  212. background: #f3f3f3;
  213. padding: 1.5rem 2rem;
  214. font-size: 16px;
  215. font-family: Arial;
  216. color: #313131;
  217. }
  218. }
  219. }
  220. .load_b {
  221. margin: 1.2rem 0;
  222. font-size: 14px;
  223. font-family: Arial;
  224. color: #005bab;
  225. text-align: center;
  226. cursor: pointer;
  227. .el-icon-loading {
  228. font-size: 24px;
  229. }
  230. .load {
  231. display: block;
  232. line-height: 32px;
  233. }
  234. }
  235. .menu_box /deep/ {
  236. // 菜单
  237. border: 1px solid #dbdbdb;
  238. margin-bottom: 2rem;
  239. .menu_b {
  240. .list {
  241. border: none;
  242. }
  243. }
  244. }
  245. @media screen and (min-width: 751px) and (max-width: 9999px) {
  246. .menu_box_pmd {
  247. display: none;
  248. }
  249. }
  250. @media screen and (min-width: 0px) and (max-width: 750px) {
  251. .antibody_box {
  252. .clout_box {
  253. margin-bottom: 20px;
  254. .title {
  255. padding: 10px !important;
  256. }
  257. }
  258. }
  259. .load_b {
  260. margin: 20px 0;
  261. }
  262. .menu_box /deep/ {
  263. // 菜单
  264. border: none;
  265. margin-bottom: 0;
  266. }
  267. }
  268. </style>