调整打卡记录页面

This commit is contained in:
huangdeliang 2021-08-17 15:17:22 +08:00
parent bb3b2f9270
commit 9594c9222c
3 changed files with 48 additions and 11 deletions

View File

@ -10,12 +10,22 @@
<div v-if="data.length"> <div v-if="data.length">
<CursorChartView :data="getChartData('weight')" /> <CursorChartView :data="getChartData('weight')" />
<el-button
icon="el-icon-view"
size="mini"
class="weigth_trend_button"
:style="`left: ${getTextWidth(title) + 30}px`"
@click="showPunchLogChart()"
>体重趋势图</el-button
>
<div <div
class="chart_zone_style" class="chart_zone_style"
v-for="chart in chartList" v-for="chart in chartList"
:key="chart.keyVal" :key="chart.keyVal"
> >
<LineChartView <LineChartView
v-if="chart.keyVal"
v-bind="chart" v-bind="chart"
:data="getChartData(chart.keyVal)" :data="getChartData(chart.keyVal)"
@onClick="handleOnChartClick" @onClick="handleOnChartClick"
@ -26,6 +36,8 @@
</div> </div>
<!-- 详情 --> <!-- 详情 -->
<PunchLogDetail ref="punchLogDetailRef"></PunchLogDetail> <PunchLogDetail ref="punchLogDetailRef"></PunchLogDetail>
<!-- 体重趋势图 -->
<PunchLogChart ref="punchLogChartRef"></PunchLogChart>
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
@ -34,6 +46,7 @@ import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
import LineChartView from "../LineChartView"; import LineChartView from "../LineChartView";
import CursorChartView from "../CursorChartView"; import CursorChartView from "../CursorChartView";
import PunchLogDetail from "@/components/PunchLog/PunchLogDetail"; import PunchLogDetail from "@/components/PunchLog/PunchLogDetail";
import PunchLogChart from "@/components/PunchLog/PunchLogChart";
export default { export default {
name: "punchLog", name: "punchLog",
@ -41,6 +54,7 @@ export default {
LineChartView, LineChartView,
CursorChartView, CursorChartView,
PunchLogDetail, PunchLogDetail,
PunchLogChart,
}, },
data() { data() {
return { return {
@ -80,6 +94,18 @@ export default {
handleOnClosed() { handleOnClosed() {
this.userObj = undefined; this.userObj = undefined;
}, },
showPunchLogChart() {
this.$refs.punchLogChartRef.showDialog(this.userObj);
},
getTextWidth(text) {
const canvas = document.createElement("canvas");
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d");
ctx.font = "16px Arial";
const { width } = ctx.measureText(text);
document.body.removeChild(canvas);
return Math.ceil(width);
},
fetchLogDatas() { fetchLogDatas() {
this.loading = true; this.loading = true;
getCustomerPhysicalSignsByCusId(this.userObj.id).then((res) => { getCustomerPhysicalSignsByCusId(this.userObj.id).then((res) => {
@ -147,5 +173,10 @@ export default {
.empty_style { .empty_style {
text-align: center; text-align: center;
} }
.weigth_trend_button {
position: absolute;
top: 16px;
}
} }
</style> </style>

View File

@ -7,7 +7,7 @@ function getComOption(title, data) {
left: 5, left: 5,
top: 8, top: 8,
textStyle: { textStyle: {
color: "#fff" // color: "#fff"
} }
}, },
textStyle: { textStyle: {
@ -41,7 +41,7 @@ function getComOption(title, data) {
color: "#fff" color: "#fff"
}, },
handleStyle: { handleStyle: {
borderColor: "#fff" // borderColor: "#fff"
} }
// filterMode: 'none', // filterMode: 'none',
}, },
@ -50,7 +50,7 @@ function getComOption(title, data) {
type: "category", type: "category",
inverse: true, inverse: true,
nameTextStyle: { nameTextStyle: {
color: "#fff" // color: "#fff"
}, },
axisLine: { axisLine: {
show: false show: false
@ -60,7 +60,7 @@ function getComOption(title, data) {
}, },
axisLabel: { axisLabel: {
textStyle: { textStyle: {
color: "#fff" // color: "#fff"
}, },
formatter: val => val.substr(5).replace("-", "/") formatter: val => val.substr(5).replace("-", "/")
}, },
@ -73,7 +73,7 @@ function getComOption(title, data) {
}, },
axisLabel: { axisLabel: {
textStyle: { textStyle: {
color: "#fff" // color: "#fff"
} }
}, },
axisTick: { axisTick: {
@ -87,10 +87,10 @@ function getComOption(title, data) {
{ {
type: "line", type: "line",
lineStyle: { lineStyle: {
color: "#fff" color: "#FF6E67"
}, },
itemStyle: { itemStyle: {
color: "#fff" color: "#333"
} }
// data, // data,
} }
@ -115,7 +115,7 @@ function getOption(type, data, title, unit, extra) {
top: 16, top: 16,
style: { style: {
text: `单位:${unit}`, text: `单位:${unit}`,
fill: "#fff" // fill: "#fff"
} }
}); });
} }
@ -126,7 +126,7 @@ function getOption(type, data, title, unit, extra) {
top: 36, top: 36,
style: { style: {
text: extra, text: extra,
fill: "#fff" // fill: "#fff"
} }
}); });
} }

View File

@ -69,7 +69,13 @@ export default {
} }
}, },
updateChart(source) { updateChart(source) {
const option = getOption(this.keyVal, source, this.label, this.unit, this.extra); const option = getOption(
this.keyVal,
source,
this.label,
this.unit,
this.extra
);
// console.log({ option }); // console.log({ option });
this.chart.clear(); this.chart.clear();
this.chart.setOption(option); this.chart.setOption(option);
@ -138,6 +144,6 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.chart_style_wrapper { .chart_style_wrapper {
background: #4b8aff; background: #FFECEC;
} }
</style> </style>