fix: 智聪健康,吃奶记录、吃奶量统计功能新增。
This commit is contained in:
208
src/pages/health/milkPowderRecord/addEdit.vue
Normal file
208
src/pages/health/milkPowderRecord/addEdit.vue
Normal file
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<view class="container" style="paddingBottom:1rpx;">
|
||||
<u-navbar
|
||||
leftIconSize="40rpx"
|
||||
leftIconColor="#333333"
|
||||
title="吃奶记录"
|
||||
>
|
||||
</u-navbar>
|
||||
<view class="section">
|
||||
<view class="section-title">{{ title}}</view>
|
||||
<view class="form-view">
|
||||
<u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" label-width="auto"
|
||||
:labelStyle="{ color: '#333333', fontSize: '30rpx' }">
|
||||
<u-form-item label="人员姓名" prop="personName" required @click="handlePerson">
|
||||
<u--input v-model="form.personName" disabled disabledColor="#ffffff" placeholder="请选择人员"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
<u-icon slot="right" name="arrow-down"></u-icon>
|
||||
</u-form-item>
|
||||
<u-form-item label="吃奶时间" prop="sucklesTime" required @click="selectDate()">
|
||||
<u--input v-model="form.sucklesTime" disabled disabledColor="#ffffff" placeholder="请选择吃奶时间" inputAlign="right" border="none"></u--input>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</u-form-item>
|
||||
<u-form-item label="吃奶量" required prop="consumption" >
|
||||
<u--input v-model="form.consumption" type="number" placeholder="请填写吃奶量"
|
||||
inputAlign="right" border="none">
|
||||
<template #suffix>
|
||||
<up-text
|
||||
text="毫升"
|
||||
></up-text>
|
||||
</template>
|
||||
</u--input>
|
||||
</u-form-item>
|
||||
<u-form-item label="奶粉品牌" prop="milkPowderBrand" >
|
||||
<u--input v-model="form.milkPowderBrand" placeholder="请填写奶粉品牌"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
</u-form-item>
|
||||
<u-form-item label="备注" prop="remark" labelPosition="top">
|
||||
<u--textarea v-model="form.remark" placeholder="请填写备注" border="none" autoHeight inputAlign="right" count
|
||||
maxlength="2000" style="padding:18rpx 0;"></u--textarea>
|
||||
</u-form-item>
|
||||
</u--form>
|
||||
<view class="form-btn">
|
||||
<u-button type="primary" text="提交" @click="submit"></u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
<u-picker itemHeight="88" :show="showPerson" :columns="personList" keyName="name" @cancel="handlePersonCancel"
|
||||
@confirm="handlePersonConfirm"></u-picker>
|
||||
<u-datetime-picker
|
||||
:show="datePickShow"
|
||||
mode="datetime"
|
||||
ref="sucklesTimeRef"
|
||||
@cancel="datePickShow=false"
|
||||
@confirm="datePickConfirm"
|
||||
itemHeight="88"
|
||||
></u-datetime-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listMilkPowderRecord, getMilkPowderRecord, delMilkPowderRecord, addMilkPowderRecord, updateMilkPowderRecord } from '@/api/health/milkPowderRecord'
|
||||
import { listPerson, } from '@/api/health/person'
|
||||
const { proxy } = getCurrentInstance()
|
||||
import dayjs from 'dayjs'
|
||||
import {onLoad,onReady} from "@dcloudio/uni-app";
|
||||
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
|
||||
import {reactive ,toRefs,ref,computed ,getCurrentInstance }from "vue";
|
||||
const datePickShow = ref(false)
|
||||
const showPerson = ref(false)
|
||||
const title = ref("吃奶记录")
|
||||
const personList = ref([])
|
||||
const data = reactive({
|
||||
form: {
|
||||
id: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
delFlag: null,
|
||||
remark: null,
|
||||
sucklesTime: null,
|
||||
consumption: null,
|
||||
personId: null,
|
||||
milkPowderBrand: null,
|
||||
spoonful: null
|
||||
},
|
||||
queryPersonParams: {
|
||||
pageNum: 1,
|
||||
status: '1',
|
||||
pageSize: 1000
|
||||
},
|
||||
rules: {
|
||||
personName: [{ required: true, message: '人员不能为空', trigger: ['change', 'blur'] }],
|
||||
sucklesTime: [{ required: true, message: '吃奶时间不能为空', trigger: ['change', 'blur'] }]
|
||||
}
|
||||
})
|
||||
const { form, queryPersonParams, rules} = toRefs(data)
|
||||
|
||||
|
||||
onLoad((option) => {
|
||||
form.value.id = option.id
|
||||
if(form.value.id!=null){
|
||||
title.value="吃奶记录-修改"
|
||||
}else{
|
||||
title.value="吃奶记录-新增"
|
||||
}
|
||||
getData()
|
||||
})
|
||||
onReady(() => {
|
||||
form.value.sucklesTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
|
||||
})
|
||||
function getData() {
|
||||
listPerson(queryPersonParams.value).then((response) => {
|
||||
personList.value = [response.rows]
|
||||
if(response.rows.length>0){
|
||||
form.value.personName= response.rows[0].name
|
||||
form.value.personId = response.rows[0].id
|
||||
}
|
||||
})
|
||||
|
||||
if(form.value.id!=null){
|
||||
getMilkPowderRecord(form.value.id).then(res => {
|
||||
form.value = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handlePerson() {
|
||||
if (personList.value[0].length === 0) {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '人员为空 ', type: 'warning'
|
||||
})
|
||||
} else {
|
||||
showPerson.value = true
|
||||
}
|
||||
}
|
||||
function handlePersonConfirm(e) {
|
||||
form.value.personName = e.value[0].name
|
||||
form.value.personId = e.value[0].id
|
||||
form.value.healthRecordName = ''
|
||||
form.value.healthRecordId = ''
|
||||
queryHealthRecordParams.value.personId=e.value[0].id
|
||||
listHealthRecord(queryHealthRecordParams.value).then((response) => {
|
||||
healthRecordList.value = [response.rows]
|
||||
showPerson.value = false
|
||||
})
|
||||
|
||||
}
|
||||
function handlePersonCancel() {
|
||||
showPerson.value = false
|
||||
}
|
||||
function selectDate() {
|
||||
datePickShow.value = true
|
||||
proxy.$refs['sucklesTimeRef'].innerValue = new Date().getTime()
|
||||
}
|
||||
function datePickConfirm(e) {
|
||||
form.value.sucklesTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss")
|
||||
datePickShow.value = false
|
||||
}
|
||||
function submit() {
|
||||
proxy.$refs['uForm'].validate().then(() => {
|
||||
if (form.value.id != null) {
|
||||
updateMilkPowderRecord(form.value).then(res => {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '修改成功', complete() {
|
||||
uni.navigateTo({ url: `/pages/health/milkPowderRecord/list` })
|
||||
}
|
||||
})
|
||||
})
|
||||
}else {
|
||||
addMilkPowderRecord(form.value).then(res => {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '新增成功', complete() {
|
||||
uni.navigateTo({ url: `/pages/health/milkPowderRecord/list` })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.section {
|
||||
margin: 24rpx;
|
||||
padding: 16rpx 24rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
|
||||
.section-title {
|
||||
width: 360rpx;
|
||||
color: #333333;
|
||||
line-height: 44rpx;
|
||||
font-size: 30rpx;
|
||||
border-left: 6rpx solid #2681FF;
|
||||
padding-left: 26rpx;
|
||||
}
|
||||
|
||||
.form-view {
|
||||
padding: 20rpx 0rpx 0 10rpx;
|
||||
|
||||
.form-btn {
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user