examTeamApp/pages/history/history.vue

207 lines
4.7 KiB
Vue
Raw Normal View History

2024-05-02 15:59:36 +08:00
<template>
<view class="common">
<view class="history">
<view class="list" v-for="(item, index) in ranklist" :key="index" @click="clickItemMethod(item)">
<uni-swipe-action>
2024-05-29 16:35:45 +08:00
<uni-swipe-action-item :right-options="item.options" @click="swipeClick($event, index)"
:disabled='type=="edit"?true:false'>
<view class="time">
<icon class="t-icon t-icon-shijian-mianxing-0"></icon>
<text>{{item.record_time}}</text>
</view>
2024-05-02 15:59:36 +08:00
<view class="item">
2024-05-29 16:35:45 +08:00
<view>{{item.v1}}<text>{{item.v1_name}}</text></view>
<view v-if="item.v2">{{item.v2}}<text>{{item.v2_name}}</text></view>
<view v-if="item.v3">{{item.v3}}<text>{{item.v3_name}}</text></view>
<view class="check" v-if="type=='edit'" @click.stop>
<uni-icons :type="isActive==item.id?'checkbox-filled':'circle'" size="22"
:color="isActive==item.id?'#FEC407':'#dfdfdf'"
@click="handleEdit(item.id)"></uni-icons>
2024-05-02 15:59:36 +08:00
</view>
2024-05-29 16:35:45 +08:00
<uni-icons type="right" v-if="type!='edit'&&acd_id!=6"></uni-icons>
2024-05-02 15:59:36 +08:00
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<view class="endtext" v-if="!lastPage || page >= lastPage"> 到底了看看别的吧 </view>
</view>
<view class="nolist" v-if="!lastPage">
2024-05-29 16:35:45 +08:00
<image src="@/static/none.png"></image>
<text>暂无数据</text>
2024-05-02 15:59:36 +08:00
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
computed: {
2024-05-29 16:35:45 +08:00
...mapState(['user']),
endDate() {
return this.$tools.getDate("start")
},
startDate() {
return this.$tools.GetDateStr(-90);
},
2024-05-02 15:59:36 +08:00
},
data() {
return {
ranklist: [],
page: 1,
2024-05-29 16:35:45 +08:00
type: "add",
2024-05-02 15:59:36 +08:00
lastPage: 1,
2024-05-29 16:35:45 +08:00
isActive: null,
acd_id: ""
2024-05-02 15:59:36 +08:00
}
},
2024-05-29 16:35:45 +08:00
onLoad(options) {
2024-05-02 15:59:36 +08:00
let that = this
2024-05-29 16:35:45 +08:00
that.acd_id = options.acd_id
that.getList()
2024-05-02 15:59:36 +08:00
},
onReachBottom() {
let that = this
console.log("onReachBottom", this.lastPage)
if (!this.lastPage || this.page >= this.lastPage) {
uni.showToast({
title: '没有更多数据!',
icon: 'none'
})
return
}
this.page++
this.getList(this.page)
},
methods: {
swipeClick(e, index) {
let that = this
let id = that.ranklist[index].id
uni.showModal({
title: '友情提示',
content: '是否删除当前测量记录?',
success: function(res) {
if (res.confirm) {
that.$model.gethistorydelete({
id: id,
2024-05-29 16:35:45 +08:00
type: that.acd_id,
2024-05-02 15:59:36 +08:00
}).then((res) => {
if (res.code != 0) {
2024-05-29 16:35:45 +08:00
that.$tools.msg(res.msg)
2024-05-02 15:59:36 +08:00
return
}
that.ranklist.splice(index, 1)
that.$store.dispatch("getUserInfo", {
2024-05-29 16:35:45 +08:00
aud_id: uni.getStorageSync('userid')
2024-05-02 15:59:36 +08:00
})
that.$tools.msg("删除成功")
})
} else if (res.cancel) {
that.$tools.msg("您已取消操作!");
}
},
})
},
clickItemMethod(item) {
2024-05-29 16:35:45 +08:00
let that = this
if (that.acd_id == "6") return
2024-05-02 15:59:36 +08:00
uni.navigateTo({
2024-05-29 16:35:45 +08:00
url: "/pages/history/historyDetail?type=" + that.acd_id + '&id=' + item.id
2024-05-02 15:59:36 +08:00
})
},
2024-05-29 16:35:45 +08:00
2024-05-02 15:59:36 +08:00
getList(page) {
let that = this
2024-05-29 16:35:45 +08:00
that.$model.gethistory({
aud_id: uni.getStorageSync('userid'),
type: that.acd_id,
page: that.page,
2024-05-02 15:59:36 +08:00
}).then((res) => {
console.log("历史记录", res)
if (res.code != 0) return
2024-05-29 16:35:45 +08:00
let options = [{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
2024-05-02 15:59:36 +08:00
res.data.rows.forEach(item => {
2024-05-29 16:35:45 +08:00
item.options = options
2024-05-02 15:59:36 +08:00
})
this.ranklist = this.ranklist.concat(res.data.rows)
this.lastPage = res.data.totalpage
})
},
2024-05-29 16:35:45 +08:00
handleEdit(id) {
this.isActive = id
},
2024-05-02 15:59:36 +08:00
}
}
</script>
<style scoped="scoped" lang="scss">
.common {
width: 100%;
min-height: 100.5vh; // 重点
overflow-y: scroll;
background-color: #f7f7f7;
}
.history {
width: calc(100% - 30px);
height: auto;
margin: 15px 15px 0;
padding-bottom: 40px;
.list {
width: 100%;
margin-bottom: 12px;
2024-05-29 16:35:45 +08:00
position: relative;
2024-05-02 15:59:36 +08:00
.item {
width: calc(100% - 20px);
height: auto;
background: #fff;
padding: 6px 10px;
display: flex;
justify-content: space-between;
border-radius: 10px;
align-items: center;
font-weight: 700;
line-height: 50rpx;
font-size: 18px !important;
text {
display: block;
color: #666;
text-align: center;
font-weight: 500;
2024-05-29 16:35:45 +08:00
font-size: 28rpx;
2024-05-02 15:59:36 +08:00
}
}
.time {
2024-05-29 16:35:45 +08:00
font-size: 28rpx;
2024-05-02 15:59:36 +08:00
color: #666;
2024-05-29 16:35:45 +08:00
display: flex;
align-items: center;
justify-content: center;
width: 100%;
icon {
width: 40rpx;
height: 40rpx;
margin-right: 5px;
}
text {
font-size: 28rpx;
margin-top: 3px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
2024-05-02 15:59:36 +08:00
}
}
}
</style>