DashboardPage.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <template>
  2. <div>
  3. <DefaultHeaderPage />
  4. <div v-if="!isLoading" class="q-pa-md">
  5. <!-- Tabs Principais: Agendamentos / Oportunidades -->
  6. <q-tabs
  7. v-model="scheduleType"
  8. dense
  9. class="text-grey"
  10. active-color="primary"
  11. indicator-color="primary"
  12. align="justify"
  13. narrow-indicator
  14. >
  15. <q-tab name="default" :label="$t('ui.navigation.schedules')" icon="event" />
  16. <q-tab name="custom" :label="$t('ui.navigation.opportunities')" icon="mdi-bullseye-arrow" />
  17. </q-tabs>
  18. <q-separator />
  19. <q-tab-panels v-model="scheduleType" animated>
  20. <!-- AGENDAMENTOS (Default) -->
  21. <q-tab-panel name="default">
  22. <q-tabs
  23. v-model="viewMode"
  24. dense
  25. class="text-grey"
  26. active-color="secondary"
  27. indicator-color="secondary"
  28. align="left"
  29. >
  30. <q-tab name="client" :label="$t('schedules.view_as_client')" icon="person" />
  31. <q-tab name="provider" :label="$t('schedules.view_as_provider')" icon="work" />
  32. </q-tabs>
  33. <q-separator />
  34. <q-tab-panels v-model="viewMode" animated>
  35. <!-- Visão Cliente -->
  36. <q-tab-panel name="client">
  37. <div class="row q-col-gutter-md">
  38. <div class="col-12">
  39. <q-select
  40. v-model="statusFilter"
  41. :options="statusFilterOptions"
  42. :label="$t('schedules.filter_by_status')"
  43. outlined
  44. dense
  45. emit-value
  46. map-options
  47. clearable
  48. class="q-mb-md"
  49. style="max-width: 300px"
  50. />
  51. </div>
  52. <div class="col-12">
  53. <q-expansion-item
  54. v-for="clientGroup in filteredGroupedDefaultSchedules"
  55. :key="clientGroup.client_id"
  56. :label="clientGroup.client_name"
  57. icon="person"
  58. header-class="text-white gradient-diarista-bg"
  59. expand-icon-class="text-white"
  60. class="q-mb-md shadow-2"
  61. default-opened
  62. >
  63. <q-card>
  64. <q-card-section>
  65. <q-list bordered separator>
  66. <q-item
  67. v-for="schedule in clientGroup.schedules"
  68. :key="schedule.id"
  69. clickable
  70. @click="openScheduleDialog(schedule)"
  71. >
  72. <div class="q-my-auto q-pr-md" style="width: 30px">
  73. {{ schedule.id }}
  74. </div>
  75. <q-item-section avatar>
  76. <q-badge :color="getStatusColor(schedule.status)" class="q-pa-sm">
  77. {{ $t(`schedules.statuses.${schedule.status}`) }}
  78. </q-badge>
  79. </q-item-section>
  80. <q-item-section>
  81. <q-item-label>
  82. <q-icon name="event" size="xs" class="q-mr-xs" color="info"/>
  83. <span class="gradient-diarista">
  84. {{ schedule.date }} {{ schedule.start_time?.substring(0, 5) }}
  85. </span>
  86. </q-item-label>
  87. <q-item-label caption>
  88. <q-icon name="person" size="xs" class="q-mr-xs" color="info"/>
  89. <span class="gradient-diarista">
  90. {{ schedule.provider_name }}
  91. </span>
  92. </q-item-label>
  93. </q-item-section>
  94. <q-item-section side>
  95. <q-item-label>
  96. {{ schedule.period_type }} {{ $t('schedules.hours') }}
  97. </q-item-label>
  98. <q-item-label caption class="text-positive text-weight-bold">
  99. {{ formatCurrency(schedule.total_amount) }}
  100. </q-item-label>
  101. </q-item-section>
  102. <q-item-section side>
  103. <q-icon name="chevron_right" />
  104. </q-item-section>
  105. </q-item>
  106. </q-list>
  107. </q-card-section>
  108. </q-card>
  109. </q-expansion-item>
  110. <div v-if="filteredGroupedDefaultSchedules.length === 0" class="text-center q-pa-xl">
  111. <q-icon name="event_busy" size="64px" color="grey-5" />
  112. <div class="text-h6 text-grey-7 q-mt-md">
  113. {{ $t('schedules.empty_state') }}
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </q-tab-panel>
  119. <!-- Visão Prestador -->
  120. <q-tab-panel name="provider">
  121. <div class="row q-col-gutter-md">
  122. <div class="col-12">
  123. <q-select
  124. v-model="statusFilter"
  125. :options="statusFilterOptions"
  126. :label="$t('schedules.filter_by_status')"
  127. outlined
  128. dense
  129. emit-value
  130. map-options
  131. clearable
  132. class="q-mb-md"
  133. style="max-width: 300px"
  134. />
  135. </div>
  136. <div class="col-12">
  137. <q-expansion-item
  138. v-for="clientGroup in filteredGroupedDefaultSchedules"
  139. :key="clientGroup.client_id"
  140. :label="clientGroup.client_name"
  141. icon="person"
  142. header-class="text-white gradient-diarista-bg"
  143. expand-icon-class="text-white"
  144. class="q-mb-md shadow-2 rounded-borders"
  145. default-opened
  146. >
  147. <q-card>
  148. <q-card-section>
  149. <q-list bordered separator>
  150. <q-item
  151. v-for="schedule in clientGroup.schedules"
  152. :key="schedule.id"
  153. clickable
  154. @click="openScheduleDialog(schedule)"
  155. >
  156. <div class="q-my-auto q-pr-md" style="width: 30px">
  157. {{ schedule.id }}
  158. </div>
  159. <q-item-section avatar>
  160. <q-badge :color="getStatusColor(schedule.status)" class="q-pa-sm">
  161. {{ $t(`schedules.statuses.${schedule.status}`) }}
  162. </q-badge>
  163. </q-item-section>
  164. <q-item-section>
  165. <q-item-label>
  166. <q-icon name="event" size="xs" class="q-mr-xs" color="info"/>
  167. <span class="gradient-diarista">
  168. {{ schedule.date }} {{ schedule.start_time?.substring(0, 5) }}
  169. </span>
  170. </q-item-label>
  171. <q-item-label caption>
  172. <q-icon name="person" size="xs" class="q-mr-xs" color="info"/>
  173. <span class="gradient-diarista">
  174. {{ schedule.provider_name }}
  175. </span>
  176. </q-item-label>
  177. </q-item-section>
  178. <q-item-section side>
  179. <q-item-label>
  180. {{ schedule.period_type }} {{ $t('schedules.hours') }}
  181. </q-item-label>
  182. <q-item-label caption class="text-positive text-weight-bold">
  183. {{ formatCurrency(schedule.total_amount) }}
  184. </q-item-label>
  185. </q-item-section>
  186. <q-item-section side>
  187. <q-icon name="chevron_right" />
  188. </q-item-section>
  189. </q-item>
  190. </q-list>
  191. </q-card-section>
  192. </q-card>
  193. </q-expansion-item>
  194. <div v-if="filteredGroupedDefaultSchedules.length === 0" class="text-center q-pa-xl">
  195. <q-icon name="event_busy" size="64px" color="grey-5" />
  196. <div class="text-h6 text-grey-7 q-mt-md">
  197. {{ $t('schedules.empty_state') }}
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </q-tab-panel>
  203. </q-tab-panels>
  204. </q-tab-panel>
  205. <q-tab-panel name="custom">
  206. <q-tabs
  207. v-model="viewMode"
  208. dense
  209. class="text-grey"
  210. active-color="secondary"
  211. indicator-color="secondary"
  212. align="left"
  213. >
  214. <q-tab name="client" :label="$t('schedules.view_as_client')" icon="person" />
  215. <q-tab name="provider" :label="$t('schedules.view_as_provider')" icon="work" />
  216. </q-tabs>
  217. <q-separator />
  218. <q-tab-panels v-model="viewMode" animated>
  219. <!-- Visão Cliente -->
  220. <q-tab-panel name="client">
  221. <div class="row q-col-gutter-md">
  222. <div class="col-12">
  223. <q-select
  224. v-model="statusFilter"
  225. :options="statusFilterOptions"
  226. :label="$t('schedules.filter_by_status')"
  227. outlined
  228. dense
  229. emit-value
  230. map-options
  231. clearable
  232. class="q-mb-md"
  233. style="max-width: 300px"
  234. />
  235. </div>
  236. <div class="col-12">
  237. <q-expansion-item
  238. v-for="clientGroup in filteredGroupedCustomSchedules"
  239. :key="clientGroup.client_id"
  240. :label="clientGroup.client_name"
  241. icon="person"
  242. header-class="text-white gradient-diarista-bg"
  243. expand-icon-class="text-white"
  244. class="q-mb-md shadow-2 rounded-borders"
  245. default-opened
  246. >
  247. <q-card>
  248. <q-card-section>
  249. <q-list bordered separator>
  250. <q-item
  251. v-for="schedule in clientGroup.schedules"
  252. :key="schedule.id"
  253. clickable
  254. @click="openCustomScheduleDialog(schedule)"
  255. >
  256. <div class="q-my-auto q-pr-md" style="width: 30px">
  257. {{ schedule.id }}
  258. </div>
  259. <q-item-section avatar>
  260. <q-badge :color="getStatusColor(schedule.status)" class="q-pa-sm">
  261. {{ $t(`schedules.statuses.${schedule.status}`) }}
  262. </q-badge>
  263. </q-item-section>
  264. <q-item-section>
  265. <q-item-label>
  266. <q-icon name="event" size="xs" class="q-mr-xs" color="info"/>
  267. <span class="gradient-diarista">
  268. {{ schedule.date }} {{ schedule.start_time?.substring(0, 5) }}
  269. </span>
  270. </q-item-label>
  271. <q-item-label caption>
  272. <q-icon name="person" size="xs" class="q-mr-xs" color="info"/>
  273. <span class="gradient-diarista">
  274. {{ schedule.provider_name || 'N/A' }}
  275. </span>
  276. </q-item-label>
  277. </q-item-section>
  278. <q-item-section side>
  279. <q-item-label>
  280. {{ schedule.period_type }} {{ $t('schedules.hours') }}
  281. </q-item-label>
  282. <q-item-label caption class="text-positive text-weight-bold">
  283. {{ formatCurrency(schedule.total_amount) }}
  284. </q-item-label>
  285. </q-item-section>
  286. <q-item-section side>
  287. <q-icon name="chevron_right" />
  288. </q-item-section>
  289. </q-item>
  290. </q-list>
  291. </q-card-section>
  292. </q-card>
  293. </q-expansion-item>
  294. <div v-if="filteredGroupedCustomSchedules.length === 0" class="text-center q-pa-xl">
  295. <q-icon name="event_busy" size="64px" color="grey-5" />
  296. <div class="text-h6 text-grey-7 q-mt-md">
  297. {{ $t('opportunities.empty_state') }}
  298. </div>
  299. </div>
  300. </div>
  301. </div>
  302. </q-tab-panel>
  303. <!-- Visão Prestador -->
  304. <q-tab-panel name="provider">
  305. <div class="row q-col-gutter-md">
  306. <div class="col-12 row q-gutter-md">
  307. <q-select
  308. v-model="statusFilter"
  309. :options="statusFilterOptions"
  310. :label="$t('schedules.filter_by_status')"
  311. outlined
  312. dense
  313. emit-value
  314. map-options
  315. clearable
  316. style="max-width: 300px"
  317. class="col-3"
  318. />
  319. <div class="col-3">
  320. <ProviderSelect
  321. v-model="selectedProvider"
  322. :label="$t('common.terms.user')"
  323. dense
  324. />
  325. </div>
  326. </div>
  327. <div class="col-12">
  328. <q-expansion-item
  329. v-for="clientGroup in filteredGroupedCustomSchedules"
  330. :key="clientGroup.client_id"
  331. :label="clientGroup.client_name"
  332. icon="person"
  333. header-class="text-white gradient-diarista-bg"
  334. expand-icon-class="text-white"
  335. class="q-mb-md shadow-2 rounded-borders"
  336. default-opened
  337. >
  338. <q-card>
  339. <q-card-section>
  340. <q-list bordered separator>
  341. <q-item
  342. v-for="schedule in clientGroup.schedules"
  343. :key="schedule.id"
  344. clickable
  345. @click="openCustomScheduleDialog(schedule)"
  346. >
  347. <div class="q-my-auto q-pr-md" style="width: 30px">
  348. {{ schedule.id }}
  349. </div>
  350. <q-item-section avatar>
  351. <q-badge :color="getStatusColor(schedule.status)" class="q-pa-sm">
  352. {{ $t(`schedules.statuses.${schedule.status}`) }}
  353. </q-badge>
  354. </q-item-section>
  355. <q-item-section>
  356. <q-item-label>
  357. <q-icon name="event" size="xs" class="q-mr-xs" color="info"/>
  358. <span class="gradient-diarista">
  359. {{ schedule.date }} {{ schedule.start_time?.substring(0, 5) }}
  360. </span>
  361. </q-item-label>
  362. <q-item-label caption>
  363. <q-icon name="person" size="xs" class="q-mr-xs" color="info"/>
  364. <span class="gradient-diarista">
  365. {{ schedule.provider_name || 'N/A' }}
  366. </span>
  367. </q-item-label>
  368. </q-item-section>
  369. <q-item-section side>
  370. <q-item-label>
  371. {{ schedule.period_type }} {{ $t('schedules.hours') }}
  372. </q-item-label>
  373. <q-item-label caption class="text-positive text-weight-bold">
  374. {{ formatCurrency(schedule.total_amount) }}
  375. </q-item-label>
  376. </q-item-section>
  377. <q-item-section side>
  378. <q-icon name="chevron_right" />
  379. </q-item-section>
  380. </q-item>
  381. </q-list>
  382. </q-card-section>
  383. </q-card>
  384. </q-expansion-item>
  385. <div v-if="selectedProvider && providerProposals.length > 0" class="q-mt-xl">
  386. <div class="text-h6 q-mb-md">{{ $t('opportunities.my_proposals') }}</div>
  387. <DefaultTable
  388. :rows="providerProposals"
  389. :columns="proposalColumns"
  390. row-key="id"
  391. flat
  392. bordered
  393. :rows-per-page-options="[10, 20, 50]"
  394. class="sticky-header-table"
  395. no-api-call
  396. :api-call="() => {}"
  397. :open-item="true"
  398. :show-columns-select="false"
  399. :show-search-field="false"
  400. :add-item="false"
  401. @on-row-click="onOpenProposal"
  402. >
  403. <template #body-cell-status="props">
  404. <q-td :props="props">
  405. <q-badge
  406. :color="props.row.deleted_at ? 'negative' : props.row.schedule?.provider_id ? 'positive' : 'warning'"
  407. :label="props.value"
  408. />
  409. </q-td>
  410. </template>
  411. </DefaultTable>
  412. </div>
  413. <div v-if="filteredGroupedCustomSchedules.length === 0" class="text-center q-pa-xl">
  414. <q-icon name="event_busy" size="64px" color="grey-5" />
  415. <div class="text-h6 text-grey-7 q-mt-md">
  416. {{ $t('opportunities.empty_state') }}
  417. </div>
  418. </div>
  419. </div>
  420. </div>
  421. </q-tab-panel>
  422. </q-tab-panels>
  423. </q-tab-panel>
  424. </q-tab-panels>
  425. </div>
  426. <div v-else class="flex flex-center full-width q-pa-xl">
  427. <q-spinner color="primary" size="50px" />
  428. </div>
  429. </div>
  430. </template>
  431. <script setup>
  432. import { onMounted, ref, computed, watch } from 'vue'
  433. import { useQuasar } from 'quasar'
  434. import { useI18n } from 'vue-i18n'
  435. import DefaultHeaderPage from 'src/components/layout/DefaultHeaderPage.vue'
  436. import ViewScheduleDialog from 'src/pages/schedule/components/ViewScheduleDialog.vue'
  437. import ViewCustomScheduleDialog from 'src/pages/opportunity/components/ViewCustomScheduleDialog.vue'
  438. import { getSchedulesGroupedByClient, getSchedulesGroupedByClientCustom, updateScheduleStatus } from 'src/api/schedule'
  439. import { getProvidersProposalsAndOpportunities } from 'src/api/customSchedule'
  440. import ProviderSelect from 'src/components/provider/ProviderSelect.vue'
  441. import DefaultTable from 'src/components/defaults/DefaultTable.vue'
  442. const $q = useQuasar()
  443. const { t } = useI18n()
  444. const isLoading = ref(true)
  445. const scheduleType = ref('default')
  446. const viewMode = ref('client')
  447. const statusFilter = ref(null)
  448. const groupedDefaultSchedules = ref([])
  449. const groupedCustomSchedules = ref([])
  450. const selectedProvider = ref(null)
  451. const providerProposals = ref([])
  452. const availableOpportunities = ref([])
  453. const statusFilterOptions = computed(() => [
  454. { label: t('schedules.all_statuses'), value: null },
  455. { label: t('schedules.statuses.pending'), value: 'pending' },
  456. { label: t('schedules.statuses.accepted'), value: 'accepted' },
  457. { label: t('schedules.statuses.rejected'), value: 'rejected' },
  458. { label: t('schedules.statuses.paid'), value: 'paid' },
  459. { label: t('schedules.statuses.cancelled'), value: 'cancelled' },
  460. { label: t('schedules.statuses.started'), value: 'started' },
  461. { label: t('schedules.statuses.finished'), value: 'finished' }
  462. ])
  463. const filteredGroupedDefaultSchedules = computed(() => {
  464. if (!statusFilter.value) {
  465. return groupedDefaultSchedules.value
  466. }
  467. return groupedDefaultSchedules.value
  468. .map(clientGroup => ({
  469. ...clientGroup,
  470. schedules: clientGroup.schedules?.filter(
  471. schedule => schedule.status === statusFilter.value
  472. )
  473. }))
  474. .filter(clientGroup => clientGroup.schedules?.length > 0)
  475. })
  476. const filteredGroupedCustomSchedules = computed(() => {
  477. if (viewMode.value === 'provider' && selectedProvider.value) {
  478. const opportunities = availableOpportunities.value
  479. if (!statusFilter.value) {
  480. return opportunities
  481. }
  482. return opportunities
  483. .map(clientGroup => ({
  484. ...clientGroup,
  485. schedules: clientGroup.schedules?.filter(
  486. schedule => schedule.status === statusFilter.value
  487. )
  488. }))
  489. .filter(clientGroup => clientGroup.schedules?.length > 0)
  490. }
  491. if (!statusFilter.value) {
  492. return groupedCustomSchedules.value
  493. }
  494. return groupedCustomSchedules.value
  495. .map(clientGroup => ({
  496. ...clientGroup,
  497. schedules: clientGroup.schedules?.filter(
  498. schedule => schedule.status === statusFilter.value
  499. )
  500. }))
  501. .filter(clientGroup => clientGroup.schedules?.length > 0)
  502. })
  503. const proposalColumns = computed(() => [
  504. {
  505. name: 'id',
  506. label: 'ID',
  507. field: 'schedule_id',
  508. align: 'left'
  509. },
  510. {
  511. name: 'client',
  512. label: t('opportunities.client'),
  513. field: row => row.schedule?.client?.user?.name || '-',
  514. align: 'left'
  515. },
  516. {
  517. name: 'date',
  518. label: t('opportunities.date'),
  519. field: row => new Date(row.schedule?.date).toLocaleDateString('pt-BR'),
  520. align: 'left'
  521. },
  522. {
  523. name: 'period',
  524. label: t('opportunities.period'),
  525. field: row => row.schedule?.period === 'morning' ? t('provider_working_days.morning') : t('provider_working_days.afternoon'),
  526. align: 'left'
  527. },
  528. {
  529. name: 'status',
  530. label: t('common.terms.status'),
  531. field: row => row.schedule?.status,
  532. align: 'left'
  533. }
  534. ])
  535. const formatCurrency = (value) => {
  536. if (!value) return 'R$ 0,00'
  537. return `R$ ${Number(value).toFixed(2).replace('.', ',')}`
  538. }
  539. const getStatusColor = (status) => {
  540. const colors = {
  541. pending: 'warning',
  542. accepted: 'positive',
  543. rejected: 'negative',
  544. paid: 'info',
  545. cancelled: 'dark',
  546. started: 'primary',
  547. finished: 'positive'
  548. }
  549. return colors[status] || 'grey'
  550. }
  551. const loadSchedules = async () => {
  552. try {
  553. isLoading.value = true
  554. const [defaultData, customData] = await Promise.all([
  555. getSchedulesGroupedByClient(),
  556. getSchedulesGroupedByClientCustom()
  557. ])
  558. groupedDefaultSchedules.value = defaultData
  559. groupedCustomSchedules.value = customData
  560. } catch (error) {
  561. $q.notify({
  562. type: 'negative',
  563. message: error.message || t('common.ui.messages.error_loading_data'),
  564. position: 'top'
  565. })
  566. } finally {
  567. isLoading.value = false
  568. }
  569. }
  570. const loadProviderProposalsAndOpportunities = async (providerId) => {
  571. try {
  572. const response = await getProvidersProposalsAndOpportunities(providerId)
  573. providerProposals.value = response.proposals
  574. availableOpportunities.value = response.opportunities
  575. } catch (error) {
  576. $q.notify({
  577. type: 'negative',
  578. message: error.message || t('common.ui.messages.error_loading_data'),
  579. position: 'top'
  580. })
  581. }
  582. }
  583. const openScheduleDialog = (schedule) => {
  584. $q.dialog({
  585. component: ViewScheduleDialog,
  586. componentProps: {
  587. schedule,
  588. viewMode: viewMode.value,
  589. onAccept: handleAccept,
  590. onReject: handleReject,
  591. onMarkAsPaid: handleMarkAsPaid,
  592. onCancel: handleCancel
  593. },
  594. persistent: true
  595. }).onOk(async () => {
  596. await loadSchedules();
  597. if (selectedProvider.value?.value) {
  598. await loadProviderProposalsAndOpportunities(selectedProvider.value.value);
  599. }
  600. })
  601. }
  602. const openCustomScheduleDialog = (schedule) => {
  603. $q.dialog({
  604. component: ViewCustomScheduleDialog,
  605. componentProps: {
  606. schedule,
  607. viewMode: viewMode.value,
  608. providerId: selectedProvider.value?.value || null,
  609. onMarkAsPaid: handleMarkAsPaid,
  610. onRefreshData: async () => {
  611. await loadSchedules();
  612. if (selectedProvider.value?.value) {
  613. await loadProviderProposalsAndOpportunities(selectedProvider.value.value);
  614. }
  615. }
  616. }
  617. })
  618. }
  619. const updateStatus = async (scheduleId, newStatus) => {
  620. try {
  621. await updateScheduleStatus(scheduleId, newStatus);
  622. await loadSchedules();
  623. } catch (error) {
  624. $q.notify({
  625. type: 'negative',
  626. message: error.message || t('common.ui.messages.error'),
  627. position: 'top'
  628. })
  629. }
  630. }
  631. const handleAccept = async (scheduleId) => {
  632. await updateStatus(scheduleId, 'accepted')
  633. }
  634. const handleReject = async (scheduleId) => {
  635. await updateStatus(scheduleId, 'rejected')
  636. }
  637. const handleMarkAsPaid = async (scheduleId) => {
  638. await updateStatus(scheduleId, 'paid')
  639. }
  640. const handleCancel = async (scheduleId) => {
  641. await updateStatus(scheduleId, 'cancelled')
  642. }
  643. const onOpenProposal = ({row}) => {
  644. openCustomScheduleDialog(row.schedule)
  645. }
  646. watch(selectedProvider, async (newProvider) => {
  647. if (newProvider?.value && viewMode.value === 'provider') {
  648. await loadProviderProposalsAndOpportunities(newProvider.value);
  649. } else {
  650. providerProposals.value = []
  651. availableOpportunities.value = []
  652. }
  653. })
  654. onMounted(async () => {
  655. await loadSchedules()
  656. })
  657. </script>
  658. <style scoped>
  659. </style>