625 lines
17 KiB
Vue
625 lines
17 KiB
Vue
<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>
|
||
<view class="add-btn" @click="handleAdd()">
|
||
<uni-icons type="plus-filled" size="18" color="#ffffff"></uni-icons>
|
||
<text>新增</text>
|
||
</view>
|
||
</view>
|
||
</u-sticky>
|
||
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
|
||
<view class="search-view">
|
||
<u-input v-model="queryParams.time" border="false" type="select" readonly placeholder="请选择交易时间" suffixIcon="calendar"
|
||
suffixIconStyle="color: #909399" class="search-input">
|
||
</u-input>
|
||
<u-icon :name="filterPanel ? 'arrow-up-fill' : 'arrow-down-fill'" color="#667eea" size="28" label="筛选"
|
||
labelPos="left" labelSize="28rpx" labelColor="#667eea" @click="filterPanel = !filterPanel"
|
||
style="display: flex; align-items: center; gap: 6rpx; padding: 8rpx 16rpx; background: rgba(102, 126, 234, 0.1); border-radius: 20rpx; border: 1rpx solid rgba(102, 126, 234, 0.3);"></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 dealTypeList" :key="item.id" class="state-item"
|
||
:class="item.selected ? 'active' : ''" @click="selectDealType(item)">{{ item.dictLabel }}</view>
|
||
</view>
|
||
<view class="select-header">交易时间</view>
|
||
<view class="selcet-content" style="padding: 0 24rpx">
|
||
<u-input
|
||
:disabled="true"
|
||
:disabledColor="'#fff'"
|
||
class="dateInput"
|
||
border="surround"
|
||
v-model="queryParams.startTime"
|
||
placeholder="请选择开始时间"
|
||
>
|
||
<template v-slot:suffix>
|
||
<u-icon name="calendar" @click="openOrCloseDate(true)"></u-icon>
|
||
</template>
|
||
</u-input>
|
||
<u-input
|
||
:disabled="true"
|
||
:disabledColor="'#fff'"
|
||
class="dateInput"
|
||
border="surround"
|
||
v-model="queryParams.endTime"
|
||
placeholder="请选择结束时间"
|
||
>
|
||
<template v-slot:suffix>
|
||
<u-icon name="calendar" @click="openOrCloseDate(false)"></u-icon>
|
||
</template>
|
||
</u-input>
|
||
</view>
|
||
</view>
|
||
<view class="btn-box">
|
||
<view class="btn-reset" @click="resetQuery()">
|
||
<uni-icons type="reload" size="16" color="#909399"></uni-icons>
|
||
<text>重置</text>
|
||
</view>
|
||
<view class="btn-confirm" @click="searchSubmit()">
|
||
<uni-icons type="checkmarkempty" size="16" color="#ffffff"></uni-icons>
|
||
<text>确定</text>
|
||
</view>
|
||
</view>
|
||
<u-datetime-picker
|
||
:closeOnClickOverlay="true"
|
||
:show="timeShow"
|
||
v-model="time"
|
||
mode="date"
|
||
@close="openOrCloseDate"
|
||
@cancel="openOrCloseDate"
|
||
@confirm="confirm"
|
||
></u-datetime-picker>
|
||
</view>
|
||
</u-transition>
|
||
</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" @click="enterDetails(item)">
|
||
<view class="item-header">
|
||
<view class="header-row">
|
||
<view class="card-icon">
|
||
<uni-icons type="wallet-filled" size="20" color="#ffffff"></uni-icons>
|
||
</view>
|
||
<text class="account-name">{{ item.accountName }}</text>
|
||
</view>
|
||
<view class="info-row">
|
||
<text class="time-text">{{ item.createTime }}</text>
|
||
<text class="type-text">{{ dictStr(item.dealType, dealTypeList) }}</text>
|
||
<text class="amount-value" :class="item.dealType === '2' ? 'loss' : 'profit'">{{ item.dealType === '2' ? '-' : '+' }}{{ item.amount }}元</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="card-body" v-if="item.remark">
|
||
<view class="remark-section">
|
||
<text class="remark-label">备注:</text>
|
||
<text class="remark-text">{{ item.remark }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="operate" @click.stop>
|
||
<view class="btn-delete" @click="handleDelete(item)">
|
||
<uni-icons type="trash" size="16" color="#f5576c"></uni-icons>
|
||
<text>删除</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</u-list-item>
|
||
<view>
|
||
</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>
|
||
<!-- 悬停按钮返回工作台-->
|
||
<suspend></suspend>
|
||
<refresh></refresh>
|
||
</template>
|
||
|
||
<script setup>
|
||
import {
|
||
listAccountDealRecord,
|
||
delAccountDealRecord,
|
||
} from '@/api/invest/accountDealRecord'
|
||
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 accountTypeList = ref([])
|
||
const dealTypeList = ref([])
|
||
const dealCategoryList = ref([])
|
||
const settingPickShow = ref(false)
|
||
const settingColumns = ref([])
|
||
const timeShow= ref(false)
|
||
const flag= ref(true)
|
||
const time =ref( Number(new Date()))
|
||
const data = reactive({
|
||
filterPanel: false,
|
||
queryParams: {
|
||
name: null,
|
||
type: '5',
|
||
time: '',
|
||
dealCategory: '2',
|
||
accountId: null,
|
||
dealType: null
|
||
}
|
||
})
|
||
const { filterPanel, queryParams} = toRefs(data)
|
||
const windowHeight = computed(() => {
|
||
uni.getSystemInfoSync().windowHeight - 50
|
||
})
|
||
onLoad(() => {
|
||
getDict()
|
||
getList()
|
||
});
|
||
|
||
onShow(() => {
|
||
if (isShow.value) {
|
||
listData.value=[]
|
||
getList()
|
||
isShow.value = false
|
||
}
|
||
});
|
||
function openOrCloseDate(data) {
|
||
timeShow.value = !timeShow.value
|
||
flag.value = data
|
||
}
|
||
function loadmore() {
|
||
pageNum.value += 1
|
||
if (status.value == 'loadmore') {
|
||
getList()
|
||
}
|
||
}
|
||
function getList() {
|
||
status.value = 'loading'
|
||
listAccountDealRecord({ 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 confirm(e) {
|
||
const date = timeHandler(new Date(e.value), '-', ':')
|
||
let formatValue = 'YYYY-MM-DD'
|
||
dayjs(date).format(formatValue)
|
||
if (flag.value) {
|
||
queryParams.value.startTime = dayjs(date).format(formatValue)
|
||
} else {
|
||
queryParams.value.endTime = dayjs(date).format(formatValue)
|
||
}
|
||
timeShow.value = false
|
||
}
|
||
function getDict() {
|
||
// 交易类型
|
||
getDicts('profit_loss').then(res => {
|
||
dealTypeList.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 selectAccountType(item) {
|
||
queryParams.value.type = item.dictValue
|
||
accountTypeList.value.map(ele => {
|
||
if (ele.dictValue == item.dictValue) {
|
||
ele.selected = true
|
||
Reflect.set(ele, 'selected', true)
|
||
} else {
|
||
Reflect.set(ele, 'selected', false)
|
||
}
|
||
})
|
||
}
|
||
function selectDealType(item) {
|
||
queryParams.value.dealType = item.dictValue
|
||
dealTypeList.value.map(ele => {
|
||
if (ele.dictValue == item.dictValue) {
|
||
ele.selected = true
|
||
Reflect.set(ele, 'selected', true)
|
||
} else {
|
||
Reflect.set(ele, 'selected', false)
|
||
}
|
||
})
|
||
}
|
||
function selectDealCategory(item) {
|
||
queryParams.value.dealCategory = item.dictValue
|
||
dealCategoryList.value.map(ele => {
|
||
if (ele.dictValue == item.dictValue) {
|
||
ele.selected = true
|
||
Reflect.set(ele, 'selected', true)
|
||
} else {
|
||
Reflect.set(ele, 'selected', false)
|
||
}
|
||
})
|
||
}
|
||
function searchSubmit() {
|
||
if(queryParams.value.startTime!=''&&queryParams.value.startTime!=undefined&&queryParams.value.endTime!=''&&queryParams.value.endTime!=undefined){
|
||
queryParams.value.time = queryParams.value.startTime+'-'+queryParams.value.endTime
|
||
}
|
||
pageNum.value = 1
|
||
listData.value = []
|
||
getList()
|
||
filterPanel.value = false
|
||
}
|
||
function searchBlur() {
|
||
pageNum.value = 1
|
||
listData.value = []
|
||
getList()
|
||
}
|
||
function resetQuery() {
|
||
queryParams.value.time = ''
|
||
queryParams.value.name = ''
|
||
queryParams.value.type = '5'
|
||
queryParams.value.dealType = ''
|
||
queryParams.value.startTime = ''
|
||
queryParams.value.endTime = ''
|
||
queryParams.value.dealCategory = '2'
|
||
accountTypeList.value.map(ele => {
|
||
Reflect.set(ele, 'selected', false)
|
||
})
|
||
dealTypeList.value.map(ele => {
|
||
Reflect.set(ele, 'selected', false)
|
||
})
|
||
dealCategoryList.value.map(ele => {
|
||
Reflect.set(ele, 'selected', false)
|
||
})
|
||
}
|
||
function enterDetails(item) {
|
||
uni.navigateTo({ url: `/pages/work/accounts/investAccountDeal/details?id=${item.id}` })
|
||
}
|
||
function handleEdit(item) {
|
||
uni.navigateTo({ url: `/pages/work/accounts/investAccountDeal/addEdit?id=${item.id}` })
|
||
isShow.value = true
|
||
}
|
||
function handleAdd() {
|
||
uni.navigateTo({ url: `/pages/work/accounts/investAccountDeal/addEdit` })
|
||
isShow.value = true
|
||
}
|
||
function handleDelete(item) {
|
||
uni.showModal({
|
||
title: '确认删除',
|
||
content: '确定要删除这条记录吗?',
|
||
confirmText: '删除',
|
||
cancelText: '取消',
|
||
confirmColor: '#f5576c',
|
||
cancelColor: '#909399',
|
||
success: function (res) {
|
||
if (res.confirm) {
|
||
delAccountDealRecord(item.id).then(() => {
|
||
uni.showToast({
|
||
title: '删除成功',
|
||
icon: 'success'
|
||
})
|
||
pageNum.value = 1
|
||
listData.value = []
|
||
getList()
|
||
})
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
</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;
|
||
z-index: 100;
|
||
|
||
.search-input {
|
||
background: #f5f7fa;
|
||
color: #333333;
|
||
flex: 1;
|
||
margin-right: 16rpx;
|
||
border-radius: 24rpx;
|
||
border: 1rpx solid #e8edf3;
|
||
}
|
||
|
||
.add-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6rpx;
|
||
padding: 12rpx 24rpx;
|
||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
border-radius: 24rpx;
|
||
box-shadow: 0 4rpx 12rpx rgba(102, 126, 234, 0.3);
|
||
transition: all 0.3s ease;
|
||
flex-shrink: 0;
|
||
|
||
&:active {
|
||
transform: scale(0.95);
|
||
box-shadow: 0 2rpx 8rpx rgba(102, 126, 234, 0.3);
|
||
}
|
||
|
||
text {
|
||
color: #ffffff;
|
||
font-size: 28rpx;
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
|
||
.filter-panel {
|
||
width: 100%;
|
||
position: absolute;
|
||
left: 0;
|
||
top: 96rpx;
|
||
background-color: rgba(0, 0, 0, 0.5);
|
||
|
||
.filter-panel-content {
|
||
background-color: #ffffff;
|
||
padding: 0 30rpx 30rpx;
|
||
border-radius: 16rpx 16rpx 0 0;
|
||
|
||
.filter-title {
|
||
color: #2c3e50;
|
||
font-size: 32rpx;
|
||
font-weight: 600;
|
||
padding: 32rpx 0 24rpx;
|
||
}
|
||
|
||
.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: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
border: 2rpx solid transparent;
|
||
color: #ffffff;
|
||
box-shadow: 0 4rpx 12rpx rgba(102, 126, 234, 0.3);
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
}
|
||
|
||
.btn-box {
|
||
display: flex;
|
||
gap: 20rpx;
|
||
padding: 24rpx 30rpx;
|
||
background-color: #fff;
|
||
box-shadow: 0rpx -10rpx 20rpx #EEEEEE;
|
||
|
||
.btn-reset,
|
||
.btn-confirm {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 8rpx;
|
||
height: 88rpx;
|
||
border-radius: 12rpx;
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
transition: all 0.3s ease;
|
||
|
||
&:active {
|
||
transform: scale(0.98);
|
||
opacity: 0.9;
|
||
}
|
||
|
||
text {
|
||
line-height: 1;
|
||
}
|
||
}
|
||
|
||
.btn-reset {
|
||
flex: 1;
|
||
background: #f5f7fa;
|
||
border: 2rpx solid #dcdfe6;
|
||
|
||
text {
|
||
color: #606266;
|
||
}
|
||
}
|
||
|
||
.btn-confirm {
|
||
flex: 1;
|
||
background: #667eea;
|
||
box-shadow: 0 2rpx 8rpx rgba(102, 126, 234, 0.2);
|
||
border: none;
|
||
|
||
text {
|
||
color: #ffffff;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.list-item {
|
||
margin: 0 24rpx 24rpx;
|
||
background-color: #fff;
|
||
border-radius: 16rpx;
|
||
overflow: hidden;
|
||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
|
||
|
||
.item-header {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 12rpx;
|
||
padding: 16rpx 24rpx;
|
||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
|
||
.header-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8rpx;
|
||
}
|
||
|
||
.card-icon {
|
||
width: 40rpx;
|
||
height: 40rpx;
|
||
border-radius: 50%;
|
||
background: rgba(255, 255, 255, 0.25);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.account-name {
|
||
font-size: 28rpx;
|
||
font-weight: 600;
|
||
color: #ffffff;
|
||
line-height: 1.2;
|
||
flex: 1;
|
||
min-width: 0;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.info-row {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
gap: 12rpx;
|
||
padding-top: 6rpx;
|
||
border-top: 1rpx solid rgba(255, 255, 255, 0.2);
|
||
}
|
||
|
||
.time-text {
|
||
font-size: 26rpx;
|
||
color: rgba(255, 255, 255, 0.9);
|
||
font-weight: 500;
|
||
line-height: 1;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.type-text {
|
||
font-size: 24rpx;
|
||
font-weight: 500;
|
||
color: rgba(255, 255, 255, 0.85);
|
||
line-height: 1;
|
||
flex: 1;
|
||
min-width: 0;
|
||
text-align: center;
|
||
}
|
||
|
||
.amount-value {
|
||
font-size: 32rpx;
|
||
font-weight: 700;
|
||
line-height: 1;
|
||
flex-shrink: 0;
|
||
|
||
&.profit {
|
||
color: #52c41a;
|
||
}
|
||
|
||
&.loss {
|
||
color: #f5576c;
|
||
}
|
||
}
|
||
}
|
||
|
||
.card-body {
|
||
padding: 20rpx 24rpx;
|
||
background: #fff;
|
||
border-top: 1rpx solid #f5f7fa;
|
||
|
||
.remark-section {
|
||
display: flex;
|
||
gap: 8rpx;
|
||
|
||
.remark-label {
|
||
font-size: 24rpx;
|
||
color: #999;
|
||
font-weight: 500;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.remark-text {
|
||
font-size: 24rpx;
|
||
color: #666;
|
||
line-height: 1.5;
|
||
flex: 1;
|
||
word-break: break-all;
|
||
}
|
||
}
|
||
}
|
||
|
||
.operate {
|
||
display: flex;
|
||
gap: 16rpx;
|
||
padding: 16rpx 24rpx 24rpx;
|
||
background: #fff;
|
||
justify-content: flex-end;
|
||
|
||
.btn-delete {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 6rpx;
|
||
padding: 0 24rpx;
|
||
height: 64rpx;
|
||
border-radius: 12rpx;
|
||
font-size: 26rpx;
|
||
font-weight: 500;
|
||
transition: all 0.3s ease;
|
||
background: rgba(245, 87, 108, 0.1);
|
||
color: #f5576c;
|
||
border: 1rpx solid rgba(245, 87, 108, 0.3);
|
||
|
||
&:active {
|
||
transform: scale(0.95);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style> |