index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="group container normal-panel normal-margin">
  3. <div style="display:flex;align-items:center;margin-bottom:16px">
  4. <el-input
  5. placeholder="请输入搜索内容"
  6. suffix-icon="el-icon-search"
  7. v-model="params.content.where.condition"
  8. style="width:200px"
  9. size="mini"
  10. class="input-with-select inline-16"
  11. @keyup.native.enter="getProductGroup(params.content.pageNumber=1)"
  12. @clear="clearData"
  13. clearable>
  14. </el-input>
  15. </div>
  16. <selectClass @brandChange="brandChange" @onClassChange="onClassChange" @Search="Search" @clearSearch="clearSearch" @clickField="clickField" :default="true"></selectClass>
  17. <div v-if="Object.keys(productGroup).length > 0">
  18. <div class="group-list content">
  19. <div class="group-item" v-for="item in productGroup" :key="item.sa_itemgroupid" @click="itemClick(item)">
  20. <div class="top">
  21. <el-image style="width:100%" :src="item.attinfos[0].url" fit="cover" />
  22. </div>
  23. <div class="bottom">
  24. <p class="title">{{item.groupname}}</p>
  25. <p class="descript">{{item.groupnum}}</p>
  26. <p class="descript"><span v-for="(cls,index) in item.itemclass" :key="cls.index">{{index === item.itemclass.length -1 ?cls.itemclassfullname:cls.itemclassfullname + ','}}</span></p>
  27. <p class="price descript">价格:<span style="color:red;font-size:16px"><small>¥</small>{{item.minprice}}</span>&nbsp;~&nbsp;<span style="color:red;font-size:16px"><small>¥</small>{{item.maxprice}}</span></p>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <el-empty description="暂无数据" v-else></el-empty>
  33. <div style="text-align:center;padding-top:36px">
  34. <el-pagination
  35. background
  36. small
  37. @size-change="handleSizeChange"
  38. @current-change="handleCurrentChange"
  39. :current-page="currentPage"
  40. :page-size="params.content.pageSize"
  41. layout="total, prev, pager, next, jumper"
  42. :total="total">
  43. </el-pagination>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import selectClass from './modules/Select.vue'
  49. export default {
  50. name: 'productgroup',
  51. data() {
  52. return {
  53. brandList:'',
  54. brandId:0,
  55. tablecols:[],
  56. productGroup:'',
  57. params: {
  58. "id": "20220926142203",
  59. "content": {
  60. "pageSize":20,
  61. "pageNumber":1,
  62. "nocache":true,
  63. "brandids":[],
  64. "where":{
  65. "condition":"",
  66. "tradefield":'',
  67. }
  68. }
  69. },
  70. total:0,
  71. currentPage:0
  72. };
  73. },
  74. components:{selectClass},
  75. computed:{
  76. },
  77. watch:{
  78. },
  79. created() {
  80. this.getbrandList()
  81. this.tablecols = this.tool.tabelCol(this.$route.name).productGroupTable.tablecols
  82. },
  83. methods: {
  84. /* 获取品牌数据 */
  85. async getbrandList() {
  86. let res = await this.$api.requested({
  87. "id": "20220922085103",
  88. "content": {
  89. "nocache":true,
  90. "where":{
  91. "condition":""
  92. }
  93. }
  94. })
  95. this.brandList = res.data.map(item => {
  96. return {
  97. label:item.brandname,
  98. value:item.sa_brandid
  99. }
  100. })
  101. this.brandId = this.brandList ? [this.brandList[0].value] : [0]
  102. this.getProductGroup()
  103. },
  104. async getProductGroup() {
  105. this.params.content.brandids = this.brandId
  106. let res = await this.$api.requested(this.params)
  107. res.data = res.data.map(e=>{
  108. if (e.attinfos.length > 0) {
  109. return e
  110. } else {
  111. e.attinfos.push({
  112. url:e.cover
  113. })
  114. return e
  115. }
  116. })
  117. console.log(res.data,'--')
  118. this.productGroup = res.data
  119. this.total = res.total
  120. this.currentPage = res.pageNumber
  121. },
  122. itemClick(id) {
  123. this.$router.push({
  124. path:'/groupDetail',
  125. query: {
  126. id:id.sa_itemgroupid,
  127. brandid:id.sa_brandid
  128. }
  129. })
  130. },
  131. brandChange(id) {
  132. this.brandId = id
  133. this.getProductGroup()
  134. },
  135. onClassChange (n) {
  136. this.params.content.where.itemclassid = n.itemclassid
  137. this.getProductGroup()
  138. },
  139. pageChange(n) {
  140. this.params.content.pageNumber = n
  141. this.getProductGroup()
  142. },
  143. Search(data) {
  144. this.params.content.where.condition = data
  145. this.params.content.pageNumber = 1
  146. this.getProductGroup()
  147. },
  148. clearSearch() {
  149. this.params.content.where.condition = ''
  150. this.params.content.pageNumber = 1
  151. this.getProductGroup()
  152. },
  153. clickField (item) {
  154. console.log(item)
  155. this.params.content.where.tradefield = item.tradefield
  156. this.getProductGroup()
  157. },
  158. handleSizeChange(val) {
  159. // console.log(`每页 ${val} 条`);
  160. this.params.content.pageSize = val
  161. this.getProductGroup()
  162. },
  163. handleCurrentChange(val) {
  164. // console.log(`当前页: ${val}`);
  165. this.params.content.pageNumber = val
  166. this.getProductGroup()
  167. },
  168. clearData(){
  169. this.params.content.pageNumber = 1
  170. this.getProductGroup()
  171. },
  172. },
  173. beforeRouteLeave (to, from,next) {
  174. if (to.name == 'groupDetail') {
  175. this.$store.commit('setPageCache',['productgroup'])
  176. } else {
  177. this.$store.commit('setPageCache',[])
  178. }
  179. console.log(this.$store.state.pageCache);
  180. next()
  181. }
  182. };
  183. </script>
  184. <style scoped>
  185. /* @media only screen and (max-width: 1200px) {
  186. .gtc {
  187. grid-template-columns: repeat(8, 1fr);
  188. }
  189. } */
  190. .content{
  191. height:calc(100vh - 400px);
  192. overflow-y: scroll;
  193. }
  194. .group .group-list {
  195. /* display: grid; */
  196. /* column-gap: 24px; */
  197. box-sizing: border-box;
  198. background-color: transparent;
  199. /* grid-template-columns: repeat(8, 1fr); */
  200. padding-top:36px;
  201. display: flex;
  202. flex-wrap: wrap;
  203. }
  204. .group .group-list .group-item {
  205. min-width: 261px;
  206. max-width: 357px;
  207. background: #ffffff;
  208. transition: all 0.1s ease-in;
  209. cursor: pointer;
  210. overflow: hidden;
  211. margin-bottom: 36px;
  212. margin-right: 16px;
  213. }
  214. .group .group-list .group-item .el-image {
  215. transition: transform 0.3s;
  216. }
  217. .group .group-list .group-item:hover .top .el-image {
  218. transform: scale(1.3);
  219. }
  220. .group .group-list .group-item .top {
  221. height: 150px;
  222. border-top-right-radius: 4px;
  223. border-top-left-radius: 4px;
  224. overflow: hidden;
  225. display: flex;
  226. justify-content: space-around;
  227. }
  228. .group .group-list .group-item .bottom {
  229. padding: 10px;
  230. border:1px solid #f1f2f3;
  231. border-top:none;
  232. }
  233. .group .group-list .group-item .bottom .title {
  234. font-size: 14px;
  235. font-family: PingFang SC-Bold, PingFang SC;
  236. font-weight: bold;
  237. color: #333333;
  238. overflow: hidden;
  239. text-overflow: ellipsis;
  240. white-space: nowrap;
  241. -webkit-line-clamp: 1;
  242. width: 100%;
  243. margin-bottom: 5px;
  244. }
  245. .group .group-list .group-item .bottom .descript {
  246. font-size: 12px;
  247. font-family: PingFang SC-Regular, PingFang SC;
  248. font-weight: 400;
  249. color: #666666;
  250. overflow: hidden;
  251. text-overflow: ellipsis;
  252. white-space: nowrap;
  253. -webkit-line-clamp: 1;
  254. width: 100%;
  255. margin-bottom: 4px;
  256. }
  257. .group .group-list .group-item .bottom .people {
  258. font-size: 10px;
  259. font-family: PingFang SC-Regular, PingFang SC;
  260. font-weight: 400;
  261. color: #999;
  262. }
  263. .page {
  264. display: flex;
  265. flex-direction: row-reverse;
  266. }
  267. </style>