Browse Source

add: 数字签名添加关闭数字签名和电子签名配置

liutian 3 tuần trước cách đây
mục cha
commit
773d1bd629

+ 7 - 3
packages/webview/src/components/Dialogs/SelectSignTypeDialog.vue

@@ -39,16 +39,20 @@ const useDocument = useDocumentStore()
 const dialogName = 'selectSignTypeDialog'
 const show = computed(() => useViewer.isElementOpen(dialogName))
 const activeTool = computed(() => useDocument.getActiveTool)
+const disableDigitalSignature = computed(() => useDocument.getDisableDigitalSignature)
+const disableElectronicSignature = computed(() => useDocument.getDisableElectronicSignature)
 
 const type = ref('electronic')
 
 const showDialog = (data) => {
   useViewer.setSelectedSignatureField(data)
-  if (activeTool.value === 'addDigitalSign') {
+  if (activeTool.value === 'addDigitalSign' || (!disableDigitalSignature.value && disableElectronicSignature.value)) {
     useViewer.openElement('addDigitalFileDialog')
+  } else if (activeTool.value === 'addElectronicSign' || (disableDigitalSignature.value && !disableElectronicSignature.value)) {
+    openSignCreatePanel()
+  } else {
+    useViewer.openElement('selectSignTypeDialog')
   }
-  else if (activeTool.value === 'addElectronicSign') openSignCreatePanel()
-  else useViewer.openElement('selectSignTypeDialog')
 }
 core.addEvent('openSelectSignTypeDialog', showDialog)
 

+ 3 - 1
packages/webview/src/components/Dialogs/SignatureAppearanceDialog.vue

@@ -125,6 +125,8 @@ const activeTool = computed(() => useDocument.getActiveTool)
 const preview = computed(() => useViewer.getDigitalSignaturePreview)
 const activeDigitalSignCreatePanel = computed(() => useViewer.isElementOpen('digitalSignCreatePanel'))
 const activeDigitalKeyboardCreatePanel = computed(() => useViewer.isElementOpen('digitalKeyboardCreatePanel'))
+const disableDigitalSignature = computed(() => useDocument.getDisableDigitalSignature)
+const disableElectronicSignature = computed(() => useDocument.getDisableElectronicSignature)
 const subject = computed(() => useViewer.getCertSubject)
 const uploadImageEl = ref(null)
 
@@ -281,7 +283,7 @@ const closePanel = (flag) => {
 
   document.body.style.overflow = ''
 
-  if (!activeTool.value && flag === 'cancel') useViewer.openElement('selectSignTypeDialog')
+  if (!activeTool.value && flag === 'cancel' && disableDigitalSignature.value && disableElectronicSignature.value) useViewer.openElement('selectSignTypeDialog')
   useViewer.setActiveSignWay('keyboard')
 
   Object.assign(configurations, {

+ 2 - 0
packages/webview/src/components/DocumentContainer/DocumentContainer.vue

@@ -274,6 +274,8 @@ window.instance.initOptions = async (options) => {
     useViewer.setUpload(false)
   }
   options.autoJumpNextSign && useDocument.setAutoJumpNextSign(true)
+  options.disableDigitalSignature && useDocument.setDisableDigitalSignature(options.disableDigitalSignature)
+  options.disableElectronicSignature && useDocument.setDisableElectronicSignature(options.disableElectronicSignature)
 
   core.addEvent('onPagesUpdated', (data) => {
     const { pageNumber } = data

+ 2 - 2
packages/webview/src/components/HeaderItems/HeaderItems.vue

@@ -165,7 +165,7 @@ let showToolMode = computed(()=>{
 
 const webviewerMode = computed(() => useViewer.getWebviewerMode)
 const activeTool = computed(() => useDocument.getActiveTool)
-const showDropdown = computed(() => popoverTool.value && popoverTool?.value[0].getMergedShow())
+const disableDigitalSignature = computed(() => useDocument.getDisableDigitalSignature)
 
 const changeToolMode = (mode) => {
   if (webviewerMode.value !== 'Standalone' && ['editor', 'document'].includes(mode)) {
@@ -173,7 +173,7 @@ const changeToolMode = (mode) => {
     else useViewer.openElement('docEditorPreventDialog')
     return
   }
-  if (mode === 'sign') {
+  if (mode === 'sign' && !disableDigitalSignature) {
     window.$message.info($t('signatures.tip'), {
       duration: 3000,
       showIcon: false

+ 5 - 3
packages/webview/src/components/SignatureToolBar/SignatureToolBar.vue

@@ -4,15 +4,15 @@
       <CreateSignField />
       <span>{{ $t('header.createSignField') }}</span>
     </Button>
-    <Button :class="{ active: activeTool === 'addDigitalSign' }" @click="changeActiveTool('addDigitalSign')" :title="$t('header.addDigitalSign')">
+    <Button v-if="!disableDigitalSignature" :class="{ active: activeTool === 'addDigitalSign' }" @click="changeActiveTool('addDigitalSign')" :title="$t('header.addDigitalSign')">
       <AddDigitalSign />
       <span>{{ $t('header.addDigitalSign') }}</span>
     </Button>
-    <Button :class="{ active: activeTool === 'addElectronicSign' }" @click="changeActiveTool('addElectronicSign')" :title="$t('header.addElectronicSign')">
+    <Button v-if="!disableElectronicSignature" :class="{ active: activeTool === 'addElectronicSign' }" @click="changeActiveTool('addElectronicSign')" :title="$t('header.addElectronicSign')">
       <AddElectronicSign />
       <span>{{ $t('header.addElectronicSign') }}</span>
     </Button>
-    <Button @click="verifyDigitalSign" :title="$t('header.verifyDigitalSign')" :disabled="!signatures.length">
+    <Button v-if="!disableDigitalSignature" @click="verifyDigitalSign" :title="$t('header.verifyDigitalSign')" :disabled="!signatures.length">
       <VerifyDigitalSign />
       <span>{{ $t('header.verifyDigitalSign') }}</span>
     </Button>
@@ -32,6 +32,8 @@
 
   const activeTool = computed(() => useDocument.getActiveTool)
   const signatures = computed(() => useDocument.getSignatures)
+const disableDigitalSignature = computed(() => useDocument.getDisableDigitalSignature)
+const disableElectronicSignature = computed(() => useDocument.getDisableElectronicSignature)
 
   const changeActiveTool = (tool) => {
     useDocument.setToolState(tool)

+ 3 - 1
packages/webview/src/components/Signatures/SignCreatePanel.vue

@@ -100,6 +100,8 @@ const show = computed(() => useViewer.isElementOpen('signCreatePanel'))
 const activeSignWay = computed(() => useViewer.getActiveElementTab('signPanel'))
 const toolMode = computed(() => useViewer.getToolMode)
 const activeTool = computed(() => useDocument.getActiveTool)
+const disableDigitalSignature = computed(() => useDocument.getDisableDigitalSignature)
+const disableElectronicSignature = computed(() => useDocument.getDisableElectronicSignature)
 
 const textSgin = ref('')
 const imageData = ref('')
@@ -184,7 +186,7 @@ const closePanel = (flag) => {
   clearProperty()
   document.body.style.overflow = ''
 
-  if (!activeTool.value && flag === 'cancel') useViewer.openElement('selectSignTypeDialog')
+  if (!activeTool.value && flag === 'cancel' && disableDigitalSignature.value && disableElectronicSignature.value) useViewer.openElement('selectSignTypeDialog')
 }
 
 const clearData = () => {

+ 14 - 0
packages/webview/src/stores/modules/document.js

@@ -159,6 +159,8 @@ export const useDocumentStore = defineStore({
     highlightForm: true,
     redactionPrompted: false, // redaction首次进入提示
     autoJumpNextSign: false,
+    disableDigitalSignature: false, // 允许数字签名
+    disableElectronicSignature: false // 允许电子签名
   }),
   getters: {
     getTotalPages () {
@@ -322,6 +324,12 @@ export const useDocumentStore = defineStore({
     getAutoJumpNextSign () {
       return this.autoJumpNextSign
     },
+    getDisableDigitalSignature() {
+      return this.disableDigitalSignature
+    },
+    getDisableElectronicSignature() {
+      return this.disableElectronicSignature
+    }
   },
   actions: {
     resetSetting () {
@@ -530,5 +538,11 @@ export const useDocumentStore = defineStore({
       this.autoJumpNextSign = val
       core.setAutoJumpNextSign(val)
     },
+    setDisableDigitalSignature (val) {
+      this.disableDigitalSignature = val
+    },
+    setDisableElectronicSignature (val) {
+      this.disableElectronicSignature = val
+    }
   }
 })