index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <div class="page">
  3. <van-list
  4. v-model="isLoadingMore"
  5. :finished="finished"
  6. :immediate-check="false"
  7. :finished-text="total ? '没有更多了' : ''"
  8. @load="onLoadMore"
  9. >
  10. <div class="page-top flex flex-col justify-center items-center">
  11. <img class="logo" :src="supplierInfo.logo" />
  12. <div class="mt-2 name">
  13. <span v-text="supplierInfo.shopName"></span><span>官方授权设备</span>
  14. </div>
  15. </div>
  16. <div class="page-content">
  17. <div class="search-title">设备种类查询:</div>
  18. <div class="search-container">
  19. <el-select
  20. v-model="listQuery.productTypeId"
  21. slot="prepend"
  22. placeholder="设备种类"
  23. class="select-type"
  24. >
  25. <template v-for="product in productSelectList">
  26. <el-option
  27. :label="product.name"
  28. :value="product.productTypeId"
  29. :key="product.productTypeId"
  30. ></el-option>
  31. </template>
  32. </el-select>
  33. <el-input
  34. :placeholder="
  35. searchQuery.type === 1 ? '请输入SN码' : '请输入机构名'
  36. "
  37. v-model="searchQuery.keyword"
  38. class="input-with-select"
  39. >
  40. <el-select
  41. v-model="searchQuery.type"
  42. slot="prepend"
  43. placeholder="请选择"
  44. >
  45. <el-option label="SN码" :value="1"></el-option>
  46. <el-option label="机构名" :value="2"></el-option>
  47. </el-select>
  48. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  49. </el-input>
  50. <el-button class="submit" type="warning" @click="onSearch"
  51. >查询</el-button
  52. >
  53. </div>
  54. <template v-if="list.length > 0 || searchFlag">
  55. <!-- 标题 -->
  56. <div class="title px-4 pt-12 pb-6 md:px-0">
  57. 共<span v-text="total"></span>台设备
  58. </div>
  59. <!-- 列表 -->
  60. <div class="list">
  61. <div
  62. class="section flex justify-between mb-4"
  63. v-for="item in list"
  64. :key="item.productId"
  65. @click="toDetail(item)"
  66. >
  67. <img class="cover" :src="item.productImage" />
  68. <div class="info">
  69. <div class="name" v-text="item.productName"></div>
  70. <div class="code">SN码:{{ item.snCode | formatSnCode }}</div>
  71. <el-popover placement="right" title="机构列表" trigger="hover">
  72. <template v-for="club in item.clubList">
  73. <div
  74. @click.stop="toClubDetail(club)"
  75. :key="club.authId"
  76. class="club-item"
  77. >
  78. {{ club.authParty }}
  79. </div>
  80. </template>
  81. <div class="club-name" slot="reference">
  82. 所属机构:
  83. <template v-for="club in item.clubList">
  84. ,<span :key="club.authId">{{ club.authParty }}</span>
  85. </template>
  86. </div>
  87. </el-popover>
  88. </div>
  89. </div>
  90. </div>
  91. <!-- 列表为空 -->
  92. <SimpleEmpty
  93. v-if="!total && !isRequest"
  94. name="icon-empty-device.png"
  95. description="敬请期待~"
  96. ></SimpleEmpty>
  97. </template>
  98. </div>
  99. </van-list>
  100. </div>
  101. </template>
  102. <script>
  103. import { debounce } from '@/utils'
  104. import { mapGetters } from 'vuex'
  105. export default {
  106. layout: 'app-ross',
  107. filters: {
  108. formatSnCode(code) {
  109. if (!code) return ''
  110. return code.replace(/^(\w{2})\w+(\w{4})$/, '$1******$2')
  111. },
  112. },
  113. data() {
  114. return {
  115. isLoadingMore: false,
  116. finished: false,
  117. isRequest: true,
  118. searchQuery: {
  119. type: 2,
  120. keyword: '测试机构A',
  121. },
  122. listQuery: {
  123. listType: 1,
  124. productTypeId: '',
  125. snCode: '',
  126. authParty: '测试机构A',
  127. pageNum: 1,
  128. pageSize: 10,
  129. },
  130. list: [],
  131. total: 0,
  132. productSelectList: [],
  133. searchFlag: false,
  134. }
  135. },
  136. computed: {
  137. ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']),
  138. },
  139. mounted() {
  140. this.fetchProductSelectList()
  141. },
  142. methods: {
  143. // 获取设备列表
  144. fetchList: debounce(async function () {
  145. try {
  146. this.isLoadingMore = true
  147. const res = await this.$http.api.getAuthProductList(this.listQuery)
  148. this.list = [...this.list, ...res.data.list]
  149. this.finished = !res.data.hasNextPage
  150. this.total = res.data.total
  151. this.isLoadingMore = false
  152. this.listQuery.pageNum += 1
  153. this.searchFlag = true
  154. } catch (error) {
  155. console.log(error)
  156. } finally {
  157. this.isRequest = false
  158. this.searchFlag = true
  159. }
  160. }, 400),
  161. // 搜索
  162. onSearch() {
  163. const { productTypeId } = this.listQuery
  164. const { type, keyword } = this.searchQuery
  165. if (!productTypeId) {
  166. return this.$toast('请选择设备分类')
  167. }
  168. if (!type) {
  169. return this.$toast('请选择搜索条件')
  170. }
  171. if (!keyword) {
  172. return this.$toast('搜索内容不能为空')
  173. }
  174. if (type === 1) {
  175. this.listQuery.snCode = keyword
  176. this.listQuery.authParty = ''
  177. } else {
  178. this.listQuery.snCode = ''
  179. this.listQuery.authParty = keyword
  180. }
  181. this.list = []
  182. this.listQuery.pageNum = 1
  183. this.fetchList()
  184. },
  185. // 获取设备种类
  186. async fetchProductSelectList() {
  187. try {
  188. const res = await this.$http.api.fetchProductSelectList({
  189. authUserId: this.authUserId,
  190. })
  191. this.productSelectList = res.data
  192. } catch (error) {
  193. console.log(error)
  194. }
  195. },
  196. // 设备详情
  197. toDetail(item) {
  198. // window.location.href = `${process.env.CIMEI_LOCAL}/product/auth/product-${item.productId}.html`
  199. this.$router.push(
  200. `${this.routePrefix}/approve/device/detail?id=${item.productId}`
  201. )
  202. },
  203. // 机构详情
  204. toClubDetail(item) {
  205. const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
  206. this.$router.push(url)
  207. },
  208. // 加载更多
  209. onLoadMore() {
  210. this.fetchList()
  211. },
  212. },
  213. }
  214. </script>
  215. <style scoped lang="scss">
  216. .input-with-select {
  217. ::v-deep {
  218. .el-input-group__prepend {
  219. background-color: #fff;
  220. }
  221. }
  222. }
  223. // pc 端
  224. @media screen and (min-width: 768px) {
  225. .el-popover {
  226. .club-item {
  227. line-height: 24px;
  228. cursor: pointer;
  229. &:hover {
  230. color: #f3920d;
  231. }
  232. }
  233. }
  234. .page {
  235. position: relative;
  236. min-height: calc(100vh - 80px - 80px);
  237. background-color: #fff;
  238. }
  239. .page-top {
  240. height: 420px;
  241. @include themify($themes) {
  242. background: themed('pc-banner-device');
  243. }
  244. background-size: auto 420px;
  245. .logo {
  246. display: block;
  247. width: 120px;
  248. height: 120px;
  249. border-radius: 50%;
  250. background: #fff;
  251. }
  252. .name {
  253. font-size: 30px;
  254. color: #fff;
  255. }
  256. }
  257. .page-content {
  258. width: 1000px;
  259. margin: 0 auto;
  260. .search-title {
  261. font-size: 16px;
  262. color: #404040;
  263. margin: 25px 0;
  264. }
  265. .search-container {
  266. display: flex;
  267. justify-content: space-between;
  268. .input-with-select {
  269. margin: 0 15px;
  270. .el-select {
  271. ::v-deep {
  272. .el-input {
  273. width: 130px;
  274. }
  275. }
  276. }
  277. }
  278. .submit {
  279. width: 295px;
  280. }
  281. }
  282. .title {
  283. font-size: 16px;
  284. color: #404040;
  285. span {
  286. @include themify($themes) {
  287. color: themed('color');
  288. }
  289. }
  290. }
  291. .list {
  292. display: flex;
  293. align-items: center;
  294. flex-wrap: wrap;
  295. justify-content: space-between;
  296. .empty {
  297. width: 390px;
  298. }
  299. .section {
  300. width: 490px;
  301. height: 136px;
  302. background-color: #f3f5f6;
  303. border-radius: 4px;
  304. box-sizing: border-box;
  305. padding: 16px;
  306. cursor: pointer;
  307. transition: all 0.4s;
  308. &:hover {
  309. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  310. }
  311. .cover {
  312. display: block;
  313. width: 104px;
  314. height: 104px;
  315. }
  316. .info {
  317. width: 336px;
  318. position: relative;
  319. .name {
  320. font-size: 18px;
  321. color: #101010;
  322. font-weight: bold;
  323. margin-bottom: 16px;
  324. margin-top: 4px;
  325. text-overflow: ellipsis;
  326. white-space: nowrap;
  327. overflow: hidden;
  328. }
  329. .code,
  330. .club-name {
  331. position: relative;
  332. font-size: 14px;
  333. color: #666;
  334. line-height: 24px;
  335. text-overflow: ellipsis;
  336. white-space: nowrap;
  337. overflow: hidden;
  338. margin-top: 6px;
  339. span {
  340. color: #1890ff;
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. // 移动 端
  349. @media screen and (max-width: 768px) {
  350. .page-top {
  351. height: 46vw;
  352. @include themify($themes) {
  353. background: themed('h5-banner-device');
  354. background-size: auto 46vw;
  355. }
  356. .logo {
  357. display: block;
  358. width: 14.8vw;
  359. height: 14.8vw;
  360. border-radius: 50%;
  361. background: #fff;
  362. }
  363. .name {
  364. font-size: 4vw;
  365. color: #fff;
  366. }
  367. }
  368. .page-content {
  369. position: relative;
  370. .search-title {
  371. font-size: 3.4vw;
  372. color: #404040;
  373. margin: 3.2vw;
  374. }
  375. .search-container {
  376. padding: 0 3.2vw;
  377. .select-type {
  378. width: 100%;
  379. }
  380. .input-with-select {
  381. margin: 3.2vw 0;
  382. .el-select {
  383. ::v-deep {
  384. .el-input {
  385. width: 130px;
  386. }
  387. }
  388. }
  389. }
  390. .submit {
  391. width: 100%;
  392. }
  393. }
  394. .title {
  395. font-size: 3.4vw;
  396. color: #404040;
  397. span {
  398. @include themify($themes) {
  399. color: themed('color');
  400. }
  401. }
  402. }
  403. .list {
  404. display: flex;
  405. align-items: center;
  406. flex-direction: column;
  407. .section {
  408. width: 93.6vw;
  409. height: 26vw;
  410. background-color: #f3f5f6;
  411. border-radius: 4px;
  412. box-sizing: border-box;
  413. padding: 3.2vw;
  414. .cover {
  415. display: block;
  416. width: 19.6vw;
  417. height: 19.6vw;
  418. }
  419. .info {
  420. position: relative;
  421. margin-left: 3.2vw;
  422. .name {
  423. font-size: 4vw;
  424. color: #101010;
  425. font-weight: bold;
  426. margin-bottom: 4vw;
  427. text-overflow: ellipsis;
  428. white-space: nowrap;
  429. overflow: hidden;
  430. }
  431. .code,
  432. .club-name {
  433. width: 66vw;
  434. position: relative;
  435. font-size: 3vw;
  436. color: #404040;
  437. line-height: 5vw;
  438. text-overflow: ellipsis;
  439. white-space: nowrap;
  440. overflow: hidden;
  441. span {
  442. color: #6d9eff;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. }
  449. }
  450. </style>