chooseDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <!--
  2. * @FileDescription: 选中弹窗
  3. * @Author: 黄琪勇
  4. * @Date:2024-03-22 15:21:44
  5. -->
  6. <template>
  7. <div class="chooseDialog">
  8. <div class="close" @click="close"></div>
  9. <div class="chooseHeader" v-if="isShowTabs">
  10. <img
  11. key="classlist"
  12. v-if="chooseType === 'classlist'"
  13. src="@/img/cloudTextbooks/classlist-active.png"
  14. @click="handleChangeType('classlist')"
  15. />
  16. <img v-else src="@/img/cloudTextbooks/classlist.png" @click="handleChangeType('classlist')" />
  17. <img key="search" v-if="chooseType === 'search'" src="@/img/cloudTextbooks/search-active.png" @click="handleChangeType('search')" />
  18. <img v-else src="@/img/cloudTextbooks/search.png" @click="handleChangeType('search')" />
  19. </div>
  20. <div class="chooseCon" v-loading="loading" v-show="chooseType === 'classlist'">
  21. <img class="imgMid" src="@/img/cloudTextbooks/shu.png" />
  22. <div class="chooseBox" v-for="(listDetails, index) in listDetailData" :key="index">
  23. <div
  24. class="operate"
  25. v-show="(index === 0 && pageNum !== 0) || (index === 1 && listData.length > pageNum + 1)"
  26. @click="handlePage(index === 0 ? 'prev' : 'next')"
  27. >
  28. <img :src="require(`@/img/cloudTextbooks/${index === 0 ? 'left' : 'right'}.png`)" />
  29. </div>
  30. <div class="chooseList">
  31. <div class="listItem" v-for="item in listDetails" :key="item.id">
  32. <div class="img">
  33. <template v-if="item.lockFlag">
  34. <img src="@/img/cloudTextbooks/jy.png" />
  35. </template>
  36. <template v-else>
  37. <img src="@/img/cloudTextbooks/bf.png" />
  38. <!-- <img src="@/img/cloudTextbooks/xm.png" /> -->
  39. </template>
  40. </div>
  41. <div class="nameCon">
  42. <div class="name">{{ item.name }}</div>
  43. <div class="text" v-if="item.useNum ?? false">已使用{{ item.useNum }}次</div>
  44. </div>
  45. <div class="play" :class="{ disabled: item.lockFlag }" @click="item.lockFlag === true || handlePaly(item.id)">查看</div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="chooseCon" v-loading="searchLoading" v-show="chooseType === 'search'">
  51. <div class="chooseBox chooseBoxSearch">
  52. <div class="chooseList">
  53. <myInput
  54. class="queryIpt"
  55. v-model="queryStr"
  56. :height="40"
  57. placeholder="请输入素材关键词"
  58. clearable
  59. @handleQuery="handleQuery"
  60. @keyup.enter="handleQuery"
  61. />
  62. <searchCollapse :search="tempSearch" :activeCollapse="activeCollapse" :courseList="listSearchData" @handleClick="handleCourseClick" />
  63. <el-empty
  64. class="empty"
  65. v-if="!listSearchData.length && !searchLoading"
  66. :image="require('@/img/layout/empty.png')"
  67. description="暂无搜索结果"
  68. />
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script setup lang="ts">
  75. import { computed, ref } from "vue"
  76. import { useDataDetailList } from "./useData"
  77. import myInput from "@/components/myInput"
  78. import searchCollapse from "./searchCollapse"
  79. import userStore from "@/store/modules/user"
  80. const { handleGetDetailList, loading, searchLoading, listDetailData, listSearchData, activeCollapse, listData, pageNum, handlePage } =
  81. useDataDetailList()
  82. import router from "@/router"
  83. const userStoreHook = userStore()
  84. const chooseType = ref<"classlist" | "search">("classlist")
  85. const queryStr = ref("")
  86. const tempSearch = ref("")
  87. const props = defineProps<{
  88. modalData: {
  89. id: string
  90. }
  91. }>()
  92. const emits = defineEmits<{
  93. (e: "onClose"): void
  94. }>()
  95. handleGetDetailList(props.modalData.id)
  96. const isShowTabs = computed(() => {
  97. return userStoreHook.roles === "GYM" ? true : false
  98. })
  99. function close() {
  100. emits("onClose")
  101. }
  102. function handlePaly(id: string) {
  103. // const url = router.resolve({
  104. // name: "coursewarePlay",
  105. // params: { id }
  106. // }).href
  107. // window.open(url, "_blank")
  108. router.push({
  109. name: "coursewarePlay",
  110. params: {
  111. id
  112. }
  113. })
  114. }
  115. function handleCourseClick(value: any) {
  116. router.push({
  117. name: "coursewarePlay",
  118. params: {
  119. id: props.modalData.id
  120. },
  121. query: {
  122. source: "search",
  123. search: queryStr.value,
  124. materialId: value.id
  125. }
  126. })
  127. }
  128. function handleChangeType(type: "classlist" | "search") {
  129. chooseType.value = type
  130. }
  131. function handleQuery() {
  132. tempSearch.value = queryStr.value
  133. handleGetDetailList(props.modalData.id, true, queryStr.value)
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .chooseDialog {
  138. width: 100%;
  139. height: 100%;
  140. padding: 40px;
  141. .close {
  142. position: absolute;
  143. top: -14px;
  144. right: -16px;
  145. width: 42px;
  146. height: 44px;
  147. cursor: pointer;
  148. background: url("@/img/useDialogConfirm/close.png") no-repeat;
  149. background-size: cover;
  150. &:hover {
  151. background: url("@/img/useDialogConfirm/closeHover.png") no-repeat;
  152. background-size: cover;
  153. }
  154. }
  155. .chooseHeader {
  156. position: absolute;
  157. top: -7px;
  158. left: 54px;
  159. img {
  160. width: 131px;
  161. height: 49px;
  162. margin-right: 12px;
  163. }
  164. }
  165. .chooseCon {
  166. width: 100%;
  167. height: 100%;
  168. display: flex;
  169. position: relative;
  170. & > :deep(.el-loading-mask) {
  171. border-radius: 17px;
  172. }
  173. .imgMid {
  174. width: 68px;
  175. height: 518px;
  176. position: absolute;
  177. left: 50%;
  178. top: 50%;
  179. transform: translate(-50%, -50%);
  180. z-index: 1;
  181. }
  182. .chooseBox {
  183. width: 50%;
  184. height: 100%;
  185. background: #f6d7c1;
  186. box-shadow: 0px 2px 3px 0px #a05400;
  187. border-radius: 17px;
  188. padding: 5px;
  189. position: relative;
  190. &:nth-child(2) {
  191. .operate {
  192. left: -30px;
  193. border-radius: 6px 0px 0px 6px;
  194. }
  195. &:hover .operate {
  196. opacity: 1;
  197. }
  198. }
  199. &:nth-child(3) {
  200. margin-left: 10px;
  201. .operate {
  202. right: -30px;
  203. border-radius: 0px 6px 6px 0px;
  204. }
  205. &:hover .operate {
  206. opacity: 1;
  207. }
  208. }
  209. .operate {
  210. width: 30px;
  211. height: 68px;
  212. background: #fffefb;
  213. position: absolute;
  214. top: 50%;
  215. transform: translate(0, -50%);
  216. cursor: pointer;
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. transition: opacity 0.28s;
  221. opacity: 0;
  222. &:hover {
  223. background-color: #edeff0;
  224. }
  225. > img {
  226. width: 13px;
  227. height: 21px;
  228. }
  229. }
  230. .chooseList {
  231. width: 100%;
  232. height: 100%;
  233. background: #fdf7f0;
  234. border-radius: 17px;
  235. padding: 0 40px 0 30px;
  236. overflow: hidden;
  237. .listItem {
  238. margin-top: 12px;
  239. padding: 10px 0;
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. border-bottom: 1px solid #eaeaea;
  244. &:first-child {
  245. margin-top: 32px;
  246. }
  247. &:last-child {
  248. border-bottom: none;
  249. }
  250. .img {
  251. flex-shrink: 0;
  252. width: 35px;
  253. height: 40%;
  254. position: relative;
  255. & > img:nth-child(1) {
  256. width: 100%;
  257. }
  258. & > img:nth-child(2) {
  259. position: absolute;
  260. left: 0;
  261. top: 0;
  262. z-index: 1;
  263. }
  264. }
  265. .nameCon {
  266. margin-left: 7px;
  267. flex-grow: 1;
  268. .name {
  269. font-weight: 600;
  270. font-size: 16px;
  271. color: #333333;
  272. padding: 3px 0;
  273. }
  274. .text {
  275. font-weight: 400;
  276. font-size: 12px;
  277. color: #777777;
  278. padding: 2px 0;
  279. }
  280. }
  281. .play {
  282. flex-shrink: 0;
  283. background: linear-gradient(180deg, #ffab71 0%, #ff6e45 100%);
  284. border-radius: 12px;
  285. text-align: center;
  286. font-weight: 500;
  287. font-size: 12px;
  288. padding: 6px 18px;
  289. color: #ffffff;
  290. letter-spacing: 1px;
  291. cursor: pointer;
  292. &:hover {
  293. opacity: $opacity-hover;
  294. }
  295. &.disabled {
  296. background: linear-gradient(180deg, #d3d3d3 0%, #b5b5b5 100%);
  297. cursor: not-allowed;
  298. &:hover {
  299. opacity: 1;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. .chooseBoxSearch {
  307. width: 100%;
  308. .chooseList {
  309. padding: 20px 80px;
  310. display: flex;
  311. flex-direction: column;
  312. .courseCollapse {
  313. margin-top: 16px;
  314. flex: 1;
  315. overflow-y: auto;
  316. overflow-x: hidden;
  317. &::-webkit-scrollbar {
  318. display: none;
  319. }
  320. }
  321. &:deep(.empty) {
  322. position: absolute;
  323. top: 50%;
  324. left: 50%;
  325. transform: translate(-50%, -50%);
  326. .el-empty__image {
  327. width: 360px;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. </style>
  335. <style lang="scss">
  336. .h-modalFrame.chooseDialog {
  337. /* prettier-ignore */
  338. --modalFrameTitHeight: 0PX;
  339. .modalFrameBox {
  340. background: url("@/img/cloudTextbooks/bg.png") no-repeat;
  341. background-size: cover;
  342. box-shadow: none;
  343. .modalFrameTitle {
  344. display: none;
  345. }
  346. }
  347. }
  348. </style>