shijiplus-web-plugin 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shijiplus-web-plugin",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "files": [
5
5
  "src"
6
6
  ],
package/src/App.vue CHANGED
@@ -1,16 +1,31 @@
1
1
  <template>
2
2
  <div id="app">
3
3
  <img id="img" alt="Vue logo" src="./assets/logo.png" />
4
+ <Button @click="showMapClick">showMap</Button>
4
5
  <plus-city-cascader></plus-city-cascader>
6
+ <TxMap
7
+ :show="showmap"
8
+ region="北京"
9
+ ></TxMap>
5
10
  </div>
6
11
  </template>
7
12
 
8
13
  <script>
9
14
  import PlusCityCascader from './components/plus-comp/plus-city-cascader/plus-city-cascader.vue'
10
15
 
16
+ import TxMap from './components/txmap/tx-map'
17
+
11
18
  export default {
12
19
  name: 'App',
13
- components: {PlusCityCascader},
20
+ components: { PlusCityCascader, TxMap },
21
+ data() {
22
+ return { showmap: false }
23
+ },
24
+ methods: {
25
+ showMapClick() {
26
+ this.showmap = true
27
+ }
28
+ },
14
29
  mounted() {
15
30
  console.log(
16
31
  'web-tool mounted!',
@@ -0,0 +1,283 @@
1
+ <template>
2
+ <Modal
3
+ v-model="show"
4
+ :width="800"
5
+ :footer-hide="true"
6
+ :closable="false"
7
+ @on-visible-change="visibleChange"
8
+ :title="'搜索区域:' + region"
9
+ class="lau"
10
+ >
11
+ <Select
12
+ ref="selectRef"
13
+ filterable
14
+ clearable
15
+ placeholder="输入关键字搜索"
16
+ :loading="searchLoading"
17
+ remote
18
+ :remote-method="placeSearch"
19
+ @on-change="placeChange"
20
+ @on-open-change="locOpenChange"
21
+ >
22
+ <Option
23
+ v-for="(option, index) in placeData"
24
+ :value="index"
25
+ :label="option.title"
26
+ :key="index"
27
+ >
28
+ <span class="f-w-600"
29
+ >{{ option.title }}
30
+ <span style="margin-left: 5px"
31
+ >{{ option.province }}{{ option.city }}{{ option.district }}</span
32
+ ></span
33
+ >
34
+ </Option>
35
+ </Select>
36
+ <div ref="atlas" id="atlas" style="width: 800px; height: 800px"></div>
37
+ </Modal>
38
+ </template>
39
+
40
+ <script>
41
+ import { TMap } from '../../libs/TMap'
42
+ import { throttle } from '../../libs/util'
43
+ export default {
44
+ name: 'TxMap',
45
+
46
+ props: ['show', 'lat', 'lng', 'posTitle', 'region'],
47
+ watch: {
48
+ show(val) {
49
+ if (val) {
50
+ this.$refs.selectRef.setQuery('')
51
+ this.$refs.selectRef.clearSingleSelect()
52
+ this.mapTX().then(() => {
53
+ if (this.region.indexOf('北京') == -1 && (!this.lat || !this.lng)) {
54
+ var geocoder = new this.tMap.service.Geocoder()
55
+ geocoder
56
+ .getLocation({
57
+ address: this.region
58
+ })
59
+ .then((resp) => {
60
+ if (resp.result) {
61
+ this.setCenter(
62
+ resp.result.location.lat,
63
+ resp.result.location.lng,
64
+ this.posTitle
65
+ )
66
+ }
67
+ })
68
+ }
69
+ const pos = this.getPosition()
70
+ this.setCenter(pos.lat, pos.lng, this.posTitle)
71
+ })
72
+ }
73
+ console.log('---------txmap-show----------', val)
74
+ },
75
+ lat(val) {
76
+ this.posLat = val
77
+ },
78
+ lng(val) {
79
+ this.posLng = val
80
+ }
81
+ },
82
+ data() {
83
+ return {
84
+ posLat: null,
85
+ posLng: null,
86
+ txmap: null,
87
+ txmapmarker: null,
88
+ searchService: null,
89
+ searchLoading: false,
90
+ placeData: [],
91
+ sugguestionService: null
92
+ }
93
+ },
94
+
95
+ methods: {
96
+ locOpenChange(e) {
97
+ if (!e) {
98
+ this.$refs.selectRef.isFocused = false
99
+ }
100
+ },
101
+ placeChange(e) {
102
+ let option = this.placeData[e]
103
+ if (option) {
104
+ this.setCenter(option.location.lat, option.location.lng, option.title)
105
+ }
106
+ },
107
+ placeSearch(query) {
108
+ const fun = () => {
109
+ this.searchLoading = true
110
+ this.sugguestionService
111
+ .getSuggestions({
112
+ keyword: query
113
+ })
114
+ .then((res) => {
115
+ if (res.data) {
116
+ this.placeData = res.data
117
+ }
118
+ })
119
+ .finally(() => {
120
+ this.searchLoading = false
121
+ })
122
+ }
123
+ throttle(fun, 1000)
124
+ },
125
+ mapTX() {
126
+ let _this = this
127
+ console.log('--------this.tMap--------', this.tMap)
128
+ if (this.tMap) {
129
+ return Promise.resolve()
130
+ }
131
+ // 'OCIBZ-URFLX-D2L4R-7CMMA-WIZ2Q-VBFWJ'
132
+ return TMap().then((tMap) => {
133
+ return new Promise((resolve) => {
134
+ let pos = _this.getPosition()
135
+ if (!_this.txmap) {
136
+ this.tMap = tMap
137
+ _this.txmap = new tMap.Map(_this.$refs['atlas'], {
138
+ // 这里经纬度代理表进入地图显示的中心区域
139
+ center: new tMap.LatLng(pos.lat, pos.lng),
140
+ draggableCursor: 'crosshair',
141
+ draggingCursor: 'pointer',
142
+ zoom: 13
143
+ })
144
+ // 绑定单击事件添加参数
145
+ this.txmap.on('click', (evt) => {
146
+ console.log('--------evt--------', evt)
147
+ this.positionChange(evt.latLng, (evt.poi && evt.poi.name) || '')
148
+ })
149
+ }
150
+ if (!_this.txmapmarker) {
151
+ _this.txmapmarker = new tMap.MultiMarker({
152
+ styles: {
153
+ // 点标记样式
154
+ marker: new tMap.MarkerStyle({
155
+ width: 20, // 样式宽
156
+ height: 30, // 样式高
157
+ direction: 'top',
158
+ anchor: { x: 10, y: 30 } // 描点位置
159
+ })
160
+ },
161
+ geometries: [
162
+ // 点标记数据数组
163
+ {
164
+ styleId: 'marker',
165
+ // 标记位置(纬度,经度,高度)
166
+ position: new tMap.LatLng(pos.lat, pos.lng),
167
+ content: pos.title,
168
+ id: 'marker'
169
+ }
170
+ ],
171
+ map: _this.txmap
172
+ })
173
+ _this.txmapmarker.on('click', (evt) => {
174
+ this.positionChange(
175
+ evt.latLng,
176
+ (evt.geometry && evt.geometry.content) || ''
177
+ )
178
+ })
179
+ }
180
+
181
+ if (!this.sugguestionService) {
182
+ this.sugguestionService = new tMap.service.Suggestion({
183
+ // 新建一个关键字输入提示类
184
+ pageSize: 20,
185
+ region: this.region, // 限制城市范围
186
+ regionFix: true // 搜索无结果时是否固定在当前城市
187
+ })
188
+ }
189
+ resolve()
190
+ })
191
+ })
192
+ },
193
+ positionChange(latLng, title) {
194
+ throttle(
195
+ () => {
196
+ var geocoder = new this.tMap.service.Geocoder()
197
+ geocoder
198
+ .getAddress({ location: latLng }) // 将给定的坐标位置转换为地址
199
+ .then((resp) => {
200
+ let address = title || `${latLng}`
201
+ let location = {}
202
+ if (resp && resp.status == 0) {
203
+ address =
204
+ resp.result.formatted_addresses.standard_address +
205
+ '/' +
206
+ resp.result.formatted_addresses.recommend
207
+ title = title || resp.result.formatted_addresses.recommend
208
+ const cityCode = resp.result.ad_info.city_code.replace(
209
+ resp.result.ad_info.nation_code,
210
+ ''
211
+ )
212
+ location = {
213
+ province: resp.result.address_component.province,
214
+ city: resp.result.address_component.city,
215
+ district: resp.result.address_component.district,
216
+ county: resp.result.address_component.district,
217
+ street: resp.result.address_component.street,
218
+ street_number: resp.result.address_component.street_number,
219
+ countyCode: resp.result.ad_info.adcode,
220
+ provinceCode: cityCode.substr(0, 2) + '0000',
221
+ cityCode,
222
+ address: resp.result.formatted_addresses.standard_address,
223
+ labelName: title,
224
+ longitude: latLng.getLng(),
225
+ latitude: latLng.getLat()
226
+ }
227
+ }
228
+ const result = {
229
+ lat: latLng.getLat(),
230
+ lng: latLng.getLng(),
231
+ title: title,
232
+ address: address,
233
+ location
234
+ }
235
+ console.log('--------result----------', result)
236
+ // 显示搜索到的地址
237
+ this.$emit('change', result)
238
+ })
239
+ },
240
+ 500,
241
+ { trailing: false }
242
+ )
243
+ // poi
244
+ },
245
+ setCenter(lat, lng, title) {
246
+ this.txmap.setCenter(new this.tMap.LatLng(lat, lng))
247
+ this.txmapmarker.updateGeometries({
248
+ styleId: 'marker',
249
+ // 标记位置(纬度,经度,高度)
250
+ position: new this.tMap.LatLng(lat, lng),
251
+ content: title || '',
252
+ id: 'marker'
253
+ })
254
+ },
255
+ getPosition() {
256
+ return {
257
+ lat: this.posLat || 39.958559212563834,
258
+ lng: this.posLng || 116.28845974975957,
259
+ title: this.posTitle || ''
260
+ }
261
+ },
262
+ visibleChange(visible) {
263
+ if (!visible) {
264
+ this.$emit('on-hide')
265
+ }
266
+ }
267
+ },
268
+ mounted() {}
269
+ }
270
+ </script>
271
+
272
+ <style lang="less" scope>
273
+ .lau {
274
+ .ivu-modal-body {
275
+ padding: 0;
276
+ .ivu-select {
277
+ .ivu-select-dropdown {
278
+ z-index: 999999;
279
+ }
280
+ }
281
+ }
282
+ }
283
+ </style>
@@ -0,0 +1,20 @@
1
+
2
+ export function TMap() {
3
+ return new Promise(function (resolve, reject) {
4
+ window.initMap = function () {
5
+ resolve(window.TMap)
6
+ }
7
+ var script = document.createElement('script')
8
+ script.type = 'text/javascript'
9
+ script.src = 'https://map.qq.com/api/gljs?v=1.exp&callback=initMap&key=OCIBZ-URFLX-D2L4R-7CMMA-WIZ2Q-VBFWJ&libraries=service'
10
+ script.onerror = reject
11
+ document.head.appendChild(script)
12
+ })
13
+ }
14
+
15
+ export function placeSuggestion(keyword) {
16
+ // let url = `https://apis.map.qq.com/ws/place/v1/suggestion?region=&keyword=${keyword}&key=354BZ-CSO33-33F3K-3TJLC-LWVK3-7PBFO`
17
+ // return fetch(url).then(res => {
18
+ // return res.json()
19
+ // })
20
+ }
package/src/libs/util.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import { export_json_to_excel as exportJsonToExcel, exportJsonToExcelBlob } from './excel'
2
2
 
3
+ export const hasChild = (item) => {
4
+ return item.children && item.children.length !== 0
5
+ }
6
+
3
7
  export const exportTableExcelBlob = (tableData, tableColumn, fileName) => {
4
8
  return new Promise((resolve, reject) => {
5
9
  try {
package/src/main.js CHANGED
@@ -1,17 +1,10 @@
1
1
  import Vue from 'vue'
2
2
  import App from './App.vue'
3
3
  import iView from 'iview'
4
- import './index.less'
5
- import i18n from '@/locale'
6
- import ExtentionPlugin from './extentionPlugin'
7
- import importDirective from './directive'
8
- import PlusComp from './components/plus-comp'
9
-
10
4
  import Tool from './index'
11
5
 
12
6
 
13
7
 
14
-
15
8
  Vue.config.productionTip = false
16
9
 
17
10
  Tool.install(Vue)