sagaProductDetail.vue 10 KB

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