vue2-client 1.2.44 → 1.2.47
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/docs/notice.md +22 -22
- package/package.json +1 -1
- package/src/App.vue +13 -7
- package/src/base-client/all.js +61 -61
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +104 -104
- package/src/base-client/components/common/AmapMarker/index.js +3 -3
- package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
- package/src/base-client/components/common/ScrollList/SrcollList.vue +113 -113
- package/src/base-client/components/common/ScrollList/index.js +3 -3
- package/src/base-client/components/common/XForm/XForm.vue +275 -275
- package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +225 -225
- package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +244 -244
- package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +452 -452
- package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +236 -236
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +121 -121
- package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +276 -276
- package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +469 -469
- package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +379 -379
- package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +359 -359
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +184 -184
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +291 -291
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +236 -236
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +256 -256
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +189 -189
- package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +722 -722
- package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +231 -231
- package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +247 -247
- package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +370 -370
- package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
- package/src/base-client/plugins/AppData.js +67 -67
- package/src/base-client/plugins/GetLoginInfoService.js +252 -252
- package/src/components/exception/ExceptionPage.vue +70 -70
- package/src/components/setting/Setting.vue +235 -235
- package/src/config/default/setting.config.js +39 -37
- package/src/config/index.js +3 -3
- package/src/layouts/SinglePageView.vue +1 -2
- package/src/layouts/header/HeaderNotice.vue +97 -97
- package/src/pages/exception/403.vue +21 -21
- package/src/pages/exception/404.vue +21 -21
- package/src/pages/exception/500.vue +21 -21
- package/src/pages/report/ReportTableHome.vue +28 -28
- package/src/pages/resourceManage/depListManage.vue +23 -23
- package/src/pages/resourceManage/funListManage.vue +23 -23
- package/src/pages/resourceManage/index.js +15 -15
- package/src/pages/resourceManage/orgListManage.vue +98 -98
- package/src/pages/resourceManage/roleListManage.vue +23 -23
- package/src/pages/resourceManage/staffListManage.vue +23 -23
- package/src/pages/system/ticket/submitTicketSuccess.vue +248 -248
- package/src/services/api/common.js +47 -47
- package/src/services/api/index.js +39 -39
- package/src/services/user.js +34 -34
- package/src/utils/indexedDB.js +146 -146
- package/src/utils/map-utils.js +17 -0
- package/src/utils/routerUtil.js +359 -359
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { commonApi, getColumnsJson, query, addOrModify, remove } from '@vue2-client/services/api/common'
|
|
2
|
-
import { CustomerDetailsViewApi } from '@vue2-client/services/api/CustomerDetailsViewApi'
|
|
3
|
-
import { DeviceBrandDetailsViewApi } from '@vue2-client/services/api/DeviceBrandDetailsViewApi'
|
|
4
|
-
import { DeviceDetailsViewApi } from '@vue2-client/services/api/DeviceDetailsViewApi'
|
|
5
|
-
import { DeviceTypeDetailsViewApi } from '@vue2-client/services/api/DeviceTypeDetailsViewApi'
|
|
6
|
-
import { DictionaryDetailsViewApi } from '@vue2-client/services/api/DictionaryDetailsViewApi'
|
|
7
|
-
import { EmployeeDetailsViewApi } from '@vue2-client/services/api/EmployeeDetailsViewApi'
|
|
8
|
-
import { FormGroupEditApi } from '@vue2-client/services/api/FormGroupEditApi'
|
|
9
|
-
import { InstructDetailsViewApi } from '@vue2-client/services/api/InstructDetailsViewApi'
|
|
10
|
-
import { iotApi } from '@vue2-client/services/api/iot'
|
|
11
|
-
import { LogDetailsViewApi } from '@vue2-client/services/api/LogDetailsViewApi'
|
|
12
|
-
import { manageApi } from '@vue2-client/services/api/manage'
|
|
13
|
-
import { MeterDetailsViewApi } from '@vue2-client/services/api/MeterDetailsViewApi'
|
|
14
|
-
import { QueryParamsDetailsViewApi } from '@vue2-client/services/api/QueryParamsDetailsViewApi'
|
|
15
|
-
import { get, post } from '@vue2-client/services/api/restTools'
|
|
16
|
-
import { serviceApi } from '@vue2-client/services/api/service'
|
|
17
|
-
import { TicketDetailsViewApi } from '@vue2-client/services/api/TicketDetailsViewApi'
|
|
18
|
-
import { WebmeterAnalysisViewApi } from '@vue2-client/services/api/WebmeterAnalysisViewApi'
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
commonApi, getColumnsJson, query, addOrModify, remove,
|
|
22
|
-
CustomerDetailsViewApi,
|
|
23
|
-
DeviceBrandDetailsViewApi,
|
|
24
|
-
DeviceDetailsViewApi,
|
|
25
|
-
DeviceTypeDetailsViewApi,
|
|
26
|
-
DictionaryDetailsViewApi,
|
|
27
|
-
EmployeeDetailsViewApi,
|
|
28
|
-
FormGroupEditApi,
|
|
29
|
-
InstructDetailsViewApi,
|
|
30
|
-
iotApi,
|
|
31
|
-
LogDetailsViewApi,
|
|
32
|
-
manageApi,
|
|
33
|
-
MeterDetailsViewApi,
|
|
34
|
-
QueryParamsDetailsViewApi,
|
|
35
|
-
get, post,
|
|
36
|
-
serviceApi,
|
|
37
|
-
TicketDetailsViewApi,
|
|
38
|
-
WebmeterAnalysisViewApi
|
|
39
|
-
}
|
|
1
|
+
import { commonApi, getColumnsJson, query, addOrModify, remove } from '@vue2-client/services/api/common'
|
|
2
|
+
import { CustomerDetailsViewApi } from '@vue2-client/services/api/CustomerDetailsViewApi'
|
|
3
|
+
import { DeviceBrandDetailsViewApi } from '@vue2-client/services/api/DeviceBrandDetailsViewApi'
|
|
4
|
+
import { DeviceDetailsViewApi } from '@vue2-client/services/api/DeviceDetailsViewApi'
|
|
5
|
+
import { DeviceTypeDetailsViewApi } from '@vue2-client/services/api/DeviceTypeDetailsViewApi'
|
|
6
|
+
import { DictionaryDetailsViewApi } from '@vue2-client/services/api/DictionaryDetailsViewApi'
|
|
7
|
+
import { EmployeeDetailsViewApi } from '@vue2-client/services/api/EmployeeDetailsViewApi'
|
|
8
|
+
import { FormGroupEditApi } from '@vue2-client/services/api/FormGroupEditApi'
|
|
9
|
+
import { InstructDetailsViewApi } from '@vue2-client/services/api/InstructDetailsViewApi'
|
|
10
|
+
import { iotApi } from '@vue2-client/services/api/iot'
|
|
11
|
+
import { LogDetailsViewApi } from '@vue2-client/services/api/LogDetailsViewApi'
|
|
12
|
+
import { manageApi } from '@vue2-client/services/api/manage'
|
|
13
|
+
import { MeterDetailsViewApi } from '@vue2-client/services/api/MeterDetailsViewApi'
|
|
14
|
+
import { QueryParamsDetailsViewApi } from '@vue2-client/services/api/QueryParamsDetailsViewApi'
|
|
15
|
+
import { get, post } from '@vue2-client/services/api/restTools'
|
|
16
|
+
import { serviceApi } from '@vue2-client/services/api/service'
|
|
17
|
+
import { TicketDetailsViewApi } from '@vue2-client/services/api/TicketDetailsViewApi'
|
|
18
|
+
import { WebmeterAnalysisViewApi } from '@vue2-client/services/api/WebmeterAnalysisViewApi'
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
commonApi, getColumnsJson, query, addOrModify, remove,
|
|
22
|
+
CustomerDetailsViewApi,
|
|
23
|
+
DeviceBrandDetailsViewApi,
|
|
24
|
+
DeviceDetailsViewApi,
|
|
25
|
+
DeviceTypeDetailsViewApi,
|
|
26
|
+
DictionaryDetailsViewApi,
|
|
27
|
+
EmployeeDetailsViewApi,
|
|
28
|
+
FormGroupEditApi,
|
|
29
|
+
InstructDetailsViewApi,
|
|
30
|
+
iotApi,
|
|
31
|
+
LogDetailsViewApi,
|
|
32
|
+
manageApi,
|
|
33
|
+
MeterDetailsViewApi,
|
|
34
|
+
QueryParamsDetailsViewApi,
|
|
35
|
+
get, post,
|
|
36
|
+
serviceApi,
|
|
37
|
+
TicketDetailsViewApi,
|
|
38
|
+
WebmeterAnalysisViewApi
|
|
39
|
+
}
|
package/src/services/user.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { LOGIN, ROUTES } from '@vue2-client/services/apiService'
|
|
2
|
-
import { request, METHOD, removeAuthorization } from '@vue2-client/utils/request'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 登录服务
|
|
6
|
-
* @param name 账户名
|
|
7
|
-
* @param password 账户密码
|
|
8
|
-
* @returns {Promise<AxiosResponse<T>>}
|
|
9
|
-
*/
|
|
10
|
-
export async function login (name, password) {
|
|
11
|
-
return request(LOGIN, METHOD.POST, {
|
|
12
|
-
name: name,
|
|
13
|
-
password: password
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function getRoutesConfig (value) {
|
|
18
|
-
return request(ROUTES, METHOD.POST, value)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 退出登录
|
|
23
|
-
*/
|
|
24
|
-
export function logout () {
|
|
25
|
-
localStorage.removeItem(process.env.VUE_APP_ROUTES_KEY)
|
|
26
|
-
localStorage.removeItem(process.env.VUE_APP_PERMISSIONS_KEY)
|
|
27
|
-
localStorage.removeItem(process.env.VUE_APP_ROLES_KEY)
|
|
28
|
-
removeAuthorization()
|
|
29
|
-
}
|
|
30
|
-
export default {
|
|
31
|
-
login,
|
|
32
|
-
logout,
|
|
33
|
-
getRoutesConfig
|
|
34
|
-
}
|
|
1
|
+
import { LOGIN, ROUTES } from '@vue2-client/services/apiService'
|
|
2
|
+
import { request, METHOD, removeAuthorization } from '@vue2-client/utils/request'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 登录服务
|
|
6
|
+
* @param name 账户名
|
|
7
|
+
* @param password 账户密码
|
|
8
|
+
* @returns {Promise<AxiosResponse<T>>}
|
|
9
|
+
*/
|
|
10
|
+
export async function login (name, password) {
|
|
11
|
+
return request(LOGIN, METHOD.POST, {
|
|
12
|
+
name: name,
|
|
13
|
+
password: password
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function getRoutesConfig (value) {
|
|
18
|
+
return request(ROUTES, METHOD.POST, value)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 退出登录
|
|
23
|
+
*/
|
|
24
|
+
export function logout () {
|
|
25
|
+
localStorage.removeItem(process.env.VUE_APP_ROUTES_KEY)
|
|
26
|
+
localStorage.removeItem(process.env.VUE_APP_PERMISSIONS_KEY)
|
|
27
|
+
localStorage.removeItem(process.env.VUE_APP_ROLES_KEY)
|
|
28
|
+
removeAuthorization()
|
|
29
|
+
}
|
|
30
|
+
export default {
|
|
31
|
+
login,
|
|
32
|
+
logout,
|
|
33
|
+
getRoutesConfig
|
|
34
|
+
}
|
package/src/utils/indexedDB.js
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
// indexDB 存储
|
|
2
|
-
import { post } from '@vue2-client/services/api'
|
|
3
|
-
|
|
4
|
-
export const indexedDB = {
|
|
5
|
-
db: undefined,
|
|
6
|
-
indexedDB: window.indexedDB || window.webkitindexedDB,
|
|
7
|
-
IDBKeyRange: window.IDBKeyRange || window.webkitIDBKeyRange, // 键范围
|
|
8
|
-
openDB: function (callback) {
|
|
9
|
-
// 建立或打开数据库,建立对象存储空间(ObjectStore)
|
|
10
|
-
const self = this
|
|
11
|
-
if (self.db) {
|
|
12
|
-
callback(self.db)
|
|
13
|
-
} else {
|
|
14
|
-
const version = 1
|
|
15
|
-
const request = self.indexedDB.open('view', version)
|
|
16
|
-
|
|
17
|
-
request.onerror = function (e) {
|
|
18
|
-
console.error('打开数据库失败:' + e.currentTarget.error.message)
|
|
19
|
-
}
|
|
20
|
-
request.onsuccess = function (e) {
|
|
21
|
-
self.db = e.target.result
|
|
22
|
-
callback(self.db)
|
|
23
|
-
}
|
|
24
|
-
request.onupgradeneeded = function (e) {
|
|
25
|
-
const db = e.target.result
|
|
26
|
-
if (!db.objectStoreNames.contains('metaCache')) {
|
|
27
|
-
// 没有该对象空间时创建该对象空间
|
|
28
|
-
db.createObjectStore('metaCache', {
|
|
29
|
-
keyPath: 'key'
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
deleteDB: function (dbname) {
|
|
36
|
-
// 删除数据库
|
|
37
|
-
const self = this
|
|
38
|
-
self.indexedDB.deleteDatabase(dbname)
|
|
39
|
-
console.log(dbname + '数据库已删除')
|
|
40
|
-
},
|
|
41
|
-
closeDB: function () {
|
|
42
|
-
const self = this
|
|
43
|
-
if (!self.db) {
|
|
44
|
-
self.db.close()
|
|
45
|
-
}
|
|
46
|
-
console.log('数据库已关闭')
|
|
47
|
-
},
|
|
48
|
-
add: function (key, data) {
|
|
49
|
-
const self = this
|
|
50
|
-
self.openDB((res) => {
|
|
51
|
-
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').add({
|
|
52
|
-
key: key,
|
|
53
|
-
data: data
|
|
54
|
-
})
|
|
55
|
-
request.onerror = function () {
|
|
56
|
-
self.update(data)
|
|
57
|
-
}
|
|
58
|
-
request.onsuccess = function () {
|
|
59
|
-
console.log('数据已存入到数据库')
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
},
|
|
63
|
-
update: function (key, data) {
|
|
64
|
-
const self = this
|
|
65
|
-
self.openDB((res) => {
|
|
66
|
-
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').put({
|
|
67
|
-
key: key,
|
|
68
|
-
data: data
|
|
69
|
-
})
|
|
70
|
-
request.onerror = function () {
|
|
71
|
-
console.error('数据更新失败')
|
|
72
|
-
}
|
|
73
|
-
request.onsuccess = function () {
|
|
74
|
-
console.log('数据已更新到数据库')
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
},
|
|
78
|
-
get: function (key, callback) {
|
|
79
|
-
const self = this
|
|
80
|
-
self.openDB((res) => {
|
|
81
|
-
// 根据存储空间的键找到对应数据
|
|
82
|
-
const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
|
|
83
|
-
const request = store.get(key)
|
|
84
|
-
request.onerror = function () {
|
|
85
|
-
console.log('读取数据失败,键:' + key)
|
|
86
|
-
}
|
|
87
|
-
request.onsuccess = function (e) {
|
|
88
|
-
const result = e.target.result
|
|
89
|
-
if (typeof (callback) === 'function') {
|
|
90
|
-
callback(result.data)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
},
|
|
95
|
-
getByWeb: function (key, url, params, callback) {
|
|
96
|
-
const self = this
|
|
97
|
-
self.openDB((res) => {
|
|
98
|
-
// 根据存储空间的键找到对应数据
|
|
99
|
-
const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
|
|
100
|
-
const request = store.get(key)
|
|
101
|
-
request.onerror = function () {
|
|
102
|
-
console.log('读取数据失败,键:' + key)
|
|
103
|
-
}
|
|
104
|
-
request.onsuccess = function (e) {
|
|
105
|
-
const result = e.target.result
|
|
106
|
-
if (!result && url) {
|
|
107
|
-
post(url, params).then((res) => {
|
|
108
|
-
self.add(key, res)
|
|
109
|
-
callback(res)
|
|
110
|
-
})
|
|
111
|
-
} else {
|
|
112
|
-
callback(result.data)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
},
|
|
117
|
-
delete: function (key) {
|
|
118
|
-
const self = this
|
|
119
|
-
self.openDB((res) => {
|
|
120
|
-
// 删除某一条记录
|
|
121
|
-
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').delete(key)
|
|
122
|
-
|
|
123
|
-
request.onerror = function () {
|
|
124
|
-
console.error('数据删除失败')
|
|
125
|
-
}
|
|
126
|
-
request.onsuccess = function (event) {
|
|
127
|
-
console.log('已删除存储空间' + 'metaCache' + '中' + key + '记录')
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
},
|
|
131
|
-
clear: function (callback) {
|
|
132
|
-
const self = this
|
|
133
|
-
self.openDB((res) => {
|
|
134
|
-
// 删除存储空间全部记录
|
|
135
|
-
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').clear()
|
|
136
|
-
|
|
137
|
-
request.onerror = function () {
|
|
138
|
-
console.error('数据删除失败')
|
|
139
|
-
}
|
|
140
|
-
request.onsuccess = function (event) {
|
|
141
|
-
console.log('已删除存储空间' + 'metaCache' + '中所有记录')
|
|
142
|
-
callback()
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
}
|
|
1
|
+
// indexDB 存储
|
|
2
|
+
import { post } from '@vue2-client/services/api'
|
|
3
|
+
|
|
4
|
+
export const indexedDB = {
|
|
5
|
+
db: undefined,
|
|
6
|
+
indexedDB: window.indexedDB || window.webkitindexedDB,
|
|
7
|
+
IDBKeyRange: window.IDBKeyRange || window.webkitIDBKeyRange, // 键范围
|
|
8
|
+
openDB: function (callback) {
|
|
9
|
+
// 建立或打开数据库,建立对象存储空间(ObjectStore)
|
|
10
|
+
const self = this
|
|
11
|
+
if (self.db) {
|
|
12
|
+
callback(self.db)
|
|
13
|
+
} else {
|
|
14
|
+
const version = 1
|
|
15
|
+
const request = self.indexedDB.open('view', version)
|
|
16
|
+
|
|
17
|
+
request.onerror = function (e) {
|
|
18
|
+
console.error('打开数据库失败:' + e.currentTarget.error.message)
|
|
19
|
+
}
|
|
20
|
+
request.onsuccess = function (e) {
|
|
21
|
+
self.db = e.target.result
|
|
22
|
+
callback(self.db)
|
|
23
|
+
}
|
|
24
|
+
request.onupgradeneeded = function (e) {
|
|
25
|
+
const db = e.target.result
|
|
26
|
+
if (!db.objectStoreNames.contains('metaCache')) {
|
|
27
|
+
// 没有该对象空间时创建该对象空间
|
|
28
|
+
db.createObjectStore('metaCache', {
|
|
29
|
+
keyPath: 'key'
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
deleteDB: function (dbname) {
|
|
36
|
+
// 删除数据库
|
|
37
|
+
const self = this
|
|
38
|
+
self.indexedDB.deleteDatabase(dbname)
|
|
39
|
+
console.log(dbname + '数据库已删除')
|
|
40
|
+
},
|
|
41
|
+
closeDB: function () {
|
|
42
|
+
const self = this
|
|
43
|
+
if (!self.db) {
|
|
44
|
+
self.db.close()
|
|
45
|
+
}
|
|
46
|
+
console.log('数据库已关闭')
|
|
47
|
+
},
|
|
48
|
+
add: function (key, data) {
|
|
49
|
+
const self = this
|
|
50
|
+
self.openDB((res) => {
|
|
51
|
+
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').add({
|
|
52
|
+
key: key,
|
|
53
|
+
data: data
|
|
54
|
+
})
|
|
55
|
+
request.onerror = function () {
|
|
56
|
+
self.update(data)
|
|
57
|
+
}
|
|
58
|
+
request.onsuccess = function () {
|
|
59
|
+
console.log('数据已存入到数据库')
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
update: function (key, data) {
|
|
64
|
+
const self = this
|
|
65
|
+
self.openDB((res) => {
|
|
66
|
+
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').put({
|
|
67
|
+
key: key,
|
|
68
|
+
data: data
|
|
69
|
+
})
|
|
70
|
+
request.onerror = function () {
|
|
71
|
+
console.error('数据更新失败')
|
|
72
|
+
}
|
|
73
|
+
request.onsuccess = function () {
|
|
74
|
+
console.log('数据已更新到数据库')
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
get: function (key, callback) {
|
|
79
|
+
const self = this
|
|
80
|
+
self.openDB((res) => {
|
|
81
|
+
// 根据存储空间的键找到对应数据
|
|
82
|
+
const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
|
|
83
|
+
const request = store.get(key)
|
|
84
|
+
request.onerror = function () {
|
|
85
|
+
console.log('读取数据失败,键:' + key)
|
|
86
|
+
}
|
|
87
|
+
request.onsuccess = function (e) {
|
|
88
|
+
const result = e.target.result
|
|
89
|
+
if (typeof (callback) === 'function') {
|
|
90
|
+
callback(result.data)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
getByWeb: function (key, url, params, callback) {
|
|
96
|
+
const self = this
|
|
97
|
+
self.openDB((res) => {
|
|
98
|
+
// 根据存储空间的键找到对应数据
|
|
99
|
+
const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
|
|
100
|
+
const request = store.get(key)
|
|
101
|
+
request.onerror = function () {
|
|
102
|
+
console.log('读取数据失败,键:' + key)
|
|
103
|
+
}
|
|
104
|
+
request.onsuccess = function (e) {
|
|
105
|
+
const result = e.target.result
|
|
106
|
+
if (!result && url) {
|
|
107
|
+
post(url, params).then((res) => {
|
|
108
|
+
self.add(key, res)
|
|
109
|
+
callback(res)
|
|
110
|
+
})
|
|
111
|
+
} else {
|
|
112
|
+
callback(result.data)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
delete: function (key) {
|
|
118
|
+
const self = this
|
|
119
|
+
self.openDB((res) => {
|
|
120
|
+
// 删除某一条记录
|
|
121
|
+
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').delete(key)
|
|
122
|
+
|
|
123
|
+
request.onerror = function () {
|
|
124
|
+
console.error('数据删除失败')
|
|
125
|
+
}
|
|
126
|
+
request.onsuccess = function (event) {
|
|
127
|
+
console.log('已删除存储空间' + 'metaCache' + '中' + key + '记录')
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
clear: function (callback) {
|
|
132
|
+
const self = this
|
|
133
|
+
self.openDB((res) => {
|
|
134
|
+
// 删除存储空间全部记录
|
|
135
|
+
const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').clear()
|
|
136
|
+
|
|
137
|
+
request.onerror = function () {
|
|
138
|
+
console.error('数据删除失败')
|
|
139
|
+
}
|
|
140
|
+
request.onsuccess = function (event) {
|
|
141
|
+
console.log('已删除存储空间' + 'metaCache' + '中所有记录')
|
|
142
|
+
callback()
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//地图相关插件
|
|
2
|
+
|
|
3
|
+
// vuecomp:传入vue组件实例即可
|
|
4
|
+
export function getLocation(vuecomp,address) {
|
|
5
|
+
return new Promise((resolve,reject)=>{
|
|
6
|
+
new vuecomp.$AMap.Geocoder({
|
|
7
|
+
radius: 500 //范围,默认:500
|
|
8
|
+
}).getLocation(address, function(status, result) {
|
|
9
|
+
console.log(result)
|
|
10
|
+
if (status === 'complete'&&result.geocodes.length) {
|
|
11
|
+
resolve({lng:result.geocodes[0].location.lng,lat:result.geocodes[0].location.lat})
|
|
12
|
+
}else{
|
|
13
|
+
reject('根据经纬度查询地址失败')
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
}
|