From c69b892d125112b96c457bccc55a414d6d624a9f Mon Sep 17 00:00:00 2001 From: sugasaki Date: Sat, 25 Apr 2020 22:49:07 +0900 Subject: [PATCH] =?UTF-8?q?#257=20=E9=80=80=E9=99=A2=E8=80=85=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=8C=E5=88=A5API=E3=81=AB=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E4=BB=B6=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cards/ConfirmedCasesDetailsCard.vue | 48 ++----------------- pages/index.vue | 2 +- services/bodikApi.js | 4 ++ store/index.js | 40 +++++++++++----- 4 files changed, 37 insertions(+), 57 deletions(-) diff --git a/brigade/nagasaki/components/cards/ConfirmedCasesDetailsCard.vue b/brigade/nagasaki/components/cards/ConfirmedCasesDetailsCard.vue index d37d563fa6db9..752af057e342d 100644 --- a/brigade/nagasaki/components/cards/ConfirmedCasesDetailsCard.vue +++ b/brigade/nagasaki/components/cards/ConfirmedCasesDetailsCard.vue @@ -63,51 +63,11 @@ export default { }, confirmedCases() { - // 検査陽性者の状況 - const patientsNotCruise = this.$store.state.patientsNotCruise - // console.log(patientsNotCruise, 'patientsNotCruise') - // if (!patientsNotCruise) return formatConfirmedCases(summary) - - const summary = Data.main_summary - // console.log(summary, 'summary') - - const allCount = this.$store.state.allCount - - const number = patientsNotCruise.length - const taiin = this.$store.state.patientsNotCruise.filter( - d => d.退院済フラグ === '1' - ).length - const dead = this.$store.state.patientsNotCruise.filter( - d => d.死亡フラグ === '1' - ).length - // console.log(taiin, 'taiin') - - // 検査実施 人数 - summary.value = allCount - - // 陽性者数 (累積) - summary.children[0].value = number + const summary = this.$store.state.patientsNotCruise // console.log(summary, 'summary') - - // 入院中 - summary.children[0].children[0].value = number - taiin - - // 軽症 - summary.children[0].children[0].children[0].value = 0 - - // 重症 - summary.children[0].children[0].children[1].value = 0 - - // 退院 - summary.children[0].children[1].value = taiin - - // 死亡 - summary.children[0].children[2].value = dead - - const confirmedCases = formatConfirmedCases(summary) - // console.log(confirmedCases, 'confirmedCases') - - return confirmedCases + // 検査陽性者の状況 + if (!summary) return formatConfirmedCases(Data.main_summary) + return summary } }, methods: {} diff --git a/pages/index.vue b/pages/index.vue index 96fe3af86e1ce..ceca0fa61f780 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -99,7 +99,7 @@ export default Vue.extend({ // }, async mounted() { // 動的に最新情報を取得する - await sleep(100) + await sleep(3000) await this.$store.dispatch('GET_BODIK_JSONP') }, head(): MetaInfo { diff --git a/services/bodikApi.js b/services/bodikApi.js index a0241bcc60df2..af674627b6a5c 100644 --- a/services/bodikApi.js +++ b/services/bodikApi.js @@ -9,6 +9,8 @@ const nagasakiPrefectureConfirmedCasesId = 'de7ce61e-1849-47a1-b758-bca3f809cdf8' const nagasakiCityNewsId = 'eb0ba50a-7a97-4029-9b75-9c6bab0568f6' +const aonyMouseId = '438f03f1-0ee8-466d-a5d9-e874f5367507' + export const fetchNagasakiPrefectureTestedCases = () => callFetchJsonp(baseUrl, nagasakiPrefectureTestedCasesId) export const fetchNagasakiPrefectureConfirmedCases = () => @@ -16,6 +18,8 @@ export const fetchNagasakiPrefectureConfirmedCases = () => export const fetchNagasakiCityNews = () => callFetchJsonp(baseUrl, nagasakiCityNewsId) +export const fetchonyMouseId = () => callFetchJsonp(baseUrl, aonyMouseId) + export const axiosNagasakiPrefectureTestedCases = axios => axios.$get(baseUrl + nagasakiPrefectureTestedCasesId) export const axiosNagasakiPrefectureConfirmedCases = axios => diff --git a/store/index.js b/store/index.js index 93be52ac70b8f..ab00a005d5a17 100644 --- a/store/index.js +++ b/store/index.js @@ -1,16 +1,15 @@ -// import axios from 'axios' import { bodikApi } from '../services' import { groupBy, reducer } from './util.js' import { convertDateToSimpleFormat } from '@/utils/formatDate' export const state = () => ({ - allCount: 0, testedNumber: [], patients: [], nagasakiCityNews: [], attributes: [], - patientsNotCruise: [], - patientsGraphNotCruise: [] + patientsNotCruise: null, + patientsGraphNotCruise: [], + otherData: [] }) export const getters = { @@ -31,11 +30,7 @@ export const mutations = { // 長崎県新型コロナウイルス感染症検査実施数のロード完了後の処理 setPrefectureTestedCases(state, data) { if (!data || data.length === 0) return - state.testedNumber = data - - // 検査件数の全数を取得 - state.allCount = data.map(x => Number(x.件数)).reduce(reducer) }, // 感染症陽性患者発表情報のロード完了後の処理 @@ -62,8 +57,11 @@ export const mutations = { allDataUpdated(state, data) { const data1 = data.data1 const data2 = data.data2 + const data3 = data.data3 if (!data1 || !data2) return + state.otherData = data3 + // state.groups = groupBy(data, r => r.公表_年月日) const notCruise = data2.map(x => x).filter(date => date.クルーズ船 !== '1') // console.log(notCruise, 'notCruise') @@ -89,10 +87,25 @@ export const mutations = { 小計: groupsNotCruise[item] ? groupsNotCruise[item].length : 0 } }) - // console.log(state.patientsGraphNotCruise, 'state.patientsGraphNotCruise') - // 検査陽性者の状況 - state.patientsNotCruise = notCruise + // 検査陽性者の状況のデータ作成 + const 退院者数 = data3.filter(d => d.KEY === '県内_退院者数') + // console.log(退院者数, '退院者数') + const taiin = 退院者数 ? Number(退院者数[0].VALUE) : 0 + // console.log(taiin, 'taiin') + // グラフ表示用のデータ作成 + const formattedData = { + 検査実施人数: data1.map(x => Number(x.件数)).reduce(reducer), + 陽性者数: notCruise.length, + 入院中: data2.length - taiin, + 軽症中等症: 0, + 重症: 0, + 死亡: notCruise.filter(d => d.死亡フラグ === '1').length, + 退院: taiin + } + // console.log(formattedData, 'formattedData') + + state.patientsNotCruise = formattedData } } @@ -127,10 +140,13 @@ export const actions = { const news = await bodikApi.fetchNagasakiCityNews() commit('setNagasakiCityNews', news.records) + const result3 = await bodikApi.fetchonyMouseId() + /// / 非同期データのロード後処理 commit('allDataUpdated', { data1: result1.records, - data2: result2.records + data2: result2.records, + data3: result3.records }) } catch (e) {} }