fix: 検索件数が多いときに画面が表示されない問題を解消
This commit is contained in:
parent
4cf9b02833
commit
ffc8d16633
@ -9,7 +9,7 @@ from src.model.db.pharmacy_product_master import PharmacyProductMasterModel
|
||||
from src.model.db.wholesaler_master import WholesalerMasterModel
|
||||
from src.model.request.bio import BioModel
|
||||
from src.model.view.bio_disp_model import BisDisplayModel
|
||||
from src.system_var import environment
|
||||
from src.system_var import constants, environment
|
||||
|
||||
|
||||
class BioViewModel(BaseModel):
|
||||
@ -52,8 +52,15 @@ class BioViewModel(BaseModel):
|
||||
|
||||
def bio_data_json_str(self):
|
||||
def date_handler(obj):
|
||||
"""json.dumpsの日付項目のフォーマットハンドラ"""
|
||||
return obj.isoformat() if hasattr(obj, 'isoformat') else obj
|
||||
return json.dumps([model.dict() for model in self.bio_data], ensure_ascii=False, default=date_handler)
|
||||
|
||||
search_data_list = [model.dict() for model in self.bio_data]
|
||||
search_data_len = len(search_data_list)
|
||||
# 1ページあたりの表示件数単位で、リストにPUSH
|
||||
part_page_size = constants.BIO_SEARCH_LIST_PAGE_SIZE
|
||||
for i in range(0, search_data_len, part_page_size):
|
||||
yield json.dumps(search_data_list[i:i + part_page_size], ensure_ascii=False, default=date_handler)
|
||||
|
||||
def make_whs_name(self):
|
||||
if not self.is_form_submitted():
|
||||
|
||||
@ -5,6 +5,9 @@ BATCH_STATUS_PROCESSING = '1'
|
||||
# 日付テーブル.dump取得状態区分:未処理
|
||||
DUMP_STATUS_UNPROCESSED = '0'
|
||||
|
||||
# 生物由来照会
|
||||
|
||||
BIO_SEARCH_LIST_PAGE_SIZE = 100
|
||||
BIO_TEMPORARY_FILE_DIR_PATH = path.join(path.curdir, 'src', 'data')
|
||||
BIO_EXCEL_TEMPLATE_FILE_PATH = path.join(BIO_TEMPORARY_FILE_DIR_PATH, 'BioData_template.xlsx')
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
{% include '_header.html' %}
|
||||
{% endwith %}
|
||||
<link rel="stylesheet" href="/static/css/bioStyle.css">
|
||||
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
// 見出し固定初期化
|
||||
@ -266,18 +266,11 @@
|
||||
|
||||
// <! --ページネーションの作成-- >
|
||||
$(function() {
|
||||
// スピナー出さない場合は以下、エスケープせず埋め込む
|
||||
// {% autoescape False%}
|
||||
let searchResultString = '{{bio.bio_data_json_str()}}'
|
||||
// {% endautoescape%}
|
||||
const searchResultData = JSON.parse(searchResultString)
|
||||
if (searchResultData.length == 0) {
|
||||
return
|
||||
}
|
||||
const searchResultData = generateSearchResult();
|
||||
if (searchResultData.length == 0) return;
|
||||
|
||||
$(".pagination").pagination({
|
||||
dataSource: function(done) {
|
||||
done(searchResultData)
|
||||
},
|
||||
dataSource: searchResultData,
|
||||
pageNumber: 1, // 初期ページ番号
|
||||
pageSize: 100, //表示するコンテンツ数
|
||||
pageRange: 2, //選択されているページネーション番号の両隣に表示する個数
|
||||
@ -287,7 +280,6 @@
|
||||
showNavigator: true,
|
||||
formatNavigator: '件数: <%= totalNumber %>件 ページ数: <%= totalPage %>',
|
||||
callback: function(data, pagination) {
|
||||
console.log(pagination.pageNumber)
|
||||
$('#result_data').html(pagination_content(data))
|
||||
}
|
||||
})
|
||||
@ -334,7 +326,6 @@
|
||||
'iko_flg',
|
||||
];
|
||||
return datas.map(function (data) {
|
||||
console.log(data);
|
||||
return `
|
||||
<tr class="result_data">
|
||||
${display_keys.map((key) =>`<td>${data[key] || ''}</td>`)}
|
||||
@ -343,6 +334,19 @@
|
||||
})
|
||||
}
|
||||
|
||||
function generateSearchResult(){
|
||||
const searchResultData = []
|
||||
// {% if bio.is_form_submitted() and not (bio.is_data_overflow_max_length() or bio.is_data_empty()) %}
|
||||
// {% autoescape False%}
|
||||
// ジェネレータで100件ずつ取ってリストに詰める
|
||||
// {% for bio_data_json_str in bio.bio_data_json_str() %}
|
||||
searchResultData.push(...JSON.parse('{{bio_data_json_str}}'))
|
||||
// {% endfor %}
|
||||
// {% endautoescape%}
|
||||
// {% endif %}
|
||||
return searchResultData
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Excel出力モーダル -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user