fix: 新功能开发完善。
This commit is contained in:
@@ -1,105 +1,135 @@
|
||||
<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="name" required >
|
||||
<u--input v-model="form.name" placeholder="请填写标题"
|
||||
<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="name" required >
|
||||
<u--input v-model="form.name" placeholder="请填写姓名"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
</u-form-item>
|
||||
<u-form-item label="类型" prop="typeName" required @click="handleShowTeam">
|
||||
<u-form-item label="昵称" prop="nickName" required >
|
||||
<u--input v-model="form.nickName" placeholder="请填写昵称"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
</u-form-item>
|
||||
<u-form-item label="类型" prop="typeName" required @click="handleType">
|
||||
<u--input v-model="form.typeName" 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="createTime" required @click="selectDate()">
|
||||
<u--input v-model="form.createTime" disabled disabledColor="#ffffff" placeholder="请选择记录时间" inputAlign="right" border="none"></u--input>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
|
||||
<u-form-item label="生日" prop="birthday" required @click="selectBirthday()">
|
||||
<u--input v-model="form.birthday" 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="排序" prop="ranking" >
|
||||
<u--input v-model="form.ranking" type="number" placeholder="请填写排序"
|
||||
inputAlign="right" border="none"></u--input>
|
||||
</u-form-item>
|
||||
<u-form-item label="内容" prop="remark" required labelPosition="top">
|
||||
<u--textarea v-model="form.remark" placeholder="请填写内容" border="none" autoHeight inputAlign="right" count
|
||||
maxlength="20000" style="padding:18rpx 0;"></u--textarea>
|
||||
<u-form-item label="身高" prop="height" >
|
||||
<u--input v-model="form.height" placeholder="请填写身高"
|
||||
inputAlign="right" border="none">
|
||||
<template #suffix>
|
||||
<up-text
|
||||
text="CM"
|
||||
></up-text>
|
||||
</template></u--input>
|
||||
</u-form-item>
|
||||
</u--form>
|
||||
<view class="form-btn">
|
||||
<u-button type="primary" text="提交" @click="submit"></u-button>
|
||||
</view>
|
||||
<u-form-item label="体重" prop="weight" >
|
||||
<u--input v-model="form.weight" placeholder="请填写体重"
|
||||
inputAlign="right" border="none">
|
||||
<template #suffix>
|
||||
<up-text
|
||||
text="KG"
|
||||
></up-text>
|
||||
</template></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>
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
<u-picker itemHeight="88" :show="showTeam" :columns="journeyTypeList" keyName="dictLabel" @cancel="handleCancel"
|
||||
@confirm="handleConfirm"></u-picker>
|
||||
<u-datetime-picker
|
||||
:show="datePickShow"
|
||||
mode="datetime"
|
||||
ref="createTimeRef"
|
||||
@cancel="datePickShow=false"
|
||||
@confirm="datePickConfirm"
|
||||
</view>
|
||||
<u-toast ref="uToast"></u-toast>
|
||||
<u-picker itemHeight="88" :show="showType" :columns="typeList" keyName="dictLabel" @cancel="handleTypeCancel"
|
||||
@confirm="handleTypeConfirm"></u-picker>
|
||||
<u-datetime-picker
|
||||
:show="birthdayShow"
|
||||
mode="date"
|
||||
ref="birthdayRef"
|
||||
@cancel="birthdayShow=false"
|
||||
@confirm="birthdayConfirm"
|
||||
itemHeight="88"
|
||||
></u-datetime-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {getHeartJourney, addHeartJourney, updateHeartJourney } from '@/api/invest/heartJourney'
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getPerson,addPerson, updatePerson } from '@/api/health/person'
|
||||
const { proxy } = getCurrentInstance()
|
||||
import { getDicts } from '@/api/system/dict/data.js'
|
||||
const { proxy } = getCurrentInstance()
|
||||
import dayjs from 'dayjs'
|
||||
import {onLoad,onReady} from "@dcloudio/uni-app";
|
||||
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
|
||||
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 showTeam = ref(false)
|
||||
const title = ref("心路历程")
|
||||
const journeyTypeList = ref([])
|
||||
const birthdayShow = ref(false)
|
||||
const title = ref("成员管理")
|
||||
|
||||
const typeList = ref([])
|
||||
const showType = ref(false)
|
||||
const data = reactive({
|
||||
form: {},
|
||||
rules: {
|
||||
name: [{ type: 'string', required: true, message: '标题不能为空', trigger: ['change', 'blur'] }],
|
||||
createTime: [{ type: 'string', required: true, message: '记录时间不能为空', trigger: ['change', 'blur'] }],
|
||||
typeName: [{ type: 'string', required: true, message: '类型不能为空', trigger: ['change', 'blur'] }],
|
||||
remark: [{ type: 'string', required: true, message: '内容不能为空', trigger: ['change', 'blur'] }],
|
||||
}
|
||||
form: {
|
||||
id: null,
|
||||
id: null,
|
||||
name: null,
|
||||
type: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
delFlag: null,
|
||||
remark: null,
|
||||
birthday: null,
|
||||
nickName: null,
|
||||
height: null,
|
||||
weight: null,
|
||||
ranking: 0
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: '姓名不能为空', trigger:['change', 'blur'] }],
|
||||
nickName: [{ required: true, message: '昵称不能为空', trigger: ['change', 'blur'] }],
|
||||
birthday: [{ required: true, message: '生日不能为空', trigger: ['change', 'blur'] }],
|
||||
typeName: [{ required: true, message: '类型不能为空', trigger: ['change', 'blur'] }],
|
||||
}
|
||||
})
|
||||
const { form, rules} = toRefs(data)
|
||||
|
||||
|
||||
onLoad((option) => {
|
||||
form.value.id = option.id
|
||||
if(form.value.id!=null){
|
||||
title.value="心路历程-修改"
|
||||
}else{
|
||||
title.value="心路历程-新增"
|
||||
}
|
||||
getDict()
|
||||
})
|
||||
onReady(() => {
|
||||
form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
|
||||
})
|
||||
function getDict() {
|
||||
// 类型
|
||||
getDicts('journey_type').then(res => {
|
||||
journeyTypeList.value =[res.data]
|
||||
})
|
||||
if(form.value.id!=null){
|
||||
getHeartJourney(form.value.id).then(res => {
|
||||
form.value = res.data
|
||||
// 类型
|
||||
getDicts('journey_type').then(result => {
|
||||
form.value.typeName=dictStr(form.value.type, result.data)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
function dictStr(val, arr) {
|
||||
form.value.id = option.id
|
||||
if(form.value.id!=null){
|
||||
title.value="成员管理-修改"
|
||||
}else{
|
||||
title.value="成员管理-新增"
|
||||
}
|
||||
getData()
|
||||
})
|
||||
onReady(() => {
|
||||
form.value.birthday = dayjs(new Date().getTime()).format("YYYY-MM-DD")
|
||||
})
|
||||
function dictStr(val, arr) {
|
||||
let str = ''
|
||||
arr.map(item => {
|
||||
if (item.dictValue === val) {
|
||||
@@ -107,78 +137,97 @@ onLoad((option) => {
|
||||
}
|
||||
})
|
||||
return str
|
||||
}
|
||||
function getData() {
|
||||
// 类型
|
||||
getDicts('person_type').then(res => {
|
||||
typeList.value =[res.data]
|
||||
})
|
||||
if(form.value.id!=null){
|
||||
getPerson(form.value.id).then(res => {
|
||||
form.value = res.data
|
||||
// 类型
|
||||
getDicts('person_type').then(result => {
|
||||
form.value.typeName=dictStr(form.value.type, result.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handleShowTeam() {
|
||||
if (journeyTypeList.value[0].length === 0) {
|
||||
|
||||
function handleType() {
|
||||
if (typeList.value[0].length === 0) {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '类型为空 ', type: 'warning'
|
||||
})
|
||||
} else {
|
||||
showTeam.value = true
|
||||
showType.value = true
|
||||
}
|
||||
}
|
||||
function handleConfirm(e) {
|
||||
}
|
||||
function handleTypeConfirm(e) {
|
||||
form.value.typeName = e.value[0].dictLabel
|
||||
form.value.type = e.value[0].dictValue
|
||||
showTeam.value = false
|
||||
showType.value = false
|
||||
}
|
||||
function handleTypeCancel() {
|
||||
showType.value = false
|
||||
}
|
||||
function handleCancel() {
|
||||
showTeam.value = false
|
||||
}
|
||||
function selectDate() {
|
||||
datePickShow.value = true
|
||||
proxy.$refs['createTimeRef'].innerValue = new Date().getTime()
|
||||
}
|
||||
function datePickConfirm(e) {
|
||||
form.value.createTime = 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) {
|
||||
updateHeartJourney(form.value).then(res => {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '修改成功', complete() {
|
||||
uni.navigateTo({ url: `/pages/work/heartJourney/list` })
|
||||
}
|
||||
})
|
||||
|
||||
function selectBirthday() {
|
||||
birthdayShow.value = true
|
||||
proxy.$refs['birthdayRef'].innerValue = new Date().getTime()
|
||||
}
|
||||
function birthdayConfirm(e) {
|
||||
form.value.birthday = dayjs(e.value).format("YYYY-MM-DD")
|
||||
birthdayShow.value = false
|
||||
}
|
||||
|
||||
|
||||
function submit() {
|
||||
proxy.$refs['uForm'].validate().then(() => {
|
||||
if (form.value.id != null) {
|
||||
updatePerson(form.value).then(res => {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '修改成功', complete() {
|
||||
uni.navigateTo({ url: `/pages/health/person/list` })
|
||||
}
|
||||
})
|
||||
}else {
|
||||
addHeartJourney(form.value).then(res => {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '新增成功', complete() {
|
||||
uni.navigateTo({ url: `/pages/work/heartJourney/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;
|
||||
}else {
|
||||
addPerson(form.value).then(res => {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '新增成功', complete() {
|
||||
uni.navigateTo({ url: `/pages/health/person/list` })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
.form-view {
|
||||
padding: 20rpx 0rpx 0 10rpx;
|
||||
|
||||
.form-btn {
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
</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>
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user