af-mobile-client-vue3 1.1.20 → 1.1.22

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,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.1.20",
4
+ "version": "1.1.22",
5
5
  "description": "Vue + Vite component lib",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -1,163 +1,163 @@
1
- <script setup lang="ts">
2
- import { deleteFile } from '@af-mobile-client-vue3/services/api/common'
3
- import { mobileUtil } from '@af-mobile-client-vue3/utils/mobileUtil'
4
- import {
5
- Button as vanButton,
6
- Uploader as vanUploader,
7
- } from 'vant'
8
- import { ref, watch } from 'vue'
9
-
10
- const props = defineProps({
11
- imageList: Array<any>,
12
- outerIndex: { default: undefined },
13
- authority: { default: 'user' },
14
- uploadMode: { default: 'server' },
15
- attr: { type: Object as () => { addOrEdit?: string }, default: () => ({}) },
16
- })
17
- const emit = defineEmits(['updateFileList'])
18
-
19
- const imageList = ref<Array<any>>(props.imageList ?? [])
20
-
21
- // 同步 props.imageList 到内部 imageList,保证每次变化都响应
22
- watch(() => props.imageList, (newVal) => {
23
- imageList.value = Array.isArray(newVal) ? [...newVal] : []
24
- }, { immediate: true })
25
-
26
- // 触发拍照
27
- function triggerCamera() {
28
- console.log('>>>> uploader 上传111')
29
- mobileUtil.execute({
30
- funcName: 'takePicture',
31
- param: {},
32
- callbackFunc: (result: any) => {
33
- console.log('>>>> 拍照 后 上传', result)
34
- if (result.status === 'success') {
35
- handlePhotoUpload(result.data)
36
- }
37
- },
38
- })
39
- }
40
-
41
- // 处理拍照后的上传
42
- function handlePhotoUpload(photoData: any) {
43
- const formData = new FormData()
44
- formData.append('resUploadMode', props.uploadMode)
45
- formData.append('pathKey', 'Default')
46
- formData.append('formType', 'image')
47
- formData.append('useType', 'Default')
48
- formData.append('resUploadStock', '1')
49
- formData.append('filename', photoData.name)
50
- formData.append('filesize', (photoData.size / 1024 / 1024).toFixed(4))
51
- formData.append('f_operator', 'server')
52
- formData.append('imgPath', photoData.filePath)
53
- formData.append('urlPath', '/api/af-revenue/resource/upload')
54
-
55
- // 添加临时预览
56
- const tempFile = {
57
- uid: Date.now() + Math.random().toString(36).substr(2, 5),
58
- name: photoData.name,
59
- status: 'uploading',
60
- message: '上传中...',
61
- url: `data:image/png;base64,${photoData.content}`,
62
- }
63
-
64
- if (!imageList.value) {
65
- imageList.value = [tempFile]
66
- }
67
- else {
68
- imageList.value.push(tempFile)
69
- }
70
-
71
- const param = {
72
- resUploadMode: props.uploadMode,
73
- pathKey: 'Default',
74
- formType: 'image',
75
- useType: 'Default',
76
- resUploadStock: '1',
77
- filename: photoData.name,
78
- filesize: photoData.size,
79
- f_operator: 'server',
80
- imgPath: photoData.filePath,
81
- urlPath: '/api/af-revenue/resource/upload',
82
- }
83
- console.log('>>>> 上传 param: ', JSON.stringify(param))
84
- // 上传到服务器
85
- mobileUtil.execute({
86
- funcName: 'uploadResource',
87
- param,
88
- callbackFunc: (result: any) => {
89
- console.log('>>>> 上传结果: ', result)
90
- if (result.status === 'success') {
91
- const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
92
- if (index !== -1) {
93
- imageList.value[index].uid = result.data.id
94
- imageList.value[index].id = result.data.id
95
- delete imageList.value[index].message
96
- imageList.value[index].status = 'done'
97
- imageList.value[index].url = result.data.f_downloadpath
98
- }
99
- }
100
- else {
101
- const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
102
- if (index !== -1) {
103
- imageList.value[index].status = 'failed'
104
- imageList.value[index].message = '上传失败'
105
- }
106
- }
107
-
108
- if (props.outerIndex !== undefined)
109
- emit('updateFileList', imageList.value.filter(item => item.status === 'done'), props.outerIndex)
110
- else
111
- emit('updateFileList', imageList.value.filter(item => item.status === 'done'))
112
- },
113
- })
114
- }
115
-
116
- // 删除图片
117
- function deleteFileFunction(file: any) {
118
- if (file.id) {
119
- deleteFile({ ids: [file.id], f_state: '删除' }).then((res: any) => {
120
- if (res.msg !== undefined) {
121
- const targetIndex = imageList.value.findIndex(item => item.id === file.id)
122
- if (targetIndex !== -1) {
123
- imageList.value.splice(targetIndex, 1)
124
- if (props.outerIndex !== undefined)
125
- emit('updateFileList', imageList.value.filter(item => item.status === 'done'), props.outerIndex)
126
- else
127
- emit('updateFileList', imageList.value.filter(item => item.status === 'done'))
128
- }
129
- }
130
- })
131
- }
132
- }
133
- </script>
134
-
135
- <template>
136
- <div class="uploader-container">
137
- <van-button
138
- v-if="props.attr?.addOrEdit !== 'readonly'"
139
- icon="photograph"
140
- type="primary"
141
- @click="triggerCamera"
142
- >
143
- 拍照
144
- </van-button>
145
-
146
- <van-uploader
147
- v-model="imageList"
148
- :show-upload="false"
149
- :deletable="props.attr?.addOrEdit !== 'readonly' && props.authority === 'admin'"
150
- :multiple="props.authority === 'admin'"
151
- :preview-image="true"
152
- :before-delete="props.attr?.addOrEdit !== 'readonly' && props.authority === 'admin' ? deleteFileFunction : undefined"
153
- />
154
- </div>
155
- </template>
156
-
157
- <style scoped lang="less">
158
- .uploader-container {
159
- display: flex;
160
- flex-direction: column;
161
- gap: 16px;
162
- }
163
- </style>
1
+ <script setup lang="ts">
2
+ import { deleteFile } from '@af-mobile-client-vue3/services/api/common'
3
+ import { mobileUtil } from '@af-mobile-client-vue3/utils/mobileUtil'
4
+ import {
5
+ Button as vanButton,
6
+ Uploader as vanUploader,
7
+ } from 'vant'
8
+ import { ref, watch } from 'vue'
9
+
10
+ const props = defineProps({
11
+ imageList: Array<any>,
12
+ outerIndex: { default: undefined },
13
+ authority: { default: 'user' },
14
+ uploadMode: { default: 'server' },
15
+ attr: { type: Object as () => { addOrEdit?: string }, default: () => ({}) },
16
+ })
17
+ const emit = defineEmits(['updateFileList'])
18
+
19
+ const imageList = ref<Array<any>>(props.imageList ?? [])
20
+
21
+ // 同步 props.imageList 到内部 imageList,保证每次变化都响应
22
+ watch(() => props.imageList, (newVal) => {
23
+ imageList.value = Array.isArray(newVal) ? [...newVal] : []
24
+ }, { immediate: true })
25
+
26
+ // 触发拍照
27
+ function triggerCamera() {
28
+ console.log('>>>> uploader 上传111')
29
+ mobileUtil.execute({
30
+ funcName: 'takePicture',
31
+ param: {},
32
+ callbackFunc: (result: any) => {
33
+ console.log('>>>> 拍照 后 上传', result)
34
+ if (result.status === 'success') {
35
+ handlePhotoUpload(result.data)
36
+ }
37
+ },
38
+ })
39
+ }
40
+
41
+ // 处理拍照后的上传
42
+ function handlePhotoUpload(photoData: any) {
43
+ const formData = new FormData()
44
+ formData.append('resUploadMode', props.uploadMode)
45
+ formData.append('pathKey', 'Default')
46
+ formData.append('formType', 'image')
47
+ formData.append('useType', 'Default')
48
+ formData.append('resUploadStock', '1')
49
+ formData.append('filename', photoData.name)
50
+ formData.append('filesize', (photoData.size / 1024 / 1024).toFixed(4))
51
+ formData.append('f_operator', 'server')
52
+ formData.append('imgPath', photoData.filePath)
53
+ formData.append('urlPath', '/api/af-revenue/resource/upload')
54
+
55
+ // 添加临时预览
56
+ const tempFile = {
57
+ uid: Date.now() + Math.random().toString(36).substr(2, 5),
58
+ name: photoData.name,
59
+ status: 'uploading',
60
+ message: '上传中...',
61
+ url: `data:image/png;base64,${photoData.content}`,
62
+ }
63
+
64
+ if (!imageList.value) {
65
+ imageList.value = [tempFile]
66
+ }
67
+ else {
68
+ imageList.value.push(tempFile)
69
+ }
70
+
71
+ const param = {
72
+ resUploadMode: props.uploadMode,
73
+ pathKey: 'Default',
74
+ formType: 'image',
75
+ useType: 'Default',
76
+ resUploadStock: '1',
77
+ filename: photoData.name,
78
+ filesize: photoData.size,
79
+ f_operator: 'server',
80
+ imgPath: photoData.filePath,
81
+ urlPath: '/api/af-revenue/resource/upload',
82
+ }
83
+ console.log('>>>> 上传 param: ', JSON.stringify(param))
84
+ // 上传到服务器
85
+ mobileUtil.execute({
86
+ funcName: 'uploadResource',
87
+ param,
88
+ callbackFunc: (result: any) => {
89
+ console.log('>>>> 上传结果: ', result)
90
+ if (result.status === 'success') {
91
+ const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
92
+ if (index !== -1) {
93
+ imageList.value[index].uid = result.data.id
94
+ imageList.value[index].id = result.data.id
95
+ delete imageList.value[index].message
96
+ imageList.value[index].status = 'done'
97
+ imageList.value[index].url = result.data.f_downloadpath
98
+ }
99
+ }
100
+ else {
101
+ const index = imageList.value.findIndex(item => item.uid === tempFile.uid)
102
+ if (index !== -1) {
103
+ imageList.value[index].status = 'failed'
104
+ imageList.value[index].message = '上传失败'
105
+ }
106
+ }
107
+
108
+ if (props.outerIndex !== undefined)
109
+ emit('updateFileList', imageList.value.filter(item => item.status === 'done'), props.outerIndex)
110
+ else
111
+ emit('updateFileList', imageList.value.filter(item => item.status === 'done'))
112
+ },
113
+ })
114
+ }
115
+
116
+ // 删除图片
117
+ function deleteFileFunction(file: any) {
118
+ if (file.id) {
119
+ deleteFile({ ids: [file.id], f_state: '删除' }).then((res: any) => {
120
+ if (res.msg !== undefined) {
121
+ const targetIndex = imageList.value.findIndex(item => item.id === file.id)
122
+ if (targetIndex !== -1) {
123
+ imageList.value.splice(targetIndex, 1)
124
+ if (props.outerIndex !== undefined)
125
+ emit('updateFileList', imageList.value.filter(item => item.status === 'done'), props.outerIndex)
126
+ else
127
+ emit('updateFileList', imageList.value.filter(item => item.status === 'done'))
128
+ }
129
+ }
130
+ })
131
+ }
132
+ }
133
+ </script>
134
+
135
+ <template>
136
+ <div class="uploader-container">
137
+ <van-button
138
+ v-if="props.attr?.addOrEdit !== 'readonly'"
139
+ icon="photograph"
140
+ type="primary"
141
+ @click="triggerCamera"
142
+ >
143
+ 拍照
144
+ </van-button>
145
+
146
+ <van-uploader
147
+ v-model="imageList"
148
+ :show-upload="false"
149
+ :deletable="props.attr?.addOrEdit !== 'readonly' && props.authority === 'admin'"
150
+ :multiple="props.authority === 'admin'"
151
+ :preview-image="true"
152
+ :before-delete="props.attr?.addOrEdit !== 'readonly' && props.authority === 'admin' ? deleteFileFunction : undefined"
153
+ />
154
+ </div>
155
+ </template>
156
+
157
+ <style scoped lang="less">
158
+ .uploader-container {
159
+ display: flex;
160
+ flex-direction: column;
161
+ gap: 16px;
162
+ }
163
+ </style>
@@ -509,7 +509,7 @@ function getData(value, callback) {
509
509
  if (getDataParams && getDataParams[attr.model])
510
510
  Object.assign(value, getDataParams[attr.model])
511
511
  Object.assign(value, userInfo.value)
512
- runLogic(logic, value.value, serviceName).then((res) => {
512
+ runLogic(logic, value, serviceName).then((res) => {
513
513
  callback(res)
514
514
  })
515
515
  }
@@ -1,154 +1,154 @@
1
- // 导入proj控件
2
- import * as proj from 'ol/proj'
3
-
4
- function forEachPoint(func) {
5
- return function (input, opt_output, opt_dimension) {
6
- const len = input.length
7
-
8
- const dimension = opt_dimension || 2
9
- let output
10
-
11
- if (opt_output) {
12
- output = opt_output
13
- }
14
- else {
15
- if (dimension !== 2) {
16
- output = input.slice()
17
- }
18
- else {
19
- output = [len]
20
- }
21
- }
22
- for (let offset = 0; offset < len; offset += dimension) {
23
- func(input, output, offset)
24
- }
25
- return output
26
- }
27
- }
28
-
29
- const gcj02 = {}
30
- const PI = Math.PI
31
- const AXIS = 6378245.0
32
- // eslint-disable-next-line no-loss-of-precision
33
- const OFFSET = 0.00669342162296594323 // (a^2 - b^2) / a^2
34
-
35
- function delta(wgLon, wgLat) {
36
- let dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
37
- let dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
38
- const radLat = (wgLat / 180.0) * PI
39
- let magic = Math.sin(radLat)
40
- magic = 1 - OFFSET * magic * magic
41
- const sqrtMagic = Math.sqrt(magic)
42
- dLat = (dLat * 180.0) / (((AXIS * (1 - OFFSET)) / (magic * sqrtMagic)) * PI)
43
- dLon = (dLon * 180.0) / ((AXIS / sqrtMagic) * Math.cos(radLat) * PI)
44
- return [dLon, dLat]
45
- }
46
-
47
- function outOfChina(lon, lat) {
48
- if (lon < 72.004 || lon > 137.8347) {
49
- return true
50
- }
51
- return lat < 0.8293 || lat > 55.8271
52
- }
53
-
54
- function transformLat(x, y) {
55
- let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
56
- ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
57
- ret += ((20.0 * Math.sin(y * PI) + 40.0 * Math.sin((y / 3.0) * PI)) * 2.0) / 3.0
58
- ret += ((160.0 * Math.sin((y / 12.0) * PI) + 320 * Math.sin((y * PI) / 30.0)) * 2.0) / 3.0
59
- return ret
60
- }
61
-
62
- function transformLon(x, y) {
63
- let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
64
- ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
65
- ret += ((20.0 * Math.sin(x * PI) + 40.0 * Math.sin((x / 3.0) * PI)) * 2.0) / 3.0
66
- ret += ((150.0 * Math.sin((x / 12.0) * PI) + 300.0 * Math.sin((x / 30.0) * PI)) * 2.0) / 3.0
67
- return ret
68
- }
69
-
70
- gcj02.toWGS84 = forEachPoint((input, output, offset) => {
71
- let lng = input[offset]
72
- let lat = input[offset + 1]
73
- if (!outOfChina(lng, lat)) {
74
- const deltaD = delta(lng, lat)
75
- lng = lng - deltaD[0] // 改回减法
76
- lat = lat - deltaD[1] // 改回减法
77
- }
78
- output[offset] = lng
79
- output[offset + 1] = lat
80
- })
81
-
82
- gcj02.fromWGS84 = forEachPoint((input, output, offset) => {
83
- let lng = input[offset]
84
- let lat = input[offset + 1]
85
- if (!outOfChina(lng, lat)) {
86
- const deltaD = delta(lng, lat)
87
- lng = lng + deltaD[0] // 改回加法
88
- lat = lat + deltaD[1] // 改回加法
89
- }
90
- output[offset] = lng
91
- output[offset + 1] = lat
92
- })
93
-
94
- const sphericalMercator = {}
95
- const RADIUS = 6378137
96
- const MAX_LATITUDE = 85.0511287798
97
- const RAD_PER_DEG = Math.PI / 180
98
-
99
- sphericalMercator.forward = forEachPoint((input, output, offset) => {
100
- const lat = Math.max(Math.min(MAX_LATITUDE, input[offset + 1]), -MAX_LATITUDE)
101
- const sin = Math.sin(lat * RAD_PER_DEG)
102
- output[offset] = RADIUS * input[offset] * RAD_PER_DEG
103
- output[offset + 1] = (RADIUS * Math.log((1 + sin) / (1 - sin))) / 2
104
- })
105
-
106
- sphericalMercator.inverse = forEachPoint((input, output, offset) => {
107
- output[offset] = input[offset] / RADIUS / RAD_PER_DEG
108
- output[offset + 1] = (2 * Math.atan(Math.exp(input[offset + 1] / RADIUS)) - Math.PI / 2) / RAD_PER_DEG
109
- })
110
-
111
- const projzh = {}
112
-
113
- projzh.ll2gmerc = function (input, opt_output, opt_dimension) {
114
- const output = gcj02.toWGS84(input, opt_output, opt_dimension) // 改用 toWGS84
115
- return projzh.ll2smerc(output, output, opt_dimension)
116
- }
117
-
118
- projzh.gmerc2ll = function (input, opt_output, opt_dimension) {
119
- const output = projzh.smerc2ll(input, input, opt_dimension)
120
- return gcj02.fromWGS84(output, opt_output, opt_dimension) // 改用 fromWGS84
121
- }
122
-
123
- // smerc2gmerc 需要修改
124
-
125
- projzh.smerc2gmerc = function (input, opt_output, opt_dimension) {
126
- let output = projzh.smerc2ll(input, input, opt_dimension)
127
- output = gcj02.toWGS84(output, output, opt_dimension) // 这里应该用 toWGS84
128
- return projzh.ll2smerc(output, output, opt_dimension)
129
- }
130
-
131
- // gmerc2smerc 需要修改
132
-
133
- projzh.gmerc2smerc = function (input, opt_output, opt_dimension) {
134
- let output = projzh.smerc2ll(input, input, opt_dimension)
135
- output = gcj02.fromWGS84(output, output, opt_dimension) // 这里应该用 fromWGS84
136
- return projzh.ll2smerc(output, output, opt_dimension)
137
- }
138
-
139
- projzh.ll2smerc = sphericalMercator.forward
140
- projzh.smerc2ll = sphericalMercator.inverse
141
-
142
- // 定义WGS84转GCJ02的投影
143
- const extent = [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]
144
- export const wgs84ToGcj02Projection = new proj.Projection({
145
- code: 'WGS84-TO-GCJ02',
146
- extent,
147
- units: 'm',
148
- })
149
-
150
- // 添加投影和转换方法
151
- proj.addProjection(wgs84ToGcj02Projection)
152
- // 注意这里转换方法的顺序与原来相反
153
- proj.addCoordinateTransforms('EPSG:4326', wgs84ToGcj02Projection, projzh.ll2gmerc, projzh.gmerc2ll)
154
- proj.addCoordinateTransforms('EPSG:3857', wgs84ToGcj02Projection, projzh.smerc2gmerc, projzh.gmerc2smerc)
1
+ // 导入proj控件
2
+ import * as proj from 'ol/proj'
3
+
4
+ function forEachPoint(func) {
5
+ return function (input, opt_output, opt_dimension) {
6
+ const len = input.length
7
+
8
+ const dimension = opt_dimension || 2
9
+ let output
10
+
11
+ if (opt_output) {
12
+ output = opt_output
13
+ }
14
+ else {
15
+ if (dimension !== 2) {
16
+ output = input.slice()
17
+ }
18
+ else {
19
+ output = [len]
20
+ }
21
+ }
22
+ for (let offset = 0; offset < len; offset += dimension) {
23
+ func(input, output, offset)
24
+ }
25
+ return output
26
+ }
27
+ }
28
+
29
+ const gcj02 = {}
30
+ const PI = Math.PI
31
+ const AXIS = 6378245.0
32
+ // eslint-disable-next-line no-loss-of-precision
33
+ const OFFSET = 0.00669342162296594323 // (a^2 - b^2) / a^2
34
+
35
+ function delta(wgLon, wgLat) {
36
+ let dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
37
+ let dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
38
+ const radLat = (wgLat / 180.0) * PI
39
+ let magic = Math.sin(radLat)
40
+ magic = 1 - OFFSET * magic * magic
41
+ const sqrtMagic = Math.sqrt(magic)
42
+ dLat = (dLat * 180.0) / (((AXIS * (1 - OFFSET)) / (magic * sqrtMagic)) * PI)
43
+ dLon = (dLon * 180.0) / ((AXIS / sqrtMagic) * Math.cos(radLat) * PI)
44
+ return [dLon, dLat]
45
+ }
46
+
47
+ function outOfChina(lon, lat) {
48
+ if (lon < 72.004 || lon > 137.8347) {
49
+ return true
50
+ }
51
+ return lat < 0.8293 || lat > 55.8271
52
+ }
53
+
54
+ function transformLat(x, y) {
55
+ let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
56
+ ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
57
+ ret += ((20.0 * Math.sin(y * PI) + 40.0 * Math.sin((y / 3.0) * PI)) * 2.0) / 3.0
58
+ ret += ((160.0 * Math.sin((y / 12.0) * PI) + 320 * Math.sin((y * PI) / 30.0)) * 2.0) / 3.0
59
+ return ret
60
+ }
61
+
62
+ function transformLon(x, y) {
63
+ let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
64
+ ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
65
+ ret += ((20.0 * Math.sin(x * PI) + 40.0 * Math.sin((x / 3.0) * PI)) * 2.0) / 3.0
66
+ ret += ((150.0 * Math.sin((x / 12.0) * PI) + 300.0 * Math.sin((x / 30.0) * PI)) * 2.0) / 3.0
67
+ return ret
68
+ }
69
+
70
+ gcj02.toWGS84 = forEachPoint((input, output, offset) => {
71
+ let lng = input[offset]
72
+ let lat = input[offset + 1]
73
+ if (!outOfChina(lng, lat)) {
74
+ const deltaD = delta(lng, lat)
75
+ lng = lng - deltaD[0] // 改回减法
76
+ lat = lat - deltaD[1] // 改回减法
77
+ }
78
+ output[offset] = lng
79
+ output[offset + 1] = lat
80
+ })
81
+
82
+ gcj02.fromWGS84 = forEachPoint((input, output, offset) => {
83
+ let lng = input[offset]
84
+ let lat = input[offset + 1]
85
+ if (!outOfChina(lng, lat)) {
86
+ const deltaD = delta(lng, lat)
87
+ lng = lng + deltaD[0] // 改回加法
88
+ lat = lat + deltaD[1] // 改回加法
89
+ }
90
+ output[offset] = lng
91
+ output[offset + 1] = lat
92
+ })
93
+
94
+ const sphericalMercator = {}
95
+ const RADIUS = 6378137
96
+ const MAX_LATITUDE = 85.0511287798
97
+ const RAD_PER_DEG = Math.PI / 180
98
+
99
+ sphericalMercator.forward = forEachPoint((input, output, offset) => {
100
+ const lat = Math.max(Math.min(MAX_LATITUDE, input[offset + 1]), -MAX_LATITUDE)
101
+ const sin = Math.sin(lat * RAD_PER_DEG)
102
+ output[offset] = RADIUS * input[offset] * RAD_PER_DEG
103
+ output[offset + 1] = (RADIUS * Math.log((1 + sin) / (1 - sin))) / 2
104
+ })
105
+
106
+ sphericalMercator.inverse = forEachPoint((input, output, offset) => {
107
+ output[offset] = input[offset] / RADIUS / RAD_PER_DEG
108
+ output[offset + 1] = (2 * Math.atan(Math.exp(input[offset + 1] / RADIUS)) - Math.PI / 2) / RAD_PER_DEG
109
+ })
110
+
111
+ const projzh = {}
112
+
113
+ projzh.ll2gmerc = function (input, opt_output, opt_dimension) {
114
+ const output = gcj02.toWGS84(input, opt_output, opt_dimension) // 改用 toWGS84
115
+ return projzh.ll2smerc(output, output, opt_dimension)
116
+ }
117
+
118
+ projzh.gmerc2ll = function (input, opt_output, opt_dimension) {
119
+ const output = projzh.smerc2ll(input, input, opt_dimension)
120
+ return gcj02.fromWGS84(output, opt_output, opt_dimension) // 改用 fromWGS84
121
+ }
122
+
123
+ // smerc2gmerc 需要修改
124
+
125
+ projzh.smerc2gmerc = function (input, opt_output, opt_dimension) {
126
+ let output = projzh.smerc2ll(input, input, opt_dimension)
127
+ output = gcj02.toWGS84(output, output, opt_dimension) // 这里应该用 toWGS84
128
+ return projzh.ll2smerc(output, output, opt_dimension)
129
+ }
130
+
131
+ // gmerc2smerc 需要修改
132
+
133
+ projzh.gmerc2smerc = function (input, opt_output, opt_dimension) {
134
+ let output = projzh.smerc2ll(input, input, opt_dimension)
135
+ output = gcj02.fromWGS84(output, output, opt_dimension) // 这里应该用 fromWGS84
136
+ return projzh.ll2smerc(output, output, opt_dimension)
137
+ }
138
+
139
+ projzh.ll2smerc = sphericalMercator.forward
140
+ projzh.smerc2ll = sphericalMercator.inverse
141
+
142
+ // 定义WGS84转GCJ02的投影
143
+ const extent = [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]
144
+ export const wgs84ToGcj02Projection = new proj.Projection({
145
+ code: 'WGS84-TO-GCJ02',
146
+ extent,
147
+ units: 'm',
148
+ })
149
+
150
+ // 添加投影和转换方法
151
+ proj.addProjection(wgs84ToGcj02Projection)
152
+ // 注意这里转换方法的顺序与原来相反
153
+ proj.addCoordinateTransforms('EPSG:4326', wgs84ToGcj02Projection, projzh.ll2gmerc, projzh.gmerc2ll)
154
+ proj.addCoordinateTransforms('EPSG:3857', wgs84ToGcj02Projection, projzh.smerc2gmerc, projzh.gmerc2smerc)
@@ -61,7 +61,13 @@ class Http {
61
61
  // 判断请求是否成功
62
62
  const isSuccess = code === ResultEnum.SUCCESS
63
63
  if (isSuccess) {
64
- return data
64
+ // 兼容 V3 请求没有data的情况
65
+ if (data) {
66
+ return data
67
+ }
68
+ else {
69
+ return response.data
70
+ }
65
71
  }
66
72
  else {
67
73
  if (code === 401) {
@@ -9,6 +9,13 @@ import { useRoute } from 'vue-router'
9
9
  const configName = ref('form_check_test')
10
10
  const serviceName = ref('af-system')
11
11
 
12
+ // const configName = ref("计划下发Form")
13
+ // const serviceName = ref("af-linepatrol")
14
+
15
+ // 表单组
16
+ // const configName = ref('lngChargeAuditMobileFormGroup')
17
+ // const serviceName = ref('af-gaslink')
18
+
12
19
  const formData = ref({})
13
20
  const formGroup = ref(null)
14
21
  const route = useRoute()
@@ -18,6 +25,36 @@ function submit(_result) {
18
25
  history.back()
19
26
  })
20
27
  }
28
+
29
+ // 表单组——数据
30
+ // function initComponents () {
31
+ // runLogic('getlngChargeAuditMobileFormGroupData', {id: 29}, 'af-gaslink').then((res) => {
32
+ // formData.value = {...res}
33
+ // })
34
+ // }
35
+
36
+ // 纯表单——数据
37
+ // function initComponents() {
38
+ // formData.value = { plan_name: 'af-llllll', plan_point: '1号点位', plan_single: '1号点位', plan_range: '2024-12-12' }
39
+ // }
40
+
41
+ // function initComponents() {
42
+ // runLogic('getlngChargeAuditMobileFormGroupData', { id: route.query?.id, o_id: route.query?.o_id }, 'af-gaslink').then((res) => {
43
+ // console.log('res------', res)
44
+ // formData.value = { ...res }
45
+ // formGroup.value.init({
46
+ // configName: configName.value,
47
+ // serviceName: serviceName.value,
48
+ // groupFormData: { ...res },
49
+ // mode: "新增"
50
+ // })
51
+ // isInit.value = true
52
+ // })
53
+ // }
54
+
55
+ // onBeforeMount(() => {
56
+ // initComponents()
57
+ // })
21
58
  </script>
22
59
 
23
60
  <template>
@@ -1,40 +1,133 @@
1
1
  <script setup lang="ts">
2
- import XFormGroup from '@af-mobile-client-vue3/components/data/XFormGroup/index.vue'
2
+ import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
3
3
  import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
4
- import { ref, toRaw } from 'vue'
5
-
6
- const configName = ref('AddConstructionForm')
7
- const serviceName = ref('af-linepatrol')
8
- const formGroup = ref(null)
9
- function safeStringify(obj) {
10
- const seen = new WeakSet()
11
- return JSON.stringify(toRaw(obj), (key, val) => {
12
- if (typeof val === 'object' && val !== null) {
13
- if (seen.has(val))
14
- return
15
- seen.add(val)
16
- }
17
- return val
18
- }, 2)
4
+ import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
5
+ import { post } from '@af-mobile-client-vue3/services/restTools'
6
+ import {
7
+ showDialog,
8
+ NavBar as VanNavBar,
9
+ Space as VanSpace,
10
+ } from 'vant'
11
+ import { defineEmits, getCurrentInstance, onBeforeMount, ref } from 'vue'
12
+ import { useRoute } from 'vue-router'
13
+
14
+ const emit = defineEmits(['onSumbit'])
15
+ const xForm = ref(null)
16
+ const id = ref(-1)
17
+ const openid = ref('')
18
+ const instance = getCurrentInstance()
19
+ const xFormInit = ref(false)
20
+ const route = useRoute()
21
+ const configName = route.query.configName as string
22
+ const serviceName = route.query.serviceName as string
23
+ const mode = route.query.mode as string
24
+ const updateData = ref({})
25
+ const title = ref('')
26
+ const groupFormItems = ref({})
27
+ const api = ref('/af-system/logic/commonQuery')
28
+ const updateId = {
29
+ queryParamsName: 'crud_oper_log_manage',
30
+ pageNo: 1,
31
+ pageSize: 20,
32
+ conditionParams: { o_id: route.params.id as string },
33
+ }
34
+ const loadUpdate = ref(false)
35
+ // const serviceName = ref('af-revenue')
36
+ const _currentEvaluate = {
37
+ id: null,
38
+ f_business_name: '',
39
+ f_evaluate_state: '',
40
+ }
41
+
42
+ // 组件挂载前获取数据
43
+ onBeforeMount(async () => {
44
+ if (instance) {
45
+ id.value = route.params.id as unknown as number
46
+ openid.value = route.params.openid as string
47
+ formInit()
48
+ }
49
+ })
50
+
51
+ // 组件初始化前的判断
52
+ async function formInit() {
53
+ getConfigByName(configName, (result) => {
54
+ groupFormItems.value = result
55
+ title.value = result.title
56
+ if (mode === '修改')
57
+ getUpdateData()
58
+ xFormInit.value = true
59
+ }, serviceName)
60
+ }
61
+
62
+ // 获取配置信息
63
+ function queryData() {
64
+
65
+ }
66
+
67
+ // 提交操作
68
+ function onSubmit(params) {
69
+ // const data = {
70
+ // id: currentEvaluate.id,
71
+ // f_json: params,
72
+ // f_evaluate_date: formatDate(new Date()),
73
+ // f_evaluate_state: '已评价',
74
+ // f_evaluate_type: '用户评价',
75
+ // f_evaluate_userid: openid.value,
76
+ // }
77
+ // openApiLogic(data, 'saveEvaluate', formServiveName).then((_res: any) => {
78
+ // showDialog({ message: '评价成功了' }).then(() => {history.back()})
79
+ // }).catch(() => {
80
+ // showDialog({ message: '评价失败了' })
81
+ // })
82
+ if (params) {
83
+ emit('onSumbit', params)
84
+ showDialog({ message: '评价成功了' }).then(() => {
85
+ history.back()
86
+ })
87
+ }
88
+ else {
89
+ showDialog({ message: '评价失败了' }).then(() => {
90
+ history.back()
91
+ })
92
+ }
19
93
  }
20
- function submit(result) {
21
- console.log('>>>> result: ', safeStringify(result))
94
+
95
+ // 查询需要修改的数据
96
+ async function getUpdateData() {
97
+ if (api.value && updateId) {
98
+ const res = await post(api.value, updateId)
99
+ updateData.value = res.data[0]
100
+ }
22
101
  }
23
102
  </script>
24
103
 
25
104
  <template>
26
- <NormalDataLayout id="XFormGroupView" title="纯表单">
105
+ <NormalDataLayout id="XFormView" title="XForm表单">
27
106
  <template #layout_content>
28
- <XFormGroup
29
- ref="formGroup"
30
- :config-name="configName"
31
- :service-name="serviceName"
32
- mode="新增"
33
- @submit="submit"
34
- />
107
+ <VanSpace direction="vertical" fill>
108
+ <VanNavBar :title="title ? mode.concat(title) : null" />
109
+ <XForm
110
+ v-if="xFormInit"
111
+ ref="xForm"
112
+ :group-form-items="JSON.parse(JSON.stringify(groupFormItems))"
113
+ :service-name="serviceName"
114
+ :form-data="updateData"
115
+ :mode="mode"
116
+ style="margin-bottom: 14px;"
117
+ @on-submit="onSubmit"
118
+ />
119
+ </VanSpace>
35
120
  </template>
36
121
  </NormalDataLayout>
37
122
  </template>
38
123
 
39
- <style scoped lang="less">
124
+ <style scoped>
125
+ .van-doc-demo-block__title {
126
+ margin: 0;
127
+ padding: 32px 16px 16px;
128
+ color: black;
129
+ font-weight: 400;
130
+ font-size: 14px;
131
+ line-height: 16px;
132
+ }
40
133
  </style>
@@ -1,118 +1,118 @@
1
- <script setup lang="ts">
2
- import type { LocationResult } from '@af-mobile-client-vue3/components/data/XOlMap/types'
3
- import LocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
4
- import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
5
- import { showNotify } from 'vant'
6
- import { ref } from 'vue'
7
-
8
- const selectedLocation = ref<LocationResult>()
9
-
10
- // 处理位置选择
11
- function handleLocationConfirm(location: LocationResult) {
12
- // console.log('选择的位置:', location)
13
- // selectedLocation.value = location
14
- showNotify({ type: 'success', message: '位置已选择' })
15
- }
16
- </script>
17
-
18
- <template>
19
- <NormalDataLayout id="XLocationPicker" title="XOlMap地址选择器">
20
- <template #layout_content>
21
- <div class="location-picker-demo">
22
- <!-- 页面标题 -->
23
- <div class="page-header">
24
- <div class="title">
25
- 位置选择
26
- </div>
27
- </div>
28
-
29
- <!-- 选择结果展示 -->
30
- <div v-if="selectedLocation" class="location-result">
31
- <div class="label">
32
- 已选位置:
33
- </div>
34
- <div class="value">
35
- {{ selectedLocation.address }}
36
- </div>
37
- <div class="coordinates">
38
- 经度: {{ selectedLocation.longitude.toFixed(6) }},
39
- 纬度: {{ selectedLocation.latitude.toFixed(6) }}
40
- </div>
41
- </div>
42
-
43
- <!-- 地图组件 -->
44
- <div class="map-container">
45
- <LocationPicker
46
- v-model="selectedLocation"
47
- :default-center="[108.948024, 34.263161]"
48
- :default-zoom="12"
49
- @confirm="handleLocationConfirm"
50
- />
51
- </div>
52
- </div>
53
- </template>
54
- </NormalDataLayout>
55
- </template>
56
-
57
- <style scoped lang="less">
58
- .location-picker-demo {
59
- width: 100%;
60
- height: 100%;
61
- position: relative;
62
- display: flex;
63
- flex-direction: column;
64
- background-color: #f7f8fa;
65
- }
66
-
67
- .page-header {
68
- height: 44px;
69
- display: flex;
70
- align-items: center;
71
- justify-content: center;
72
- background: white;
73
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
74
- position: relative;
75
- z-index: 1;
76
-
77
- .title {
78
- font-size: 16px;
79
- color: #333;
80
- font-weight: 500;
81
- }
82
- }
83
-
84
- .location-result {
85
- background: white;
86
- padding: 12px 16px;
87
- margin: 10px;
88
- border-radius: 8px;
89
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
90
-
91
- .label {
92
- font-size: 14px;
93
- color: #666;
94
- margin-bottom: 4px;
95
- }
96
-
97
- .value {
98
- font-size: 16px;
99
- color: #333;
100
- margin-bottom: 8px;
101
- word-break: break-all;
102
- }
103
-
104
- .coordinates {
105
- font-size: 12px;
106
- color: #999;
107
- }
108
- }
109
-
110
- .map-container {
111
- flex: 1;
112
- position: relative;
113
- margin: 0 10px 10px 10px;
114
- border-radius: 8px;
115
- overflow: hidden;
116
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
117
- }
118
- </style>
1
+ <script setup lang="ts">
2
+ import type { LocationResult } from '@af-mobile-client-vue3/components/data/XOlMap/types'
3
+ import LocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
4
+ import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
5
+ import { showNotify } from 'vant'
6
+ import { ref } from 'vue'
7
+
8
+ const selectedLocation = ref<LocationResult>()
9
+
10
+ // 处理位置选择
11
+ function handleLocationConfirm(location: LocationResult) {
12
+ // console.log('选择的位置:', location)
13
+ // selectedLocation.value = location
14
+ showNotify({ type: 'success', message: '位置已选择' })
15
+ }
16
+ </script>
17
+
18
+ <template>
19
+ <NormalDataLayout id="XLocationPicker" title="XOlMap地址选择器">
20
+ <template #layout_content>
21
+ <div class="location-picker-demo">
22
+ <!-- 页面标题 -->
23
+ <div class="page-header">
24
+ <div class="title">
25
+ 位置选择
26
+ </div>
27
+ </div>
28
+
29
+ <!-- 选择结果展示 -->
30
+ <div v-if="selectedLocation" class="location-result">
31
+ <div class="label">
32
+ 已选位置:
33
+ </div>
34
+ <div class="value">
35
+ {{ selectedLocation.address }}
36
+ </div>
37
+ <div class="coordinates">
38
+ 经度: {{ selectedLocation.longitude.toFixed(6) }},
39
+ 纬度: {{ selectedLocation.latitude.toFixed(6) }}
40
+ </div>
41
+ </div>
42
+
43
+ <!-- 地图组件 -->
44
+ <div class="map-container">
45
+ <LocationPicker
46
+ v-model="selectedLocation"
47
+ :default-center="[108.948024, 34.263161]"
48
+ :default-zoom="12"
49
+ @confirm="handleLocationConfirm"
50
+ />
51
+ </div>
52
+ </div>
53
+ </template>
54
+ </NormalDataLayout>
55
+ </template>
56
+
57
+ <style scoped lang="less">
58
+ .location-picker-demo {
59
+ width: 100%;
60
+ height: 100%;
61
+ position: relative;
62
+ display: flex;
63
+ flex-direction: column;
64
+ background-color: #f7f8fa;
65
+ }
66
+
67
+ .page-header {
68
+ height: 44px;
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ background: white;
73
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
74
+ position: relative;
75
+ z-index: 1;
76
+
77
+ .title {
78
+ font-size: 16px;
79
+ color: #333;
80
+ font-weight: 500;
81
+ }
82
+ }
83
+
84
+ .location-result {
85
+ background: white;
86
+ padding: 12px 16px;
87
+ margin: 10px;
88
+ border-radius: 8px;
89
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
90
+
91
+ .label {
92
+ font-size: 14px;
93
+ color: #666;
94
+ margin-bottom: 4px;
95
+ }
96
+
97
+ .value {
98
+ font-size: 16px;
99
+ color: #333;
100
+ margin-bottom: 8px;
101
+ word-break: break-all;
102
+ }
103
+
104
+ .coordinates {
105
+ font-size: 12px;
106
+ color: #999;
107
+ }
108
+ }
109
+
110
+ .map-container {
111
+ flex: 1;
112
+ position: relative;
113
+ margin: 0 10px 10px 10px;
114
+ border-radius: 8px;
115
+ overflow: hidden;
116
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
117
+ }
118
+ </style>
@@ -1,133 +0,0 @@
1
- <script setup lang="ts">
2
- import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
3
- import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
4
- import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
5
- import { post } from '@af-mobile-client-vue3/services/restTools'
6
- import {
7
- showDialog,
8
- NavBar as VanNavBar,
9
- Space as VanSpace,
10
- } from 'vant'
11
- import { defineEmits, getCurrentInstance, onBeforeMount, ref } from 'vue'
12
- import { useRoute } from 'vue-router'
13
-
14
- const emit = defineEmits(['onSumbit'])
15
- const xForm = ref(null)
16
- const id = ref(-1)
17
- const openid = ref('')
18
- const instance = getCurrentInstance()
19
- const xFormInit = ref(false)
20
- const route = useRoute()
21
- const configName = route.query.configName as string
22
- const serviceName = route.query.serviceName as string
23
- const mode = route.query.mode as string
24
- const updateData = ref({})
25
- const title = ref('')
26
- const groupFormItems = ref({})
27
- const api = ref('/af-system/logic/commonQuery')
28
- const updateId = {
29
- queryParamsName: 'crud_oper_log_manage',
30
- pageNo: 1,
31
- pageSize: 20,
32
- conditionParams: { o_id: route.params.id as string },
33
- }
34
- const loadUpdate = ref(false)
35
- // const serviceName = ref('af-revenue')
36
- const _currentEvaluate = {
37
- id: null,
38
- f_business_name: '',
39
- f_evaluate_state: '',
40
- }
41
-
42
- // 组件挂载前获取数据
43
- onBeforeMount(async () => {
44
- if (instance) {
45
- id.value = route.params.id as unknown as number
46
- openid.value = route.params.openid as string
47
- formInit()
48
- }
49
- })
50
-
51
- // 组件初始化前的判断
52
- async function formInit() {
53
- getConfigByName(configName, (result) => {
54
- groupFormItems.value = result
55
- title.value = result.title
56
- if (mode === '修改')
57
- getUpdateData()
58
- xFormInit.value = true
59
- }, serviceName)
60
- }
61
-
62
- // 获取配置信息
63
- function queryData() {
64
-
65
- }
66
-
67
- // 提交操作
68
- function onSubmit(params) {
69
- // const data = {
70
- // id: currentEvaluate.id,
71
- // f_json: params,
72
- // f_evaluate_date: formatDate(new Date()),
73
- // f_evaluate_state: '已评价',
74
- // f_evaluate_type: '用户评价',
75
- // f_evaluate_userid: openid.value,
76
- // }
77
- // openApiLogic(data, 'saveEvaluate', formServiveName).then((_res: any) => {
78
- // showDialog({ message: '评价成功了' }).then(() => {history.back()})
79
- // }).catch(() => {
80
- // showDialog({ message: '评价失败了' })
81
- // })
82
- if (params) {
83
- emit('onSumbit', params)
84
- showDialog({ message: '评价成功了' }).then(() => {
85
- history.back()
86
- })
87
- }
88
- else {
89
- showDialog({ message: '评价失败了' }).then(() => {
90
- history.back()
91
- })
92
- }
93
- }
94
-
95
- // 查询需要修改的数据
96
- async function getUpdateData() {
97
- if (api.value && updateId) {
98
- const res = await post(api.value, updateId)
99
- updateData.value = res.data[0]
100
- }
101
- }
102
- </script>
103
-
104
- <template>
105
- <NormalDataLayout id="XFormView" title="XForm表单">
106
- <template #layout_content>
107
- <VanSpace direction="vertical" fill>
108
- <VanNavBar :title="title ? mode.concat(title) : null" />
109
- <XForm
110
- v-if="xFormInit"
111
- ref="xForm"
112
- :group-form-items="JSON.parse(JSON.stringify(groupFormItems))"
113
- :service-name="serviceName"
114
- :form-data="updateData"
115
- :mode="mode"
116
- style="margin-bottom: 14px;"
117
- @on-submit="onSubmit"
118
- />
119
- </VanSpace>
120
- </template>
121
- </NormalDataLayout>
122
- </template>
123
-
124
- <style scoped>
125
- .van-doc-demo-block__title {
126
- margin: 0;
127
- padding: 32px 16px 16px;
128
- color: black;
129
- font-weight: 400;
130
- font-size: 14px;
131
- line-height: 16px;
132
- }
133
- </style>