Рефакторинг кода бэкенда и фронтенда
This commit is contained in:
1 parent
949087bd83
commit
631cecc8cd
4 files changed
+27
-17
No files matched your search
@@ -12,6 +12,7 @@ class DictEmployeeAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
# class DictEmployeeAdmin(admin.ModelAdmin):
|
# class DictEmployeeAdmin(admin.ModelAdmin):
|
||||||
class IlineComitteeFiles(admin.StackedInline):
|
class IlineComitteeFiles(admin.StackedInline):
|
||||||
|
# readonly_fields = ['file_name']
|
||||||
model = Committee1Files
|
model = Committee1Files
|
||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class Committee1(models.Model):
|
|||||||
|
|
||||||
class Committee1Files(models.Model):
|
class Committee1Files(models.Model):
|
||||||
id_committee1 = models.ForeignKey(Committee1, models.DO_NOTHING, db_column='id_committee1', db_comment='╚─ ъюьшёёшш')
|
id_committee1 = models.ForeignKey(Committee1, models.DO_NOTHING, db_column='id_committee1', db_comment='╚─ ъюьшёёшш')
|
||||||
file_name = models.FileField(upload_to='comitee_files')
|
file_name = models.FileField(null=True, blank=True, upload_to='comitee_files')
|
||||||
|
# file_name = models.CharField(max_length=1024, db_comment='╚ь Їрщыр')
|
||||||
is_actual = models.IntegerField(db_comment='╧Ёшчэръ ръЄєры№эюёЄш Їрщыр')
|
is_actual = models.IntegerField(db_comment='╧Ёшчэръ ръЄєры№эюёЄш Їрщыр')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -38,6 +39,9 @@ class Committee1Files(models.Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.file_name)
|
return str(self.file_name)
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Committee2(models.Model):
|
class Committee2(models.Model):
|
||||||
|
|||||||
@@ -47,11 +47,10 @@
|
|||||||
<v-card-actions v-for="file in category.files" :key="file.id" class="overflow-y-auto">
|
<v-card-actions v-for="file in category.files" :key="file.id" class="overflow-y-auto">
|
||||||
<v-card-text
|
<v-card-text
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
:ref_="openPDF(burl + file.url)"
|
@click="openPDF(file.url), loading=true">
|
||||||
@click="openPDF(burl + file.url), loading=true">
|
|
||||||
{{ file.name }}
|
{{ file.name }}
|
||||||
</v-card-text>
|
</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-btn icon='mdi-file-download-outline' color="green" @click="downloadItem(burl + file.url, file.name)"></v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,8 +66,12 @@
|
|||||||
:fluid="true"
|
:fluid="true"
|
||||||
class="py-0">
|
class="py-0">
|
||||||
<v-card-actions :key="file.id">
|
<v-card-actions :key="file.id">
|
||||||
<v-card-text>{{ get_name(decodeURI(file.file_name.replace(/\.[^/.]+$/, ""))) }}</v-card-text>
|
<v-card-text
|
||||||
<v-btn icon="mdi-file-pdf-box" color="red" @click="openPDF(burl + checkNameFiles(file)), loading=true"></v-btn>
|
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-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-card-actions>
|
||||||
</v-container>
|
</v-container>
|
||||||
@@ -125,8 +128,8 @@ pagecounter();
|
|||||||
const safetyData = ref([]);
|
const safetyData = ref([]);
|
||||||
const responsibilityData = ref();
|
const responsibilityData = ref();
|
||||||
const showMore = ref(false);
|
const showMore = ref(false);
|
||||||
const showFile = ref(false);
|
const showFile = ref(true);
|
||||||
let pdfSource = '';
|
let pdfSource = ref("");
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const tab = ref('');
|
const tab = ref('');
|
||||||
const burl = baseURL.slice(0,-1);
|
const burl = baseURL.slice(0,-1);
|
||||||
@@ -135,10 +138,14 @@ const route = useRoute();
|
|||||||
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
|
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
|
||||||
function getSafety() {
|
function getSafety() {
|
||||||
axiosApiInstance.get(`api/safety/files/?chapter_id=${route.params.chapter_id}`).then(result => {
|
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({
|
const formainpage = computed({
|
||||||
get() {
|
get() {
|
||||||
let arr=[]
|
let arr=[]
|
||||||
@@ -154,7 +161,6 @@ const formainpage = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function getResponsibility() {
|
function getResponsibility() {
|
||||||
axiosApiInstance.get(`api/safety/committee_files/`).then(result => {
|
axiosApiInstance.get(`api/safety/committee_files/`).then(result => {
|
||||||
responsibilityData.value = result.data
|
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
|
showFile.value = true
|
||||||
if (showFile) {
|
|
||||||
return pdfSource = url
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function get_name(namestr){
|
function get_name(namestr){
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<v-row no-gutters class="gap h-100 ">
|
<v-row no-gutters class="gap h-100 ">
|
||||||
<v-col cols="9" class="flex-column" >
|
<v-col cols="9" class="flex-column" >
|
||||||
<v-row no-gutters class="h-100 justify-center">
|
<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" />
|
<VuePdfEmbed v-if="schema.url.endsWith('.pdf')" :source="burl + schema.url" width="500" />
|
||||||
<v-img v-else
|
<v-img v-else
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -61,6 +61,7 @@ defineProps(
|
|||||||
require:true
|
require:true
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const urlschema=ref(null)
|
const urlschema=ref(null)
|
||||||
const burl = baseURL.slice(0,-1)
|
const burl = baseURL.slice(0,-1)
|
||||||
const openFirstPlan = ref(false)
|
const openFirstPlan = ref(false)
|
||||||
|
|||||||
Reference in new issue
Block a user