1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

体温上报 历史上报信息

This commit is contained in:
2022-12-28 21:48:44 +08:00
parent 4594fe8e80
commit 494e578628
9 changed files with 341 additions and 57 deletions

View File

@@ -41,61 +41,67 @@
</style>
<template>
<view class="form">
<view>
<view v-if="!isFilled" class="form">
<view class="row">
<view class="rowItem rowLeft center">
<text>姓名</text>
</view>
<view class="rowItem rowRight center">
<input class="rowRightElement" :value="formData.userRealname" disabled="true" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>姓名</text>
<view class="row">
<view class="rowItem rowLeft center">
<text>填报时间</text>
</view>
<view class="rowItem rowRight center">
<input class="rowRightElement" :value="formData.time" disabled="true" />
</view>
</view>
<view class="rowItem rowRight center">
<input class="rowRightElement" :value="formData.userRealname" disabled="true" />
<view class="row">
<view class="rowItem rowLeft center">
<text>地址</text>
</view>
<view class="rowItem rowRight center" @tap="chooseLocation">
<input class="rowRightElement" placeholder="点击获取当前位置" v-model="formData.address" disabled="true"
maxlength="500" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>今日体温</text>
</view>
<view class="rowItem rowRight center">
<radio-group class="rowRightElement" @change="(e) => formData.temperature = e.detail.value">
<radio value="0" checked="true" />正常&nbsp;
<radio value="1" />异常(37.3°)
</radio-group>
</view>
</view>
<view class="tips-area">
<view class="tips" style="color: red;">
* 本人承诺以上所填报的内容全部真实并愿意承担相应责任
</view>
</view>
<view style="text-align: center;">
<button class="controlBtn" size="mini" type="none" @tap="myreport">历史填报</button>
<button class="controlBtn" size="mini" type="primary" @tap="report">提交</button>
</view>
<textarea v-if="this.debugMode" maxlength="-1" disabled="true" auto-height="true" style="width: 100%"
:value="JSON.stringify(formData, null, 8)"></textarea>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>填报时间</text>
</view>
<view class="rowItem rowRight center">
<input class="rowRightElement" :value="formData.time" disabled="true" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>地址</text>
</view>
<view class="rowItem rowRight center" @tap="chooseLocation">
<input class="rowRightElement" placeholder="点击获取当前位置" v-model="formData.address" disabled="true"
maxlength="500" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>今日体温</text>
</view>
<view class="rowItem rowRight center">
<radio-group class="rowRightElement" @change="(e) => formData.temperature = e.detail.value">
<radio value="0" checked="true" />正常&nbsp;
<radio value="1" />异常(37.3°)
</radio-group>
</view>
</view>
<view class="tips-area">
<view class="tips" style="color: red;">
* 本人承诺以上所填报的内容全部真实并愿意承担相应责任
</view>
</view>
<view style="text-align: center;">
<view v-else style="text-align: center;">
<!-- -->
<view style="margin: 40px 0;">{{ filledMsg }}</view>
<button class="controlBtn" size="mini" type="none" @tap="myreport">历史填报</button>
<button class="controlBtn" size="mini" type="primary" @tap="report">提交</button>
</view>
<textarea v-if="this.debugMode" maxlength="-1" disabled="true" auto-height="true" style="width: 100%"
:value="JSON.stringify(formData, null, 8)"></textarea>
</view>
</template>
@@ -116,17 +122,69 @@ export default {
time: '',
timestamp: '',
temperature: 0,
}
},
// 是否填报过
isFilled: true,
filledMsg: "",
}
},
onShow() {
console.log('onShow')
this.userInfo = Taro.getStorageSync("userInfo")
console.log("this.userInfo", this.userInfo)
this.formData.userId = this.userInfo.id
this.formData.userRealname = this.userInfo.realname
this.updateTime();
this.timeInterval = setInterval(this.updateTime, 1000);
// 获取用户当日是否填报过
Taro.showLoading({ title: '加载中' })
var that = this;
Taro.request({
url: `${this.baseUrl}/access/report/getLatestRecord`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
userId: this.userInfo.id
},
success: function (d) {
Taro.hideLoading()
let result = d.data
console.log("result", result)
if (result.success) {
console.log("result.data", result.data);
if (result.data == null || new Date(result.data.time) < new Date(new Date().toISOString().substring(0, 10))) {
// 如果没有填报记录,或者填报记录不是今天,那么说明没有填报过
that.isFilled = false
} else {
// 有今日记录,说明已经填报过
that.isFilled = true
that.filledMsg = "您已完成今日体温填报"
}
} else {
Taro.showToast({
title: "加载填报信息失败",
icon: 'error',
duration: 2000
})
}
},
fail: function () {
Taro.hideLoading()
Taro.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
},
complete: function () {
Taro.hideNavigationBarLoading();
}
})
},
onHide() {
@@ -173,9 +231,16 @@ export default {
})
Taro.hideLoading()
},
// 体温上报 提交按钮
report() {
console.log("点击提交", "this.formData", this.formData)
if (!this.formData.address) {
Taro.showToast({
title: "请获取当前位置",
icon: 'error'
})
return;
}
Taro.showLoading({ title: '加载中' })
var that = this;
Taro.request({
@@ -192,6 +257,9 @@ export default {
Taro.hideLoading()
let result = d.data;
if (result.success) {
// 填报完成
that.isFilled = true
that.filledMsg = "您已完成今日体温填报"
console.log("result.data", result.data);
Taro.showToast({
title: "填报成功",
@@ -226,6 +294,12 @@ export default {
that.debugMode && console.log("end complete")
}
})
},
// 历史填报
myreport() {
Taro.navigateTo({
url: "/pages/residents/reportHistory"
})
}
}
}

View File

@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '体温上报 - 历史记录',
})

