Рефакторинг кода бэкенда и фронтенда
This commit is contained in:
1 parent
949087bd83
commit
631cecc8cd
4 files changed
+27
-17
No files matched your search
@@ -47,11 +47,10 @@
|
||||
<v-card-actions v-for="file in category.files" :key="file.id" class="overflow-y-auto">
|
||||
<v-card-text
|
||||
class="cursor-pointer"
|
||||
:ref_="openPDF(burl + file.url)"
|
||||
@click="openPDF(burl + file.url), loading=true">
|
||||
@click="openPDF(file.url), loading=true">
|
||||
{{ file.name }}
|
||||
</v-card-text>
|
||||
<v-btn icon="mdi-file-pdf-box" color="red" @click="openPDF(burl + file.url), loading=true"></v-btn>
|
||||
<v-btn icon="mdi-file-pdf-box" color="red" @click="openPDF(file.url), loading=true"></v-btn>
|
||||
<v-btn icon='mdi-file-download-outline' color="green" @click="downloadItem(burl + file.url, file.name)"></v-btn>
|
||||
</v-card-actions>
|
||||
</div>
|
||||
@@ -67,8 +66,12 @@
|
||||
:fluid="true"
|
||||
class="py-0">
|
||||
<v-card-actions :key="file.id">
|
||||
<v-card-text>{{ get_name(decodeURI(file.file_name.replace(/\.[^/.]+$/, ""))) }}</v-card-text>
|
||||
<v-btn icon="mdi-file-pdf-box" color="red" @click="openPDF(burl + checkNameFiles(file)), loading=true"></v-btn>
|
||||
<v-card-text
|
||||
class="cursor-pointer"
|
||||
@click="openPDF(checkNameFiles(file)), loading=true">
|
||||
{{ get_name(decodeURI(file.file_name.replace(/\.[^/.]+$/, ""))) }}
|
||||
</v-card-text>
|
||||
<v-btn icon="mdi-file-pdf-box" color="red" @click="openPDF(checkNameFiles(file)), loading=true"></v-btn>
|
||||
<v-btn icon='mdi-file-download-outline' color="green" @click="downloadItem(burl + checkNameFiles(file), get_name(decodeURI(file.file_name)))"></v-btn>
|
||||
</v-card-actions>
|
||||
</v-container>
|
||||
@@ -125,8 +128,8 @@ pagecounter();
|
||||
const safetyData = ref([]);
|
||||
const responsibilityData = ref();
|
||||
const showMore = ref(false);
|
||||
const showFile = ref(false);
|
||||
let pdfSource = '';
|
||||
const showFile = ref(true);
|
||||
let pdfSource = ref("");
|
||||
const loading = ref(false);
|
||||
const tab = ref('');
|
||||
const burl = baseURL.slice(0,-1);
|
||||
@@ -135,10 +138,14 @@ const route = useRoute();
|
||||
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
|
||||
function getSafety() {
|
||||
axiosApiInstance.get(`api/safety/files/?chapter_id=${route.params.chapter_id}`).then(result => {
|
||||
safetyData.value = result.data
|
||||
|
||||
safetyData.value = result.data
|
||||
console.log(safetyData.value);
|
||||
loading.value=true
|
||||
pdfSource.value =burl + safetyData.value[0].categories[1].files[0].url
|
||||
console.log(safetyData.value);
|
||||
})
|
||||
}
|
||||
|
||||
const formainpage = computed({
|
||||
get() {
|
||||
let arr=[]
|
||||
@@ -154,7 +161,6 @@ const formainpage = computed({
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function getResponsibility() {
|
||||
axiosApiInstance.get(`api/safety/committee_files/`).then(result => {
|
||||
responsibilityData.value = result.data
|
||||
@@ -178,11 +184,9 @@ const downloadItem = (url, fileName) => {
|
||||
})
|
||||
};
|
||||
|
||||
function openPDF(url) {
|
||||
function openPDF(url) {
|
||||
pdfSource.value = burl+url
|
||||
showFile.value = true
|
||||
if (showFile) {
|
||||
return pdfSource = url
|
||||
}
|
||||
};
|
||||
|
||||
function get_name(namestr){
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<v-row no-gutters class="gap h-100 ">
|
||||
<v-col cols="9" class="flex-column" >
|
||||
<v-row no-gutters class="h-100 justify-center">
|
||||
<v-col lg="6" class="meheight " v-for="schema in formainpage" :key="key">
|
||||
<v-col lg="6" class="meheight" v-for="schema in formainpage" :key="schema.id">
|
||||
<VuePdfEmbed v-if="schema.url.endsWith('.pdf')" :source="burl + schema.url" width="500" />
|
||||
<v-img v-else
|
||||
class="cursor-pointer"
|
||||
@@ -47,7 +47,7 @@
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -61,6 +61,7 @@ defineProps(
|
||||
require:true
|
||||
},
|
||||
)
|
||||
|
||||
const urlschema=ref(null)
|
||||
const burl = baseURL.slice(0,-1)
|
||||
const openFirstPlan = ref(false)
|
||||
|
||||
Reference in new issue
Block a user