You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

279 lines
8.4 KiB

3 years ago
import { Notification } from 'element-ui'
var plugin = null // 放在外面,解决销毁不掉的问题
export default {
state: {
// 返回的图片地址
doctorSignImg: '', // 主刀医生图片
index: 0, // 控制usb弹框提示执行次数
plugin: null,
2 years ago
type: 1, // 1 验光师 2 医生 3 配戴者 4 监护人
3 years ago
// 签名按钮是否显示
2 years ago
// optomFlag: true,
// wearerFlag: true,
// guardianFlag: true,
// readFlag: true,
// lensFlag: true,
// wearerOrGuardianFlag: true,
3 years ago
// 返回的图片地址
2 years ago
optomSign: '',
3 years ago
doctorSign: '',
patientSign: '',
guardianSign: '',
2 years ago
optomSign2: '',
doctorSign2: '',
patientSign2: '',
guardianSign2: '',
operator: '',
informedDocSign: '',
informPatientSign: '',
2 years ago
checkSign: '',
fundusDocSign: '',
kinSign: '',
performerSign: '',
2 years ago
checkerSign: '',
minorPatientSign: '',
minorKinSign: ''
3 years ago
},
getters: {
doctorSignImg: state => state.doctorSignImg,
2 years ago
optomSign: state => state.optomSign,
3 years ago
doctorSign: state => state.doctorSign,
patientSign: state => state.patientSign,
guardianSign: state => state.guardianSign,
2 years ago
optomSign2: state => state.optomSign2,
doctorSign2: state => state.doctorSign2,
patientSign2: state => state.patientSign2,
guardianSign2: state => state.guardianSign2,
operator: state => state.operator,
informedDocSign: state => state.informedDocSign,
informPatientSign: state => state.informPatientSign,
2 years ago
checkSign: state => state.checkSign,
2 years ago
fundusDocSign: state => state.fundusDocSign,
kinSign: state => state.kinSign,
performerSign: state => state.performerSign,
2 years ago
checkerSign: state => state.checkerSign,
minorPatientSign: state => state.minorPatientSign,
minorKinSign: state => state.minorKinSign
3 years ago
},
mutations: {
// 销毁签字笔
destroyPlugin(state) {
if (plugin) {
plugin.DestroyPlugin()
}
},
initPlugin(state) {
state.index++
// console.log(state.index)
if (plugin) {
console.log('--------3333-------')
plugin.DestroyPlugin()
}
plugin = new PluginNSV()
plugin.InitPlugin((item) => {
if (item === 1) {
// set pen size
plugin.setPenSizeRange(1, 5, null)
// set pen color
plugin.setPenColor(0, 0, 0, null)
plugin.setDisplayMapMode(1, 0, 0, null)
this.commit('checkDevice')
console.log('succeeded')
} else {
console.log('fails')
}
})
/* confirm event*/
plugin.onConfirm = () => {
this.commit('saveSignToBase64')
this.commit('endSign')
plugin.mouseControl(false, null)
}
// /*clear event*/
plugin.onClear = () => {
this.commit('clearSign')
}
/* cancel event*/
plugin.onCancel = () => {
this.commit('endSign')
}
// 监听插件连接服务的状态
plugin.onStateChange = (item) => {}
// if (state.index === 1) {
// 设备是否连接--use是否插上
plugin.onDevNotifyEvent = (item) => {
if (item === 1) {
Notification.success({
title: '成功',
message: '签字笔已插入',
showClose: false,
duration: 800
})
} else {
Notification.error({
title: '提示',
message: '签字笔已拔出',
showClose: false,
duration: 800
})
}
}
},
checkDevice(state) {
if (plugin) {
plugin.isConnected((item, args) => {
if (item) {
var ret = parseInt(args[0])
if (ret === 1) {
2 years ago
Notification.success({
title: 'Info',
message: '设备已连接',
showClose: false
})
3 years ago
} else {
2 years ago
Notification.success({
title: 'Info',
message: '设备未连接',
showClose: false
})
3 years ago
}
} else {
alert('isConnected error,description:' + args[0])
}
})
}
},
2 years ago
beginSign(state, index) {
state.type = index
3 years ago
if (plugin) {
plugin.beginSign((item, args) => {})
}
// document.getElementById('img_sign_result').src = '';
},
clearSign(state, val) {
if (plugin) {
plugin.clearSign((item, args) => {})
}
// Reset the image.
state.doctorSignImg = ''
},
endSign(state) {
if (plugin) {
/* plugin.endSign(null);*/
plugin.endSign((item, args) => {})
}
},
saveSignToBase64(state) {
if (plugin) {
// Get the plugin's signature image data.
plugin.saveSignToBase64(/* 615, 272*/0, 0, (item, args) => {
if (item) {
// console.log(args)
const img_base64_data = args[0]
// console.log(img_base64_data)
const img_base64 = 'data:image/png;base64,' + img_base64_data
2 years ago
// state.doctorSignImg = img_base64
if (state.type === 1) {
this.commit('optomSign', img_base64)
} else if (state.type === 2) {
this.commit('doctorSign', img_base64)
} else if (state.type === 3) {
this.commit('patientSign', img_base64)
} else if (state.type === 4) {
this.commit('guardianSign', img_base64)
} else if (state.type === 5) {
this.commit('optomSign2', img_base64)
} else if (state.type === 6) {
this.commit('doctorSign2', img_base64)
} else if (state.type === 7) {
this.commit('patientSign2', img_base64)
} else if (state.type === 8) {
this.commit('guardianSign2', img_base64)
} else if (state.type === 9) {
this.commit('operator', img_base64)
} else if (state.type === 10) {
this.commit('informedDocSign', img_base64)
} else if (state.type === 11) {
this.commit('informPatientSign', img_base64)
2 years ago
} else if (state.type === 12) {
this.commit('fundusDocSign', img_base64)
} else if (state.type === 13) {
this.commit('kinSign', img_base64)
} else if (state.type === 14) {
this.commit('performerSign', img_base64)
} else if (state.type === 15) {
this.commit('checkerSign', img_base64)
2 years ago
} else if (state.type === 16) {
this.commit('checkSign', img_base64)
2 years ago
} else if (state.type === 17) {
this.commit('minorPatientSign', img_base64)
} else if (state.type === 18) {
this.commit('minorKinSign', img_base64)
2 years ago
}
3 years ago
} else {
// debugPrint("saveSignToBase64 error,description:" + args[0]);
}
})
}
},
doctorSignImg(state, val) {
state.doctorSignImg = val
},
2 years ago
optomSign(state, val) {
state.optomSign = val
3 years ago
},
doctorSign(state, val) {
state.doctorSign = val
},
patientSign(state, val) {
state.patientSign = val
},
guardianSign(state, val) {
state.guardianSign = val
},
2 years ago
optomSign2(state, val) {
state.optomSign2 = val
3 years ago
},
2 years ago
doctorSign2(state, val) {
state.doctorSign2 = val
3 years ago
},
2 years ago
patientSign2(state, val) {
state.patientSign2 = val
3 years ago
},
2 years ago
guardianSign2(state, val) {
state.guardianSign2 = val
3 years ago
},
operator(state, val) {
state.operator = val
},
informedDocSign(state, val) {
state.informedDocSign = val
},
informPatientSign(state, val) {
state.informPatientSign = val
},
2 years ago
checkSign(state, val) {
state.checkSign = val
2 years ago
},
fundusDocSign(state, val) {
state.fundusDocSign = val
},
kinSign(state, val) {
state.kinSign = val
},
performerSign(state, val) {
state.performerSign = val
},
checkerSign(state, val) {
state.checkerSign = val
2 years ago
},
minorPatientSign(state, val) {
state.minorPatientSign = val
},
minorKinSign(state, val) {
state.minorKinSign = val
}
3 years ago
}
}