index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <el-dialog
  3. title="资源库"
  4. :visible.sync="dialogVisible"
  5. width="80%"
  6. :modal="true"
  7. :modal-append-to-body="false"
  8. :appen-to-body="true"
  9. class="bs-dialog-wrap bs-el-dialog"
  10. @closed="close"
  11. >
  12. <div class="content">
  13. <div class="big-screen-list-wrap">
  14. <div class="top-search-wrap">
  15. <el-input
  16. v-model="searchKey"
  17. class="bs-el-input"
  18. placeholder="请输入图片名称"
  19. prefix-icon="el-icon-search"
  20. clearable
  21. @clear="reSearch"
  22. @keyup.enter.native="reSearch"
  23. />
  24. <el-select
  25. v-model="code"
  26. class="bs-el-select"
  27. popper-class="bs-el-select"
  28. placeholder="请选择类型"
  29. clearable
  30. @change="reSearch"
  31. >
  32. <el-option
  33. v-for="item in options"
  34. :key="item.id"
  35. :label="item.name"
  36. :value="item.code"
  37. />
  38. </el-select>
  39. <el-button
  40. size="small"
  41. style="margin-right: 20px"
  42. type="primary"
  43. @click="reSearch"
  44. >
  45. 搜索
  46. </el-button>
  47. </div>
  48. <div
  49. v-if="list.length !== 0"
  50. v-loading="loading"
  51. class="list-wrap bs-scrollbar"
  52. element-loading-text="加载中"
  53. :style="{
  54. display: gridComputed ? 'grid' : 'flex',
  55. justifyContent: gridComputed ? 'space-around' : 'flex-start'
  56. }"
  57. >
  58. <!-- <div v-if="list.length !== 0"> -->
  59. <div
  60. v-for="screen in list"
  61. :key="screen.id"
  62. class="big-screen-card-wrap"
  63. :style="{
  64. width: gridComputed ? 'auto' : '290px'
  65. }"
  66. @click="chooseImg(screen)"
  67. >
  68. <div
  69. :class="focus.id == screen.id ? 'focus' : ''"
  70. class="big-screen-card-inner"
  71. >
  72. <div class="big-screen-card-img">
  73. <el-image
  74. :src="screen.url"
  75. fit="contain"
  76. style="width: 100%; height: 100%"
  77. >
  78. <div
  79. slot="placeholder"
  80. class="image-slot"
  81. >
  82. 加载中···
  83. </div>
  84. </el-image>
  85. </div>
  86. <div class="big-screen-bottom">
  87. <div
  88. class="left-bigscreen-title"
  89. :title="screen.originalName"
  90. >
  91. {{ screen.originalName }}
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div
  98. v-else
  99. class="empty"
  100. >
  101. 暂无数据
  102. </div>
  103. <div class="footer-pagination-wrap">
  104. <div class="bs-pagination">
  105. <el-pagination
  106. class="bs-el-pagination"
  107. popper-class="bs-el-pagination"
  108. background
  109. layout="total, prev, pager, next, sizes"
  110. :page-size="size"
  111. prev-text="上一页"
  112. next-text="下一页"
  113. :total="totalCount"
  114. :page-sizes="[10, 20, 50, 100]"
  115. :current-page="current"
  116. @current-change="currentChangeHandle"
  117. @size-change="sizeChangeHandle"
  118. />
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <div
  124. slot="footer"
  125. class="dialog-footer"
  126. >
  127. <el-button
  128. class="bs-el-button-default"
  129. @click="dialogVisible = false"
  130. >
  131. 取消
  132. </el-button>
  133. <el-button
  134. type="primary"
  135. @click="confirm"
  136. >
  137. 确定
  138. </el-button>
  139. </div>
  140. </el-dialog>
  141. </template>
  142. <script>
  143. import { get } from 'packages/js/utils/http'
  144. import { pageMixins } from 'packages/js/mixins/page'
  145. import _ from 'lodash'
  146. export default {
  147. name: 'SourceDialog',
  148. mixins: [pageMixins],
  149. props: {},
  150. data () {
  151. return {
  152. dialogVisible: false,
  153. loading: false,
  154. options: [],
  155. code: '',
  156. focus: -1,
  157. list: [],
  158. searchKey: ''
  159. }
  160. },
  161. computed: {
  162. gridComputed () {
  163. return this.list.length > 3
  164. }
  165. },
  166. mounted () {},
  167. methods: {
  168. chooseImg (img) {
  169. this.focus = _.cloneDeep(img)
  170. },
  171. close () {},
  172. init () {
  173. this.dialogVisible = true
  174. this.current = 1
  175. this.searchKey = ''
  176. this.code = ''
  177. this.focus = -1
  178. this.getDataList()
  179. this.getCatalogList()
  180. },
  181. confirm () {
  182. this.dialogVisible = false
  183. if (this.focus !== -1) {
  184. this.$emit('getImg', this.focus)
  185. }
  186. },
  187. getDataList () {
  188. this.loading = true
  189. get('/bigScreen/file', {
  190. module: this.code,
  191. current: this.current,
  192. size: this.size,
  193. extension: '',
  194. searchKey: this.searchKey
  195. })
  196. .then((data) => {
  197. this.list = data.list
  198. this.totalCount = data.totalCount
  199. })
  200. .finally(() => {
  201. this.loading = false
  202. })
  203. },
  204. // 获取目录的列表
  205. getCatalogList () {
  206. get('/bigScreen/type/list/resourceCatalog')
  207. .then((data) => {
  208. this.options = data
  209. })
  210. .catch(() => {})
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. @import '~packages/assets/style/bsTheme.scss';
  217. .big-screen-list-wrap {
  218. position: relative;
  219. height: 100%;
  220. margin:0 16px;
  221. padding: 16px;
  222. color: #9ea9b2;
  223. background-color: var(--bs-background-2) !important;
  224. .top-search-wrap {
  225. display: flex;
  226. align-items: center;
  227. justify-content: flex-end;
  228. margin-bottom: 12px;
  229. .el-input {
  230. width: 200px;
  231. margin-right: 20px;
  232. /deep/.el-input__inner {
  233. background-color: var(--bs-background-1) !important;
  234. }
  235. }
  236. .el-select {
  237. margin-right: 20px;
  238. /deep/.el-input__inner {
  239. background: var(--bs-background-1) !important;
  240. background-color: var(--bs-background-1) !important;
  241. }
  242. }
  243. }
  244. .list-wrap {
  245. /* display: grid; */
  246. overflow: auto;
  247. // 间隙自适应
  248. justify-content: space-around;
  249. // max-height: calc(100vh - 270px);
  250. display: grid;
  251. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  252. grid-gap: 15px;
  253. // /deep/ .el-loading-mask {
  254. // display: flex;
  255. // align-items: center;
  256. // justify-content: center;
  257. // height: calc(100vh - 260px) !important;
  258. // z-index: 999;
  259. // top: 50px;
  260. // }
  261. .big-screen-card-wrap {
  262. position: relative;
  263. height: 230px;
  264. cursor: pointer;
  265. &:hover {
  266. .screen-card__hover {
  267. height: 180px;
  268. }
  269. }
  270. .screen-card__hover {
  271. position: absolute;
  272. z-index: 999;
  273. top: 0;
  274. right: 0;
  275. left: 0;
  276. display: flex;
  277. overflow: hidden;
  278. align-items: center;
  279. justify-content: center;
  280. height: 0;
  281. transition: height 0.4s;
  282. background: #00000099;
  283. }
  284. .focus {
  285. color: var(--bs-el-text) !important;
  286. border: 1px solid var(--bs-el-color-primary) !important;
  287. }
  288. .big-screen-card-inner {
  289. overflow: hidden;
  290. width: 100%;
  291. height: 100%;
  292. cursor: pointer;
  293. background-color: var(--bs-background-2);
  294. box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  295. color: var(--bs-el-title);
  296. border: 1px solid var(--bs-background-2);
  297. &:hover {
  298. color: var(--bs-el-text);
  299. border: 1px solid var(--bs-el-color-primary);
  300. }
  301. .add-big-screen-card-text {
  302. font-size: 24px;
  303. }
  304. .big-screen-card-img {
  305. width: 100%;
  306. height: 180px;
  307. img {
  308. width: 100%;
  309. height: 100%;
  310. object-fit: cover;
  311. }
  312. /deep/.image-slot {
  313. height: 100%;
  314. background-color: var(--bs-background-2);
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. }
  319. /deep/.el-image__error {
  320. background-color: #1d1d1d;
  321. }
  322. }
  323. .big-screen-bottom {
  324. display: flex;
  325. align-items: center;
  326. flex-direction: row;
  327. justify-content: space-between;
  328. box-sizing: border-box;
  329. width: 100%;
  330. /*height: 26px;*/
  331. padding: 0 10px;
  332. height: calc(100% - 180px);
  333. color: var(--bs-el-title);
  334. background-color: var(--bs-background-2);
  335. .left-bigscreen-title {
  336. font-size: 14px;
  337. overflow: hidden;
  338. width: 100%;
  339. white-space: nowrap;
  340. text-overflow: ellipsis;
  341. }
  342. .right-bigscreen-time-title {
  343. font-size: 14px;
  344. overflow: hidden;
  345. width: 140px;
  346. white-space: nowrap;
  347. text-overflow: ellipsis;
  348. }
  349. }
  350. .big-screen-card-text {
  351. font-size: 14px;
  352. padding: 10px;
  353. text-align: center;
  354. color: #333;
  355. }
  356. }
  357. .big-screen-card-inner-add {
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. }
  362. }
  363. }
  364. .el-loading-parent--relative {
  365. position: unset !important;
  366. }
  367. .footer-pagination-wrap {
  368. display: flex;
  369. align-items: center;
  370. justify-content: flex-end;
  371. width: 100%;
  372. margin-top: 16px;
  373. padding: 0 16px;
  374. }
  375. }
  376. .bs-pagination {
  377. ::v-deep .el-input__inner {
  378. width: 110px !important;
  379. border: none;
  380. background: var(--bs-el-background-1);
  381. }
  382. }
  383. .empty {
  384. width: 100%;
  385. height: 70%;
  386. min-height: 300px;
  387. display: flex;
  388. justify-content: center;
  389. align-items: center;
  390. }
  391. </style>