客户档案加上打卡记录以及体重趋势图

This commit is contained in:
xiezhijun 2021-04-10 18:10:36 +08:00
parent fe7834e640
commit 78399c52e7
16 changed files with 802 additions and 150 deletions

View File

@ -6,6 +6,7 @@ import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
import com.stdiet.common.core.page.TableDataInfo; import com.stdiet.common.core.page.TableDataInfo;
import com.stdiet.common.enums.BusinessType; import com.stdiet.common.enums.BusinessType;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.oss.AliyunOSSUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils;
import com.stdiet.common.utils.poi.ExcelUtil; import com.stdiet.common.utils.poi.ExcelUtil;
@ -107,7 +108,7 @@ public class SysWxUserLogController extends BaseController {
if( sysWxUserLog != null && StringUtils.isNotEmpty(sysWxUserLog.getOpenid())){ if( sysWxUserLog != null && StringUtils.isNotEmpty(sysWxUserLog.getOpenid())){
SysWxUserLog dateLog = sysWxUserLogService.selectSysWxUserLogByDateAndOpenId(sysWxUserLog); SysWxUserLog dateLog = sysWxUserLogService.selectSysWxUserLogByDateAndOpenId(sysWxUserLog);
if(dateLog != null && dateLog.getId().intValue() != sysWxUserLog.getId().intValue()){ if(dateLog != null && dateLog.getId().intValue() != sysWxUserLog.getId().intValue()){
return AjaxResult.error("今日该用户已打卡,无法重复打卡"); return AjaxResult.error("该用户"+ DateUtils.dateTime(sysWxUserLog.getLogTime())+"已打卡,无法重复打卡");
} }
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog)); return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
}else{ }else{
@ -189,4 +190,14 @@ public class SysWxUserLogController extends BaseController {
sysWxUserLog.setImagesUrl(downUrlList); sysWxUserLog.setImagesUrl(downUrlList);
return AjaxResult.success(sysWxUserLog); return AjaxResult.success(sysWxUserLog);
} }
/**
* 根据客户ID查询对应打卡体重数据
*/
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:list')")
@GetMapping("/getAllPunchLogByCustomerId")
public AjaxResult getAllPunchLogByCustomerId(SysWxUserLog sysWxUserLog) {
List<SysWxUserLog> list = sysWxUserLogService.getWxUserLogListByCustomerId(sysWxUserLog);
return AjaxResult.success(list);
}
} }

View File

@ -73,6 +73,9 @@ public class SysWxUserLog extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
private Date logTime; private Date logTime;
//客户ID
private Long customerId;
/** /**
* 非持久化字段客户姓名 * 非持久化字段客户姓名
*/ */

View File

@ -78,4 +78,11 @@ public interface SysWxUserLogMapper
*/ */
SysWxUserLog selectSysWxUserLogByDateAndOpenId(SysWxUserLog sysWxUserLog); SysWxUserLog selectSysWxUserLogByDateAndOpenId(SysWxUserLog sysWxUserLog);
/**
* 根据客户ID查询对应打卡体重数据
* @param sysWxUserLog
* @return
*/
List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog);
} }

View File

@ -80,4 +80,11 @@ public interface ISysWxUserLogService
*/ */
SysWxUserLog selectSysWxUserLogByDateAndOpenId(SysWxUserLog sysWxUserLog); SysWxUserLog selectSysWxUserLogByDateAndOpenId(SysWxUserLog sysWxUserLog);
/**
* 根据客户ID查询对应打卡体重数据
* @param sysWxUserLog
* @return
*/
List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog);
} }

View File

@ -124,4 +124,13 @@ public class SysWxUserLogServiceImpl implements ISysWxUserLogService {
return sysWxUserLogMapper.selectSysWxUserLogByDateAndOpenId(sysWxUserLog); return sysWxUserLogMapper.selectSysWxUserLogByDateAndOpenId(sysWxUserLog);
} }
/**
* 根据客户ID查询对应打卡体重数据
* @param sysWxUserLog
* @return
*/
public List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog){
return sysWxUserLogMapper.getWxUserLogListByCustomerId(sysWxUserLog);
}
} }

View File

