Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import { boot } from 'quasar/wrappers'
|
||||
import axios from 'axios'
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: 'http://localhost:8080/api',
|
||||
timeout: 180000,
|
||||
withCredentials: true // refresh cookie kullanıyorsan kalsın
|
||||
})
|
||||
|
||||
export default boot(() => {
|
||||
api.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem('token') // ✅ senin authStore key’in
|
||||
|
||||
if (token) {
|
||||
config.headers = config.headers || {}
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
|
||||
return config
|
||||
})
|
||||
})
|
||||
@@ -233,6 +233,7 @@ import { useQuasar } from 'quasar'
|
||||
import { useOrderListStore } from 'src/stores/OrdernewListStore'
|
||||
import { useAuthStore } from 'src/stores/authStore'
|
||||
import { usePermission } from 'src/composables/usePermission'
|
||||
import api from 'src/services/api'
|
||||
|
||||
const { canRead } = usePermission()
|
||||
const canReadOrder = canRead('order')
|
||||
@@ -270,22 +271,24 @@ function exportExcel () {
|
||||
OrderDate: store.filters.OrderDate || ''
|
||||
})
|
||||
|
||||
const url = `http://localhost:8080/api/orders/export?${params.toString()}`
|
||||
|
||||
fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`
|
||||
}
|
||||
api.get(`/orders/export?${params.toString()}`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
.then(res => res.blob())
|
||||
.then(res => res.data)
|
||||
.then(blob => {
|
||||
const link = document.createElement('a')
|
||||
link.href = URL.createObjectURL(blob)
|
||||
link.download = 'siparis_listesi.xlsx'
|
||||
link.click()
|
||||
})
|
||||
.catch(() => {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'Excel dosyasi indirilemedi',
|
||||
position: 'top-right'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function formatDate (s) {
|
||||
if (!s) return ''
|
||||
const [y, m, d] = String(s).split('-')
|
||||
@@ -383,23 +386,16 @@ function selectOrder (row) {
|
||||
async function printPDF (row) {
|
||||
if (!row?.OrderHeaderID) return
|
||||
|
||||
const token = useAuthStore().token
|
||||
const url = `http://localhost:8080/api/order/pdf/${row.OrderHeaderID}`
|
||||
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
const res = await api.get(`/order/pdf/${row.OrderHeaderID}`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
|
||||
if (!res.ok) throw new Error()
|
||||
|
||||
const blob = await res.blob()
|
||||
window.open(URL.createObjectURL(blob), '_blank')
|
||||
window.open(URL.createObjectURL(res.data), '_blank')
|
||||
} catch {
|
||||
$q.notify({ type: 'negative', message: 'PDF yüklenemedi' })
|
||||
}
|
||||
}
|
||||
|
||||
function clearFilters () {
|
||||
store.filters.search = ''
|
||||
store.filters.CurrAccCode = ''
|
||||
@@ -562,3 +558,4 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -3,11 +3,14 @@ import axios from 'axios'
|
||||
import qs from 'qs'
|
||||
import { useAuthStore } from 'stores/authStore'
|
||||
|
||||
export const API_BASE_URL = process.env.VITE_API_BASE_URL || '/api'
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://localhost:8080/api',
|
||||
baseURL: API_BASE_URL,
|
||||
timeout: 180000,
|
||||
paramsSerializer: params =>
|
||||
qs.stringify(params, { arrayFormat: 'repeat' })
|
||||
qs.stringify(params, { arrayFormat: 'repeat' }),
|
||||
withCredentials: true
|
||||
})
|
||||
|
||||
// REQUEST
|
||||
@@ -21,7 +24,6 @@ api.interceptors.request.use((config) => {
|
||||
url.startsWith('/password/forgot') ||
|
||||
url.startsWith('/password/reset')
|
||||
|
||||
|
||||
if (!isPublic && auth?.token) {
|
||||
config.headers ||= {}
|
||||
config.headers.Authorization = `Bearer ${auth.token}`
|
||||
@@ -32,6 +34,7 @@ api.interceptors.request.use((config) => {
|
||||
|
||||
// RESPONSE
|
||||
let isLoggingOut = false
|
||||
|
||||
api.interceptors.response.use(
|
||||
r => r,
|
||||
async (error) => {
|
||||
@@ -47,7 +50,6 @@ api.interceptors.response.use(
|
||||
}
|
||||
)
|
||||
|
||||
// HELPERS
|
||||
export const get = (u, p = {}, c = {}) =>
|
||||
api.get(u, { params: p, ...c }).then(r => r.data)
|
||||
|
||||
@@ -61,7 +63,6 @@ export const del = (u, p = {}, c = {}) =>
|
||||
api.delete(u, { params: p, ...c }).then(r => r.data)
|
||||
|
||||
export const download = (u, p = {}, c = {}) =>
|
||||
api.get(u, { params: p, responseType: 'blob', ...c })
|
||||
.then(r => r.data)
|
||||
api.get(u, { params: p, responseType: 'blob', ...c }).then(r => r.data)
|
||||
|
||||
export default api
|
||||
|
||||
Reference in New Issue
Block a user