shijiplus-web-plugin 0.1.13 → 0.1.15

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.13",
3
+ "version": "0.1.15",
4
4
  "files": [
5
5
  "src"
6
6
  ],
package/src/App.vue CHANGED
@@ -2,15 +2,18 @@
2
2
  <div id="app">
3
3
  <img id="img" alt="Vue logo" src="./assets/logo.png" />
4
4
  <plus-city-cascader></plus-city-cascader>
5
+ <TxMap></TxMap>
5
6
  </div>
6
7
  </template>
7
8
 
8
9
  <script>
9
10
  import PlusCityCascader from './components/plus-comp/plus-city-cascader/plus-city-cascader.vue'
10
11
 
12
+ import TxMap from './components/txmap/tx-map'
13
+
11
14
  export default {
12
15
  name: 'App',
13
- components: {PlusCityCascader},
16
+ components: { PlusCityCascader, TxMap },
14
17
  mounted() {
15
18
  console.log(
16
19
  'web-tool mounted!',
@@ -8,7 +8,8 @@ export default {
8
8
  }
9
9
  },
10
10
  methods: {
11
- invokeExportExcel(searchForm, apiFunction) {
11
+ invokeExportExcel(searchForm, apiFunction, options = {}) {
12
+ const { exportDesc } = this.$merge({}, options)
12
13
  const checkExportDataTotal = (searchForm) => {
13
14
  return apiFunction({
14
15
  ...searchForm,
@@ -34,6 +35,8 @@ export default {
34
35
  }).then((res) => {
35
36
  if (res && res.data) {
36
37
  exportData.push(...res.data)
38
+ } else {
39
+ throw Error('导出失败')
37
40
  }
38
41
  this.orderExportModalPercent = (exportData.length / (this.totalCount || 1) * 100).toFixed(2)
39
42
  if (processUpdate) {
@@ -56,23 +59,77 @@ export default {
56
59
  }, 0)
57
60
  return
58
61
  }
59
- const instance = this.$getComponentInstance(PlusCircleProgressModal)
60
- instance.$on('on-close', (e) => {
62
+ const processInstance = this.$getComponentInstance(PlusCircleProgressModal)
63
+ processInstance.$on('on-close', (e) => {
61
64
  setTimeout(() => {
62
- this.$removeVComp(instance)
65
+ this.$removeVComp(processInstance)
63
66
  }, 500)
64
67
  })
65
- instance.show()
68
+ processInstance.show({ exportDesc })
66
69
  return excelExportFun(1, this.orderExportPageSize, (process) => {
67
- instance.updatePercent(process)
70
+ processInstance.updatePercent(process)
68
71
  }).catch(() => {
69
72
  // 宏任务最后执行
70
73
  setTimeout(() => {
71
74
  this.$Message.error('导出失败', 3)
72
- this.$removeVComp(instance)
75
+ this.$removeVComp(processInstance)
73
76
  }, 0)
74
77
  })
75
78
  })
79
+ },
80
+ exportAllData(searchForm, options = {}) {
81
+ let exportData = []
82
+ let totalCount = 0
83
+ const { apiFunction, exportDesc } = this.$merge({}, options)
84
+ const excelExportFun = (processUpdate) => {
85
+ return apiFunction({
86
+ ...searchForm
87
+ }).then((res) => {
88
+ if (res && res.data) {
89
+ totalCount = res.data.length
90
+ exportData.push(...res.data)
91
+ } else {
92
+ throw Error('导出失败')
93
+ }
94
+ let orderExportModalPercent = (exportData.length / (totalCount || 1) * 100).toFixed(2)
95
+ if (processUpdate) {
96
+ processUpdate(orderExportModalPercent)
97
+ }
98
+ if (exportData.length < totalCount) {
99
+ return excelExportFun(processUpdate)
100
+ }
101
+ return exportData
102
+ }).catch((error) => {
103
+ console.log('--------error---------', error)
104
+ throw Error('导出失败')
105
+ })
106
+ }
107
+ return new Promise((resolve, reject) => {
108
+ excelExportFun((process) => {
109
+ console.log('-------excelExport-----process--------', process)
110
+ }).then(data => {
111
+ resolve(data)
112
+ }).catch(() => {
113
+ // 宏任务最后执行
114
+ setTimeout(() => {
115
+ this.$Message.error('导出失败', 3)
116
+ }, 0)
117
+ reject(new Error('导出失败'))
118
+ })
119
+ })
120
+ },
121
+ createProcessInstance() {
122
+ const processInstance = this.$getComponentInstance(PlusCircleProgressModal)
123
+ processInstance.$on('on-close', (e) => {
124
+ setTimeout(() => {
125
+ this.$removeVComp(processInstance)
126
+ }, 500)
127
+ })
128
+ processInstance.show()
129
+ return processInstance
130
+ },
131
+ destroyProcessInstance(processInstance) {
132
+ processInstance.handlerClose()
76
133
  }
77
134
  }
78
135
  }
@@ -24,7 +24,10 @@
24
24
  </div>
25
25
  </div>
26
26
  </div>
27
- <slot name="table">
27
+ <div ref="headerRef">
28
+ <slot name="header"></slot>
29
+ </div>
30
+ <slot name="table" :pageData="pageData" :height="height">
28
31
  <Table
29
32
  :style="tableStyle"
30
33
  :columns="showColumns"
@@ -209,6 +212,9 @@ export default {
209
212
  if (this.$refs.searchAreaRef) {
210
213
  tHeight -= this.$refs.searchAreaRef.clientHeight
211
214
  }
215
+ if (this.$refs.headerRef) {
216
+ tHeight -= this.$refs.headerRef.clientHeight
217
+ }
212
218
  if (this.$refs.footerRef) {
213
219
  tHeight -= this.$refs.footerRef.clientHeight
214
220
  }
@@ -0,0 +1,281 @@
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
+ this.setCenter(this.lat, this.lng, this.posTitle)
70
+ })
71
+ }
72
+ console.log('---------txmap-show----------', val)
73
+ },
74
+ lat(val) {
75
+ this.posLat = val
76
+ },
77
+ lng(val) {
78
+ this.posLng = val
79
+ }
80
+ },
81
+ data() {
82
+ return {
83
+ posLat: null,
84
+ posLng: null,
85
+ txmap: null,
86
+ txmapmarker: null,
87
+ searchService: null,
88
+ searchLoading: false,
89
+ placeData: [],
90
+ sugguestionService: null
91
+ }
92
+ },
93
+
94
+ methods: {
95
+ locOpenChange(e) {
96
+ if (!e) {
97
+ this.$refs.selectRef.isFocused = false
98
+ }
99
+ },
100
+ placeChange(e) {
101
+ let option = this.placeData[e]
102
+ if (option) {
103
+ this.setCenter(option.location.lat, option.location.lng, option.title)
104
+ }
105
+ },
106
+ placeSearch(query) {
107
+ const fun = () => {
108
+ this.searchLoading = true
109
+ this.sugguestionService
110
+ .getSuggestions({
111
+ keyword: query
112
+ })
113
+ .then((res) => {
114
+ if (res.data) {
115
+ this.placeData = res.data
116
+ }
117
+ })
118
+ .finally(() => {
119
+ this.searchLoading = false
120
+ })
121
+ }
122
+ throttle(fun, 1000)
123
+ },
124
+ mapTX() {
125
+ let _this = this
126
+ if (this.tMap) {
127
+ return Promise.resolve()
128
+ }
129
+ // 'OCIBZ-URFLX-D2L4R-7CMMA-WIZ2Q-VBFWJ'
130
+ return TMap().then((tMap) => {
131
+ return new Promise((resolve) => {
132
+ let pos = _this.getPosition()
133
+ if (!_this.txmap) {
134
+ this.tMap = tMap
135
+ _this.txmap = new tMap.Map(_this.$refs['atlas'], {
136
+ // 这里经纬度代理表进入地图显示的中心区域
137
+ center: new tMap.LatLng(pos.lat, pos.lng),
138
+ draggableCursor: 'crosshair',
139
+ draggingCursor: 'pointer',
140
+ zoom: 13
141
+ })
142
+ // 绑定单击事件添加参数
143
+ this.txmap.on('click', (evt) => {
144
+ console.log('--------evt--------', evt)
145
+ this.positionChange(evt.latLng, (evt.poi && evt.poi.name) || '')
146
+ })
147
+ }
148
+ if (!_this.txmapmarker) {
149
+ _this.txmapmarker = new tMap.MultiMarker({
150
+ styles: {
151
+ // 点标记样式
152
+ marker: new tMap.MarkerStyle({
153
+ width: 20, // 样式宽
154
+ height: 30, // 样式高
155
+ direction: 'top',
156
+ anchor: { x: 10, y: 30 } // 描点位置
157
+ })
158
+ },
159
+ geometries: [
160
+ // 点标记数据数组
161
+ {
162
+ styleId: 'marker',
163
+ // 标记位置(纬度,经度,高度)
164
+ position: new tMap.LatLng(pos.lat, pos.lng),
165
+ content: pos.title,
166
+ id: 'marker'
167
+ }
168
+ ],
169
+ map: _this.txmap
170
+ })
171
+ _this.txmapmarker.on('click', (evt) => {
172
+ this.positionChange(
173
+ evt.latLng,
174
+ (evt.geometry && evt.geometry.content) || ''
175
+ )
176
+ })
177
+ }
178
+
179
+ if (!this.sugguestionService) {
180
+ this.sugguestionService = new tMap.service.Suggestion({
181
+ // 新建一个关键字输入提示类
182
+ pageSize: 20,
183
+ region: this.region, // 限制城市范围
184
+ regionFix: true // 搜索无结果时是否固定在当前城市
185
+ })
186
+ }
187
+ resolve()
188
+ })
189
+ })
190
+ },
191
+ positionChange(latLng, title) {
192
+ throttle(
193
+ () => {
194
+ var geocoder = new this.tMap.service.Geocoder()
195
+ geocoder
196
+ .getAddress({ location: latLng }) // 将给定的坐标位置转换为地址
197
+ .then((resp) => {
198
+ let address = title || `${latLng}`
199
+ let location = {}
200
+ if (resp && resp.status == 0) {
201
+ address =
202
+ resp.result.formatted_addresses.standard_address +
203
+ '/' +
204
+ resp.result.formatted_addresses.recommend
205
+ title = title || resp.result.formatted_addresses.recommend
206
+ const cityCode = resp.result.ad_info.city_code.replace(
207
+ resp.result.ad_info.nation_code,
208
+ ''
209
+ )
210
+ location = {
211
+ province: resp.result.address_component.province,
212
+ city: resp.result.address_component.city,
213
+ district: resp.result.address_component.district,
214
+ county: resp.result.address_component.district,
215
+ street: resp.result.address_component.street,
216
+ street_number: resp.result.address_component.street_number,
217
+ countyCode: resp.result.ad_info.adcode,
218
+ provinceCode: cityCode.substr(0, 2) + '0000',
219
+ cityCode,
220
+ address: resp.result.formatted_addresses.standard_address,
221
+ labelName: title,
222
+ longitude: latLng.getLng(),
223
+ latitude: latLng.getLat()
224
+ }
225
+ }
226
+ const result = {
227
+ lat: latLng.getLat(),
228
+ lng: latLng.getLng(),
229
+ title: title,
230
+ address: address,
231
+ location
232
+ }
233
+ console.log('--------result----------', result)
234
+ // 显示搜索到的地址
235
+ this.$emit('change', result)
236
+ })
237
+ },
238
+ 500,
239
+ { trailing: false }
240
+ )
241
+ // poi
242
+ },
243
+ setCenter(lat, lng, title) {
244
+ this.txmap.setCenter(new this.tMap.LatLng(lat, lng))
245
+ this.txmapmarker.updateGeometries({
246
+ styleId: 'marker',
247
+ // 标记位置(纬度,经度,高度)
248
+ position: new this.tMap.LatLng(lat, lng),
249
+ content: title || '',
250
+ id: 'marker'
251
+ })
252
+ },
253
+ getPosition() {
254
+ return {
255
+ lat: this.posLat || 39.958559212563834,
256
+ lng: this.posLng || 116.28845974975957,
257
+ title: this.posTitle || ''
258
+ }
259
+ },
260
+ visibleChange(visible) {
261
+ if (!visible) {
262
+ this.$emit('on-hide')
263
+ }
264
+ }
265
+ },
266
+ mounted() {}
267
+ }
268
+ </script>
269
+
270
+ <style lang="less" scope>
271
+ .lau {
272
+ .ivu-modal-body {
273
+ padding: 0;
274
+ .ivu-select {
275
+ .ivu-select-dropdown {
276
+ z-index: 999999;
277
+ }
278
+ }
279
+ }
280
+ }
281
+ </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 {