@ -84,6 +84,9 @@
<if test="id != null"> <if test="id != null">
and wxlog.id = #{id} and wxlog.id = #{id}
</if> </if>
<if test="customerId != null">
and sc.id = #{customerId}
</if>
<if test="phone != null and phone != ''">and (sc.name like concat('%',#{phone},'%') or wxinfo.phone like concat('%',#{phone},'%') )</if> <if test="phone != null and phone != ''">and (sc.name like concat('%',#{phone},'%') or wxinfo.phone like concat('%',#{phone},'%') )</if>
<if test="appid != null"> <if test="appid != null">
and wxinfo.appid = #{appid} and wxinfo.appid = #{appid}
@ -94,7 +97,9 @@
<if test="afterNutritionistId != null"> <if test="afterNutritionistId != null">
and su_atferSale.user_id = #{afterNutritionistId} and su_atferSale.user_id = #{afterNutritionistId}
</if> </if>
order by wxlog.create_time desc <if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')</if>
<if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if>
order by wxlog.log_time desc
</select> </select>
<select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo"> <select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
@ -251,4 +256,15 @@
) sss GROUP BY yearMonth,day_cha LIMIT 2 ) sss GROUP BY yearMonth,day_cha LIMIT 2
</select> </select>
<!-- 后台根据用户ID查询该用户的打卡体重 -->
<select id="getWxUserLogListByCustomerId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
SELECT wxlog.id,wxlog.log_time,wxlog.weight FROM sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0
where wxinfo.phone is not null and sc.id = #{customerId}
<if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')</if>
<if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if>
order by wxlog.log_time asc
</select>
</mapper> </mapper>

View File

@ -50,6 +50,8 @@
"element-ui": "2.13.2", "element-ui": "2.13.2",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"fuse.js": "3.4.4", "fuse.js": "3.4.4",
"highcharts": "^9.0.1",
"highcharts-vue": "^1.3.5",
"html2canvas": "^1.0.0-rc.7", "html2canvas": "^1.0.0-rc.7",
"immer": "^8.0.1", "immer": "^8.0.1",
"js-beautify": "1.10.2", "js-beautify": "1.10.2",

View File

