query-keyword.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <script setup>
  2. /**
  3. * element-plus组件
  4. */
  5. import {
  6. ElMessage
  7. } from 'element-plus';
  8. /**
  9. * element-plus字体
  10. */
  11. import jt3dNavigation from 'cesium-navigation-es6';
  12. import {
  13. Search,
  14. DArrowRight
  15. } from '@element-plus/icons-vue';
  16. import {
  17. inject
  18. } from "vue";
  19. const getMapInstance = inject("getMapInstance");
  20. jt3d = getMapInstance();
  21. </script>
  22. <template>
  23. <div class="query-keyword fadein-left">
  24. <el-input v-model="search.searchKey" placeholder="请输入查询关键字" @change="searchKeyChange" @input="searchKeyChange" clearable>
  25. <template #append>
  26. <el-button :icon="Search" @click="btnSearchClick" />
  27. </template>
  28. </el-input>
  29. <div class="autocomplete " v-if="search.searchListShow">
  30. <ul>
  31. <li v-for="(item,index) in search.searchCompleteData" :key="index" @click="SearchSelect(index)">
  32. {{ item }}
  33. </li>
  34. </ul>
  35. </div>
  36. <div class="query-result" v-if="resultListShow">
  37. <template v-if="resultCompleteData && resultCompleteData.length">
  38. <ul>
  39. <li v-for="(item, i) in resultCompleteData" :key="i" class="query-result__item" @click.stop="flyTo(item)">
  40. <div class="query-result__context">
  41. <p class="query-result-text" :title="item.name">
  42. <span class="query-result-text_num">{{ i + 1 }}</span>
  43. {{ item.name }}
  44. </p>
  45. <p class="query-result-sub">{{ item.label }}</p>
  46. </div>
  47. <p class="query-result__more">
  48. <el-icon>
  49. <DArrowRight />
  50. </el-icon>
  51. </p>
  52. </li>
  53. </ul>
  54. <div class="query-result__page">
  55. <p class="query-result-allcount">共{{ resultCompleteData.length }}条结果</p>
  56. <el-pagination layout="prev, pager, next" size="small" :total="resultCompleteData.length" pageSize="1" :simple="true" />
  57. </div>
  58. </template>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. let jt3d = undefined;
  64. export default {
  65. props: {
  66. },
  67. /**
  68. * 数据
  69. */
  70. data() {
  71. return {
  72. search: {
  73. searchKey: "", // input框输入的值,用v-model双向绑定
  74. searchDataList: [], // autocomplete查询数据,一般由后端返回
  75. searchCompleteData: [], // autocomplete查询到的数据
  76. searchListShow: false,
  77. },
  78. resultCompleteData: [], // 查询结果
  79. resultListShow: false,
  80. pagination: {
  81. size: "small",
  82. total: 0,
  83. pageSize: 6,
  84. simple: true
  85. }
  86. }
  87. },
  88. /**
  89. * 方法
  90. */
  91. methods: {
  92. /**
  93. * 比例尺、指南针
  94. */
  95. initNavigation(jt3d) {
  96. let options = {};
  97. // 用于在使用重置导航重置地图视图时设置默认视图控制。接受的值是Cesium.Cartographic 和 Cesium.Rectangle.
  98. options.defaultResetView = Cesium.Rectangle.fromDegrees(121.13766, 36.99670, 121.94984, 37.55286);
  99. // options.defaultResetView = Cesium.Cartographic.fromDegrees(103.84,31.15,24000);
  100. // options.defaultResetView = Cesium.Cartographic.fromDegrees(Cesium.Math.toRadians(103.84),Cesium.Math.toRadians(31.15),Cesium.Math.toRadians(24000));
  101. options.orientation = {
  102. heading: Cesium.Math.toRadians(0),
  103. pitch: Cesium.Math.toRadians(-90),
  104. roll: 0
  105. };
  106. //相机延时
  107. options.duration = 4; //默认为3s
  108. // 用于启用或禁用罗盘。
  109. options.enableCompass = true;
  110. // 用于启用或禁用指南针外环。
  111. options.enableCompassOuterRing = true;
  112. // 用于启用或禁用缩放控件。
  113. options.enableZoomControls = true;
  114. // 用于启用或禁用距离图例。
  115. options.enableDistanceLegend = false;
  116. //修改重置视图的tooltip
  117. options.resetTooltip = "重置视图";
  118. //修改放大按钮的tooltip
  119. options.zoomInTooltip = "放大";
  120. //修改缩小按钮的tooltip
  121. options.zoomOutTooltip = "缩小";
  122. //如需自定义罗盘控件,请看下面的自定义罗盘控件
  123. new jt3dNavigation(jt3d._viewer, options);
  124. },
  125. /**
  126. * 在 Input 值改变时触发
  127. * 当 modelValue 改变时,当输入框失去焦点或用户按Enter时触发
  128. */
  129. searchKeyChange() {
  130. let _self = this;
  131. this.search.searchListShow = true;
  132. this.resultListShow = false;
  133. let searchRegex = new RegExp(this.search.searchKey, 'i');
  134. this.search.searchCompleteData = []; // 先把原有的数据清空,重新查询
  135. if (this.search.searchKey === '') return; //如果什么都没有输入,则不用查找
  136. this.search.searchDataList.forEach((item) => {
  137. if (searchRegex.test(item.label)) {
  138. _self.search.searchCompleteData.push(item.label)
  139. }
  140. });
  141. },
  142. /**
  143. * 选中联想查询数据
  144. * @param {Object} index
  145. */
  146. SearchSelect(index) {
  147. this.search.searchListShow = false;
  148. console.log(this.search.searchCompleteData[index]);
  149. this.getSearchData(this.search.searchCompleteData[index]);
  150. },
  151. /**
  152. * 查询按钮
  153. */
  154. btnSearchClick() {
  155. if (this.search.searchKey === "") {
  156. ElMessage("请输入查询关键字");
  157. return;
  158. }
  159. this.getSearchData(this.search.searchKey);
  160. },
  161. /**
  162. * 数据查询
  163. * @param {Object} queryString
  164. */
  165. getSearchData(queryString) {
  166. let _self = this;
  167. _self.$http.get('/getTableList', {
  168. tableName: 'base_sys_role',
  169. sqlWhere: " label like '%" + queryString + "%'",
  170. orderByField: ''
  171. }).then(res => {
  172. console.log('从服务端搜索数据', res.data)
  173. _self.resultCompleteData = res.data;
  174. _self.resultListShow = true;
  175. _self.search.searchListShow = false;
  176. });
  177. }
  178. },
  179. mounted() {
  180. //比例尺、指南针
  181. this.initNavigation(jt3d);
  182. let _self = this;
  183. _self.$http.get('/getTableList', {
  184. tableName: 'base_sys_role',
  185. sqlWhere: '',
  186. orderByField: ''
  187. }).then(res => {
  188. console.log('从服务端搜索数据', res.data)
  189. _self.search.searchDataList = res.data;
  190. });
  191. }
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. $jt3d-text-color:#fff;
  196. $jt3d-content-color:#fff;
  197. $jt3d-select-bg:red;
  198. .query-keyword {
  199. position: absolute;
  200. top: 80rem;
  201. width: 200rem;
  202. left: 10rem;
  203. border: 1rem solid rgb(0 44 126 / 100%);
  204. .el-input {
  205. --el-input-bg-color: rgb(0 44 126 / 50%);
  206. --el-input-border-color: rgb(0 44 126 / 50%);
  207. --el-input-placeholder-color: #fff;
  208. --el-fill-color-blank: rgb(0 44 126 / 80%);
  209. --el-text-color-regular: #fff;
  210. --el-color-primary: #fff --el-border-radius-base:0rem;
  211. --el-border-radius-base: 0rem;
  212. .el-button {
  213. background-color: rgb(0 44 126 / 100%);
  214. color: #fff;
  215. }
  216. }
  217. .autocomplete {
  218. --el-fill-color-blank: rgb(0 44 126 / 0%);
  219. }
  220. }
  221. .autocomplete ul {
  222. font-family: sans-serif;
  223. position: absolute;
  224. list-style: none;
  225. background: rgb(0 44 126 / 30%);
  226. margin: 0;
  227. width: 80%;
  228. margin-top: 1rem;
  229. margin-left: -1rem;
  230. border: 1rem solid rgb(0 44 126 / 100%);
  231. }
  232. .autocomplete ul li {
  233. text-decoration: none;
  234. display: block;
  235. background: rgb(0 44 126 / 30%);
  236. color: #fff;
  237. padding: 5rem;
  238. margin-left: -40rem;
  239. text-align: left;
  240. }
  241. .autocomplete ul li:hover,
  242. .autocomplete ul li.focus-list {
  243. color: white;
  244. background: #2F9AF7;
  245. }
  246. .query-result {
  247. position: absolute;
  248. border-top: none;
  249. padding-bottom: 0rem;
  250. width: 100%;
  251. z-index: 100;
  252. border: 1rem solid rgb(0 44 126 / 100%);
  253. background: rgb(0 44 126 / 30%);
  254. margin-left: -1rem;
  255. --el-fill-color-blank: rgb(0 44 126 / 0%);
  256. --color: #fff;
  257. --el-color-primary: #fff;
  258. .query-result__item {
  259. height: 80rem;
  260. padding: 0 10rem;
  261. display: flex;
  262. justify-content: flex-start;
  263. align-items: center;
  264. margin-left: -40rem;
  265. text-align: left;
  266. &:hover {
  267. // background-color: var(--mars-select-bg);
  268. }
  269. .query-result__context {
  270. flex-grow: 1;
  271. width: 90%;
  272. .query-result-text {
  273. font-size: 16rem;
  274. width: 200rem;
  275. font-family: Source Han Sans CN;
  276. font-weight: 400;
  277. // color: var($jt3d-text-color);
  278. color: $jt3d-text-color;
  279. .query-result-text_num {
  280. width: 20rem;
  281. height: 20rem;
  282. margin-right: 5rem;
  283. display: inline-block;
  284. text-align: center;
  285. background: rgb(0 44 126 / 100%);
  286. }
  287. }
  288. .query-result-sub {
  289. font-size: 14rem;
  290. width: 200rem;
  291. margin-left: 19rem;
  292. font-family: Source Han Sans CN;
  293. font-weight: 400;
  294. // color: var($jt3d-content-color);
  295. color: $jt3d-content-color;
  296. }
  297. }
  298. .query-result__more {
  299. font-size: 14rem;
  300. font-family: Source Han Sans CN;
  301. font-weight: 400;
  302. // color: var($jt3d-content-color);
  303. color: $jt3d-content-color;
  304. }
  305. }
  306. .query-result__page {
  307. display: flex;
  308. justify-content: space-between;
  309. padding: 5rem;
  310. .query-result-allcount {
  311. font-size: 14rem;
  312. // color: var($jt3d-text-color);
  313. color: $jt3d-text-color;
  314. }
  315. }
  316. }
  317. /* 四个边角样式 */
  318. // .borderstyle {
  319. // position: relative;
  320. // width: 100%;
  321. // height: 490rem;
  322. // padding: 10rem;
  323. // border: 1rem solid #008aff70 !important;
  324. // background-color: rgba(5, 45, 115, 0.7) !important;
  325. // box-shadow: 0 4rem 15rem 1rem #02213bb3;
  326. .angle-border {
  327. position: absolute;
  328. width: 12rem;
  329. height: 12rem;
  330. }
  331. .angle-border-blue {
  332. position: absolute;
  333. width: 70rem;
  334. height: 30rem;
  335. }
  336. .left-top-border {
  337. top: -2rem;
  338. left: -2rem;
  339. border-left: 2rem solid #008affdd;
  340. border-top: 2rem solid #008affdd;
  341. }
  342. .right-top-border {
  343. top: -2rem;
  344. right: -2rem;
  345. border-right: 2rem solid #008affdd;
  346. border-top: 2rem solid #008affdd;
  347. }
  348. .left-bottom-border {
  349. bottom: -2rem;
  350. left: -2rem;
  351. border-bottom: 2rem solid #FFFFFF;
  352. border-left: 2rem solid #FFFFFF;
  353. }
  354. .right-bottom-border {
  355. bottom: -2rem;
  356. right: -2rem;
  357. border-right: 2rem solid #FFFFFF;
  358. border-bottom: 2rem solid #FFFFFF;
  359. }
  360. // }
  361. </style>