QueryTool.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <div>
  3. <div class='query' v-drag="'.query .ant-card-head'">
  4. <a-card v-show='value' title='查询' class='queryPanel'>
  5. <a-icon slot='extra' class='panelClose' type='close' @click="$emit('input',false)"/>
  6. <a-input-group compact>
  7. <a-select v-model='queryType' style='width:45%' @change='selectChange'>
  8. <a-select-option v-for='(item,index) in list' :key='item.id' :value='item.tablename'>
  9. {{ item.tablealias }}
  10. </a-select-option>
  11. </a-select>
  12. <a-select v-model='queryList' style='width:50%;margin-left: 3%' @pressEnter='handleSearch'>
  13. <a-select-option v-for='(item,index) in this.queryLists' :key='item.id' :value='item.queryname'>
  14. {{ item.chinesename }}
  15. </a-select-option>
  16. </a-select>
  17. <a-select v-if="this.queryList.includes('SF')" @pressEnter='handleSearch' v-model='keyword' style='width:76%;margin-top: 3%'>
  18. <a-select-option value='是'>
  19. 是
  20. </a-select-option>
  21. <a-select-option value='否'>
  22. 否
  23. </a-select-option>
  24. </a-select>
  25. <a-select v-else-if="this.queryList.includes('SY')" @pressEnter='handleSearch' v-model='keyword' style='width:76%;margin-top: 3%'>
  26. <a-select-option value='出让'>
  27. 出让
  28. </a-select-option>
  29. <a-select-option value='划拨'>
  30. 划拨
  31. </a-select-option>
  32. <a-select-option value='转让'>
  33. 转让
  34. </a-select-option>
  35. <a-select-option value='作价出资'>
  36. 作价出资
  37. </a-select-option>
  38. </a-select>
  39. <a-input-search v-else allow-clear :loading='isLoading' style='width: 86%;margin-top: 3%' v-model='keyword'
  40. @search='handleSearch' :placeholder='placeholder'
  41. @pressEnter='handleSearch'/>
  42. <a-tooltip placement='bottom' v-if="this.queryList.includes('SF')||this.queryList.includes('SY')">
  43. <template slot='title'>
  44. <span>搜索</span>
  45. </template>
  46. <a-button icon="search" style='width: 10%;margin-top: 3%' @click='handleSearch'></a-button>
  47. </a-tooltip>
  48. <a-tooltip placement='bottom'>
  49. <template slot='title'>
  50. <span>重置</span>
  51. </template>
  52. <a-button type='primary' icon='reload' style='width: 10%;margin-top: 3%;margin-left: 2%'
  53. @click='reset'></a-button>
  54. </a-tooltip>
  55. </a-input-group>
  56. <template v-if='returntree'>
  57. <a-list style='margin-top: 20px;' item-layout='horizontal' :data-source='data' :pagination='pagination'>
  58. <a-collapse :bordered='false'>
  59. <a-collapse-panel v-for='item in data' :key='item.id' :header='item.name' style='overflow: hidden'>
  60. <a-list :data-source='item.subInfos'>
  61. <a-list-item slot='renderItem' slot-scope='subItem, index' @click='handleCoord(subItem)'>
  62. {{ subItem.mainInfo }}
  63. <template v-if='subItem.shapeArea !==null'>
  64. <span> —— </span>
  65. <span>{{ subItem.shapeArea }}</span>
  66. </template>
  67. </a-list-item>
  68. </a-list>
  69. <a-icon slot='extra' type='profile' @click='handleAttributes($event,item)'></a-icon>
  70. </a-collapse-panel>
  71. </a-collapse>
  72. </a-list>
  73. </template>
  74. <template v-else>
  75. <a-list style='margin-top: 20px;' item-layout='horizontal' :data-source='data' :pagination='pagination'>
  76. <a-list-item slot='renderItem' slot-scope='item, index'>
  77. <a-list-item-meta @click='handleCoord(item)' :description='item.name'>
  78. <span slot='title'>{{ item.otherInfo }}</span>
  79. <a-avatar slot='avatar' class='result' :src='require(`../static/result${index+1}.png`)'>
  80. </a-avatar>
  81. </a-list-item-meta>
  82. <!-- <a-tag color='blue' style='padding-left: 0.5em;'>-->
  83. <!-- {{ item.layerName }}-->
  84. <!-- </a-tag>-->
  85. <!-- <a-button slot='actions' type='primary' ghost size='small' @click='handleDetail(item)'>-->
  86. <!-- 详情-->
  87. <!-- </a-button>-->
  88. </a-list-item>
  89. </a-list>
  90. </template>
  91. </a-card>
  92. </div>
  93. <locate-by-geoinfo ref='locateByGeoinfo'></locate-by-geoinfo>
  94. <query-info ref='detail' v-model='infoShow'></query-info>
  95. </div>
  96. </template>
  97. <script>
  98. import {getAction, httpAction} from '../../../api/manage';
  99. import LocateByGeoinfo from './LocateByGeoinfo';
  100. import QueryInfo from './QueryInfo';
  101. export default {
  102. name: 'queryTool',
  103. components: {QueryInfo, LocateByGeoinfo},
  104. data() {
  105. return {
  106. map: '',
  107. visible: false,
  108. list: [], //查询类型下拉列表
  109. isLoading: false,
  110. vectorLayer: '',
  111. queryType: '',
  112. lastType: '',
  113. keyword: '',
  114. returntree: false,
  115. data: [],
  116. placeholder: '',
  117. queryList: '',
  118. onPage: false,
  119. queryLists: [],
  120. pagination: {
  121. onChange: page => {
  122. this.pagination.current = page;
  123. this.onPage = true;
  124. this.handleSearch();
  125. },
  126. disabled: false,
  127. pageSize: 10,
  128. total: 0,
  129. size: 'small',
  130. current: 1
  131. },
  132. infoShow: false
  133. };
  134. },
  135. props: {
  136. value: {
  137. type: Boolean,
  138. default: false,
  139. required: true
  140. },
  141. queryConfigUrl: {
  142. type: String,
  143. required: true
  144. },
  145. queryUrl: {
  146. type: String,
  147. required: true
  148. }
  149. },
  150. watch: {
  151. value(val) {
  152. if (val === false) {
  153. //清空搜索框
  154. // this.keyword = '';
  155. this.infoShow = false;
  156. } else {
  157. }
  158. }
  159. },
  160. inject: ['basicMap'],
  161. async created() {
  162. let {success, result} = await getAction(this.queryConfigUrl, {
  163. username: this.$store.state.user.info.username,
  164. topicId: this.basicMap.topicId
  165. });
  166. if (success) {
  167. if (result.length == 0) {
  168. this.$message.warn('没有查询到配置信息,请联系管理员!');
  169. } else {
  170. this.list = result;
  171. this.queryType = this.list[0].tablename;
  172. this.placeholder = this.list[0].inputTip;
  173. this.returntree = this.list[0].returntree == 'true' ? true : false;
  174. this.queryLists = this.list[0].queryList;
  175. }
  176. } else {
  177. this.$message.warn('没有查询到配置信息,请联系管理员!');
  178. }
  179. },
  180. mounted() {
  181. this.selectChange()
  182. },
  183. methods: {
  184. async handleSearch() {
  185. if (this.queryType && this.keyword && this.queryList.length > 0) {
  186. this.infoShow = false;
  187. if (this.queryType !== this.lastType) {
  188. this.pagination.current = 1;
  189. if (this.lastType != '') {
  190. this.basicMap.changeLayerVisibleByTableName(this.lastType, false);
  191. }
  192. }
  193. this.basicMap.changeLayerVisibleByTableName(this.queryType, true);
  194. if (!this.onPage) {
  195. this.pagination.current = 1;
  196. }
  197. this.lastType = this.queryType;
  198. this.isLoading = true;
  199. this.pagination.disabled = true;
  200. // let queryItem = this.list.find((item) => {
  201. // return item.tablename === this.queryType;
  202. // });
  203. this.onPage = false;
  204. let {success, message, result} = await getAction(this.queryUrl, {
  205. queryType: this.queryType,
  206. queryList: this.queryList,
  207. returntree: this.returntree,
  208. queryInfo: this.keyword,
  209. pageNo: this.pagination.current,
  210. pageSize: 10
  211. });
  212. if (success) {
  213. this.isLoading = false;
  214. this.pagination.disabled = false;
  215. if (result.total === 0 || result === '') {
  216. this.$message.error('没有查询到信息');
  217. this.data = [];
  218. this.pagination.total = 0;
  219. return;
  220. }
  221. this.data = result.records;
  222. this.pagination.total = result.total;
  223. } else {
  224. this.$message.info(message);
  225. }
  226. } else {
  227. this.$message.warn('请输入查询关键字!');
  228. }
  229. },
  230. selectChange(val) {
  231. let temp = [];
  232. this.queryList = [];
  233. temp = this.list.filter((item) => {
  234. return item.tablename === val;
  235. });
  236. this.data = [];
  237. // this.placeholder = temp[0].inputTip;
  238. this.returntree = temp[0].returntree == 'true' ? true : false;
  239. this.queryLists = temp[0].queryList;
  240. },
  241. handleCoord(item) {
  242. this.$refs.locateByGeoinfo.locate(item);
  243. },
  244. handleAttributes(event, item) {
  245. event.stopPropagation();
  246. this.infoShow = true;
  247. this.$refs.detail.loadDetail(item.attributes);
  248. },
  249. handleDetail(item) {
  250. this.handleCoord(item);
  251. this.infoShow = true;
  252. this.$refs.detail.loadDetail(item.attributes);
  253. },
  254. clear() {
  255. this.$refs.locateByGeoinfo.clear();
  256. },
  257. reset() {
  258. this.data = [];
  259. this.pagination.total = 0;
  260. this.infoShow = false;
  261. this.keyword = '';
  262. this.clear();
  263. }
  264. /*createVectorLayer() {
  265. if (this.map === '' || this.vectorLayer === '') return
  266. const vectorSource = new VectorSource();
  267. this.vectorLayer = new VectorLayer({
  268. name: 'locMap',
  269. source: vectorSource,
  270. style: new Style({
  271. fill: new Fill({
  272. color: 'rgba(255, 255, 255, 0.6)',
  273. }),
  274. stroke: new Stroke({
  275. color: '#ff0000',
  276. lineDash: [6, 6],
  277. width: 2
  278. }),
  279. image: new CircleStyle({
  280. radius: 7,
  281. fill: new Fill({
  282. color: '#ffcc33',
  283. }),
  284. }),
  285. }),
  286. zIndex: 100
  287. })
  288. this.map.addLayer(this.vectorLayer);
  289. }*/
  290. }
  291. };
  292. </script>
  293. <style>
  294. .query .queryPanel {
  295. width: 450px;
  296. box-shadow: 0 0 5px #357ee5;
  297. color: #1890ff;
  298. }
  299. .query a > .anticon {
  300. /* vertical-align: 0.2em; */
  301. }
  302. .ant-list-item:hover {
  303. background: #e6f7ff;
  304. cursor: pointer;
  305. }
  306. .query .ant-avatar {
  307. /* background: url("https://img1.baidu.com/it/u=1159474645,508069395&fm=26&fmt=auto"); */
  308. }
  309. .query .ant-list-item {
  310. align-items: flex-start;
  311. }
  312. .query .ant-list-item-action {
  313. margin-left: 10px;
  314. }
  315. .ant-avatar.result > img {
  316. display: inline-block;
  317. height: auto;
  318. width: auto;
  319. }
  320. #queryTool .ant-spin-nested-loading {
  321. max-height: calc(500px - 48px - 32px - 20px - 24px - 24.5px);
  322. overflow-y: auto;
  323. }
  324. .query ::-webkit-scrollbar {
  325. width: 3px !important;
  326. height: 3px;
  327. }
  328. .query ::-webkit-scrollbar-thumb {
  329. border-radius: 5px;
  330. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
  331. background: rgba(24, 144, 255, 0.73);
  332. }
  333. .query .queryPanel .ant-list-item-meta-title {
  334. width: 230px;
  335. overflow: hidden;
  336. text-overflow: ellipsis;
  337. white-space: nowrap;
  338. }
  339. li > div {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. margin-bottom: 8px;
  344. }
  345. /*.icon-close {*/
  346. /* cursor: pointer;*/
  347. /* position: absolute;*/
  348. /* right: 5px;*/
  349. /* top: 5px;*/
  350. /*}*/
  351. </style>