Добавлен функционал скачивания файлов
This commit is contained in:
1 parent
8885fa0949
commit
68e0c717e5
4 files changed
+46
-8
No files matched your search
Generated
+6
@@ -15,6 +15,7 @@
|
|||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
"date-fns": "^2.30.0",
|
"date-fns": "^2.30.0",
|
||||||
"express-vue": "^5.12.0",
|
"express-vue": "^5.12.0",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"pinia": "^2.0.23",
|
"pinia": "^2.0.23",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
@@ -10568,6 +10569,11 @@
|
|||||||
"node": "^10.12.0 || >=12.0.0"
|
"node": "^10.12.0 || >=12.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/file-saver": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
|
||||||
|
},
|
||||||
"node_modules/file-system-cache": {
|
"node_modules/file-system-cache": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-system-cache/-/file-system-cache-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-system-cache/-/file-system-cache-2.3.0.tgz",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
"date-fns": "^2.30.0",
|
"date-fns": "^2.30.0",
|
||||||
"express-vue": "^5.12.0",
|
"express-vue": "^5.12.0",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"pinia": "^2.0.23",
|
"pinia": "^2.0.23",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const spravURL = 'http://10.252.44.33/accounting6/images/photo/'
|
|||||||
// const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://${window.location.host}/`;
|
// const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://${window.location.host}/`;
|
||||||
const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
|
const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
|
||||||
const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
|
const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
|
||||||
|
const safetyURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000': `http://10.252.44.60:9965`;
|
||||||
// для релизного меняем 'http://ukd/'
|
// для релизного меняем 'http://ukd/'
|
||||||
// const baseURL = 'http://127.0.0.1:8000/';
|
// const baseURL = 'http://127.0.0.1:8000/';
|
||||||
|
|
||||||
@@ -89,4 +90,4 @@ async error => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export { axiosApiInstance, clearAxios, baseURL,spravURL,baseWS }
|
export { axiosApiInstance, clearAxios, baseURL,spravURL,baseWS, safetyURL }
|
||||||
@@ -8,11 +8,13 @@
|
|||||||
<!-- Безопасность -->
|
<!-- Безопасность -->
|
||||||
<!-- {{ safetyData }} -->
|
<!-- {{ safetyData }} -->
|
||||||
<v-row class="bg-red">
|
<v-row class="bg-red">
|
||||||
<v-col>
|
<v-col cols="6">
|
||||||
<v-card v-for="item in safetyData" :key="item.id">
|
<v-card v-for="item in safetyData" :key="item.id">
|
||||||
<v-card-title>{{ item.name }}</v-card-title>
|
<v-card-title>{{ item.name }}</v-card-title>
|
||||||
<v-card-actions v-for="category in item.categories" :key="item.id + category.id" >
|
<!-- <v-card-actions
|
||||||
<v-btn>{{ category.name }}</v-btn>
|
v-for="category in item.categories"
|
||||||
|
:key="item.id + category.id">
|
||||||
|
<v-btn variant="text">{{ category.name }}</v-btn>
|
||||||
<v-btn
|
<v-btn
|
||||||
:icon="showMore[item.id + category.id] ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
:icon="showMore[item.id + category.id] ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
||||||
@click="showMore[item.id + category.id] = !showMore[item.id + category.id]">
|
@click="showMore[item.id + category.id] = !showMore[item.id + category.id]">
|
||||||
@@ -26,8 +28,29 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</div>
|
</div>
|
||||||
</v-expand-transition>
|
</v-expand-transition>
|
||||||
|
</v-card-actions> -->
|
||||||
|
<v-container
|
||||||
|
v-for="category in item.categories"
|
||||||
|
:key="item.id + category.id"
|
||||||
|
:fluid="true"
|
||||||
|
class="py-0">
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn variant="text">{{ category.name }}</v-btn>
|
||||||
|
<v-btn
|
||||||
|
:icon="showMore[item.id + category.id] ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
||||||
|
@click="showMore[item.id + category.id] = !showMore[item.id + category.id]">
|
||||||
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
<v-expand-transition>
|
||||||
|
<div v-show="showMore[item.id + category.id]">
|
||||||
|
<v-card-actions v-for="file in category.files" :key="file.id">
|
||||||
|
<v-card-text>{{ file.name }}</v-card-text>
|
||||||
|
<v-btn icon="mdi-eye" color="grey"></v-btn>
|
||||||
|
<v-btn icon='mdi-cloud-download' color="grey" @click="downloadItem(safetyURL + file.url, file.name)"></v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</div>
|
||||||
|
</v-expand-transition>
|
||||||
|
</v-container>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -36,7 +59,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onBeforeMount } from 'vue';
|
import { ref, onBeforeMount } from 'vue';
|
||||||
import { pagecounter } from '@/utils/universal_functions'
|
import { pagecounter } from '@/utils/universal_functions'
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance, safetyURL } from '@/utils/axios-api';
|
||||||
|
import { saveAs } from 'file-saver'
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
pagecounter();
|
pagecounter();
|
||||||
|
|
||||||
@@ -47,15 +72,20 @@ onBeforeMount(() => {
|
|||||||
axiosApiInstance.get(`api/safety/files/`).then(result => {
|
axiosApiInstance.get(`api/safety/files/`).then(result => {
|
||||||
safetyData.value = result.data
|
safetyData.value = result.data
|
||||||
})
|
})
|
||||||
console.log(safetyData);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Проверяем по ID на какой категории срабатывает клик на раскрытии/скрытии, чтобы избежать срабатывания у всех категорий одновременно
|
||||||
showMore.value = safetyData.value.reduce((acc, value) => {
|
showMore.value = safetyData.value.reduce((acc, value) => {
|
||||||
acc[value.id] = false
|
acc[value.id] = false
|
||||||
return acc
|
return acc
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
const downloadItem = (url, fileName) => {
|
||||||
|
axios.get(url, {responseType: 'blob'})
|
||||||
|
.then(response => {
|
||||||
|
saveAs(response.data, fileName)
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Reference in new issue
Block a user