Commit 5b5021b0 authored by 张杰's avatar 张杰

添加记录页面部分页面数据填充

parent 87386bce
......@@ -24,8 +24,16 @@ module.exports = {
classId: classId,
studentIds: studentIds
}
return request.post('/preschool/wxsite/teacher/signin.do', params)
},
queryRecordList(recordCategory, recordType, signSummaryIds) {
var params = {
recordCategory: recordCategory,
recordType: recordType,
signSummaryIds: signSummaryIds
}
return request.post('/preschool/wxsite/teacher/queryRecordList.do', params)
}
}
\ No newline at end of file
......@@ -36,7 +36,20 @@ App({
globalData: {
userInfo: null,
//一些默认值
operate_btn_height: 80
operate_btn_height: 80,
recordTypes: {
"diet_morning": '早餐',
"diet_afternoon": "午餐",
"diet_evening": "晚餐",
"diet_morning_more": "上午加餐",
"diet_afternoon_more": "下午加餐",
"diet_water": "喝水",
"diet_milk": "饮用牛奶",
"sleep_time": "睡觉时间",
"wc_pee": "小便",
"wc_poo": "便",
"wc_diaper": "换尿布"
},
}
})
\ No newline at end of file
// pages/add_record/index.js
const req = require('../../api/teacher.js')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
radioValues: [
{ 'value': '饮食', 'selected': true },
{ 'value': '睡觉', 'selected': false },
{ 'value': 'WC', 'selected': false },
radioValues: [{
'value': '饮食',
'code': 'diet',
'selected': true
},
{
'value': '睡觉',
'code': 'sleep',
'selected': false
},
{
'value': 'WC',
'code': 'wc',
'selected': false
},
],
clazz: [],
controlIndex:0,
categorys: ['早餐', '午餐', '晚餐', '上午加餐', '下午加餐', '喝水', '牛奶'],
selectIndex:0,
studentIds:[],
controlIndex: 0,
categoryCode: ['diet_morning', 'diet_afternoon', 'diet_evening', 'diet_morning_more', 'diet_afternoon_more', 'diet_water', 'diet_milk'],
categorys: [],
typeIndex: 0,
inputModel: [
],
selectPic: []
selectPic: [],
recordTypes: app.globalData.recordTypes,
eatCellTags: {},
//获取到的数据
eatRecord:[],
sleepRecord:[],
wcRecord:[]
},
//添加图片
......@@ -28,7 +51,7 @@ Page({
wx.chooseImage({
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
success: function(res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
for (var i in res.tempFilePaths) {
that.data.selectPic.push(res.tempFilePaths[i])
......@@ -40,7 +63,7 @@ Page({
})
},
previewPic:function(e) {
previewPic: function(e) {
var current = this.data.selectPic[e.target.dataset.index]
wx.previewImage({
current: current,
......@@ -49,122 +72,258 @@ Page({
},
//删除图片
deleteImg:function(e) {
deleteImg: function(e) {
var that = this
that.data.selectPic.splice(e.currentTarget.dataset.index,1)
that.data.selectPic.splice(e.currentTarget.dataset.index, 1)
that.setData({
selectPic: that.data.selectPic
})
},
tapCategory: function(e) {
//选择小分类
tapType: function(e) {
this.setData({
selectIndex: e.target.dataset.index,
typeIndex: e.target.dataset.index,
})
this.getRecord()
},
indexChanged: function(e){
// 点中的是组中第个元素
var index = e.target.dataset.index;
// 读取原始的数组
var radioValues = this.data.radioValues;
for (var i = 0; i < radioValues.length; i++){
// 全部改为非选中
radioValues[i].selected = false;
// 当前那个改为选中
radioValues[index].selected = true;
}
indexChanged: function(e) {
// 点中的是组中第个元素
var index = e.target.dataset.index;
// 读取原始的数组
var radioValues = this.data.radioValues;
for (var i = 0; i < radioValues.length; i++) {
// 全部改为非选中
radioValues[i].selected = false;
// 当前那个改为选中
radioValues[index].selected = true;
}
// console.log(radioValues)
// 写回数据
this.setData({
radioValues: radioValues,
// 写回数据
this.setData({
radioValues: radioValues,
controlIndex: index
});
// clazz状态
this.clazzStatus();
},
onLoad: function(){
// onLoad 比 onReady 更早调用,后者为选中时屏幕闪动一下
this.clazzStatus();
},
clazzStatus: function(){
/* 此方法分别被加载时调用,点击某段时调用 */
// class样式表如"selected last","selected"
var clazz = [];
// 参照数据源
var radioValues = this.data.radioValues;
for (var i = 0; i < radioValues.length; i++){
// 默认为空串,即普通按钮
var cls = '';
// 高亮,追回selected
if (radioValues[i].selected) {
cls += 'selected ';
}
// 最后个元素, 追加last
if (i == radioValues.length - 1) {
cls += 'last ';
}
//去掉尾部空格
cls = cls.replace(/(\s*$)/g,'');
clazz[i] = cls;
}
});
// clazz状态
this.clazzStatus();
this.getRecord()
},
// 初始化分类数据
configCategory: function() {
var categorys = this.data.categorys
for (var i = 0; i < this.data.categoryCode.length; i++) {
let category = this.data.recordTypes[this.data.categoryCode[i]]
categorys.push(category)
}
this.setData({
categorys: categorys
})
},
getRecord: function() {
let studentIds = this.data.studentIds
console.log(studentIds)
let category = this.data.radioValues[this.data.controlIndex].code
let type = ''
if(this.data.controlIndex == 0) {
type = this.data.categoryCode[this.data.typeIndex]
}
req.queryRecordList(category, type, studentIds).then(res => {
console.log(res)
var eatCellTags = this.data.eatCellTags
var optionTag = ['diet_morning', 'diet_afternoon', 'diet_evening', 'diet_morning_more', 'diet_afternoon_more']
for (var i = 0; i < res.length; i++) {
var item = res[i]
if (item.recordItems.length == 0) {
//没有记录时, 自动生成一条
var r = {}
r.recordType = type
r.recordCategory = category
item.recordItems.push(r)
}
for (var k = 0; k < item.recordItems.length; k++) {
var r = item.recordItems[k]
if (r.recordCategory == 'sleep') {
r.cellType = 'input'
r.cellUnit = '分钟'
break
}
if (r.recordCategory == 'wc') {
r.cellType = 'select'
r.cellOptions = ['pee', 'poo', 'diaper']
break
}
if (r.recordType == 'diet_milk') {
r.cellType = 'input'
r.cellUnit = '毫升'
break
}
if (r.recordType == 'diet_water') {
r.cellType = 'input'
r.cellUnit = '次'
break
}
for (var j = 0, len = optionTag.length; j < len; j++) {
var tag = optionTag[j]
if (r.recordType == tag) {
r.cellType = 'select'
r.cellOptions = ['少', '正常', '多']
break
}
}
}
}
if (this.data.controlIndex == 0) {
this.setData({
eatRecord: res
})
} else if (this.data.controlIndex == 1) {
this.setData({
sleepRecord: res
})
} else if (this.data.controlIndex == 2) {
this.setData({
wcRecord: res
})
}
})
},
quantityCellTap: function (e) {
console.log(e.currentTarget.dataset.optionindex)
let records
if (this.data.controlIndex == 0) {
records = this.data.eatRecord
} else if (this.data.controlIndex == 1) {
records = this.data.sleepRecord
} else if (this.data.controlIndex == 2) {
records = this.data.wcRecord
}
for (var i = 0; i < records.length; i++) {
var item = records[i].recordItems[0]
item.optionIndex = e.currentTarget.dataset.optionindex
}
if (this.data.controlIndex == 0) {
this.setData({
eatRecord: records
})
} else if (this.data.controlIndex == 1) {
this.setData({
sleepRecord: records
})
} else if (this.data.controlIndex == 2) {
this.setData({
wcRecord: records
})
}
},
onLoad: function(options) {
this.data.studentIds = JSON.parse(options.studentIds)
// onLoad 比 onReady 更早调用,后者为选中时屏幕闪动一下
this.clazzStatus();
//分类数据
this.configCategory()
//获取选中的分类的记录
this.getRecord()
},
clazzStatus: function() {
/* 此方法分别被加载时调用,点击某段时调用 */
// class样式表如"selected last","selected"
var clazz = [];
// 参照数据源
var radioValues = this.data.radioValues;
for (var i = 0; i < radioValues.length; i++) {
// 默认为空串,即普通按钮
var cls = '';
// 高亮,追回selected
if (radioValues[i].selected) {
cls += 'selected ';
}
// 最后个元素, 追加last
if (i == radioValues.length - 1) {
cls += 'last ';
}
//去掉尾部空格
cls = cls.replace(/(\s*$)/g, '');
clazz[i] = cls;
}
// console.log(clazz)
// 写回数据
this.setData({
clazz: clazz
});
},
// 写回数据
this.setData({
clazz: clazz
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
......@@ -15,7 +15,7 @@
<!-- 分类选项 -->
<view class="category">
<view wx:for="{{categorys}}">
<view class="eat_category_btn {{selectIndex == index ? 'selected' : ''}}" bindtap='tapCategory' data-index='{{index}}'>
<view class="eat_category_btn {{typeIndex == index ? 'selected' : ''}}" bindtap='tapType' data-index='{{index}}'>
{{item}}
</view>
</view>
......@@ -23,15 +23,14 @@
<view class='kg-separater'></view>
<!-- 数量 -->
<view style='margin:20rpx'>
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{type:'input',unit:'毫升'}}"></template>
</view>
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{type:'input',unit:'毫升'}}"></template>
</view>
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{type:'select',options:['少','正常','多多']}}"></template>
<view wx:for="{{eatRecord}}">
<view wx:for="{{item.recordItems}}" wx:for-item="r">
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{title:item.recordStudentName,type:r.cellType,unit:r.cellUnit, options: r.cellOptions, selectOptionIndex:r.optionIndex}}"></template>
</view>
</view>
</view>
</view>
<view class='kg-separater'></view>
<template is="section_header" data="{{title:'今日拍照'}}"></template>
......@@ -56,11 +55,12 @@
<!-- 滑动区域 -->
<scroll-view style='height:calc(100vh - 50px - 2rpx - 20rpx - 140rpx)' scroll-y='true'>
<view style='margin:20rpx'>
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{type:'input',unit:'分钟'}}"></template>
</view>
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{type:'input',unit:'分钟'}}"></template>
<view wx:for="{{sleepRecord}}">
<view wx:for="{{item.recordItems}}" wx:for-item="r">
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{title:item.recordStudentName,type:r.cellType,unit:r.cellUnit, options: r.cellOptions, selectOptionIndex:r.optionIndex}}"></template>
</view>
</view>
</view>
</view>
</scroll-view>
......@@ -70,9 +70,12 @@
<view hidden='{{controlIndex != 2}}'>
<scroll-view style='height:calc(100vh - 50px - 2rpx - 20rpx - 140rpx)' scroll-y='true'>
<view style='margin:20rpx'>
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{type:'select',options:['pee','poo','diaper']}}"></template>
<text class='kg-text-normal-gray' style='margin-top:30rpx' space="ensp">pee: 4次 poo: 1次 diaper: 9次</text>
<view wx:for="{{wcRecord}}">
<view wx:for="{{item.recordItems}}" wx:for-item="r">
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{title:item.recordStudentName,type:r.cellType,unit:r.cellUnit, options: r.cellOptions, selectOptionIndex:r.optionIndex}}"></template>
</view>
</view>
</view>
</view>
</scroll-view>
......
// pages/home/parents/index.js
const request = require('../../../api/parrent.js')
const app = getApp()
Page({
......@@ -13,20 +13,7 @@ Page({
page: 0,
pageSize: 15,
records: [],
recordTypes: {
"diet_morning": '早餐',
"diet_afternoon": "午餐",
"diet_milk": "牛奶",
"diet_evening": "晚餐",
"diet_morning_more": "上午加餐",
"diet_afternoon_more": "下午加餐",
"diet_water": "喝水",
"diet_milk": "饮用牛奶",
"sleep_time": "睡觉时间",
"wc_pee": "小便",
"wc_poo": "便",
"wc_diaper": "换尿布"
},
recordTypes: app.globalData.recordTypes,
eatStates: {
"less": "少",
"normal": "正常",
......
......@@ -31,7 +31,7 @@ Page({
let selected = !e.currentTarget.dataset.check
let tags = this.data.selectTags
tags[e.currentTarget.dataset.index] = selected
tags[e.currentTarget.dataset.cellindex] = selected
this.setData({
selectTags: tags
})
......
......@@ -10,7 +10,7 @@
<view style='margin:20rpx'>
<view wx:for="{{records}}">
<view class='kg-quantity-cell'>
<template is='quantity_cell' data="{{title:item.name,type:'check',unit:'毫升', index:index,checked:selectTags[index]}}"></template>
<template is='quantity_cell' data="{{title:item.name,type:'check',unit:'毫升', cellIndex:index, checked:selectTags[index]}}"></template>
</view>
</view>
</view>
......
......@@ -7,20 +7,29 @@ Page({
* 页面的初始数据
*/
data: {
signIcon:"/src/img/signin.png",
userIcon:"/src/img/defaut_teacher_icon.png",
records:[],
signIcon: "/src/img/signin.png",
userIcon: "/src/img/defaut_teacher_icon.png",
records: [],
},
operateTap: function (event) {
tapCell: function(e) {
console.log(e)
let studentId = e.currentTarget.dataset.studentid
wx.navigateTo({
url: '/pages/add_record/index?studentIds=' + JSON.stringify([studentId]),
})
},
operateTap: function(event) {
console.log(event._relatedInfo.anchorTargetText)
wx.navigateTo({
url: '/pages/add_record/index',
})
},
signTap: function (e) {
signTap: function(e) {
wx.navigateTo({
url: '/pages/home/sign/index',
})
......@@ -29,22 +38,22 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
// 设置日期
let date = new Date()
let dateStr = utils.formatDate(date)
this.setData({
dateStr: dateStr
})
request.querySignSummary("4028048267a65d0f0167a69ae1910058", "4028048267a5969b0167a5b22f3807f8").then(res =>{
request.querySignSummary("4028048267a65d0f0167a69ae1910058", "4028048267a5969b0167a5b22f3807f8").then(res => {
console.log(res)
for (var i = 0; i < res.length; i++) {
var item = res[i]
item.signDate = item.signDate.substr(0,10)
item.signDate = item.signDate.substr(0, 10)
}
this.setData({
records: res
......@@ -52,56 +61,56 @@ Page({
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
......@@ -13,7 +13,7 @@
<scroll-view style='height:calc(100vh - 200rpx - 140rpx)' scroll-y='true'>
<template is="section_header" data="{{title:dateStr}}"></template>
<view wx:for="{{records}}">
<view class='home-student-info'>
<view class='home-student-info' bindtap='tapCell' data-studentId='{{item.id}}'>
<!-- 名字 -->
<view class='home-student-name'>
<view class='kg-text-normal-dark'>{{item.signStudentName}}</view>
......
......@@ -32,15 +32,15 @@
<view wx:if="{{type == 'select'}}">
<!-- 选择型cell -->
<view class='kg-flex-row'>
<view wx:for="{{options}}">
<view class="eat_category_btn {{selectIndex == index ? 'selected' : ''}}" bindtap='tap' data-index='{{index}}' style='width: 120rpx;margin-right: 0rpx;margin-bottom: 0rpx;margin-left:20rpx;'>{{item}}</view>
<view wx:for="{{options}}" wx:for-index="optionIndex">
<view class="eat_category_btn {{selectOptionIndex == optionIndex ? 'selected' : ''}}" bindtap='quantityCellTap' data-optionIndex='{{optionIndex}}' data-cellIndex='{{cellIndex}}' style='width: 120rpx;margin-right: 0rpx;margin-bottom: 0rpx;margin-left:20rpx;'>{{item}}</view>
</view>
</view>
</view>
<view wx:if="{{type == 'check'}}">
<!-- 选择型cell -->
<image src="{{checked == true ? '/src/img/btn_selected.png' : '/src/img/btn_unselected.jpg'}}" style="height:20px; width:20px;margin-right:4px;" bindtap='tapBox' data-index="{{index}}" data-check='{{checked}}'></image>
<image src="{{checked == true ? '/src/img/btn_selected.png' : '/src/img/btn_unselected.jpg'}}" style="height:20px; width:20px;margin-right:4px;" bindtap='tapBox' data-cellIndex="{{cellIndex}}" data-check='{{checked}}'></image>
</view>
</view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment