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