mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-28 15:15:34 +08:00
Fix stock export on task [SCI-9477] (#6400)
This commit is contained in:
parent
d236ba0a5b
commit
357eebee40
5 changed files with 32 additions and 24 deletions
|
|
@ -50,4 +50,20 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.export-consumption-button', function(e) {
|
||||||
|
const selectedRows = $(this).data('rows') || RepositoryDatatable.selectedRows();
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
window.initExportStockConsumptionModal();
|
||||||
|
|
||||||
|
if (window.exportStockConsumptionModalComponent) {
|
||||||
|
window.exportStockConsumptionModalComponent.fetchRepositoryData(
|
||||||
|
selectedRows,
|
||||||
|
{ repository_id: $(this).data('objectId') },
|
||||||
|
);
|
||||||
|
$('#modal-info-repository-row').modal('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
<div class="flex flex-col ">
|
<div class="flex flex-col ">
|
||||||
<span class="inline-block font-semibold pb-[6px]">{{
|
<span class="inline-block font-semibold pb-[6px]">{{
|
||||||
i18n.t('repositories.item_card.default_columns.repository_name') }}</span>
|
i18n.t('repositories.item_card.default_columns.repository_name') }}</span>
|
||||||
<span class="repository-name flex text-sn-dark-grey" :title="repositoryName">
|
<span class="repository-name flex text-sn-dark-grey" :title="repository?.name">
|
||||||
{{ repositoryName }}
|
{{ repository?.name }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@
|
||||||
<Reminder :value="column.value" :valueType="column.value_type" />
|
<Reminder :value="column.value" :valueType="column.value_type" />
|
||||||
</span>
|
</span>
|
||||||
<component :is="column.data_type" :key="index" :data_type="column.data_type" :colId="column.id"
|
<component :is="column.data_type" :key="index" :data_type="column.data_type" :colId="column.id"
|
||||||
:colName="column.name" :colVal="column.value" :repositoryRowId="repositoryRowId"
|
:colName="column.name" :colVal="column.value" :repositoryRowId="repositoryRowId" :repositoryId="repository?.id"
|
||||||
:permissions="permissions" @closeSidebar="toggleShowHideSidebar(null)" />
|
:permissions="permissions" @closeSidebar="toggleShowHideSidebar(null)" />
|
||||||
<div id="dashed-divider" :class="{ 'hidden': index === customColumns.length - 1 }"
|
<div id="dashed-divider" :class="{ 'hidden': index === customColumns.length - 1 }"
|
||||||
class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey">
|
class="flex h-[1px] py-0 border-dashed border-[1px] border-sn-light-grey">
|
||||||
|
|
@ -221,7 +221,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
currentItemUrl: null,
|
currentItemUrl: null,
|
||||||
dataLoading: false,
|
dataLoading: false,
|
||||||
repositoryName: null,
|
repository: null,
|
||||||
defaultColumns: null,
|
defaultColumns: null,
|
||||||
customColumns: null,
|
customColumns: null,
|
||||||
assignedModules: null,
|
assignedModules: null,
|
||||||
|
|
@ -273,7 +273,7 @@ export default {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: (result) => {
|
success: (result) => {
|
||||||
this.repositoryRowId = result.id
|
this.repositoryRowId = result.id
|
||||||
this.repositoryName = result.repository_name;
|
this.repository = result.repository;
|
||||||
this.defaultColumns = result.default_columns;
|
this.defaultColumns = result.default_columns;
|
||||||
this.customColumns = result.custom_columns;
|
this.customColumns = result.custom_columns;
|
||||||
this.dataLoading = false
|
this.dataLoading = false
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
<div class="font-inter text-sm font-semibold leading-5 relative">
|
<div class="font-inter text-sm font-semibold leading-5 relative">
|
||||||
<span>{{ colName }}</span>
|
<span>{{ colName }}</span>
|
||||||
<a style="text-decoration: none;"
|
<a style="text-decoration: none;"
|
||||||
class="absolute right-0 text-sn-science-blue visited:text-sn-science-blue hover:text-sn-science-blue font-inter text-sm font-normal cursor-pointer"
|
class="absolute right-0 text-sn-science-blue visited:text-sn-science-blue hover:text-sn-science-blue
|
||||||
|
font-inter text-sm font-normal cursor-pointer export-consumption-button"
|
||||||
v-if="permissions?.can_export_repository_stock === true"
|
v-if="permissions?.can_export_repository_stock === true"
|
||||||
@click.prevent="exportConsumptionCallback"
|
|
||||||
:data-rows="JSON.stringify([repositoryRowId])"
|
:data-rows="JSON.stringify([repositoryRowId])"
|
||||||
|
:data-object-id="repositoryId"
|
||||||
>
|
>
|
||||||
{{ i18n.t('repositories.item_card.stock_export') }}
|
{{ i18n.t('repositories.item_card.stock_export') }}
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -35,6 +36,7 @@ export default {
|
||||||
colId: Number,
|
colId: Number,
|
||||||
colName: String,
|
colName: String,
|
||||||
colVal: Object,
|
colVal: Object,
|
||||||
|
repositoryId: Number,
|
||||||
repositoryRowId: null,
|
repositoryRowId: null,
|
||||||
permissions: null
|
permissions: null
|
||||||
},
|
},
|
||||||
|
|
@ -42,21 +44,6 @@ export default {
|
||||||
this.stock_formatted = this.colVal.stock_formatted
|
this.stock_formatted = this.colVal.stock_formatted
|
||||||
this.stock_amount = this.colVal.stock_amount
|
this.stock_amount = this.colVal.stock_amount
|
||||||
this.low_stock_threshold = this.colVal.low_stock_threshold
|
this.low_stock_threshold = this.colVal.low_stock_threshold
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
exportConsumptionCallback(event) {
|
|
||||||
$('#exportStockConsumptionModal')
|
|
||||||
.one('show.bs.modal', function() {
|
|
||||||
$('#exportStockConsumptionModal').attr(
|
|
||||||
'data-rows',
|
|
||||||
$(event.target).attr('data-rows')
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.one('hide.bs.modal', function() {
|
|
||||||
$('#exportStockConsumptionModal').attr('data-rows', null);
|
|
||||||
})
|
|
||||||
.modal('show');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<h4 class="modal-title"> {{ i18n.t('zip_export.consumption_modal_label') }} </h4>
|
<h4 class="modal-title"> {{ i18n.t('zip_export.consumption_modal_label') }} </h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>{{ i18n.t('zip_export.consumption_header_html', { repository: this.repository?.name }) }} </p>
|
<p>{{ i18n.t('zip_export.consumption_header_html', { repository: repository?.name }) }} </p>
|
||||||
<p v-html="i18n.t('zip_export.consumption_body_html')"> </p>
|
<p v-html="i18n.t('zip_export.consumption_body_html')"> </p>
|
||||||
<p class='pb-0' v-html="i18n.t('zip_export.consumption_footer_html')"></p>
|
<p class='pb-0' v-html="i18n.t('zip_export.consumption_footer_html')"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.id @repository_row.id
|
json.id @repository_row.id
|
||||||
json.repository_name @repository.name
|
|
||||||
|
json.repository do
|
||||||
|
json.id @repository.id
|
||||||
|
json.name @repository.name
|
||||||
|
end
|
||||||
|
|
||||||
json.permissions do
|
json.permissions do
|
||||||
json.can_export_repository_stock can_export_repository_stock?(@repository_row.repository)
|
json.can_export_repository_stock can_export_repository_stock?(@repository_row.repository)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue