102 lines
2.8 KiB
Vue
102 lines
2.8 KiB
Vue
<template>
|
||
<div class="result-table">
|
||
<el-alert v-if="state.error" :title="state.error" :closable="false" type="error">
|
||
<el-button type="text" size="mini" @click="$emit('page', state.page)">重试</el-button>
|
||
</el-alert>
|
||
<template v-else>
|
||
<el-table
|
||
v-loading="state.loading"
|
||
:data="state.rows"
|
||
:empty-text="state.loading ? '正在查询' : emptyText"
|
||
size="mini"
|
||
border
|
||
max-height="430"
|
||
highlight-current-row
|
||
@row-click="selectRow"
|
||
>
|
||
<el-table-column
|
||
v-for="col in columns"
|
||
:key="col[0]"
|
||
:prop="col[0]"
|
||
:sortable="col[0] === '风险分值'"
|
||
:label="col[1] || col[0]"
|
||
:min-width="col[2] || 88"
|
||
show-overflow-tooltip
|
||
>
|
||
<template slot-scope="scope">
|
||
<el-tag v-if="col[0] === '风险等级'" :type="levelStyle(scope.row.风险等级)" size="mini">{{
|
||
scope.row.风险等级
|
||
}}</el-tag>
|
||
<span v-else>{{ display(scope.row, col[0]) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column v-if="action" label="操作" width="82">
|
||
<template
|
||
slot-scope="scope"
|
||
><el-button type="text" size="mini" @click.stop="$emit('open', scope.row)">{{
|
||
action
|
||
}}</el-button></template
|
||
>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
:current-page="state.page"
|
||
:total="state.total"
|
||
:page-size="20"
|
||
:disabled="state.loading"
|
||
:pager-count="5"
|
||
small
|
||
layout="total, prev, pager, next"
|
||
@current-change="$emit('page', $event)"
|
||
/>
|
||
</template>
|
||
</div>
|
||
</template>
|
||
<script>
|
||
export default {
|
||
name: 'SupplierResultTable',
|
||
props: {
|
||
columns: { type: Array, required: true },
|
||
state: { type: Object, required: true },
|
||
emptyText: { type: String, default: '暂无数据' },
|
||
action: { type: String, default: '' }
|
||
},
|
||
methods: {
|
||
selectRow(row) {
|
||
if (this.action) this.$emit('select', row)
|
||
},
|
||
levelStyle(level) {
|
||
return { 高: 'danger', 中: 'warning', 低: 'success' }[level] || 'info'
|
||
},
|
||
display(row, field) {
|
||
if (field === '到货率') return row.到货率 + '%'
|
||
if (field === '分批到货进度') {
|
||
return (
|
||
'累计 ' +
|
||
row.累计到货数量 +
|
||
' / ' +
|
||
row.采购数量 +
|
||
(row.单位 || '') +
|
||
',剩余 ' +
|
||
row.剩余到货数量 +
|
||
',' +
|
||
row.到货批次数 +
|
||
' 批'
|
||
)
|
||
}
|
||
return row[field] == null || row[field] === '' ? '—' : row[field]
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<style scoped>
|
||
.result-table {
|
||
min-width: 0;
|
||
}
|
||
.el-pagination {
|
||
margin: 8px 0;
|
||
max-width: 100%;
|
||
white-space: normal;
|
||
}
|
||
</style>
|