fix: 新功能开发完善。

This commit is contained in:
tianyongbao
2024-10-28 13:09:06 +08:00
parent df34762355
commit 66c776c753
48 changed files with 5845 additions and 1633 deletions

View File

@@ -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>

View File

@@ -1,92 +0,0 @@
<template>
<view class="container" style="paddingBottom:1rpx;">
<u-navbar
leftIconSize="40rpx"
leftIconColor="#333333"
title="心路历程详情"
>
</u-navbar>
<view class="section">
<u-cell-group>
<u-cell title="标题:" titleStyle="font-weight:bolder" :value="detailInfo.name"></u-cell>
<u-cell title="类型:" titleStyle="font-weight:bolder" :value="detailInfo.type"></u-cell>
<u-cell title="记录时间:" titleStyle="font-weight:bolder" :value="detailInfo.createTime"></u-cell>
<u-cell title="内容:" titleStyle="font-weight:bolder" center :value="detailInfo.remark"> </u-cell>
</u-cell-group>
</view>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script setup>
import { getHeartJourney} from '@/api/invest/heartJourney'
import { getDicts } from '@/api/system/dict/data.js'
import {onLoad} from "@dcloudio/uni-app";
import {reactive ,toRefs,ref,computed }from "vue";
const id = ref('')
const data = reactive({
detailInfo: {}
})
const {detailInfo} = toRefs(data)
onLoad((option) => {
id.value = option.id
getInfo()
})
function getInfo() {
getHeartJourney(id.value).then(res => {
detailInfo.value = res.data
// 类型
getDicts('journey_type').then(result => {
detailInfo.value.type=dictStr(detailInfo.value.type, result.data)
})
})
}
function dictStr(val, arr) {
let str = ''
arr.map(item => {
if (item.dictValue === val) {
str = item.dictLabel
}
})
return str
}
</script>
<style lang="scss" scoped>
.section {
margin: 24rpx;
padding: 16rpx 24rpx;
background-color: #fff;
border-radius: 8rpx;
.section-title {
width: 280rpx;
color: #333333;
line-height: 44rpx;
font-size: 30rpx;
border-left: 6rpx solid #2681FF;
padding-left: 26rpx;
}
.content {
width: 647rpx;
font-size: 28rpx;
color: #333333;
line-height: 40rpx;
text-align: left;
}
.img-con {
display: flex;
flex-wrap: wrap;
gap: 20rpx
}
.form-view {
padding: 20rpx 0rpx 0 10rpx;
.form-btn {
padding-top: 20rpx;
}
}
}
</style>

View File

