Просмотр исходного кода

feat: enhance CitySelect and StateSelect components to check for label presence in selection logic; add item handling in ContractsPage

alvesantos 5 дней назад
Родитель
Сommit
7c0649c48b

+ 1 - 1
src/components/selects/CitySelect.vue

@@ -145,7 +145,7 @@ const filterFn = (value, update) => {
 };
 
 const selectCityById = (id) => {
-  if (selectedCity.value?.value === id) {
+  if (selectedCity.value?.value === id && selectedCity.value?.label) {
     return;
   }
 

+ 1 - 1
src/components/selects/StateSelect.vue

@@ -143,7 +143,7 @@ const selectStateByCode = (code) => {
 };
 
 const selectStateById = (id) => {
-  if (selectedState.value?.value === id) {
+  if (selectedState.value?.value === id && selectedState.value?.label) {
     return;
   }
 

+ 15 - 0
src/pages/contracts/ContractsPage.vue

@@ -42,9 +42,11 @@
         descricao="contratos"
         no-api-call
         title="Contratos"
+        :add-item="canAdd"
         :columns
         :feminino="false"
         :loading="isLoading"
+        @on-add-item="handleAdd"
       >
         <template #body-cell-contato="{ row }">
           <q-td>
@@ -277,6 +279,10 @@ const signedFileInputRef = ref(null);
 const uploadingSignedId = ref(null);
 const rows = ref([]);
 
+const canAdd = computed(() =>
+  permissions.getAccess("franchisee_contracts", "add"),
+);
+
 const canEdit = computed(() =>
   permissions.getAccess("franchisee_contracts", "edit"),
 );
@@ -361,6 +367,15 @@ const handleCancel = (contract) => {
   );
 };
 
+const handleAdd = () => {
+  $q.dialog({
+    component: AddEditContractDialog,
+    componentProps: {
+      selectStudent: true,
+    },
+  }).onOk(loadContracts);
+};
+
 const handleEdit = (contract) => {
   $q.dialog({
     component: AddEditContractDialog,