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

@@ -0,0 +1,266 @@
<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="请填写活动名称"
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="活动地点" required prop="place" >
<u--input v-model="form.place" placeholder="请填写活动地点"
inputAlign="right" border="none"></u--input>
</u-form-item>
<u-form-item label="成员" required prop="partner" >
<u--input v-model="form.partner" placeholder="请填写成员"
inputAlign="right" border="none"></u--input>
</u-form-item>
<u-form-item label="开始时间" prop="startTime" required @click="selectStartTime()">
<u--input v-model="form.startTime" 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="endTime" required @click="selectEndTime()">
<u--input v-model="form.endTime" 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="exerciseTime" >
<u--input v-model="form.exerciseTime" placeholder="请填写活动时长"
inputAlign="right" border="none"></u--input>
</u-form-item>
<u-form-item label="总费用" prop="totalCost" >
<u--input v-model="form.totalCost" 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="costDetail" labelPosition="top">
<u--textarea v-model="form.costDetail" placeholder="请填写费用明细" border="none" autoHeight inputAlign="right" count
maxlength="2000" style="padding:18rpx 0;"></u--textarea>
</u-form-item>
<u-form-item label="饮食" prop="foods" labelPosition="top">
<u--textarea v-model="form.foods" placeholder="请填写饮食" border="none" autoHeight inputAlign="right" count
maxlength="2000" style="padding:18rpx 0;"></u--textarea>
</u-form-item>
<u-form-item label="收获" prop="harvest" labelPosition="top">
<u--textarea v-model="form.harvest" placeholder="请填写收获" border="none" autoHeight inputAlign="right" count
maxlength="2000" style="padding:18rpx 0;"></u--textarea>
</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="showType" :columns="typeList" keyName="dictLabel" @cancel="handleTypeCancel"
@confirm="handleTypeConfirm"></u-picker>
<u-datetime-picker
:show="startTimeShow"
mode="datetime"
ref="startTimeRef"
@cancel="startTimeShow=false"
@confirm="startTimeConfirm"
itemHeight="88"
></u-datetime-picker>
<u-datetime-picker
:show="endTimeShow"
mode="datetime"
ref="endTimeRef"
@cancel="endTimeShow=false"
@confirm="endTimeConfirm"
itemHeight="88"
></u-datetime-picker>
</view>
</template>
<script setup>
import { getActivity, addActivity, updateActivity } from '@/api/health/activity'
const { proxy } = getCurrentInstance()
import { getDicts } from '@/api/system/dict/data.js'
import dayjs from 'dayjs'
import {onLoad,onReady} from "@dcloudio/uni-app";
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
import {reactive ,toRefs,ref,computed ,getCurrentInstance }from "vue";
const birthdayShow = ref(false)
const title = ref("活动记录")
const startTimeShow = ref(false)
const endTimeShow = ref(false)
const typeList = ref([])
const showType = ref(false)
const data = reactive({
form: {
id: null,
name: null,
type: null,
place: null,
activityVolume: null,
exerciseTime: null,
startTime: null,
endTime: null,
harvest: null,
foods: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
delFlag: null,
remark: null,
totalCost: null,
partner: null,
costDetail: null
},
rules: {
name: [{ required: true, message: '活动名称不能为空', trigger:['change', 'blur'] }],
place: [{ required: true, message: '活动地点不能为空', trigger: ['change', 'blur'] }],
partner: [{ required: true, message: '成员不能为空', trigger: ['change', 'blur'] }],
startTime: [{ required: true, message: '开始时间不能为空', trigger: ['change', 'blur'] }],
endTime: [{ 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="活动记录-新增"
}
getData()
})
onReady(() => {
form.value.startTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
})
function dictStr(val, arr) {
let str = ''
arr.map(item => {
if (item.dictValue === val) {
str = item.dictLabel
}
})
return str
}
function selectStartTime() {
startTimeShow.value = true
proxy.$refs['startTimeRef'].innerValue = new Date().getTime()
}
function startTimeConfirm(e) {
form.value.startTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss")
startTimeShow.value = false
}
function selectEndTime() {
endTimeShow.value = true
proxy.$refs['endTimeRef'].innerValue = new Date().getTime()
}
function endTimeConfirm(e) {
form.value.endTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss")
endTimeShow.value = false
}
function getData() {
// 类型
getDicts('activity_type').then(res => {
typeList.value =[res.data]
})
if(form.value.id!=null){
getActivity(form.value.id).then(res => {
form.value = res.data
// 类型
getDicts('activity_type').then(result => {
form.value.typeName=dictStr(form.value.type, result.data)
})
})
}
}
function handleType() {
if (typeList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '类型为空 ', type: 'warning'
})
} else {
showType.value = true
}
}
function handleTypeConfirm(e) {
form.value.typeName = e.value[0].dictLabel
form.value.type = e.value[0].dictValue
showType.value = false
}
function handleTypeCancel() {
showType.value = false
}
function submit() {
proxy.$refs['uForm'].validate().then(() => {
if (form.value.id != null) {
updateActivity(form.value).then(res => {
proxy.$refs['uToast'].show({
message: '修改成功', complete() {
uni.navigateTo({ url: `/pages/health/activity/list` })
}
})
})
}else {
addActivity(form.value).then(res => {
proxy.$refs['uToast'].show({
message: '新增成功', complete() {
uni.navigateTo({ url: `/pages/health/activity/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>

View File

@@ -0,0 +1,352 @@
<template>
<view class="container">
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
<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">
<u--text lines="1" iconStyle="font-size: 18px; color: #333333; font-weight:bold"
:text="dictStr(item.type,typeList) +''+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.place }}</text>
</view>
<view class="item-row">
<text class="row-label">成员</text>
<text class="row-value">{{ item.partner }}</text>
</view>
<view class="item-row">
<text class="row-label">开始时间</text>
<text class="row-value">{{ item.startTime }}</text>
</view>
<view class="item-row">
<text class="row-label">结束时间</text>
<text class="row-value">{{ item.endTime }}</text>
</view>
<view class="item-row">
<text class="row-label">活动时长</text>
<text class="row-value">{{ item.exerciseTime }}</text>
</view>
<view class="item-row">
<text class="row-label">活动量</text>
<text class="row-value">{{ item.activityVolume }}</text>
</view>
<view class="item-row">
<text class="row-label">总费用</text>
<text class="row-value">{{ item.totalCost }}</text>
</view>
<view class="item-row">
<text class="row-label">费用明细</text>
<text class="row-value">{{ item.costDetail }}</text>
</view>
<view class="item-row">
<text class="row-label">饮食</text>
<text class="row-value">{{ item.foods }}</text>
</view>
<view class="item-row">
<text class="row-label">收获</text>
<text class="row-value">{{ item.harvest }}</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="handleEdit(item)">修改</view>
<view class="btn filling" @click="handleDelete(item)">删除</view>
</view>
</view>
</u-list-item>
<view>
</view>
<u-loadmore :status="status" loadingIcon="semicircle" height="88" fontSize="32rpx" @loadmore="loadmore" />
</u-list>
</view>
</template>
<script setup>
import { listActivity, delActivity } from '@/api/health/activity'
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 typeList = ref([])
const flag= ref(true)
const data = reactive({
filterPanel: false,
queryParams: {
name: null,
type: null,
nickName: null
}
})
const { filterPanel, queryParams} = toRefs(data)
const windowHeight = computed(() => {
uni.getSystemInfoSync().windowHeight - 50
})
onLoad(() => {
getList()
});
onShow(() => {
if (isShow.value) {
listData.value=[]
getList()
isShow.value = false
}
});
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') {
getList()
}
}
function getList() {
// 类型
getDicts('activity_type').then(res => {
typeList.value = res.data
})
status.value = 'loading'
listActivity({ 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'
} else {
status.value = 'nomore'
}
}).catch(() => {
status.value = 'nomore'
})
}
function handleEdit(item) {
uni.navigateTo({ url: `/pages/health/activity/addEdit?id=${item.id}` })
isShow.value = true
}
function handleAdd() {
uni.navigateTo({ url: `/pages/health/activity/addEdit` })
isShow.value = true
}
function handleDelete(item) {
uni.showModal({
title: '提示',
content: '你确定要删除吗',
success: function (res) {
if (res.confirm) {
delActivity(item.id)
uni.navigateTo({ url: `/pages/health/activity/list` })
} else if (res.cancel) {
console.log('取消');
}
}
});
}
</script>
<style lang="scss" scoped>
.btnAdd {
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 8rpx;
display:float;
text-align: center;
}
.search-view {
padding: 12rpx 32rpx;
background-color: #ffffff;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
.search-input {
background: #F5F5F5;
color: #333333;
margin-right: 36rpx;
}
.filter-panel {
width: 100%;
position: absolute;
left: 0;
top: 96rpx;
background-color: rgba(0, 0, 0, 0.5);
.filter-panel-content {
background-color: #ffff;
padding: 0 30rpx 30rpx;
.filter-title {
color: #000000;
font-size: 30rpx;
font-weight: 500;
padding: 30rpx 0;
}
.state-list {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.state-item {
width: 210rpx;
height: 72rpx;
border: 1rpx solid rgba(0, 0, 0, 0.25);
border-radius: 72rpx;
text-align: center;
line-height: 72rpx;
margin: 0 20rpx 20rpx 0;
font-size: 28rpx;
color: #000000;
}
.active {
background-color: rgba(222, 241, 255, 1);
border: 1rpx solid rgba(22, 119, 255, 1);
}
}
}
.btn-box {
display: flex;
padding: 24rpx 30rpx;
background-color: #fff;
box-shadow: 0rpx -10rpx 20rpx #EEEEEE;
}
}
}
.list-item {
margin: 0 24rpx 24rpx;
padding: 32rpx;
background-color: #fff;
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16rpx;
.status {
.status-item {
width: 120rpx;
height: 44rpx;
text-align: center;
line-height: 44rpx;
border-radius: 4rpx;
font-size: 24rpx;
}
.status1 {
background: #F0F0F0;
color: #8C8C8C;
}
.status2 {
background: rgba(38, 129, 255, 0.2);
color: #2681FF;
}
.status3 {
background: #F7F7F7;
color: #2681FF;
}
.status4 {
background: rgba(255, 85, 51, 0.2);
color: #FF5533;
}
.status5 {
background: #F7F7F7;
color: rgba(0, 0, 0, 0.85);
}
.status7 {
background: rgba(255, 129, 51, 0.2);
color: #FF8133;
}
.status8 {
background: rgba(65, 217, 165, 0.2);
color: #41D9A5;
}
}
}
.item-row {
padding: 16rpx 0;
.row-label {
color: rgba(0, 0, 0, 0.55);
}
.row-value {
color: rgba(0, 0, 0, 0.85)
}
}
.operate {
display: flex;
justify-content: flex-end;
.btn {
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 8rpx;
margin-left: 5rpx;
text-align: center;
}
.circulation {
background: rgba(0, 0, 0, 0.04);
margin-right: 24rpx;
color: rgba(0, 0, 0, 0.85);
}
.filling {
background: #2681FF;
border-radius: 8rpx;
color: #FFFFFF;
}
}
}
</style>