@@ -1,53 +1,55 @@
<template>
<view class="container">
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
<view class="search-view">
<u--input v-model="queryParams.name" border="false" placeholder="请输入标题" class="search-input"
@blur="searchBlur" suffixIcon="search" suffixIconStyle="color: #909399">
</u--input>
<u-icon :name="filterPanel ? 'arrow-up-fill' : 'arrow-down-fill'" color="#666666" size="28" label="筛选"
labelPos="left" labelSize="32rpx" labelColor="#666666" @click="filterPanel = !filterPanel"></u-icon>
<u-icon name="plus-circle-fill" color="#666666" size="28" style="margin-left:10px" label="新增"
labelPos="left" labelSize="32rpx" labelColor="#666666" @click="handleAdd()"></u-icon>
<u-transition :show="filterPanel" mode="fade">
<view class="filter-panel" :style="{ height: `${windowHeight - 42}px` }">
<view class="filter-panel-content">
<view class="filter-title">类型</view>
<view class="state-list">
<view v-for="item in journeyTypeList" :key="item.id" class="state-item"
:class="item.selected ? 'active' : ''" @click="selectStatus(item)">{{ item.dictLabel }}</view>
</view>
</view>
<view class="btn-box">
<u-button text="重置" style="margin-right:20rpx" @click="resetQuery()"></u-button>
<u-button type="primary" text="确定" @click="searchSubmit()"></u-button>
</view>
</view>
</u-transition>
</view>
</u-sticky>
<view class="search-view">
<u-input v-model="queryParams.name" border="false" type="select" @click="handleSearch" placeholder="请填入名称或昵称" suffixIcon="search"
suffixIconStyle="color: #909399" class="search-input">
</u-input>
<u-icon name="plus-circle-fill" color="#666666" size="28" style="margin-left:10px" label="新增"
labelPos="left" labelSize="32rpx" labelColor="#666666" @click="handleAdd()"></u-icon>
</view>
</u-sticky>
<u-list @scrolltolower="loadmore" :spaceHeight="116" lowerThreshold="100">
<u-list-item v-for="(item, index) in listData" :key="index">
<view class="list-item">
<view class="item-header" @click="enterDetails(item)">
<u--text suffixIcon="arrow-right" lines="1" iconStyle="font-size: 18px; color: #333333; font-weight:bold"
<view class="item-header">
<u--text lines="1" iconStyle="font-size: 18px; color: #333333; font-weight:bold"
:text="item.name" size="30rpx" color="#333333" :bold="true"></u--text>
</view>
<view class="item-row">
<text class="row-label">昵称</text>
<text class="row-value">{{ item.nickName }}</text>
</view>
<view class="item-row">
<text class="row-label">类型</text>
<text class="row-value">{{ dictStr(item.type, journeyTypeList) }}</text>
<text class="row-value">{{ dictStr(item.type,typeList) }}</text>
</view>
<view class="item-row">
<text class="row-label">记录时间</text>
<text class="row-value">{{ item.createTime }}</text>
<text class="row-label">生日</text>
<text class="row-value">{{ item.birthday }}</text>
</view>
<view class="item-row">
<text class="row-label">内容</text>
<text class="row-label">年龄</text>
<text class="row-value">{{ item.age }}</text>
</view>
<view class="item-row">
<text class="row-label">身高CM</text>
<text class="row-value">{{ item.height }}</text>
</view>
<view class="item-row">
<text class="row-label">体重KG</text>
<text class="row-value">{{ item.weight }}</text>
</view>
<view class="item-row">
<text class="row-label">排序</text>
<text class="row-value">{{ item.ranking }}</text>
</view>
<view class="item-row">
<text class="row-label">备注</text>
<text class="row-value">{{ item.remark }}</text>
</view>
<view class="operate" >
<!-- <view class="btn filling" @click="enterDetails(item)">查看</view > -->
<view class="btn filling" @click="handleEdit(item)">修改</view>
<view class="btn filling" @click="handleEdit(item)">修改</view>
<view class="btn filling" @click="handleDelete(item)">删除</view>
</view>
</view>
@@ -56,29 +58,30 @@
</view>
<u-loadmore :status="status" loadingIcon="semicircle" height="88" fontSize="32rpx" @loadmore="loadmore" />
</u-list>
<u-picker itemHeight="88" :show="settingPickShow" :columns="settingColumns" keyName="settingName"
@confirm="settingConfirm" @cancel="settingCancel"></u-picker>
</view>
</template>
<script setup>
import { listHeartJourney, delHeartJourney } from '@/api/invest/heartJourney'
import { listPerson, delPerson } from '@/api/health/person'
import { getDicts } from '@/api/system/dict/data.js'
import { timeHandler } from '@/utils/common.ts'
import {onLoad,onShow} from "@dcloudio/uni-app";
import dayjs from 'dayjs'
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
import {reactive ,toRefs,ref,computed }from "vue";
const pageNum = ref(1)
const listData = ref([])
const isShow = ref(false)
const status = ref('loadmore')
const journeyTypeList = ref([])
const settingPickShow = ref(false)
const settingColumns = ref([])
const typeList = ref([])
const flag= ref(true)
const data = reactive({
filterPanel: false,
queryParams: {
name: '',
type: '',
name: null,
type: null,
nickName: null
}
})
const { filterPanel, queryParams} = toRefs(data)
@@ -86,7 +89,6 @@ const windowHeight = computed(() => {
uni.getSystemInfoSync().windowHeight - 50
})
onLoad(() => {
getDict()
getList()
});
@@ -98,6 +100,22 @@ onLoad(() => {
}
});
function handleSearch() {
pageNum.value = 1
listData.value = []
getList()
}
function dictStr(val, arr) {
let str = ''
arr.map(item => {
if (item.dictValue === val) {
str = item.dictLabel
}
})
return str
}
function loadmore() {
pageNum.value += 1
if (status.value == 'loadmore') {
@@ -105,8 +123,12 @@ function loadmore() {
}
}
function getList() {
// 类型
getDicts('person_type').then(res => {
typeList.value = res.data
})
status.value = 'loading'
listHeartJourney({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
listPerson({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
listData.value = listData.value.concat(res.rows)
if (listData.value.length < res.total) {
status.value = 'loadmore'
@@ -117,67 +139,13 @@ function getList() {
status.value = 'nomore'
})
}
function getDict() {
// 类型
getDicts('journey_type').then(res => {
journeyTypeList.value = res.data
})
}
function settingConfirm(e) {
queryParams.value.settingId = e.value[0].settingId
queryParams.value.settingName = e.value[0].settingName
settingPickShow.value = false
}
function settingCancel() {
settingPickShow.value = false
}
function dictStr(val, arr) {
let str = ''
arr.map(item => {
if (item.dictValue === val) {
str = item.dictLabel
}
})
return str
}
function selectStatus(item) {
queryParams.value.type = item.dictValue
journeyTypeList.value.map(ele => {
if (ele.dictValue == item.dictValue) {
ele.selected = true
Reflect.set(ele, 'selected', true)
} else {
Reflect.set(ele, 'selected', false)
}
})
}
function searchSubmit() {
pageNum.value = 1
listData.value = []
getList()
filterPanel.value = false
}
function searchBlur() {
pageNum.value = 1
listData.value = []
getList()
}
function resetQuery() {
queryParams.value.name = '',
queryParams.value.type = ''
journeyTypeList.value.map(ele => {
Reflect.set(ele, 'selected', false)
})
}
function enterDetails(item) {
uni.navigateTo({ url: `/pages/work/heartJourney/details?id=${item.id}` })
}
function handleEdit(item) {
uni.navigateTo({ url: `/pages/work/heartJourney/addEdit?id=${item.id}` })
uni.navigateTo({ url: `/pages/health/person/addEdit?id=${item.id}` })
isShow.value = true
}
function handleAdd() {
uni.navigateTo({ url: `/pages/work/heartJourney/addEdit` })
uni.navigateTo({ url: `/pages/health/person/addEdit` })
isShow.value = true
}
function handleDelete(item) {
@@ -186,8 +154,8 @@ function selectStatus(item) {
content: '你确定要删除吗',
success: function (res) {
if (res.confirm) {
delHeartJourney(item.id)
uni.navigateTo({ url: `/pages/work/heartJourney/list` })
delPerson(item.id)
uni.navigateTo({ url: `/pages/health/person/list` })
} else if (res.cancel) {
console.log('取消');
}
@@ -214,7 +182,6 @@ function selectStatus(item) {
justify-content: space-between;
align-items: center;
position: relative;
margin-bottom: 24rpx;
.search-input {
background: #F5F5F5;