我的签字自动回显
This commit is contained in:
@@ -44,6 +44,10 @@ module.exports = {
|
|||||||
value: {
|
value: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
this.signatureContent = val
|
this.signatureContent = val
|
||||||
|
// 父页面异步初始化后仍未提供签名时,统一回显当前用户在“我的签名”中保存的签名。
|
||||||
|
if (!val) {
|
||||||
|
this.loadUserSignature()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
@@ -51,12 +55,51 @@ module.exports = {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
signatureContent: null,
|
signatureContent: null,
|
||||||
|
userSignatureContent: "",
|
||||||
|
userSignatureLoaded: false,
|
||||||
|
userSignatureLoading: false,
|
||||||
showSignaturePanel: false,
|
showSignaturePanel: false,
|
||||||
historyLayerName: "",
|
historyLayerName: "",
|
||||||
historyLayerUnsubscribe: null
|
historyLayerUnsubscribe: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* 读取当前登录用户在“我的签名”中保存的签名。
|
||||||
|
* 无请求参数;接口返回用户签名记录,组件仅在当前 v-model 为空时回填签名 URL。
|
||||||
|
*/
|
||||||
|
loadUserSignature() {
|
||||||
|
if (this.value) return
|
||||||
|
if (this.userSignatureLoaded) {
|
||||||
|
this.applyUserSignature()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.userSignatureLoading) return
|
||||||
|
|
||||||
|
this.userSignatureLoading = true
|
||||||
|
this.$axios.post("/platform/signature/get")
|
||||||
|
.then((res) => {
|
||||||
|
const signatureData = res.code === 0 ? (res.data || {}) : {}
|
||||||
|
this.userSignatureContent = signatureData.signature || ""
|
||||||
|
this.userSignatureLoaded = true
|
||||||
|
this.applyUserSignature()
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// 默认签名读取失败时保留空状态,用户仍可进入签字板完成本次签名。
|
||||||
|
this.userSignatureLoaded = true
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.userSignatureLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 仅为空值补充默认签名,避免覆盖历史业务签名或用户刚完成的现场签名。
|
||||||
|
applyUserSignature() {
|
||||||
|
if (this.value || !this.userSignatureContent) return
|
||||||
|
this.signatureContent = this.userSignatureContent
|
||||||
|
this.$emit("input", this.userSignatureContent)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开签字板。
|
* 打开签字板。
|
||||||
* 无请求参数;优先向全局历史栈增加当前签字弹层,返回值为空。
|
* 无请求参数;优先向全局历史栈增加当前签字弹层,返回值为空。
|
||||||
|
|||||||
Reference in New Issue
Block a user