<template>
|
<view class="main">
|
<view class="top-statistics">
|
<view class="content-statistics">
|
<view class="content-text">发运统计</view>
|
<view class="content-text">共{{ totalLength }}车</view>
|
<view class="content-text">共{{ totalTon }}吨</view>
|
</view>
|
</view>
|
<view class="collapse-main">
|
<u-collapse>
|
<u-collapse-item :title="dateRange" value="筛选">
|
<view class="filter-main">
|
<view class="filter-body">
|
<view class="condition-name">煤种:</view>
|
<view class="filter-name">
|
<view class="filter-button" v-for="(item, index) in coalList" :key="index" @click="filterCondition(0, index, item.condition)">
|
<u-button shape="circle" :text="item.condition" :type="item.active ? 'success' : ''" size="small"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="filter-body">
|
<view class="condition-name">类型:</view>
|
<view class="filter-name">
|
<view class="filter-button" v-for="(item, index) in typeList" :key="index" @click="filterCondition(1, index, item.condition)">
|
<u-button shape="circle" :text="item.condition" :type="item.active ? 'success' : ''" size="small"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="filter-body">
|
<view class="condition-name">客户:</view>
|
<view class="filter-name">
|
<view class="filter-button" v-for="(item, index) in customerList" :key="index" @click="filterCondition(2, index, item.condition)">
|
<u-button shape="circle" :text="item.condition" :type="item.active ? 'success' : ''" size="small"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="filter-body" v-if="roleType == 1">
|
<view class="condition-name">货代:</view>
|
<view class="filter-name">
|
<view class="filter-button" v-for="(item, index) in forwarderList" :key="index" @click="filterCondition(3, index, item.condition)">
|
<u-button shape="circle" :text="item.condition" :type="item.active ? 'success' : ''" size="small"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="filter-body" v-if="roleType != 3">
|
<view class="condition-name">车队:</view>
|
<view class="filter-name">
|
<view class="filter-button" v-for="(item, index) in fleetList" :key="index" @click="filterCondition(4, index, item.condition)">
|
<u-button shape="circle" :text="item.condition" :type="item.active ? 'success' : ''" size="small"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="filter-body" v-if="roleType != 1">
|
<view class="condition-name">矿场:</view>
|
<view class="filter-name">
|
<view class="filter-button" v-for="(item, index) in filedList" :key="index" @click="filterCondition(5, index, item.condition)">
|
<u-button shape="circle" :text="item.condition" :type="item.active ? 'success' : ''" size="small"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="filter-body">
|
<view class="condition-name">日期:</view>
|
<view class="filter-name">
|
<u-button :text="dateselect" @click="opencalendar"></u-button>
|
<view class="filter-button">
|
<uni-calendar
|
ref="calendar"
|
class="uni-calendar--hook"
|
:clear-date="true"
|
:date="info.date"
|
:insert="info.insert"
|
:lunar="info.lunar"
|
:startDate="info.startDate"
|
:endDate="info.endDate"
|
:range="info.range"
|
@confirm="confirm"
|
/>
|
</view>
|
</view>
|
</view>
|
</view>
|
</u-collapse-item>
|
</u-collapse>
|
</view>
|
<view class="date-information">
|
<view class="statistics-card" v-for="(item, index) in filterList" :key="index">
|
<view class="card-title">
|
<view class="title-date">{{ item.condition }}</view>
|
<view class="title-number">
|
共{{ item.taskCoalList.length }}车 {{
|
item.taskCoalList.reduce((prev, cur) => {
|
return prev + cur.clean;
|
}, 0)
|
}}吨
|
</view>
|
</view>
|
<view class="card-main" v-for="(value, i) in item.taskCoalList" :key="i">
|
<view class="arrow-right"><u-icon name="arrow-right" size="50"></u-icon></view>
|
<view class="main-body">
|
<view class="coal-name">煤种:{{ value.coalName || '' }}</view>
|
<view class="clean">执行量:{{ value.clean || 0 }}</view>
|
<view class="out-time">出场时间:{{ value.outTime || '' }}</view>
|
<view class="car-number">车牌号:{{ value.carNo || '' }}</view>
|
<view class="filedName">矿场:{{ value.filedName || '' }}</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
conditionList: [],
|
coalList: [],
|
typeList: [],
|
customerList: [],
|
forwarderList: [],
|
fleetList: [],
|
filedList: [],
|
isactive: false,
|
info: {
|
lunar: false,
|
range: true,
|
insert: false,
|
selected: []
|
},
|
first: '',
|
last: '',
|
taskList: [],
|
filterList: [],
|
totalLength: 0,
|
totalTon: 0
|
};
|
},
|
onShow() {
|
this.firstDate();
|
this.lastDate();
|
this.getShipping();
|
this.getTmTaskCoalData();
|
},
|
methods: {
|
firstDate() {
|
let y = new Date().getFullYear(); //获取年份
|
let m = new Date().getMonth() + 1; //获取月份
|
let d = '01';
|
m = m < 10 ? '0' + m : m; //月份补 0
|
this.first = [y, m, d].join('-');
|
},
|
lastDate() {
|
let y = new Date().getFullYear(); //获取年份
|
let m = new Date().getMonth() + 1; //获取月份
|
let d = new Date(y, m, 0).getDate(); //获取当月最后一日
|
m = m < 10 ? '0' + m : m; //月份补 0
|
d = d < 10 ? '0' + d : d; //日数补 0
|
this.last = [y, m, d].join('-');
|
},
|
// 筛选条件
|
getShipping() {
|
this.$reqGet('getShippingCondition', { startTime: this.first, endTime: this.last }).then(res => {
|
this.conditionList = res.data;
|
this.coalList = res.data
|
.filter(v => v.conditionType == 0)
|
.map(item => {
|
return {
|
...item,
|
active: false
|
};
|
});
|
this.typeList = res.data
|
.filter(v => v.conditionType == 1)
|
.map(item => {
|
return {
|
...item,
|
active: false
|
};
|
});
|
this.customerList = res.data
|
.filter(v => v.conditionType == 2)
|
.map(item => {
|
return {
|
...item,
|
active: false
|
};
|
});
|
this.forwarderList = res.data
|
.filter(v => v.conditionType == 3)
|
.map(item => {
|
return {
|
...item,
|
active: false
|
};
|
});
|
this.fleetList = res.data
|
.filter(v => v.conditionType == 4)
|
.map(item => {
|
return {
|
...item,
|
active: false
|
};
|
});
|
this.filedList = res.data
|
.filter(v => v.conditionType == 5)
|
.map(item => {
|
return {
|
...item,
|
active: false
|
};
|
});
|
});
|
},
|
// 获取数据
|
getTmTaskCoalData() {
|
uni.showLoading({
|
title: '加载中'
|
});
|
this.$reqGet('getTmTaskCoalData', { startTime: this.first, endTime: this.last }).then(res => {
|
this.filterList = this.taskList = res.data;
|
if (this.filterList.length != 0) {
|
this.totalLength = this.filterList.map(v => v.taskCoalList.length).reduce((x, y) => x + y);
|
this.totalTon = this.filterList.map(v =>
|
v.taskCoalList.reduce((prev, cur) => {
|
return cur.clean + prev;
|
}, 0)
|
);
|
this.totalTon = this.totalTon.reduce((x, y) => x + y);
|
} else {
|
this.totalLength = 0;
|
this.totalTon = 0;
|
}
|
uni.hideLoading();
|
});
|
},
|
// 筛选数据
|
filterCondition(value, i, data) {
|
switch (value) {
|
case 0:
|
this.coalList[i].active = !this.coalList[i].active;
|
break;
|
case 1:
|
this.typeList[i].active = !this.typeList[i].active;
|
break;
|
case 2:
|
this.customerList[i].active = !this.customerList[i].active;
|
break;
|
case 3:
|
this.forwarderList[i].active = !this.forwarderList[i].active;
|
break;
|
case 4:
|
this.fleetList[i].active = !this.fleetList[i].active;
|
break;
|
case 5:
|
this.filedList[i].active = !this.filedList[i].active;
|
break;
|
}
|
|
const validateFn = key => (v, arr) => {
|
if (arr.length == 0) {
|
return true;
|
} else {
|
return arr.includes(v[key]);
|
}
|
};
|
let conditionMapping = {
|
coalName: this.coalList.filter(v => v.active == true).map(item => item.condition),
|
orderType: this.typeList.filter(v => v.active == true).map(item => item.condition),
|
customerName: this.customerList.filter(v => v.active == true).map(item => item.condition),
|
xsUser2Name: this.forwarderList.filter(v => v.active == true).map(item => item.condition),
|
fleetName: this.fleetList.filter(v => v.active == true).map(item => item.condition),
|
filedName: this.filedList.filter(v => v.active == true).map(item => item.condition)
|
};
|
|
const mapping = {
|
coalName: validateFn('coalName'),
|
orderType: validateFn('orderType'),
|
customerName: validateFn('customerName'),
|
xsUser2Name: validateFn('xsUser2Name'),
|
fleetName: validateFn('fleetName'),
|
filedName: validateFn('filedName')
|
};
|
this.filterList = this.taskList.map(val => {
|
return {
|
condition: val.condition,
|
conditionId: val.conditionId,
|
conditionType: val.conditionType,
|
taskCoalList: val.taskCoalList.filter(v => Reflect.ownKeys(conditionMapping).every(key => mapping[key](v, conditionMapping[key])))
|
};
|
});
|
if (this.filterList.length != 0) {
|
this.totalLength = this.filterList.map(v => v.taskCoalList.length).reduce((x, y) => x + y);
|
this.totalTon = this.filterList.map(v =>
|
v.taskCoalList.reduce((prev, cur) => {
|
return cur.clean + prev;
|
}, 0)
|
);
|
this.totalTon = this.totalTon.reduce((x, y) => x + y);
|
} else {
|
this.totalLength = 0;
|
this.totalTon = 0;
|
}
|
},
|
confirm(e) {
|
this.first = e.range.before;
|
this.last = e.range.after;
|
},
|
opencalendar() {
|
this.$refs.calendar.open();
|
}
|
},
|
computed: {
|
roleType() {
|
return uni.getStorageSync('roleType');
|
},
|
dateRange() {
|
return `日期:${this.first}-${this.last}`;
|
},
|
dateselect() {
|
return `${this.first}-${this.last}`;
|
}
|
},
|
watch: {
|
dateselect(newV, old) {
|
let tempDate = `${this.first}-${this.last}`;
|
console.log(newV, '新', old, '旧', tempDate, '一开始');
|
if (newV != old && old != '-') {
|
this.first = newV.slice(0, 10);
|
this.last = newV.slice(11);
|
this.getTmTaskCoalData();
|
}
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
::v-deep .u-cell__value {
|
color: #9ec16c !important;
|
font-size: vww(18) !important;
|
}
|
::v-deep .filter-name:nth-last-child(1) {
|
.u-button {
|
width: 66%;
|
}
|
}
|
.main {
|
width: 96%;
|
margin: 0 auto;
|
background-color: #e8eaec;
|
/*顶部统计栏*/
|
.top-statistics {
|
width: 100%;
|
height: vww(50);
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
.content-statistics {
|
width: 100%;
|
height: 100%;
|
padding: 0 vww(10);
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
.content-text {
|
width: vww(80);
|
height: vww(30);
|
font-size: vww(20);
|
color: #393a3c;
|
}
|
}
|
}
|
// 选项折叠框
|
.collapse-main {
|
width: 100%;
|
margin-top: vww(10);
|
background-color: #fff;
|
border: 1px solid #cccccc;
|
border-radius: vww(5);
|
.filter-main {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-around;
|
.filter-body {
|
width: 100%;
|
position: relative;
|
display: flex;
|
justify-content: flex-start;
|
flex-wrap: wrap;
|
.condition-name {
|
font-size: vww(16);
|
}
|
.filter-name {
|
width: 100%;
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: flex-start;
|
align-items: flex-start;
|
position: relative;
|
top: vww(-34);
|
|
.filter-button {
|
color: #393a3c;
|
height: vww(16);
|
padding: vww(8);
|
margin: vww(5) vww(5);
|
&:nth-child(1) {
|
margin-left: vww(48);
|
}
|
}
|
}
|
}
|
}
|
}
|
// 日期发运
|
.date-information {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
.statistics-card {
|
width: 100%;
|
margin-top: vww(8);
|
border: 1px solid #cccccc;
|
border-radius: vww(5);
|
background-color: #fff;
|
min-height: vww(120);
|
display: flex;
|
flex-direction: column;
|
justify-content: space-between;
|
.card-title {
|
width: 100%;
|
height: vww(40);
|
line-height: vww(40);
|
padding-left: vww(5);
|
color: #bcbcbc;
|
border-bottom: 1px solid #cccccc;
|
display: flex;
|
.title-date {
|
width: vww(90);
|
margin-right: vww(10);
|
}
|
.title-number {
|
flex: 1;
|
}
|
}
|
.card-main {
|
width: 100%;
|
flex: 1;
|
position: relative;
|
.arrow-right {
|
position: absolute;
|
right: vww(14);
|
top: vww(18);
|
}
|
.main-body {
|
width: 80%;
|
height: vww(60);
|
margin-top: vww(5);
|
padding: vww(3);
|
color: #686868;
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: space-around;
|
}
|
}
|
}
|
}
|
}
|
</style>
|