3 changed files with 328 additions and 2 deletions
-
4src/api/order/onTimeRate.js
-
44src/views/modules/base/dictMaintenance.vue
-
282src/views/modules/order/onTimeRate.vue
@ -0,0 +1,4 @@ |
|||||
|
import { createAPI } from '@/utils/httpRequest.js' |
||||
|
|
||||
|
// On Time Rate 统计:按供应商聚合,GET 查询参数(site/year/monthStart/monthEnd/可选 supplierName/customer)
|
||||
|
export const listOnTimeRate = params => createAPI('/order/onTimeRate/list', 'get', params) |
||||
@ -0,0 +1,282 @@ |
|||||
|
<template> |
||||
|
<div class="mod-on-time-rate"> |
||||
|
<el-form :inline="true" label-position="top" :model="searchData"> |
||||
|
<el-form-item label="A_OBD Date"> |
||||
|
<span class="date-pair"> |
||||
|
<el-date-picker v-model="searchData.obdDateStart" type="date" placeholder="Start Date" |
||||
|
value-format="yyyy-MM-dd" style="width:130px" /> |
||||
|
<span class="date-sep">-</span> |
||||
|
<el-date-picker v-model="searchData.obdDateEnd" type="date" placeholder="End Date" |
||||
|
value-format="yyyy-MM-dd" style="width:130px" /> |
||||
|
</span> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<span style="cursor: pointer" slot="label" @click="openSupplierSelect"><a href="#">供应商编码</a></span> |
||||
|
<el-input v-model="searchData.supplierNo" style="width: 130px" @keyup.enter.native="searchList"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label=" "> |
||||
|
<el-button type="primary" size="medium" @click="searchList">查询</el-button> |
||||
|
<download-excel |
||||
|
:fields="fields()" |
||||
|
:data="exportList" |
||||
|
type="xls" |
||||
|
:name="exportName" |
||||
|
:header="exportHeader" |
||||
|
worksheet="On Time Rate" |
||||
|
class="el-button el-button--primary el-button--medium"> |
||||
|
{{ "导出" }} |
||||
|
</download-excel> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<div class="summary-bar" v-loading="dataListLoading"> |
||||
|
<span class="summary-label">On Time Rate 统计</span> |
||||
|
<span class="summary-item">总出运批次:<b class="summary-value">{{ summaryTotal.totalBatch }}</b></span> |
||||
|
<span class="summary-item">On Time Rate(Total):<b class="summary-value">{{ formatRate(summaryTotal.rateTotal) }}</b></span> |
||||
|
<span class="summary-item">On Time Rate(Supplier):<b class="summary-value">{{ formatRate(summaryTotal.rateSupplier) }}</b></span> |
||||
|
<span class="summary-tip">{{ summaryScopeTip }}</span> |
||||
|
</div> |
||||
|
|
||||
|
<el-table |
||||
|
:height="height" |
||||
|
:data="displayList" |
||||
|
border |
||||
|
v-loading="dataListLoading" |
||||
|
size="mini" |
||||
|
:row-class-name="tableRowClassName" |
||||
|
style="width: 100%;"> |
||||
|
<el-table-column prop="supplierNo" label="供应商编码" min-width="120" header-align="center" align="center" show-overflow-tooltip /> |
||||
|
<el-table-column prop="supplierName" label="供应商名称" min-width="240" header-align="center" align="left" show-overflow-tooltip /> |
||||
|
<el-table-column prop="shortName" label="供应商简称" min-width="140" header-align="center" align="center" show-overflow-tooltip /> |
||||
|
<el-table-column prop="rateTotal" label="On Time Rate(Total)" min-width="160" header-align="center" align="center"> |
||||
|
<template slot-scope="scope">{{ formatRate(scope.row.rateTotal) }}</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column prop="rateSupplier" label="On Time Rate(Supplier)" min-width="180" header-align="center" align="center"> |
||||
|
<template slot-scope="scope">{{ formatRate(scope.row.rateSupplier) }}</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column prop="totalBatch" label="Total Shipped Batches" min-width="150" header-align="center" align="center" /> |
||||
|
<el-table-column prop="delayBatch" label="Delay Batches" min-width="130" header-align="center" align="center" /> |
||||
|
<el-table-column prop="supplierDelayBatch" label="Supplier Delay Batches" min-width="160" header-align="center" align="center" /> |
||||
|
</el-table> |
||||
|
|
||||
|
<Chooselist ref="baseList" @getBaseData="getBaseData" /> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { listOnTimeRate } from '@/api/order/onTimeRate' |
||||
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
||||
|
import dayjs from 'dayjs' |
||||
|
|
||||
|
export default { |
||||
|
name: 'OnTimeRate', |
||||
|
components: { Chooselist }, |
||||
|
data () { |
||||
|
return { |
||||
|
height: 300, |
||||
|
userSite: this.$store.state.user.site, |
||||
|
searchData: { |
||||
|
obdDateStart: '', |
||||
|
obdDateEnd: '', |
||||
|
supplierNo: '' |
||||
|
}, |
||||
|
dataList: [], |
||||
|
dataListLoading: false, |
||||
|
// 导出 |
||||
|
exportName: 'OnTimeRate统计' + dayjs().format('YYYYMMDDHHmmss'), |
||||
|
exportHeader: ['On Time Rate 统计'] |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
// 合计口径:累加各行原始计数后重算总体比率(非各行平均) |
||||
|
summaryTotal () { |
||||
|
let total = 0 |
||||
|
let onTime = 0 |
||||
|
let delay = 0 |
||||
|
let nonSupplierDelay = 0 |
||||
|
let supplierDelay = 0 |
||||
|
this.dataList.forEach(row => { |
||||
|
total += row.totalBatch || 0 |
||||
|
onTime += row.onTimeBatch || 0 |
||||
|
delay += row.delayBatch || 0 |
||||
|
nonSupplierDelay += row.nonSupplierDelayBatch || 0 |
||||
|
supplierDelay += row.supplierDelayBatch || 0 |
||||
|
}) |
||||
|
return { |
||||
|
totalBatch: total, |
||||
|
delayBatch: delay, |
||||
|
supplierDelayBatch: supplierDelay, |
||||
|
rateTotal: total > 0 ? (onTime * 100 / total) : null, |
||||
|
rateSupplier: total > 0 ? ((onTime + nonSupplierDelay) * 100 / total) : null |
||||
|
} |
||||
|
}, |
||||
|
// 展示列表:数据行 + 末尾追加一行合计(本 Element-UI 版本固定 height 下 show-summary 不渲染,改用真实行展示总计) |
||||
|
displayList () { |
||||
|
if (!this.dataList.length) { |
||||
|
return [] |
||||
|
} |
||||
|
const st = this.summaryTotal |
||||
|
return this.dataList.concat([{ |
||||
|
isSummary: true, |
||||
|
supplierNo: '合计', |
||||
|
supplierName: '', |
||||
|
shortName: '', |
||||
|
totalBatch: st.totalBatch, |
||||
|
delayBatch: st.delayBatch, |
||||
|
supplierDelayBatch: st.supplierDelayBatch, |
||||
|
rateTotal: st.rateTotal, |
||||
|
rateSupplier: st.rateSupplier |
||||
|
}]) |
||||
|
}, |
||||
|
// 导出列表:与页面显示一致,追加合计行 |
||||
|
exportList () { |
||||
|
const rows = this.dataList.map(row => ({ |
||||
|
supplierNo: row.supplierNo, |
||||
|
supplierName: row.supplierName, |
||||
|
shortName: row.shortName, |
||||
|
totalBatch: row.totalBatch, |
||||
|
delayBatch: row.delayBatch, |
||||
|
supplierDelayBatch: row.supplierDelayBatch, |
||||
|
rateTotalText: this.formatRate(row.rateTotal), |
||||
|
rateSupplierText: this.formatRate(row.rateSupplier) |
||||
|
})) |
||||
|
rows.push({ |
||||
|
supplierNo: '合计', |
||||
|
supplierName: '', |
||||
|
shortName: '', |
||||
|
totalBatch: this.summaryTotal.totalBatch, |
||||
|
delayBatch: this.summaryTotal.delayBatch, |
||||
|
supplierDelayBatch: this.summaryTotal.supplierDelayBatch, |
||||
|
rateTotalText: this.formatRate(this.summaryTotal.rateTotal), |
||||
|
rateSupplierText: this.formatRate(this.summaryTotal.rateSupplier) |
||||
|
}) |
||||
|
return rows |
||||
|
}, |
||||
|
summaryScopeTip () { |
||||
|
const parts = [] |
||||
|
const { obdDateStart, obdDateEnd } = this.searchData |
||||
|
if (obdDateStart && obdDateEnd) { |
||||
|
parts.push(`${obdDateStart} ~ ${obdDateEnd}`) |
||||
|
} else if (obdDateStart) { |
||||
|
parts.push(`${obdDateStart} 起`) |
||||
|
} else if (obdDateEnd) { |
||||
|
parts.push(`至 ${obdDateEnd}`) |
||||
|
} |
||||
|
if (this.searchData.supplierNo) { |
||||
|
parts.push(`供应商编码:${this.searchData.supplierNo}`) |
||||
|
} |
||||
|
return parts.length ? `当前条件:${parts.join(',')}(按 A_OBD 出运日期)` : '未选日期,默认统计所有已发货订单' |
||||
|
} |
||||
|
}, |
||||
|
mounted () { |
||||
|
this.$nextTick(() => { |
||||
|
this.height = window.innerHeight - 250 |
||||
|
}) |
||||
|
// 日期非必填,进页默认查询所有已发货订单 |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
methods: { |
||||
|
openSupplierSelect () { |
||||
|
const strVal = this.searchData.supplierNo || '' |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs.baseList.init(520, strVal, '') |
||||
|
}) |
||||
|
}, |
||||
|
getBaseData (data) { |
||||
|
if (!data) { |
||||
|
return |
||||
|
} |
||||
|
this.searchData.supplierNo = data.supplier_no || data.supplierNo || '' |
||||
|
}, |
||||
|
searchList () { |
||||
|
if (this.searchData.obdDateStart && this.searchData.obdDateEnd |
||||
|
&& this.searchData.obdDateStart > this.searchData.obdDateEnd) { |
||||
|
this.$message.warning('起始日期不能晚于结束日期') |
||||
|
return |
||||
|
} |
||||
|
this.getDataList() |
||||
|
}, |
||||
|
getDataList () { |
||||
|
this.dataListLoading = true |
||||
|
listOnTimeRate({ |
||||
|
site: this.userSite, |
||||
|
obdDateStart: this.searchData.obdDateStart, |
||||
|
obdDateEnd: this.searchData.obdDateEnd, |
||||
|
supplierNo: this.searchData.supplierNo || '' |
||||
|
}).then(({ data }) => { |
||||
|
if (data && data.code === 0) { |
||||
|
this.dataList = data.rows || [] |
||||
|
} else { |
||||
|
this.$message.error((data && data.msg) || '查询失败') |
||||
|
this.dataList = [] |
||||
|
} |
||||
|
}).catch(() => { |
||||
|
this.$message.error('查询失败') |
||||
|
this.dataList = [] |
||||
|
}).finally(() => { |
||||
|
this.dataListLoading = false |
||||
|
}) |
||||
|
}, |
||||
|
formatRate (val) { |
||||
|
if (val === null || val === undefined || val === '') { |
||||
|
return '-' |
||||
|
} |
||||
|
return Number(val).toFixed(2) + '%' |
||||
|
}, |
||||
|
tableRowClassName ({ row }) { |
||||
|
return row && row.isSummary ? 'summary-row' : '' |
||||
|
}, |
||||
|
fields () { |
||||
|
return { |
||||
|
'供应商编码': 'supplierNo', |
||||
|
'供应商名称': 'supplierName', |
||||
|
'供应商简称': 'shortName', |
||||
|
'On Time Rate(Total)': 'rateTotalText', |
||||
|
'On Time Rate(Supplier)': 'rateSupplierText', |
||||
|
'Total Shipped Batches': 'totalBatch', |
||||
|
'Delay Batches': 'delayBatch', |
||||
|
'Supplier Delay Batches': 'supplierDelayBatch' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.summary-bar { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
flex-wrap: wrap; |
||||
|
gap: 16px; |
||||
|
padding: 8px 12px; |
||||
|
margin-bottom: 8px; |
||||
|
background: #f5f7fa; |
||||
|
border: 1px solid #ebeef5; |
||||
|
border-radius: 4px; |
||||
|
font-size: 13px; |
||||
|
} |
||||
|
.summary-label { |
||||
|
font-weight: 600; |
||||
|
color: #303133; |
||||
|
} |
||||
|
.summary-item .summary-value { |
||||
|
color: #409eff; |
||||
|
margin-left: 4px; |
||||
|
} |
||||
|
.summary-tip { |
||||
|
color: #909399; |
||||
|
font-size: 12px; |
||||
|
} |
||||
|
.date-pair { |
||||
|
display: inline-flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.date-sep { |
||||
|
margin: 0 6px; |
||||
|
color: #606266; |
||||
|
} |
||||
|
/deep/ .summary-row { |
||||
|
font-weight: 700; |
||||
|
background-color: #f5f7fa; |
||||
|
} |
||||
|
</style> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue