6955784e93
Co-authored-by: Cursor <cursoragent@cursor.com>
190 lines
5.8 KiB
Vue
190 lines
5.8 KiB
Vue
<template>
|
|
<div class="tr-table-panel">
|
|
<div class="tr-table-panel__toolbar">
|
|
<div>
|
|
<el-button
|
|
v-if="hasPermission('transport_reconciliation_add')"
|
|
type="primary"
|
|
@click="$emit('create')"
|
|
>新增</el-button
|
|
>
|
|
<el-button type="primary" plain @click="$emit('export')">导出</el-button>
|
|
</div>
|
|
<settlement-table-tools
|
|
:columns="columnSettingOptions"
|
|
v-model:visible-column-keys="visibleColumnKeys"
|
|
v-model:table-size="tableSize"
|
|
:search-visible="searchVisible"
|
|
@update:search-visible="$emit('update:searchVisible', $event)"
|
|
@refresh="$emit('refresh')"
|
|
/>
|
|
</div>
|
|
<el-table
|
|
v-loading="loading"
|
|
:data="rows"
|
|
:size="tableSize"
|
|
border
|
|
@selection-change="handleSelectionChange"
|
|
>
|
|
<el-table-column type="selection" width="52" fixed="left" align="center" />
|
|
<el-table-column type="index" label="序号" width="64" fixed="left" align="center" />
|
|
<el-table-column
|
|
v-for="column in visibleColumns"
|
|
:key="column.prop"
|
|
v-bind="column"
|
|
align="center"
|
|
show-overflow-tooltip
|
|
>
|
|
<template #default="{ row }">
|
|
<el-link v-if="column.link" type="primary" @click="emitAction('view', row)">{{
|
|
row[column.prop] || '-'
|
|
}}</el-link>
|
|
<span v-else-if="column.money">{{ formatMoney(row[column.prop], row.currency) }}</span>
|
|
<el-tag
|
|
v-else-if="column.prop === 'reconciliationStatusName'"
|
|
:type="row.reconciliationStatus === 'completed' ? 'success' : 'warning'"
|
|
>{{ row[column.prop] || '-' }}</el-tag
|
|
>
|
|
<span v-else>{{ displayValue(row[column.prop]) }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" width="220" fixed="right" align="center">
|
|
<template #default="{ row }"
|
|
><div class="tr-table-panel__links">
|
|
<el-link
|
|
v-for="action in rowActions(row)"
|
|
:key="action.type"
|
|
:type="action.danger ? 'danger' : 'primary'"
|
|
@click="emitAction(action.type, row)"
|
|
>{{ action.label }}</el-link
|
|
>
|
|
</div></template
|
|
>
|
|
</el-table-column>
|
|
</el-table>
|
|
<div class="tr-table-panel__pagination">
|
|
<el-pagination
|
|
:current-page="page.current"
|
|
:page-size="page.size"
|
|
:total="page.total"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
@current-change="current => $emit('page-change', { current, size: page.size })"
|
|
@size-change="size => $emit('page-change', { current: 1, size })"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import SettlementTableTools from './settlement-table-tools.vue';
|
|
|
|
export default {
|
|
name: 'TransportReconciliationTablePanel',
|
|
components: { SettlementTableTools },
|
|
props: {
|
|
rows: { type: Array, default: () => [] },
|
|
columns: { type: Array, default: () => [] },
|
|
loading: { type: Boolean, default: false },
|
|
page: { type: Object, required: true },
|
|
hasPermission: { type: Function, required: true },
|
|
searchVisible: { type: Boolean, default: true },
|
|
},
|
|
emits: [
|
|
'create',
|
|
'export',
|
|
'refresh',
|
|
'page-change',
|
|
'update:selection',
|
|
'action',
|
|
'update:searchVisible',
|
|
],
|
|
data() {
|
|
return {
|
|
selection: [],
|
|
tableSize: 'default',
|
|
visibleColumnKeys: [],
|
|
knownColumnProps: [],
|
|
};
|
|
},
|
|
computed: {
|
|
columnSettingOptions() {
|
|
return this.columns.map(column => ({
|
|
prop: column.prop,
|
|
label: column.label,
|
|
}));
|
|
},
|
|
visibleColumns() {
|
|
if (!this.visibleColumnKeys.length) return this.columns;
|
|
return this.columns.filter(column => this.visibleColumnKeys.includes(column.prop));
|
|
},
|
|
},
|
|
watch: {
|
|
columns: {
|
|
immediate: true,
|
|
handler(columns) {
|
|
const props = columns.map(column => column.prop);
|
|
if (!this.visibleColumnKeys.length) {
|
|
this.visibleColumnKeys = props;
|
|
this.knownColumnProps = props;
|
|
return;
|
|
}
|
|
const visible = new Set(this.visibleColumnKeys);
|
|
const known = new Set(this.knownColumnProps || []);
|
|
props.forEach(prop => {
|
|
if (!known.has(prop)) visible.add(prop);
|
|
});
|
|
this.knownColumnProps = props;
|
|
this.visibleColumnKeys = props.filter(prop => visible.has(prop));
|
|
},
|
|
},
|
|
},
|
|
methods: {
|
|
handleSelectionChange(value) {
|
|
this.selection = value;
|
|
this.$emit('update:selection', value);
|
|
},
|
|
emitAction(type, row) {
|
|
this.$emit('action', { type, row });
|
|
},
|
|
isEditable(row) {
|
|
return row.reconciliationStatus === 'unfinished';
|
|
},
|
|
rowActions(row) {
|
|
const actions = [{ type: 'view', label: '查看' }];
|
|
if (this.hasPermission('transport_reconciliation_delete') && this.isEditable(row))
|
|
actions.push({ type: 'delete', label: '删除', danger: true });
|
|
if (this.hasPermission('transport_reconciliation_complete') && this.isEditable(row))
|
|
actions.push({ type: 'complete', label: '确认' });
|
|
return actions;
|
|
},
|
|
displayValue(value) {
|
|
return value === null || value === undefined || value === '' ? '-' : value;
|
|
},
|
|
formatMoney(value, currency = 'RMB') {
|
|
return `${Number(value || 0).toFixed(2)} ${currency || 'RMB'}`;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.tr-table-panel__toolbar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 12px 0;
|
|
}
|
|
.tr-table-panel__links {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
}
|
|
.tr-table-panel__pagination {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
margin-top: 12px;
|
|
}
|
|
</style>
|