Explorar el Código

add: 表单新增值改变事件

liutian hace 1 mes
padre
commit
eb7917db1f

+ 24 - 0
packages/core/src/form/check_box.js

@@ -520,6 +520,14 @@ export default class CheckBox extends Base {
         type: 'modify',
         annotation: annotation
       })
+
+      this.eventBus.dispatch('formFieldValuesChange', {
+        type: 'checkbox',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
+        pageNumber: this.page + 1,
+        isChecked: this.annotation.isChecked,
+      })
     }
   }
 
@@ -861,6 +869,14 @@ export default class CheckBox extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
+
+      'isChecked' in props && this.eventBus.dispatch('formFieldValuesChange', {
+        type: 'checkbox',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
+        pageNumber: this.page + 1,
+        isChecked: this.annotation.isChecked,
+      })
     }
   }
 
@@ -937,6 +953,14 @@ export default class CheckBox extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
+
+    'isChecked' in props && this.eventBus.dispatch('formFieldValuesChange', {
+      type: 'checkbox',
+      id: this.annotation.name,
+      fieldName: this.annotation.fieldName,
+      pageNumber: this.page + 1,
+      isChecked: this.annotation.isChecked,
+    })
   }
 
   judgeCheckboxIsOne (name) {

+ 16 - 0
packages/core/src/form/combo_box.js

@@ -970,6 +970,14 @@ export default class ComboBox extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
+
+      'selected' in props && this.eventBus.dispatch('formFieldValuesChange', {
+        type: 'combobox',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
+        pageNumber: this.page + 1,
+        selectedItem: this.annotation.items[props.selected].Value,
+      })
     }
   }
 
@@ -1039,6 +1047,14 @@ export default class ComboBox extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
+
+    'selected' in props && this.eventBus.dispatch('formFieldValuesChange', {
+      type: 'combobox',
+      id: this.annotation.name,
+      fieldName: this.annotation.fieldName,
+      pageNumber: this.page + 1,
+      selectedItem: this.annotation.items[props.selected].Value,
+    })
   }
 
   changeSelectAvailable () {

+ 16 - 0
packages/core/src/form/list_box.js

@@ -959,6 +959,14 @@ export default class ListBox extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
+
+      'selected' in props && this.eventBus.dispatch('formFieldValuesChange', {
+        type: 'combobox',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
+        pageNumber: this.page + 1,
+        selectedItem: this.annotation.items[props.selected].Value,
+      })
     }
   }
 
@@ -1028,6 +1036,14 @@ export default class ListBox extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
+
+    'selected' in props && this.eventBus.dispatch('formFieldValuesChange', {
+      type: 'combobox',
+      id: this.annotation.name,
+      fieldName: this.annotation.fieldName,
+      pageNumber: this.page + 1,
+      selectedItem: this.annotation.items[props.selected].Value,
+    })
   }
 
   changeSelectAvailable() {

+ 24 - 0
packages/core/src/form/radio_button.js

@@ -523,6 +523,14 @@ export default class RadioButton extends Base {
         type: 'modify',
         annotation: annotation
       })
+
+      this.eventBus.dispatch('formFieldValuesChange', {
+        type: 'radiobutton',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
+        pageNumber: this.page + 1,
+        isChecked: this.annotation.isChecked,
+      })
     }
   }
 
@@ -862,6 +870,14 @@ export default class RadioButton extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
+
+      'isChecked' in props && this.eventBus.dispatch('formFieldValuesChange', {
+        type: 'radiobutton',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
+        pageNumber: this.page + 1,
+        isChecked: this.annotation.isChecked,
+      })
     }
   }
 
@@ -941,6 +957,14 @@ export default class RadioButton extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
+
+    'isChecked' in props && this.eventBus.dispatch('formFieldValuesChange', {
+      type: 'radiobutton',
+      id: this.annotation.name,
+      fieldName: this.annotation.fieldName,
+      pageNumber: this.page + 1,
+      isChecked: this.annotation.isChecked,
+    })
   }
 
   cancelSameGroupButton () {

+ 6 - 0
packages/core/src/form/text_field.js

@@ -485,6 +485,8 @@ export default class TextField extends Base {
 
       this.eventBus.dispatch('formFieldValuesChange', {
         type: 'textfield',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
         pageNumber: this.page + 1,
         contents: this.annotation.contents,
       })
@@ -887,6 +889,8 @@ export default class TextField extends Base {
 
       'contents' in props && this.eventBus.dispatch('formFieldValuesChange', {
         type: 'textfield',
+        id: this.annotation.name,
+        fieldName: this.annotation.fieldName,
         pageNumber: this.page + 1,
         contents: this.annotation.contents,
       })
@@ -1092,6 +1096,8 @@ export default class TextField extends Base {
     })
     'contents' in props && this.eventBus.dispatch('formFieldValuesChange', {
       type: 'textfield',
+      id: this.annotation.name,
+      fieldName: this.annotation.fieldName,
       pageNumber: this.page + 1,
       contents: this.annotation.contents,
     })

+ 2 - 2
packages/core/src/worker/compdfkit_worker.js

@@ -269,13 +269,13 @@ class CPDFWorker {
       if (annotation.opacity) {
         setAnnotTransparency(annotation)
       }
-      if (annotation.contents && annotation.operate === 'mod-form') {
+      if ('contents' in annotation && annotation.operate === 'mod-form') {
         const result = setTextFieldContent(annotation)
         if (result) {
           return result
         }
       }
-      if (annotation.contents && annotation.operate === 'mod-annot') {
+      if ('contents' in annotation && annotation.operate === 'mod-annot') {
         setAnnotContent(annotation)
       }
       if (annotation.linePoints) {

+ 2 - 2
packages/core/webviewer.js

@@ -95,10 +95,10 @@ class Viewer {
     this.iframe = iframe
     this.options?.backgroundColor && iframe.setAttribute("data-bgcolor", this.options.backgroundColor),
     this.options?.assetPath && iframe.setAttribute("data-assetpath", encodeURIComponent(this.options.assetPath)),
-    this.loadListener = function() {
+    this.loadListener = async function() {
       var $iframe = self.iframe;
       self.instance = $iframe.contentWindow.instance;
-      self.instance.initOptions(self.options)
+      await self.instance.initOptions(self.options)
       self._trigger("ready");
     },
     iframe.addEventListener("load", this.loadListener),

+ 1 - 0
packages/webview/src/components/RightPanel/RightPanel.vue

@@ -361,6 +361,7 @@
 
   const updateProperty = (props) => {
     editItem.value = ''
+    isOneCheckbox.value = true
 
     if (!props) {
       selectedElement.value = null