select.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <!-- todo: 旧版的初始场景设置时弹窗,可以删了? -->
  3. <div class="select-commodity">
  4. <a class="close" @click="$emit('cancle')">+</a>
  5. <h3 class="title">{{ title }}</h3>
  6. <div class="filtert">
  7. <div>
  8. <input
  9. type="text"
  10. placeholder="输入关键词"
  11. v-model="key"
  12. @keyup.enter="search"
  13. />
  14. <i
  15. @click="search"
  16. class="iconfont iconsearch"
  17. ></i>
  18. </div>
  19. </div>
  20. <template>
  21. <div class="scene-layer">
  22. <tabList :list="info.catalogRoot" :cls="'w-menu'" @clickItem="item=>{taboneActive = item}" :hiddenHover="true" :active="taboneActive" :id="'selct11'" :subId="'selct111'">
  23. </tabList>
  24. <tabList v-if="childTab.length > 1" :list="childTab" :cls="'w-menu'" :hiddenHover="true" @clickItem="item=>{tabtowActive = item}"
  25. :active="tabtowActive" :id="'subselct11'" :subId="'subselct111'">
  26. </tabList>
  27. <div>
  28. <div class="pano-con" v-if="filterScenes.length > 0">
  29. <ul>
  30. <li
  31. v-for="(item, i) in filterScenes"
  32. @click="select = item"
  33. :class="{ 'li-active': select.sceneCode == item.sceneCode }"
  34. :key="i"
  35. >
  36. <div class="typeli">
  37. <i
  38. class="iconfont iconedit_type_3d"
  39. :class="{'iconedit_type_panorama':item.type!=='4dkk'}"
  40. ></i>
  41. </div>
  42. <div class="img">
  43. <img :key="i" :src="`${item.icon}?rnd=${Math.random()}`" alt="" />
  44. </div>
  45. <div class="ui-title">
  46. <span>{{
  47. item.sceneTitle
  48. }}</span>
  49. </div>
  50. </li>
  51. </ul>
  52. </div>
  53. <div class="nodata" v-else>
  54. <img :src="$noresult" alt="">
  55. <span>{{!!isClickSearch?'未搜索到结果~':'暂无素材'}}</span>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <div class="btns">
  61. <a @click="$emit('cancle')">取消</a>
  62. <a :class="{ disable: disable }" @click="$emit('submit', select)">确定</a>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import tabList from "@/components/tablist";
  68. import { mapGetters } from "vuex";
  69. import { getTabSceneList } from "@/api";
  70. export default {
  71. components: {tabList},
  72. props: {
  73. selected: {
  74. default() {
  75. return {};
  76. },
  77. type: Object | String,
  78. },
  79. title: {
  80. default: "",
  81. type: String,
  82. }
  83. },
  84. watch: {
  85. taboneActive: {
  86. immediate:true,
  87. deep:true,
  88. handler: function (newVal,oldVal) {
  89. if (!newVal.id) {
  90. this.taboneActive = this.info.catalogRoot[0]
  91. }
  92. let temp = []
  93. newVal.children && newVal.children.forEach(item=>{
  94. this.info.catalogs.forEach(sub=>{
  95. if (item==sub.id) {
  96. temp.push(sub)
  97. }
  98. })
  99. })
  100. this.childTab = temp
  101. if (this.childTab.length == 1 || newVal!=oldVal) {
  102. this.tabtowActive = this.childTab[0]
  103. }
  104. },
  105. },
  106. tabtowActive: {
  107. immediate:true,
  108. handler: function (newVal) {
  109. if (!newVal) {
  110. this.tabtowActive = this.childTab[0]
  111. } else{
  112. this.$emit("catalog",newVal);
  113. this.scenes = this.info.scenes.filter(item=>{
  114. return newVal.id == item.category
  115. })
  116. this.key = ''
  117. this.search()
  118. }
  119. }
  120. }
  121. },
  122. computed: {
  123. ...mapGetters({
  124. tablist:'tablist',
  125. info: "info",
  126. backupInfo: "backupInfo"
  127. }),
  128. disable() {
  129. return !this.select.id;
  130. }
  131. },
  132. data() {
  133. return {
  134. taboneActive:{children:[]},
  135. tabtowActive:'',
  136. select:{...this.selected},
  137. list:[],
  138. childTab:[],
  139. scenes:[],
  140. filterScenes:[],
  141. isClickSearch:'',
  142. key: ""
  143. };
  144. },
  145. methods: {
  146. search(){
  147. let tmp = this.scenes.filter(item=>{
  148. if (item.sceneTitle.indexOf(this.key)>-1) {
  149. return item
  150. }
  151. })
  152. this.filterScenes = tmp.sort((a,b)=>a.weight-b.weight)
  153. },
  154. getTabSceneList(catalogId=null){
  155. if (!catalogId) {
  156. catalogId = this.taboneActive.children.length<=0 ? this.taboneActive.id : this.tabtowActive.id
  157. }
  158. getTabSceneList({catalogId},(data)=>{
  159. this.list = data.data||[]
  160. })
  161. },
  162. },
  163. mounted() {
  164. this.key = "";
  165. },
  166. };
  167. </script>
  168. <style lang="less" scoped>
  169. ::-webkit-scrollbar-track {
  170. box-shadow: inset 0 0 5px rgb(0 0 0 / 20%);
  171. border-radius: 4px;
  172. background: #fff;
  173. }
  174. .select-commodity {
  175. position: fixed;
  176. z-index: 3;
  177. left: 50%;
  178. top: 50%;
  179. transform: translateX(-50%) translateY(-50%);
  180. color: #202020;
  181. background: #ffffff;
  182. max-width: 960px;
  183. width: 100%;
  184. border-radius: 6px;
  185. }
  186. .select-commodity > * {
  187. padding: 15px;
  188. }
  189. .title {
  190. font-size: 16px;
  191. line-height: 20px;
  192. font-weight: 400;
  193. margin: 0;
  194. font-weight: bold;
  195. border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  196. }
  197. .close {
  198. position: absolute;
  199. right: -8px;
  200. top: -15px;
  201. font-size: 25px;
  202. color: #909090;
  203. transform: rotate(45deg);
  204. cursor: pointer;
  205. }
  206. .filtert {
  207. padding: 15px;
  208. }
  209. .filtert > div {
  210. width: 210px;
  211. height: 34px;
  212. background: rgba(22, 26, 26, 1);
  213. border-radius: 2px;
  214. display: inline-block;
  215. margin-right: 10px;
  216. position: relative;
  217. vertical-align: middle;
  218. }
  219. .filtert > div > select,
  220. .filtert > div > input {
  221. box-sizing: border-box;
  222. width: 100%;
  223. height: 100%;
  224. border: none;
  225. background: none;
  226. color: #202020;
  227. padding: 8px 10px;
  228. outline: none;
  229. background: #ffffff;
  230. border: 1px solid #ebebeb;
  231. }
  232. .filtert > div > input {
  233. padding-right: 40px;
  234. }
  235. .filtert > div > i {
  236. position: absolute;
  237. top: 50%;
  238. transform: translateY(-50%);
  239. right: 10px;
  240. cursor: pointer;
  241. color: @color;
  242. }
  243. .scene-layer {
  244. min-height: 400px;
  245. max-height: 60vh;
  246. overflow-y: auto;
  247. position: relative;
  248. .nodata {
  249. position: absolute;
  250. left: 50%;
  251. top: 40%;
  252. transform: translate(-50%, -50%);
  253. }
  254. .pano-con{
  255. background: #fff;
  256. padding: 0;
  257. > ul {
  258. > li{
  259. cursor: pointer;
  260. margin: 10px 10px 30px 0;
  261. .ui-title {
  262. > span {
  263. color: #202020;
  264. }
  265. }
  266. .typeli,
  267. .oper {
  268. background: rgba(0, 0, 0, 0.5);
  269. .iconfont{
  270. color:#fff
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .btns {
  278. text-align: center;
  279. > a {
  280. width: 120px;
  281. height: 40px;
  282. text-align: center;
  283. line-height: 40px;
  284. opacity: 1;
  285. border-radius: 20px;
  286. font-size: 12px;
  287. cursor: pointer;
  288. display: inline-block;
  289. color: @color;
  290. margin: 0 10px;
  291. &:nth-child(2) {
  292. background-color: @color;
  293. color: #fff;
  294. }
  295. &:nth-child(1) {
  296. border: 1px solid @color;
  297. }
  298. }
  299. .disable {
  300. pointer-events: none !important;
  301. opacity: 0.5 !important;
  302. }
  303. }
  304. </style>