View File

@@ -0,0 +1,131 @@
<template>
<view>
<view style="margin: 20px; text-align: center;">
<text>姓名{{ displayName }}</text>
</view>
<view class="container">
<view class="item" :class="item.temperature == 1 ? 'abnormal' : 'normal'" v-for="item of displayResult">
<view>
<view class="record_time">
<!-- 填报时间 -->
{{ item.time }}
</view>
<view class="record_address">
<!-- 地址 -->
{{ item.address }}
</view>
</view>
<view class="statusText">{{ item.temperature == 1 ? "异常" : "正常" }}</view>
</view>
</view>
</view>
</template>
<script>
import Taro from '@tarojs/taro'
import utils from '../../utils/utils'
export default {
data() {
return {
...Taro.getApp().globalData,
userInfo: null,
displayName: '',
displayResult: [],
}
},
onShow() {
console.log('onShow')
this.userInfo = Taro.getStorageSync("userInfo")
this.displayName = this.userInfo.realname
// 获取用户填报历史
Taro.showLoading({ title: '加载中' })
var that = this;
Taro.request({
url: `${this.baseUrl}/access/report/getRecordList`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
userId: this.userInfo.id
},
success: function (d) {
Taro.hideLoading()
let result = d.data
console.log("result", result)
if (result.success) {
console.log("result.data", result.data)
that.displayResult = result.data.map(item => {
// 时间友好化显示
let t = new Date(item.time).getTime() + 8 * 3600 * 1000
item.time = new Date(t).toISOString().substring(0, 19).replace("T", " ")
return item
})
} else {
Taro.showToast({
title: "加载填报信息失败",
icon: 'error',
duration: 2000
})
}
},
fail: function () {
Taro.hideLoading()
Taro.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
},
complete: function () {
Taro.hideNavigationBarLoading();
}
})
},
onHide() {
console.log('onHide')
clearInterval(this.timeInterval)
},
methods: {
}
}
</script>
<style>
.item {
/* background-color: #dedede; */
border-radius: 8px;
margin: 20px 32px;
padding: 25px;
display: grid;
grid-template-columns: 1fr 130px;
place-items: center;
color: white;
}
.item.normal {
background-color: green;
}
.item.abnormal {
background-color: red;
}
.record_time {
font-size: 30px;
}
.record_address {
font-size: 25px;
}
.statusText {
font-size: large;
font-weight: bold;
}
</style>