index.vue 8.0 KB

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