@zscreate/zhxy-app-component 1.0.119 → 1.0.120
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.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {toAwait} from "../../../utils/util";
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
export default {
|
|
4
|
+
methods: {
|
|
5
|
+
async getOpenId() {
|
|
6
|
+
let openId = Vue.prototype._openId
|
|
7
|
+
if (openId) return Promise.resolve(openId)
|
|
8
|
+
|
|
9
|
+
const [ err , res ] = await toAwait(this.$u.get('/sys/user/getUserPublicOpenId'))
|
|
10
|
+
openId = await this.$async_encryption(res.result)
|
|
11
|
+
Vue.prototype._openId = openId
|
|
12
|
+
return openId
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -294,6 +294,7 @@ export default {
|
|
|
294
294
|
if (this.dataObj && this.dataObj.list) {
|
|
295
295
|
this.rules = {};
|
|
296
296
|
this.generateModle(this.dataObj.list);
|
|
297
|
+
this.updateFormDataToModels()
|
|
297
298
|
console.log(JSON.stringify(this.models))
|
|
298
299
|
}
|
|
299
300
|
},
|
|
@@ -304,6 +305,8 @@ export default {
|
|
|
304
305
|
if (this.dataObj && this.dataObj.list) {
|
|
305
306
|
this.rules = {};
|
|
306
307
|
this.generateModle(this.dataObj.list);
|
|
308
|
+
|
|
309
|
+
this.updateFormDataToModels()
|
|
307
310
|
console.log(this.models)
|
|
308
311
|
console.log(JSON.stringify(this.models))
|
|
309
312
|
}
|
|
@@ -334,6 +337,7 @@ export default {
|
|
|
334
337
|
|
|
335
338
|
},
|
|
336
339
|
mounted() {
|
|
340
|
+
|
|
337
341
|
// 回显关联组件
|
|
338
342
|
// setTimeout(() => {
|
|
339
343
|
// this.getchildren()
|
|
@@ -356,6 +360,15 @@ export default {
|
|
|
356
360
|
// this.initPo();
|
|
357
361
|
},
|
|
358
362
|
methods: {
|
|
363
|
+
updateFormDataToModels() {
|
|
364
|
+
// 将formData 中未绑定表单key 的数据也复制到models
|
|
365
|
+
const modelsKeys = Object.keys(this.models)
|
|
366
|
+
Object.keys(this.value).forEach(key => {
|
|
367
|
+
if (!modelsKeys.includes(key)) {
|
|
368
|
+
this.models[key] = this.value[key]
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
},
|
|
359
372
|
verifyLogsList(model) {
|
|
360
373
|
const list = this.verifyLogs[model]
|
|
361
374
|
if (model !== this.verifyNode && list.length >= 1) return list.slice(0, list.length - 1)
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script>
|
|
27
|
-
|
|
27
|
+
import {downloadFile, getOpenId, toAwait} from "../../utils/util";
|
|
28
28
|
|
|
29
29
|
export default {
|
|
30
30
|
props: {
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
percent: 0,
|
|
52
52
|
show: true,
|
|
53
53
|
uploadIng: false,
|
|
54
|
+
openId: undefined,
|
|
54
55
|
isShow:true,//是否展示点击上传
|
|
55
56
|
}
|
|
56
57
|
},
|
|
@@ -60,7 +61,10 @@
|
|
|
60
61
|
this.getShow(val)
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
|
-
mounted() {
|
|
64
|
+
async mounted() {
|
|
65
|
+
if (this.widget.options.uploadEncrypt) {
|
|
66
|
+
this.openId = await getOpenId()
|
|
67
|
+
}
|
|
64
68
|
if(this.disabled){
|
|
65
69
|
this.isShow =!this.disabled
|
|
66
70
|
}
|
|
@@ -84,7 +88,7 @@
|
|
|
84
88
|
downLoadFile(path, name, item) {
|
|
85
89
|
let baseUrl = this.downLoadUrl
|
|
86
90
|
if (this.widget.options.uploadEncrypt) {
|
|
87
|
-
path =
|
|
91
|
+
path = `/sys/common/downloadZip?fileId=${item.fileId}&openId=${this.openId}`
|
|
88
92
|
baseUrl = process.uniEnv.BASE_API || process.uniEnv.apiUrl
|
|
89
93
|
}
|
|
90
94
|
downloadFile(baseUrl, { path, name })
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
24
|
<script>
|
|
25
|
+
import {getOpenId, toAwait} from "../../utils/util";
|
|
26
|
+
|
|
25
27
|
var _self;
|
|
26
28
|
export default {
|
|
27
29
|
props: {
|
|
@@ -54,12 +56,16 @@ export default {
|
|
|
54
56
|
emitList: [],
|
|
55
57
|
uploadIng: false,
|
|
56
58
|
showProgress: true,
|
|
59
|
+
openId: undefined,
|
|
57
60
|
header: {
|
|
58
61
|
'X-Access-Token': uni.getStorageSync('token') || this.$store.state.token || this.$store.getters.token
|
|
59
62
|
},
|
|
60
63
|
};
|
|
61
64
|
},
|
|
62
|
-
created() {
|
|
65
|
+
async created() {
|
|
66
|
+
if (this.widget.options.uploadEncrypt) {
|
|
67
|
+
this.openId = await getOpenId()
|
|
68
|
+
}
|
|
63
69
|
if (this.widget && Object.keys(this.widget).length > 0) {
|
|
64
70
|
this.initWidget();
|
|
65
71
|
this.showImage();
|
|
@@ -173,7 +179,6 @@ export default {
|
|
|
173
179
|
})
|
|
174
180
|
},
|
|
175
181
|
onOversize() {
|
|
176
|
-
debugger
|
|
177
182
|
uni.showToast({
|
|
178
183
|
title: `文件超出${this.maxSize/1024}KB!`,
|
|
179
184
|
icon: 'none',
|
|
@@ -191,7 +196,7 @@ export default {
|
|
|
191
196
|
};
|
|
192
197
|
tempItem.url = this.uniEnv.imgUrl + tempItem.url;
|
|
193
198
|
if (tempItem.fileId) {
|
|
194
|
-
tempItem.url = (process.uniEnv.BASE_API || process.uniEnv.apiUrl) +
|
|
199
|
+
tempItem.url = (process.uniEnv.BASE_API || process.uniEnv.apiUrl) + `/sys/common/downloadZip?fileId=${tempItem.fileId}&openId=${this.openId}`
|
|
195
200
|
}
|
|
196
201
|
return tempItem;
|
|
197
202
|
})
|
package/package.json
CHANGED
package/utils/util.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
1
2
|
function formatTime(time) {
|
|
2
3
|
if (typeof time !== 'number' || time < 0) {
|
|
3
4
|
return time
|
|
@@ -184,6 +185,15 @@ function downloadFile(downLoadUrl, { path, name }) {
|
|
|
184
185
|
*/
|
|
185
186
|
const toAwait = promise => promise.then( res => [null, res ]).catch(error => [error])
|
|
186
187
|
|
|
188
|
+
const getOpenId = async function () {
|
|
189
|
+
let openId = Vue.prototype._openId
|
|
190
|
+
if (openId) return Promise.resolve(openId)
|
|
191
|
+
|
|
192
|
+
const [ err , res ] = await toAwait(Vue.prototype.$u.get('/sys/user/getUserPublicOpenId'))
|
|
193
|
+
openId = await Vue.prototype.$async_encryption(res.result)
|
|
194
|
+
Vue.prototype._openId = openId
|
|
195
|
+
return openId
|
|
196
|
+
}
|
|
187
197
|
module.exports = {
|
|
188
198
|
formatTime: formatTime,
|
|
189
199
|
formatLocation: formatLocation,
|
|
@@ -191,5 +201,6 @@ module.exports = {
|
|
|
191
201
|
toAwait,
|
|
192
202
|
cloneObj: cloneObj,
|
|
193
203
|
_debounce:_debounce,
|
|
194
|
-
downloadFile
|
|
204
|
+
downloadFile,
|
|
205
|
+
getOpenId
|
|
195
206
|
}
|