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.

388 lines
8.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<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;">
<u-dropdown @open="openmask" @close="closemask" :class="mask?'':'overflowmask'" ref="uDropdown">
<u-dropdown-item v-model="proStatusId" :title="proStatus==''?'处理方式':proStatus" @change="toChangeStatus"
:options="prostatusList">
</u-dropdown-item>
<u-dropdown-item v-model="lzStatusId" :title="lzStatus==''?'状态':lzStatus" @change="toChangelzStatus"
:options="lzstatusList">
</u-dropdown-item>
</u-dropdown>
<block v-for="(item, index) in dataList">
<u-card :title="item.created_at" padding="20" margin="20rpx" :border="true"
:thumb="thumb" thumb-width="36">
<view class="" slot="body" @click="todetail(item.id)">
<u-row gutter="16">
<u-col span="4">
<view class="demo-layout bg-purple">巡查项目:</view>
</u-col>
<u-col span="8">
<view class="demo-layout bg-purple-light">{{item.name}}</view>
</u-col>
</u-row>
<u-row gutter="16">
<u-col span="4">
<view class="demo-layout bg-purple">处理方式:</view>
</u-col>
<u-col span="8">
<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="4">
<view class="demo-layout bg-purple">定位地址:</view>
</u-col>
<u-col span="12">
{{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: '#0385e5'
},
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: '',
proStatusId: '',
lzStatus: '',
lzStatusId: '',
keyword: "",
title: "",
prostatusList: [{
label: "所有",
value: "",
id: ""
}, {
label: "无异常",
value: 1,
}, {
label: "已处理",
value: 2,
}, {
label: "不可现场处理",
value: 3
}],
lzstatusList: [{
label: "所有",
value: "",
id: ""
}, {
label: "已提交",
value: 1,
}, {
label: "已处理",
value: 2,
}, {
label: "未处理",
value: 3
}]
}
},
onReachBottom: function(e) {
if(this.currentPage>=this.lastPage){
this.loadStatus = "nomore"
return;
}
this.loadPage(this.currentPage + 1);
},
onPullDownRefresh: function(e) {
this.loadStatus = 'loadmore';
console.log("onPullDownRefresh")
this.loadPage(1);
},
onShow: function() {
var that = this;
},
onLoad(options) {
this.loadPage(1);
},
onNavigationBarButtonTap(val) {
window.android.finish();
},
methods: {
openmask(){
this.mask=true
// this.isPullDown(false);
},
closemask(){
this.mask=false
// this.isPullDown(true);
},
toChangeStatus: function(value) {
for(var m of this.prostatusList){
if(value == m.value){
this.proStatus = m.label
}
}
this.loadPage(1);
this.$refs.uDropdown.close();
},
toChangelzStatus: function(value) {
for(var m of this.lzstatusList){
if(value == m.value){
this.lzStatus = m.label
}
}
this.loadPage(1);
this.$refs.uDropdown.close();
},
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()
var that = this;
this.util.request({
bindThis: that,
api: '/api/mobile/daily-inspection/index',
customLoading: false,
data: {
page: page,
page_size: 5,
keyword: that.keyword,
status:that.proStatusId,
lzstatus:that.lzStatusId
},
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) {
uni.showToast({
icon: "none",
title: "提交成功",
complete() {
that.loadPage(1)
},
duration: 2000
})
},
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: #0385e5;
padding: 20rpx;
}
.listfixed{
position: fixed;
width:100%;
}
.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>