Explorar o código

fix: beforeSave may not define issue

0xJacky %!s(int64=2) %!d(string=hai) anos
pai
achega
a19878aaeb
Modificáronse 1 ficheiros con 22 adicións e 22 borrados
  1. 22 22
      frontend/src/components/StdDataDisplay/StdCurd.vue

+ 22 - 22
frontend/src/components/StdDataDisplay/StdCurd.vue

@@ -93,7 +93,7 @@ function clear_error() {
 
 const ok = async () => {
     clear_error()
-    await props.beforeSave(data)
+    await props?.beforeSave?.(data)
     props.api!.save(data.id, data).then((r: any) => {
         message.success($gettext('Save Successfully'))
         Object.assign(data, r)
@@ -131,13 +131,13 @@ function edit(id: any) {
             </template>
 
             <std-table
-                    ref="table"
-                    v-bind="props"
-                    @clickEdit="edit"
-                    @selected="onSelect"
-                    :key="update"
-                    :get_params="get_params"
-                    :exportCsv="exportCsv"
+                ref="table"
+                v-bind="props"
+                @clickEdit="edit"
+                @selected="onSelect"
+                :key="update"
+                :get_params="get_params"
+                :exportCsv="exportCsv"
             >
                 <template v-slot:actions="slotProps">
                     <slot name="actions" :actions="slotProps.record"/>
@@ -146,22 +146,22 @@ function edit(id: any) {
         </a-card>
 
         <a-modal
-                class="std-curd-edit-modal"
-                :mask="false"
-                :title="data.id ? $gettext('Modify') : $gettext('Add')"
-                :visible="visible"
-                :cancel-text="$gettext('Cancel')"
-                :ok-text="$gettext('OK')"
-                @cancel="cancel"
-                @ok="ok"
-                :width="600"
-                destroyOnClose
+            class="std-curd-edit-modal"
+            :mask="false"
+            :title="data.id ? $gettext('Modify') : $gettext('Add')"
+            :visible="visible"
+            :cancel-text="$gettext('Cancel')"
+            :ok-text="$gettext('OK')"
+            @cancel="cancel"
+            @ok="ok"
+            :width="600"
+            destroyOnClose
         >
             <std-data-entry
-                    ref="std_data_entry"
-                    :data-list="editableColumns()"
-                    v-model:data-source="data"
-                    :error="error"
+                ref="std_data_entry"
+                :data-list="editableColumns()"
+                v-model:data-source="data"
+                :error="error"
             />
             <slot name="edit" :data="data"/>
         </a-modal>