18 changed files with 426 additions and 404 deletions
@ -0,0 +1,121 @@ |
|||
import { Notification } from 'element-ui' |
|||
import emptySign from '@static/js/emptySign' |
|||
export default { |
|||
data() { |
|||
return { |
|||
plugin: null, |
|||
optomFlag: true, |
|||
wearerFlag: true, |
|||
guardianFlag: true, |
|||
readFlag: true, |
|||
currentSignText: '' |
|||
} |
|||
}, |
|||
methods: { |
|||
// 销毁签字笔
|
|||
destroyPlugin(state) { |
|||
console.log(this.plugin) |
|||
if (this.plugin) { |
|||
console.log('--------3333-------') |
|||
this.plugin.DestroyPlugin() |
|||
} |
|||
}, |
|||
initPlugin(text) { |
|||
// console.log(JSON.parse(window.sessionStorage.getItem('signPlugin')))
|
|||
// if (this.plugin) {
|
|||
// this.plugin.DestroyPlugin()
|
|||
// }
|
|||
this.plugin = new PluginNSV() |
|||
// window.sessionStorage.setItem('signPlugin', JSON.stringify(this.plugin))
|
|||
const that = this |
|||
console.log('plugin', this.plugin) |
|||
this.plugin.InitPlugin(function(state) { |
|||
if (state === 1) { |
|||
// set pen size
|
|||
that.plugin.setPenSizeRange(1, 5, null) |
|||
// set pen color
|
|||
that.plugin.setPenColor(0, 0, 0, null) |
|||
that.plugin.setDisplayMapMode(1, 0, 0, null) |
|||
console.log('succeeded') |
|||
that.beginSign(text) |
|||
} else { |
|||
console.log('fails') |
|||
} |
|||
}) |
|||
|
|||
/* confirm event*/ |
|||
this.plugin.onConfirm = function() { |
|||
that.saveSignToBase64() |
|||
that.endSign() |
|||
} |
|||
// /*clear event*/
|
|||
this.plugin.onClear = function() { |
|||
this.clearSign() |
|||
} |
|||
/* cancel event*/ |
|||
this.plugin.onCancel = function() { |
|||
this.endSign() |
|||
} |
|||
this.plugin.onStateChange = function(state) {} |
|||
|
|||
this.plugin.onDevNotifyEvent = function(state) { |
|||
if (state === 1) { |
|||
Notification.success({ |
|||
title: '成功', |
|||
message: '签字笔已插入', |
|||
showClose: false, |
|||
duration: 800 |
|||
}) |
|||
} else { |
|||
Notification.error({ |
|||
title: '提示', |
|||
message: '签字笔已拔出', |
|||
showClose: false, |
|||
duration: 800 |
|||
}) |
|||
} |
|||
} |
|||
}, |
|||
beginSign(text) { |
|||
const that = this |
|||
that.currentSignText = text |
|||
console.log(that.plugin) |
|||
if (this.plugin) { |
|||
console.log(123) |
|||
this.plugin.beginSign(function(state, args) { |
|||
}) |
|||
} |
|||
// document.getElementById('img_sign_result').src = '';
|
|||
}, |
|||
clearSign() { |
|||
if (this.plugin) { |
|||
this.plugin.clearSign(function(state, args) {}) |
|||
} |
|||
}, |
|||
endSign() { |
|||
if (this.plugin) { |
|||
/* plugin.endSign(null);*/ |
|||
this.plugin.endSign(function(state, args) {}) |
|||
} |
|||
}, |
|||
saveSignToBase64() { |
|||
if (this.plugin) { |
|||
// Get the plugin's signature image data.
|
|||
this.plugin.saveSignToBase64(/* 615, 272*/0, 0, (state, args) => { |
|||
if (state) { |
|||
const img_base64_data = args[0] |
|||
const img_base64 = 'data:image/png;base64,' + img_base64_data |
|||
this.formListValue[this.currentSignText] = img_base64 |
|||
if (this.formListValue[this.currentSignText] === emptySign) { |
|||
this.$message.error('签字未成功请重新签字') |
|||
} |
|||
this.destroyPlugin() |
|||
} else { |
|||
// debugPrint("saveSignToBase64 error,description:" + args[0]);
|
|||
} |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue