sagaProductDetail.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div>
  3. <div class="saga-brand-box mt90 por">
  4. <div class="breadcrumb-content">
  5. <div style="width: 1020px">
  6. <el-breadcrumb
  7. separator-class="el-icon-arrow-right"
  8. style="max-width: 470px;display: inline-block"
  9. >
  10. <el-breadcrumb-item>所有分类</el-breadcrumb-item>
  11. <el-breadcrumb-item>{{this.$route.query.major}}</el-breadcrumb-item>
  12. <el-breadcrumb-item>{{this.$route.query.system}}</el-breadcrumb-item>
  13. <el-breadcrumb-item>{{this.$route.query.class}}</el-breadcrumb-item>
  14. </el-breadcrumb>
  15. <span
  16. v-for="(item,index) in allSelect"
  17. :key="index"
  18. v-if="item.check && item.name != '全部'"
  19. class="select"
  20. >{{item.BrandCname}}
  21. <i class="el-icon-close" @click="deleteCurrent(item,index)"></i></span>
  22. </div>
  23. <span class="total poa">共<b>{{total}}</b>件相关产品</span>
  24. </div>
  25. <div class="device-sys">
  26. <div class="left">品牌:</div>
  27. <div class="main" :class="more=='收起'? 'mt30':''">
  28. <ul v-if="more=='更多'">
  29. <li
  30. v-for="(item,index) in allDate"
  31. :key="index"
  32. v-if="index < 9"
  33. v-show="item.name != '全部'"
  34. :class="item.check ?'light':''">
  35. <span @click="handleCurrentBrand(item,index)" style="cursor: pointer">
  36. {{item.BrandCname}}
  37. </span>
  38. </li>
  39. </ul>
  40. <template v-else>
  41. <div :class="more=='收起' ? 'check':''">
  42. <span
  43. class="saga-product-letter"
  44. v-for="(list, letter,index) in brandList"
  45. :key="index"
  46. @click="handleLetter(index,list,letter)"
  47. :class="idx=== index?'litter-light':''"
  48. > {{letter}}</span>
  49. </div>
  50. <ul>
  51. <li
  52. v-for="(item,index) in allDate"
  53. :key="index"
  54. v-show="item.name != '全部'"
  55. :class="item.check ?'light':''">
  56. <span @click="handleCurrentBrand(item,index)" style="cursor: pointer">
  57. {{item.BrandCname}}
  58. </span>
  59. </li>
  60. </ul>
  61. </template>
  62. </div>
  63. <div class="right" :class="more == '更多' ? 'dark' :'light'" style="position:relative;">
  64. <el-dropdown @command="handleCommand" style="line-height: 40px;" v-show="more=='收起'"
  65. :class="more=='收起'?'pos-drop':''">
  66. <span class="el-dropdown-link">
  67. {{sortName}}<i class="el-icon-arrow-down el-icon--right"></i>
  68. </span>
  69. <el-dropdown-menu slot="dropdown">
  70. <el-dropdown-item v-for="(val, key) in sortMap" :key="key" :command="key">{{val}}</el-dropdown-item>
  71. </el-dropdown-menu>
  72. </el-dropdown>
  73. <p style="cursor: pointer;" @click="allData" :class="more=='收起'? 'pos-down':''">{{more}}
  74. <span :class="more=='更多' ? 'el-icon-caret-bottom':'el-icon-caret-top'"></span>
  75. </p>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="saga-brand-box mt20">
  80. <detailTable :table="table"/>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import detailTable from "../../public/detailTable";
  86. import {prodTypeQuery} from "@/api/product"
  87. import {brandQueryByClass} from "@/api/brand"
  88. import {mapGetters} from "vuex"
  89. export default {
  90. data() {
  91. return {
  92. idx: 0,
  93. more: '更多',
  94. isShow: true,
  95. brandList: [],
  96. allDate: [],
  97. temporary: [],//全部数据
  98. allSelect: [],//选择的数据
  99. sortMap: {
  100. zh: "中文排序",
  101. en: "英文排序",
  102. },
  103. sortName: "中文排序",
  104. sort: "zh",
  105. total: 0,
  106. table: []
  107. }
  108. },
  109. components: {detailTable},
  110. created() {
  111. this.getDate()
  112. this.getProductList()
  113. },
  114. mounted() {
  115. },
  116. computed: {
  117. ...mapGetters('layout', ['dictionary']),
  118. },
  119. methods: {
  120. getDate() {
  121. let param = {
  122. GroupId: this.dictionary.groupId,
  123. ProjectId: this.dictionary.projectId,
  124. Type: this.sort,
  125. ClassCode: this.$route.query.code,
  126. Orders: 'name asc, createTime desc'
  127. }
  128. brandQueryByClass(param, res => {
  129. this.brandList = res.Content ? res.Content[0] : []
  130. this.brandList = Object.assign({
  131. '全部': [{
  132. name: '全部'
  133. }
  134. ]
  135. }, this.brandList)
  136. this.temporary = []
  137. this.allDate = []
  138. this.allSelect = []
  139. for (let key in this.brandList) {
  140. if (Array.isArray(this.brandList[key])) {
  141. let list = this.temporary.concat(this.brandList[key])
  142. list.map(i => this.$set(i, 'check', false))
  143. this.temporary = list
  144. this.allDate = list
  145. this.allSelect = list
  146. }
  147. }
  148. })
  149. },
  150. getProductList() {
  151. let params = {
  152. "Cascade": [
  153. {"Name": "brand"}
  154. ],
  155. Filters: `prodCode='${this.$route.query.code}'`
  156. }
  157. prodTypeQuery(params, res => {
  158. this.total = res.Total
  159. this.table = res.Content.map(i => ({...i, brandName: i.Brand.BrandCname}))
  160. })
  161. },
  162. handleCommand(command) {// 切换排序方式
  163. this.sortName = this.sortMap[command]
  164. this.sort = command
  165. this.idx = 0
  166. this.getDate()
  167. this.getProductList()
  168. },
  169. allData() {
  170. this.isShow = !this.isShow
  171. if (this.isShow) {
  172. this.more = '收起'
  173. } else {
  174. this.more = '更多'
  175. }
  176. },
  177. handleLetter(index, list, letter) {
  178. this.idx = index
  179. this.allDate = list
  180. if (index == 0) {
  181. this.allDate = this.temporary
  182. }
  183. },
  184. handleCurrentBrand(item, index) {
  185. item.check = !item.check
  186. this.allSelect.map((i, idx) => {
  187. if (idx == index) {
  188. i.check = item.check
  189. }
  190. })
  191. this.handleQuery(this.allSelect)
  192. },
  193. deleteCurrent(item, index) {
  194. item.check = false
  195. this.allSelect.map((i, idx) => {
  196. if (idx == index) {
  197. i.check = item.check
  198. }
  199. })
  200. this.handleQuery(this.allSelect)
  201. },
  202. handleQuery(arr) {
  203. let filter = this.allSelect.filter(i => i.check), str = ''
  204. str = filter.map(i => `brandID='${i.BrandID}'`).join(' or ')
  205. if (str) {
  206. let params = {
  207. "Cascade": [
  208. {"Name": "brand"}
  209. ],
  210. Filters: `prodCode='${this.$route.query.code}';(${str})`
  211. }
  212. prodTypeQuery(params, res => {
  213. this.total = res.Total
  214. this.table = res.Content.map(i => ({...i, brandName: i.Brand.BrandCname}))
  215. })
  216. } else {
  217. this.getProductList()
  218. }
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .mt90 {
  225. margin-top: 90px;
  226. }
  227. .mt20 {
  228. margin-top: 20px;
  229. }
  230. .mt30 {
  231. margin-top: 30px;
  232. }
  233. .por {
  234. position: relative;
  235. }
  236. .poa {
  237. position: absolute;
  238. }
  239. .saga-brand-box {
  240. width: 100%;
  241. padding: 16px;
  242. box-sizing: border-box;
  243. background: rgba(255, 255, 255, 1);
  244. .breadcrumb-content {
  245. display: flex;
  246. border-bottom: 1px solid #EFF0F1;
  247. padding-bottom: 20px;
  248. .total {
  249. text-align: right;
  250. color: #8D9399;
  251. right: 0;
  252. margin-right: 30px;
  253. b {
  254. color: #1F2429;
  255. }
  256. }
  257. .select {
  258. margin-left: 20px;
  259. display: inline-block;
  260. background: #EFF0F1;
  261. padding: 0 10px;
  262. line-height: 20px;
  263. cursor: pointer;
  264. margin-top: -3px;
  265. margin-bottom: 10px;
  266. }
  267. }
  268. .device-sys {
  269. display: flex;
  270. margin-top: 10px;
  271. border-bottom: 1px solid #EFF0F1;
  272. padding-bottom: 10px;
  273. position: relative;
  274. .left {
  275. padding-top: 6px;
  276. color: #8D9399;
  277. width: 50px;
  278. }
  279. .right {
  280. width: 100px;
  281. text-align: center;
  282. padding-top: 6px;
  283. }
  284. .main {
  285. color: #1F2429;
  286. width: 1020px;
  287. max-height: 150px;
  288. overflow: auto;
  289. ul {
  290. li {
  291. display: inline-block;
  292. line-height: 25px;
  293. width: 230px;
  294. margin-right: 20px;
  295. text-align: left;
  296. overflow: hidden;
  297. text-overflow: ellipsis;
  298. white-space: nowrap;
  299. cursor: pointer;
  300. }
  301. }
  302. }
  303. .saga-product-letter {
  304. display: inline-block;
  305. padding: 3px;
  306. background: #EEEEEE;
  307. margin-right: 5px;
  308. font-size: 12px;
  309. cursor: pointer;
  310. }
  311. }
  312. /deep/ .el-breadcrumb__item:first-child .el-breadcrumb__inner:first-child {
  313. color: #8D9399
  314. }
  315. .dark {
  316. color: #8D9399
  317. }
  318. .light {
  319. color: #3A8DDE;
  320. }
  321. .litter-light {
  322. background: #D1E3F4 !important;
  323. color: #3A8DDE;
  324. }
  325. .check {
  326. position: absolute;
  327. top: 5px;
  328. }
  329. .pos-drop {
  330. top: -10px;
  331. left: -80px;
  332. }
  333. .pos-down {
  334. position: relative;
  335. top: -38px;
  336. }
  337. }
  338. </style>