Bladeren bron

add: 表单新增值改变事件

liutian 3 maanden geleden
bovenliggende
commit
eb7917db1f

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

@@ -520,6 +520,14 @@ export default class CheckBox extends Base {
         type: 'modify',
         type: 'modify',
         annotation: annotation
         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',
         type: 'modify',
         annotation: updateAnnot
         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',
       type: 'modify',
       annotation: updateAnnot
       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) {
   judgeCheckboxIsOne (name) {

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

@@ -970,6 +970,14 @@ export default class ComboBox extends Base {
         type: 'modify',
         type: 'modify',
         annotation: updateAnnot
         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',
       type: 'modify',
       annotation: updateAnnot
       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 () {
   changeSelectAvailable () {

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

@@ -959,6 +959,14 @@ export default class ListBox extends Base {
         type: 'modify',
         type: 'modify',
         annotation: updateAnnot
         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',
       type: 'modify',
       annotation: updateAnnot
       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() {
   changeSelectAvailable() {

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

@@ -523,6 +523,14 @@ export default class RadioButton extends Base {
         type: 'modify',
         type: 'modify',
         annotation: annotation
         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',
         type: 'modify',
         annotation: updateAnnot
         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',
       type: 'modify',
       annotation: updateAnnot
       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 () {
   cancelSameGroupButton () {

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

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

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

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

+ 2 - 2
packages/core/webviewer.js

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

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

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