index.vue 9.4 KB

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