You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

385 lines
8.4 KiB

4 years ago
<template>
<view class="boxContent">
<view class="box-header">
<view class="search-wrap">
<!-- 如果使用u-search组件必须要给v-model绑定一个变量 -->
<u-search v-model="keyword" placeholder="地址/河道等" @change="tosearch()" @search="tosearch()" height="56"
:action-style="{color: '#fff'}">
</u-search>
</view>
</view>
<view :class="mask?'list listfixed':'list'" style="padding-top: 100rpx;">
4 years ago
<u-dropdown @open="openmask" @close="closemask" :class="mask?'':'overflowmask'" ref="uDropdown">
4 years ago
<u-dropdown-item v-model="proStatusId" :title="proStatus==''?'处理方式':proStatus" @change="toChangeStatus"
4 years ago
:options="prostatusList">
</u-dropdown-item>
4 years ago
<u-dropdown-item v-model="lzStatusId" :title="lzStatus==''?'状态':lzStatus" @change="toChangelzStatus"
:options="lzstatusList">
</u-dropdown-item>
4 years ago
</u-dropdown>
<block v-for="(item, index) in dataList">
<u-card :title="item.created_at" padding="20" margin="20rpx" :border="true"
4 years ago
:thumb="thumb" thumb-width="36">
4 years ago
<view class="" slot="body" @click="todetail(item.id)">
<u-row gutter="16">
<u-col span="3">
<view class="demo-layout bg-purple">巡查项目</view>
</u-col>
<u-col span="9">
<view class="demo-layout bg-purple-light">{{item.name}}</view>
</u-col>
</u-row>
<u-row gutter="16">
<u-col span="3">
4 years ago
<view class="demo-layout bg-purple">处理方式</view>
4 years ago
</u-col>
<u-col span="9">
<u-tag v-if="item.status==1" text="无异常" type="primary" />
<u-tag v-if="item.status==2" text="已现场处理" type="warning" />
<u-tag v-if="item.status==3" text="不可现场处理" type="error" />
</u-col>
</u-row>
<u-row gutter="16" v-if="item.status==3">
<u-col span="3">
<view class="demo-layout bg-purple">定位地址</view>
</u-col>
<u-col span="9">
{{item.address}}
</u-col>
</u-row>
</view>
<view class="footer" slot="foot">
<block >
<u-button :custom-style="editStyle" type="primary" size="medium"
@click="toedit(item.id)" :ripple="true">编辑
</u-button>
</block>
<block >
<u-button type="error" size="medium" @click="del(item.id)"
:custom-style="customStyle" :ripple="true">删除
</u-button>
</block>
</view>
</u-card>
</block>
<u-loadmore class="loadmore" :status="loadStatus" :load-text="loadText"/>
<u-empty text="暂无数据" margin-top="200" v-if="dataList.length==0" mode="list"></u-empty>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
export default {
data() {
return {
background: {
backgroundColor: '#007AFF'
},
mask: false,
loadStatus:"loadmore",
loadText:{
loadmore:"加载更多",
nomore:"已经到底了"
},
dataList: [],
thumb: "/static/img/location.png",
currentPage: 0,
lastPage:0,
editStyle:{
fontSize:'30rpx'
},
customStyle: {
marginLeft: '20px',
fontSize:'30rpx'
},
currentRole: "inspector", //前端用户角色inspector巡查员manager管理员operator现场处置人员
proStatus: '',
4 years ago
proStatusId: '',
lzStatus: '',
lzStatusId: '',
4 years ago
keyword: "",
title: "",
prostatusList: [{
label: "所有",
value: "",
id: ""
}, {
label: "无异常",
value: 1,
}, {
label: "已处理",
value: 2,
}, {
label: "不可现场处理",
value: 3
4 years ago
}],
lzstatusList: [{
label: "所有",
value: "",
id: ""
}, {
label: "已提交",
value: 1,
}, {
label: "已处理",
value: 2,
}, {
label: "未处理",
value: 3
4 years ago
}]
}
},
onReachBottom: function(e) {
if(this.currentPage>=this.lastPage){
this.loadStatus = "nomore"
return;
}
this.loadPage(this.currentPage + 1);
},
onPullDownRefresh: function(e) {
this.loadStatus = 'loadmore';
4 years ago
console.log("onPullDownRefresh")
4 years ago
this.loadPage(1);
},
onShow: function() {
var that = this;
},
onLoad(options) {
this.loadPage(1);
},
methods: {
openmask(){
this.mask=true
4 years ago
// this.isPullDown(false);
4 years ago
},
closemask(){
this.mask=false
4 years ago
// this.isPullDown(true);
4 years ago
},
toChangeStatus: function(value) {
for(var m of this.prostatusList){
if(value == m.value){
this.proStatus = m.label
}
}
this.loadPage(1);
this.$refs.uDropdown.close();
4 years ago
},
toChangelzStatus: function(value) {
for(var m of this.lzstatusList){
if(value == m.value){
this.lzStatus = m.label
}
}
this.loadPage(1);
this.$refs.lzuDropdown.close();
4 years ago
},
tosearch() {
this.loadPage(1)
this.$refs.uDropdown.close();
},
todetail: function(id) {
uni.navigateTo({
url: "../dailyInfo/dailyInfo?id=" + id
})
},
toedit(id){
uni.navigateTo({
url: "../dailyInspection/dailyInspection?id=" + id
})
},
loadPage: function(page) {
uni.hideKeyboard()
4 years ago
var that = this;
4 years ago
this.util.request({
bindThis: that,
api: '/api/mobile/daily-inspection/index',
customLoading: false,
data: {
page: page,
page_size: 5,
keyword: that.keyword,
4 years ago
status:that.proStatusId,
lzstatus:that.lzStatusId
4 years ago
},
utilSuccess: function(r) {
var res = r.data;
that.lastPage = r.last_page;
uni.stopPullDownRefresh(); // 服务器总条数 < 每页条数, 会将第一页的条数重新返回
if(r.total<6){
that.loadStatus = "nomore";
}
var hasNoMore = that.dataList.length < 5 && page > 1 ;
if (hasNoMore || res.length == 0 && page > 1) {
that.loadStatus = "nomore";
// 已加载到最后一页
uni.showToast({
title: '已加载到最后一页',
icon: 'none'
});
return;
}
var dataList = that.dataList;
if (page == 1) {
dataList = res;
} else {
dataList.push(...res);
}
for (var m of dataList) {
m.created_at = m.created_at.split("T")[0]
}
that.currentPage = page;
that.dataList = dataList;
},
utilFail: function(res) {
uni.stopPullDownRefresh();
if (page == 1) {
that.currentPage = page;
}
this.util.alert(res);
}
});
},
del(id){
var that = this;
uni.showModal({
title: '提示',
content: '是否确定删除?',
success(res) {
if(res.confirm){
that.util.request({
api: '/api/mobile/daily-inspection/destroy',
customLoading: false,
method:"get",
data: {
id:id
},
utilSuccess: function(r) {
4 years ago
uni.showToast({
icon: "none",
title: "提交成功",
complete() {
that.loadPage(1)
},
duration: 2000
4 years ago
})
},
utilFail:function(r) {
this.util.alert(res);
},
})
}else if(res.cancel){
}
}
})
}
}
}
</script>
<style>
.boxContent {
background: #f3f4f6;
min-height: 100vh;
}
.footer {
display: flex;
justify-content: flex-end;
}
.box-header {
position: fixed;
top: 0;
width: 100%;
z-index: 99;
}
.u-row {
margin: 10rpx 0;
font-size: 28rpx;
}
.u-card{
z-index: 1;
}
</style>
<style scoped lang="scss">
.overflowmask{
overflow: hidden;
}
.loadmore{
padding:24rpx!important
}
.search-wrap {
background: #007AFF;
padding: 20rpx;
}
.listfixed{
position: fixed;
width:100%;
4 years ago
}
.u-config-wrap {
padding: 30rpx;
}
.bg-purple {
font-weight: bold;
}
.slot-content {
background-color: #FFFFFF;
padding: 24rpx;
.item-box {
margin-bottom: 50rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.item {
border: 1px solid $u-type-primary;
color: $u-type-primary;
padding: 8rpx 40rpx;
border-radius: 100rpx;
margin-top: 30rpx;
}
.active {
color: #FFFFFF;
background-color: $u-type-primary;
}
}
}
</style>