@ -60,3 +60,14 @@ export function getPunchLogDetail(id) {
params: {} params: {}
}) })
} }
// 根据用户ID查询打卡日志详情
export function getAllPunchLogByCustomerId(query) {
return request({
url: '/custom/wxUserLog/getAllPunchLogByCustomerId',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,114 @@
<template>
<div>
<highcharts :options="chartOptions" ></highcharts>
</div>
</template>
<script>
//highcharts线
export default {
name: "PunchLogChart",
components: {
},
data() {
return {
chartOptions:{
chart: {
type: 'line'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories: this.chartOption.xAxisData
},
yAxis: {
title: {
text: this.chartOption.yAxisTitle
}
},
plotOptions: {
line: {
dataLabels: {
//
enabled: true
},
//
enableMouseTracking: false
}
},
series: [{
name: this.chartOption.seriesName,
data: this.chartOption.seriesData
}],
credits: {
enabled: false //LOGO
},
exporting: {
buttons:{ //
contextButton:{
menuItems: [{
text: '下载图片',
onclick: function () {
this.exportChart({
width: 1000
});
}
}]
},
/*exportButton:{ //配置导出按钮
width:50,
symbolSize:20,
borderWidth:2,
borderRadius:0,
hoverBorderColor:'red',
height:30,
symbolX:25,
symbolY:15,
x:-150,
y:20
},*/
},
filename: this.chartOption.imageFileName,//
type:'image/png',//
width:1000 //
},
navigation: {
buttonOptions: {
enabled: true
},
menuStyle: {
background: '#E0E0E0'
}
}
}
};
},
methods: {
},
props:{
chartOption: {
type: Object,
default: function(){
return {
imageFileName: "体重趋势变化折线图",
yAxisTitle: "",
seriesName: "",
xAxisData: [],
seriesData: []
};
}
}
}
};
</script>
<style lang="scss" scoped>
</style>

View File

@ -0,0 +1,190 @@
<template>
<el-drawer
:title="title"
:close-on-press-escape="false"
:visible.sync="visible"
@closed="handleOnClosed"
size="45%"
>
<div class="app-container punchLog_drawer_wrapper">
<div class="header">
<section>
<el-button icon="el-icon-view" size="mini" @click="showPunchLogChart()"
>体重趋势图
</el-button>
</section>
<section>
<el-button
icon="el-icon-refresh"
size="mini"
@click="getList"
circle
/>
</section>
</div>
<el-table :data="punchLogList" v-loading="planLoading" height="80%">
<el-table-column label="打卡日期" align="center" prop="logTime"/>
<el-table-column label="体重(斤)" align="center" prop="weight"/>
<el-table-column label="饮水量(ml)" align="center" prop="water"/>
<el-table-column label="营养师" align="center" prop="nutritionist" />
<el-table-column label="售后" align="center" prop="afterNutritionist" />
<el-table-column label="操作" align="center" width="160">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="showPunchLogDetail(scope.row)"
v-hasPermi="['custom:wxUserLog:query']"
>详情
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:wxUserLog:edit']"
>修改
</el-button>
<el-button
type="text"
icon="el-icon-delete"
v-hasPermi="['custom:wxUserLog:remove']"
@click="handleOnDelete(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<!-- 详情 -->
<PunchLogDetail ref="punchLogDetailRef"></PunchLogDetail>
<!-- 编辑 -->
<PunchLogEdit ref="punchLogEditRef"></PunchLogEdit>
<!-- 体重趋势图 -->
<PunchLogChart ref="punchLogChartRef"></PunchLogChart>
</el-drawer>
</template>
<script>
import {
addWxUserLog,
delWxUserLog,
exportWxUserLog,
getWxUserLog,
listWxUserLog,
updateWxUserLog,
} from "@/api/custom/wxUserLog";
import PunchLogDetail from "@/components/PunchLog/PunchLogDetail";
import PunchLogEdit from "@/components/PunchLog/PunchLogEdit";
import PunchLogChart from "@/components/PunchLog/PunchLogChart";
import dayjs from "dayjs";
export default {
name: "CustomerPunchLog",
components: {
PunchLogDetail,PunchLogEdit,PunchLogChart
},
data() {
return {
open: false,
visible: false,
title: "",
planLoading: false,
data: null,
punchLogList: [],
total: 0,
//
queryParams: {
pageNum: 1,
pageSize: 10,
customerId: null
},
};
},
methods: {
showDrawer(data) {
// console.log(data);
this.data = data;
if (this.data == undefined || this.data == null) {
return;
}
this.punchLogList = [];
this.total = 0;
this.visible = true;
this.title = `${this.data.name}」打卡记录`;
this.getList();
},
getList() {
this.planLoading = true;
this.queryParams.customerId = this.data.id;
listWxUserLog(this.queryParams).then((response) => {
if(response.code == 200){
this.punchLogList = response.rows;
this.total = response.total;
}
this.planLoading = false;
});
},
reset() {
},
handleOnClosed(){
this.data = null
},
showPunchLogDetail(data){
this.$refs.punchLogDetailRef.showDialog(data);
},
showPunchLogChart(){
this.$refs.punchLogChartRef.showDialog(this.data);
},
handleUpdate(data){
this.$refs.punchLogEditRef.showDialog(data, () => {
this.getList();
});
},
/** 删除按钮操作 */
handleOnDelete(row) {
const ids = row.id;
this.$confirm(
'是否确定删除该用户' + row.logTime + '的打卡记录?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
)
.then(function () {
return delWxUserLog(ids);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
})
.catch(function () {});
},
},
};
</script>
<style lang="scss" scoped>
/deep/ :focus {
outline: 0;
}
.punchLog_drawer_wrapper {
height: calc(100vh - 77px);
.header {
margin-bottom: 8px;
display: flex;
align-items: center;
justify-content: space-between;
}
}
</style>

View File

@ -0,0 +1,89 @@
<template>
<el-dialog
:visible.sync="visible"
:title="title"
append-to-body
@closed="onClosed"
width="1000px"
>
<div id="container">
<LineCharts v-if="visible" :chartOption="punchLogChartOption"></LineCharts>
</div>
</el-dialog>
</template>
<script>
import {
getAllPunchLogByCustomerId
} from "@/api/custom/wxUserLog";
import LineCharts from "@/components/Highcharts/LineCharts";
export default {
name: "PunchLogChart",
components: {
LineCharts
},
data() {
return {
visible: false,
title: "",
data: null,
punchLogChartOption:{
imageFileName: "体重趋势图",
yAxisTitle: "体重(斤)",
seriesName: "体重趋势(斤)",
xAxisData: [],
seriesData: []
},
punchLogList:[],
queryParams:{
customerId: null
}
};
},
methods: {
showDialog(data) {
this.data = data;
this.title = `${data.name}」体重趋势图`;
this.queryParams.customerId = data.id;
this.punchLogChartOption.imageFileName = data.name + "体重趋势图"
this.getAllPunchLogByCustomerId();
},
getAllPunchLogByCustomerId() {
getAllPunchLogByCustomerId(this.queryParams).then((res) => {
if (res.code == 200) {
this.punchLogList = res.data;
this.dealPunchLogList(res.data);
this.visible = true;
}
});
},
dealPunchLogList(data){
let xAxisData = [];
let seriesData = [];
if(data && data.length > 0){
data.forEach((element,index) => {
xAxisData.push(element.logTime);
seriesData.push(element.weight);
if(index == data.length-1){
this.punchLogChartOption.xAxisData = xAxisData;
this.punchLogChartOption.seriesData = seriesData;
}
});
}else{
this.punchLogChartOption.xAxisData = xAxisData;
this.punchLogChartOption.seriesData = seriesData;
}
},
onClosed() {
this.data = null;
this.punchLog = null;
this.punchLogList = [];
}
},
};
</script>
<style lang="scss" scoped>
</style>

View File

@ -27,7 +27,7 @@
<TableDetailMessage :data="punchLogDetail"></TableDetailMessage> <TableDetailMessage :data="punchLogDetail"></TableDetailMessage>
<h3>图片信息</h3> <h3>图片信息</h3>
<div style="height: 400px; overflow: auto"> <div style="height: 400px; overflow: auto">
<div> <div v-if="punchLog != null && punchLog.imagesUrl.breakfastImages.length > 0">
<h4>早餐</h4> <h4>早餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.breakfastImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.breakfastImages" title="点击大图预览" :key="index"
@ -37,7 +37,7 @@
</el-image> </el-image>
</div> </div>
</div> </div>
<div> <div v-if="punchLog != null && punchLog.imagesUrl.lunchImages.length > 0">
<h4>午餐</h4> <h4>午餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.lunchImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.lunchImages" title="点击大图预览" :key="index"
@ -47,7 +47,7 @@
</el-image> </el-image>
</div> </div>
</div> </div>
<div> <div v-if="punchLog != null && punchLog.imagesUrl.dinnerImages.length > 0">
<h4>晚餐</h4> <h4>晚餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.dinnerImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.dinnerImages" title="点击大图预览" :key="index"
@ -57,7 +57,7 @@
</el-image> </el-image>
</div> </div>
</div> </div>
<div> <div v-if="punchLog != null && punchLog.imagesUrl.extraMealImages.length > 0">
<h4>加餐</h4> <h4>加餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.extraMealImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.extraMealImages" title="点击大图预览" :key="index"
@ -67,7 +67,7 @@
</el-image> </el-image>
</div> </div>
</div> </div>
<div> <div v-if="punchLog != null && punchLog.imagesUrl.bodyImages.length > 0">
<h4>体型对比照</h4> <h4>体型对比照</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.bodyImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.bodyImages" title="点击大图预览" :key="index"
@ -105,7 +105,7 @@ export default {
punchTitleData: [ punchTitleData: [
["姓名", "体重(斤)","饮水量(ml)"], ["姓名", "体重(斤)","饮水量(ml)"],
["睡觉时间", "起床时间","运动锻炼"], ["睡觉时间", "起床时间","运动锻炼"],
["情绪","按食谱进食","食谱外食物"], ["情绪","按食谱进食","其他食物"],
["熬夜失眠", "起床排便","是否便秘"] ["熬夜失眠", "起床排便","是否便秘"]
], ],
// //
@ -175,6 +175,7 @@ export default {
onClosed() { onClosed() {
this.data = null; this.data = null;
this.punchLog = null, this.punchLog = null,
this.imageUrl = [],
this.punchLogDetail = [] this.punchLogDetail = []
} }
}, },

View File

@ -0,0 +1,271 @@
<template>
<!-- 修改打卡记录基础信息对话框 -->
<el-dialog :title="title" :visible.sync="visible" width="600px" append-to-body>
<el-row :gutter="15">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="12">
<el-form-item label="体重" prop="weight">
<el-input v-model="form.weight" placeholder="请输入体重" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="打卡日期" prop="logTime">
<el-date-picker
clearable
size="small"
style="width: 192px;"
v-model="form.logTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择打卡时间"
:picker-options="logTimePickerOptions"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="睡觉时间" prop="sleepTime">
<el-time-select
clearable
size="small"
style="width: 192px"
v-model="form.sleepTime"
:picker-options="{
start: '00:00',
step: '00:15',
end: '23:45',
}"
placeholder="选择睡觉时间"
>
</el-time-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="起床时间" prop="wakeupTime">
<el-time-select
clearable
size="small"
style="width: 192px"
v-model="form.wakeupTime"
:picker-options="{
start: '00:00',
step: '00:15',
end: '23:45',
}"
placeholder="选择睡觉时间"
>
</el-time-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="运动锻炼" prop="sport">
<el-select v-model="form.sport" placeholder="请选择运动情况">
<el-option
v-for="dict in yesNoOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="按食谱" prop="diet">
<el-select v-model="form.diet" placeholder="请选择饮食情况">
<el-option
v-for="dict in yesNoOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="熬夜失眠" prop="insomnia">
<el-select v-model="form.insomnia" placeholder="请选择熬夜失眠">
<el-option
v-for="dict in yesNoOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="起床排便" prop="defecation">
<el-select v-model="form.defecation" placeholder="请选择排便情况">
<el-option
v-for="dict in yesNoOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="便秘" prop="constipation">
<el-select v-model="form.constipation" placeholder="请选择便秘情况">
<el-option
v-for="dict in yesNoOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="饮水量" prop="water">
<el-input v-model="form.water" style="width: 192px" placeholder="请输入饮水量" />
</el-form-item>
</el-col>
<el-col>
<el-form-item label="情绪" prop="emotion">
<el-input
v-model="form.emotion"
type="textarea"
placeholder="请输入情绪"
/>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="其他食物" prop="slyEatFood">
<el-input
v-model="form.slyEatFood"
type="textarea"
placeholder="请输入其他食物"
/>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</template>
<script>
import {
getWxUserLog,updateWxUserLog
} from "@/api/custom/wxUserLog";
import dayjs from "dayjs";
export default {
name: "PunchLogEdit",
components: {
},
data() {
return {
visible: false,
title: "",
punchLog: null,
form: {},
rules:{
weight: [
{ required: true, message: "体重不能为空", trigger: "blur" },
{
required: true,
trigger: "blur",
pattern: /^(([^0][0-9]+|0)\.([0-9]{1,2})$)|^([^0][0-9]+|0)$/,
message: "体重格式不正确",
},
],
water: [
{ required: true, message: "饮水量不能为空", trigger: "blur" },
{
required: true,
trigger: "blur",
pattern: /^([^0][0-9]+|0)$/,
message: "饮水量格式不正确",
}
],
logTime: [
{ required: true, message: "打卡时间不能为空", trigger: "blur" },
]
},
logTimePickerOptions: {
disabledDate(time) {
return time.getTime() > dayjs()
},
},
yesNoOptions: [],
callback: null
};
},
created(){
this.getDicts("sys_yes_no").then((response) => {
this.yesNoOptions = response.data;
});
},
methods: {
showDialog(data, callback) {
this.punchLog = data;
this.callback = callback;
this.title = `修改「${data.customerName}`+" "+`${data.logTime}」打卡记录`;
this.getWxUserLog();
},
getWxUserLog() {
this.reset();
getWxUserLog(this.punchLog.id).then((response) => {
if (response.code == 200) {
this.form = response.data;
this.visible = true;
}
});
},
reset(){
this.form = {
id: null,
weight: null,
sleepTime: null,
wakeupTime: null,
sport: null,
diet: null,
insomnia: null,
defecation: null,
water: null,
logTime: null,
constipation: null,
emotion: null,
slyEatFood: null
};
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateWxUserLog(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.visible = false;
this.callback && this.callback();
}
});
}
}
});
},
onClosed() {
this.form = null;
this.punchLog = null
},
cancel(){
this.visible = false
}
},
};
</script>
<style lang="scss" scoped>
</style>

