Explorar el Código

feat: adiciona actions para pagina de franchisee

ebagabee hace 2 semanas
padre
commit
f1071ae9fe

+ 18 - 4
src/components/defaults/DefaultTable.vue

@@ -77,14 +77,21 @@
 
     <template #body-cell-actions="{ row }">
       <q-td auto-width>
-        <q-item-section class="no-wrap" style="flex-direction: row">
+        <q-item-section class="no-wrap" style="flex-direction: row; gap: 4px">
           <slot name="body-cell-actions" :row="row" />
+          <q-btn
+            v-if="openItemRoute"
+            outline
+            icon="mdi-pencil-outline"
+            style="width: 36px"
+            @click.prevent.stop="router.push({ name: openItemRoute, params: { id: row.id } })"
+          />
           <q-btn
             v-if="deleteFunction"
             outline
             icon="mdi-trash-can-outline"
             style="width: 36px"
-            class="q-ml-auto q-mr-sm"
+            color="negative"
             @click.prevent.stop="onDelete(row.id)"
           />
         </q-item-section>
@@ -112,13 +119,20 @@
               </template>
               <template v-else>
                 <slot name="body-cell-actions" :row="row" />
-                <q-item-section v-if="deleteFunction">
+                <q-item-section v-if="openItemRoute || deleteFunction" style="flex-direction: row; gap: 4px">
+                  <q-btn
+                    v-if="openItemRoute"
+                    outline
+                    icon="mdi-pencil-outline"
+                    style="width: 36px"
+                    @click.prevent.stop="router.push({ name: openItemRoute, params: { id: row.id } })"
+                  />
                   <q-btn
                     v-if="deleteFunction"
                     outline
                     icon="mdi-trash-can-outline"
                     style="width: 36px"
-                    class="q-mr-sm"
+                    color="negative"
                     @click.prevent.stop="onDelete(row.id)"
                   />
                 </q-item-section>

+ 2 - 1
src/pages/franchisee/FranchiseePage.vue

@@ -12,6 +12,7 @@
         open-item
         open-item-route="UnitEditPage"
         :api-call="getUnits"
+        :delete-function="deleteUnit"
         add-item-route="UnitAddPage"
       />
     </div>
@@ -19,7 +20,7 @@
 </template>
 
 <script setup>
-import { getUnits } from "src/api/unit";
+import { getUnits, deleteUnit } from "src/api/unit";
 import DefaultTable from "src/components/defaults/DefaultTable.vue";
 import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
 import { ref } from "vue";

+ 6 - 2
src/pages/unit/tabs/UnitDataTab.vue

@@ -249,8 +249,12 @@ onMounted(async () => {
 
 const { loading, execute } = useSubmitHandler({
   formRef,
-  onSuccess: () => {
-    router.push({ name: "FranchiseePage" });
+  onSuccess: (result) => {
+    if (props.unitId) {
+      router.push({ name: "FranchiseePage" });
+    } else {
+      router.push({ name: "UnitEditPage", params: { id: result.id } });
+    }
   },
 });