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,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;