View File

@ -19,6 +19,11 @@ import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config"; import { getConfigKey } from "@/api/system/config";
import VueScrollTo from "vue-scrollto"; import VueScrollTo from "vue-scrollto";
import VueResource from "vue-resource" import VueResource from "vue-resource"
import HighchartsVue from 'highcharts-vue'
import Highcharts from 'highcharts'
//图片导出模块
import exportingInit from 'highcharts/modules/exporting'
exportingInit(Highcharts)
import { import {
addDateRange, addDateRange,
@ -69,6 +74,7 @@ Vue.component("Pagination", Pagination);
Vue.component("RightToolbar", RightToolbar); Vue.component("RightToolbar", RightToolbar);
Vue.use(permission); Vue.use(permission);
Vue.use(HighchartsVue);
/** /**
* If you don't want to use mock-server * If you don't want to use mock-server

View File

@ -235,10 +235,27 @@
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
label="打卡记录"
align="center"
v-hasPermi="['custom:wxUserLog:list']"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="handleClickCustomerPunchLog(scope.row)"
>详情
</el-button>
</template>
</el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
fixed="right" fixed="right"
width="120"
class-name="small-padding fixed-width" class-name="small-padding fixed-width"
> >
<template slot-scope="scope"> <template slot-scope="scope">
@ -375,6 +392,8 @@
<heatStatisticsDrawer ref="heatStatisticsRef"></heatStatisticsDrawer> <heatStatisticsDrawer ref="heatStatisticsRef"></heatStatisticsDrawer>
<!-- 食谱计划抽屉 --> <!-- 食谱计划抽屉 -->
<RecipesPlanDrawer ref="recipesPlanDrawerRef" /> <RecipesPlanDrawer ref="recipesPlanDrawerRef" />
<!-- 客户打卡记录 -->
<CustomerPunchLogDrawer ref="customerPunchLogDrawerRef"></CustomerPunchLogDrawer>
</div> </div>
</template> </template>
@ -394,6 +413,7 @@ import PhysicalSignsDialog from "@/components/PhysicalSignsDialog";
import ContractDrawer from "@/components/ContractDrawer"; import ContractDrawer from "@/components/ContractDrawer";
import HeatStatisticsDrawer from "@/components/HeatStatisticsDrawer"; import HeatStatisticsDrawer from "@/components/HeatStatisticsDrawer";
import RecipesPlanDrawer from "@/components/RecipesPlanDrawer"; import RecipesPlanDrawer from "@/components/RecipesPlanDrawer";
import CustomerPunchLogDrawer from "@/components/PunchLog/CustomerPunchLog";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
@ -404,6 +424,7 @@ export default {
"contract-drawer": ContractDrawer, "contract-drawer": ContractDrawer,
heatStatisticsDrawer: HeatStatisticsDrawer, heatStatisticsDrawer: HeatStatisticsDrawer,
RecipesPlanDrawer, RecipesPlanDrawer,
CustomerPunchLogDrawer
}, },
data() { data() {
const userId = store.getters && store.getters.userId; const userId = store.getters && store.getters.userId;
@ -552,6 +573,10 @@ export default {
handleClickHeatStatistics(row) { handleClickHeatStatistics(row) {
this.$refs["heatStatisticsRef"].showDrawer(row); this.$refs["heatStatisticsRef"].showDrawer(row);
}, },
handleClickCustomerPunchLog(row) {
this.$refs["customerPunchLogDrawerRef"].showDrawer(row);
},
// //
cancel() { cancel() {
this.open = false; this.open = false;

View File

@ -52,6 +52,20 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="打卡日期" prop="logTimeScope" style="margin-left:15px">
<el-date-picker
v-model="logTimeScope"
type="daterange"
range-separator="至"
start-placeholder="打卡开始日期"
end-placeholder="打卡结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
:picker-options="logTimePickerOptions"
>
</el-date-picker>
</el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
type="cyan" type="cyan"
@ -233,6 +247,7 @@
label="操作" label="操作"
align="center" align="center"
class-name="small-padding fixed-width" class-name="small-padding fixed-width"
width="140"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -242,14 +257,14 @@
v-hasPermi="['custom:wxUserLog:query']" v-hasPermi="['custom:wxUserLog:query']"
>详情 >详情
</el-button> </el-button>
<!--<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['custom:wxUserLog:edit']" v-hasPermi="['custom:wxUserLog:edit']"
>修改 >修改
</el-button>--> </el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -270,136 +285,9 @@
@pagination="getList" @pagination="getList"
/> />
<!-- 添加或修改微信用户记录对话框 --> <!-- 编辑 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> <PunchLogEdit ref="punchLogEditRef"></PunchLogEdit>
<el-row :gutter="15"> <!-- 详情 -->
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="12">
<el-form-item label="体重" prop="weight">
<el-input v-model="form.weight" placeholder="请输入体重" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="打卡日期" prop="logTime">
<el-date-picker
clearable
size="small"
style="width: 200px"
v-model="form.logTime"
type="date"
value-format="yyyy-MM-dd"
:picker-options="logTimePickerOptions"
placeholder="选择睡觉时间"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="睡觉时间" prop="sleepTime">
<el-time-select
clearable
size="small"
style="width: 200px"
v-model="form.sleepTime"
:picker-options="{
start: '00:00',
step: '00:15',
end: '23:45',
}"
placeholder="选择睡觉时间"
>
</el-time-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="起床时间" prop="wakeupTime">
<el-time-select
clearable
size="small"
style="width: 200px"
v-model="form.wakeupTime"
:picker-options="{
start: '00:00',
step: '00:15',
end: '23:45',
}"
placeholder="选择睡觉时间"
>
</el-time-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="运动锻炼" prop="sport">
<el-select v-model="form.sport" placeholder="请选择运动情况">
<el-option
v-for="dict in sportOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="按食谱" prop="diet">
<el-select v-model="form.diet" placeholder="请选择饮食情况">
<el-option
v-for="dict in dietOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="熬夜失眠" prop="insomnia">
<el-select v-model="form.insomnia" placeholder="请选择熬夜失眠">
<el-option
v-for="dict in insomniaOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="起床排便" prop="defecation">
<el-select v-model="form.defecation" placeholder="请选择排便情况">
<el-option
v-for="dict in defecationOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="饮水量" prop="water">
<el-input v-model="form.water" placeholder="请输入饮水量" />
</el-form-item>
</el-col>
<el-col>
<el-form-item label="备注" prop="remark">
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<PunchLogDetail ref="punchLogDetailRef"></PunchLogDetail> <PunchLogDetail ref="punchLogDetailRef"></PunchLogDetail>
</div> </div>
</template> </template>
@ -415,7 +303,9 @@ import {
} from "@/api/custom/wxUserLog"; } from "@/api/custom/wxUserLog";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import PunchLogDetail from "@/components/PunchLog/PunchLogDetail"; import PunchLogDetail from "@/components/PunchLog/PunchLogDetail";
import PunchLogEdit from "@/components/PunchLog/PunchLogEdit";
import AutoHideMessage from "@/components/AutoHideMessage"; import AutoHideMessage from "@/components/AutoHideMessage";
import dayjs from "dayjs";
export default { export default {
name: "WxUserLog", name: "WxUserLog",
data() { data() {
@ -463,13 +353,14 @@ export default {
rules: {}, rules: {},
logTimePickerOptions: { logTimePickerOptions: {
disabledDate(time) { disabledDate(time) {
return time.getTime() > Date.now(); return time.getTime() > dayjs()
}, },
}, },
logTimeScope: null
}; };
}, },
components:{ components:{
PunchLogDetail,AutoHideMessage PunchLogDetail,AutoHideMessage,PunchLogEdit
}, },
created() { created() {
this.getList(); this.getList();
@ -501,6 +392,8 @@ export default {
/** 查询微信用户记录列表 */ /** 查询微信用户记录列表 */
getList() { getList() {
this.loading = true; this.loading = true;
this.queryParams.beginTime = this.logTimeScope && this.logTimeScope.length > 0 ? this.logTimeScope[0] : null;
this.queryParams.endTime = this.logTimeScope && this.logTimeScope.length > 0 ? this.logTimeScope[1] : null;
listWxUserLog(this.queryParams).then((response) => { listWxUserLog(this.queryParams).then((response) => {
this.wxUserLogList = response.rows; this.wxUserLogList = response.rows;
this.total = response.total; this.total = response.total;
@ -573,6 +466,7 @@ export default {
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.logTimeScope = null;
this.handleQuery(); this.handleQuery();
}, },
// //
@ -589,12 +483,8 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.$refs.punchLogEditRef.showDialog(row, () => {
const id = row.id || this.ids; this.getList();
getWxUserLog(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改微信用户记录";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -626,7 +516,7 @@ export default {
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; const ids = row.id || this.ids;
this.$confirm( this.$confirm(
'是否确认删除微信用户记录编号为"' + ids + '"的数据项?', '是否确认删除该用户的打卡记录?',
"警告", "警告",
{ {
confirmButtonText: "确定", confirmButtonText: "确定",