Skip to content

Commit

Permalink
Merge pull request #95 from Disfactory/bugfix/report-record-date
Browse files Browse the repository at this point in the history
bugfix/report-record-date
  • Loading branch information
Yukaii authored Apr 14, 2021
2 parents 48935ed + 89044ea commit 08be732
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/CreateFactorySteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

<div class="d-block mr-7" style="height: 36px; width: 1px; background-color: #EAF3BF;" />

<h5 class=" mr-2">精度</h5>
<h5 class=" mr-2">經度</h5>

<v-text-field hide-details class=" mr-7" outilned solo v-model="locationInputState.longitude" placeholder="例:121.5231872" dense />

Expand Down Expand Up @@ -129,7 +129,7 @@
以下經緯度版本為WGS84
</p>

<h3 class="mb-2">精度</h3>
<h3 class="mb-2">經度</h3>

<v-text-field outilned solo v-model="locationInputState.longitude" placeholder="例:121.5231872" />

Expand Down
28 changes: 22 additions & 6 deletions src/components/FactoryDetailPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<p class="caption mb-0" style="color: #A1A1A1;">
工廠編號 {{ factoryId }} <br>
最後更新 2020/4/12
{{ lastUpdatedAt }}
</p>

<div class="copied-message flex justify-center align-items-center" v-if="showCopiedMessage && !scrollOff">
Expand Down Expand Up @@ -276,22 +276,37 @@ export default createComponent({
if (appState.factoryData) {
(async () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
reportRecords.value = await getFactoryReportRecords(appState.factoryData?.id!)
reportRecords.value = ((await getFactoryReportRecords(appState.factoryData?.id!)) || []).sort((a, b) => {
return new Date(b.created_at) >= new Date(a.created_at) ? 1 : -1
})
})()
}
})
const pastDescriptions = computed(() => {
return reportRecords.value.sort((a, b) => {
return new Date(b.created_at) >= new Date(a.created_at) ? 1 : -1
}).map(record => {
return reportRecords.value.map(record => {
const date = new Date(record.created_at)
const dateStr = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDay()}`
const dateStr = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
return {
date: dateStr,
others: record.others
}
}).filter(rec => rec.others)
})
const lastUpdatedAt = computed(() => {
if (!appState.factoryData || !appState.factoryData.reported_at) {
return null
}
let date
if (reportRecords.value.length === 0) {
date = new Date(appState.factoryData.reported_at)
} else {
date = new Date(reportRecords.value[0].created_at)
}
const dateStr = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
return `最後更新 ${dateStr}`
})
return {
full,
Expand All @@ -309,6 +324,7 @@ export default createComponent({
factoryName,
factoryAddressAndLandcode,
pastDescriptions,
lastUpdatedAt,
longitude,
latitude,
factoryDetailScrollerRef,
Expand Down

0 comments on commit 08be732

Please sign in to comment.