|
|
@@ -34,6 +34,9 @@
|
|
|
<view v-else-if="column.type === 'file'">
|
|
|
<cwg-file :path="row[column.prop]" />
|
|
|
</view>
|
|
|
+ <view v-else-if="column.type === 'note'">
|
|
|
+ <text>{{ getNoteText(row, locale, userStore) }}</text>
|
|
|
+ </view>
|
|
|
<cwg-icon v-else-if="column.type === 'more'" name="crm-chevron-down"
|
|
|
class="crm-chevron-down" :size="16" color="#007" />
|
|
|
<template v-else>
|
|
|
@@ -55,8 +58,9 @@
|
|
|
|
|
|
<!-- 总计行 -->
|
|
|
<uni-tr v-if="showSummary" class="summary-row">
|
|
|
- <uni-td v-for="(column, index) in displayColumns" :key="'summary-' + column.prop" :align="column.align || 'center'"
|
|
|
- class="summary-cell" :style="getCellStyle(column, currentSummaryData)">
|
|
|
+ <uni-td v-for="(column, index) in displayColumns" :key="'summary-' + column.prop"
|
|
|
+ :align="column.align || 'center'" class="summary-cell"
|
|
|
+ :style="getCellStyle(column, currentSummaryData)">
|
|
|
<!-- 当有 summaryMethod 时,按照返回的数组直接渲染 -->
|
|
|
<template v-if="props.summaryMethod">
|
|
|
<text>{{ computedSummaryRow[index] !== undefined ? computedSummaryRow[index] : '' }}</text>
|
|
|
@@ -64,17 +68,21 @@
|
|
|
<template v-else>
|
|
|
<!-- 特定列的总计自定义插槽,例如 #summary-volume="{ row }" -->
|
|
|
<template v-if="$slots['summary-' + column.prop]">
|
|
|
- <slot :name="'summary-' + column.prop" :row="currentSummaryData" :column="column" :index="index"></slot>
|
|
|
+ <slot :name="'summary-' + column.prop" :row="currentSummaryData" :column="column"
|
|
|
+ :index="index"></slot>
|
|
|
</template>
|
|
|
<!-- 如果没有特定插槽,尝试常规渲染 -->
|
|
|
<template v-else>
|
|
|
- <template v-if="currentSummaryData && currentSummaryData[column.prop] !== undefined && currentSummaryData[column.prop] !== null">
|
|
|
+ <template
|
|
|
+ v-if="currentSummaryData && currentSummaryData[column.prop] !== undefined && currentSummaryData[column.prop] !== null">
|
|
|
<!-- 如果有常规插槽,并且总计数据里有该字段的值,则复用常规插槽渲染 -->
|
|
|
- <slot v-if="column.slot" :name="column.slot" :row="currentSummaryData" :column="column" :index="index">
|
|
|
+ <slot v-if="column.slot" :name="column.slot" :row="currentSummaryData"
|
|
|
+ :column="column" :index="index">
|
|
|
{{ currentSummaryData[column.prop] }}
|
|
|
</slot>
|
|
|
<!-- 否则使用格式化函数 -->
|
|
|
- <text v-else>{{ formatCellValue(currentSummaryData[column.prop], column, currentSummaryData) }}</text>
|
|
|
+ <text v-else>{{ formatCellValue(currentSummaryData[column.prop], column,
|
|
|
+ currentSummaryData) }}</text>
|
|
|
</template>
|
|
|
<!-- 如果总计数据里没有该字段的值,第一列显示总计文本,其他留空 -->
|
|
|
<text v-else>{{ index === 0 ? summaryText : '' }}</text>
|
|
|
@@ -121,13 +129,22 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 移动端详情弹窗 -->
|
|
|
- <cwg-detail-popup v-model:visible="detailVisible" title="详情" :items="detailItems" />
|
|
|
+ <!-- <cwg-detail-popup v-model:visible="detailVisible" title="详情" :items="detailItems" /> -->
|
|
|
+ <cwg-detail-popup v-model:visible="detailVisible" title="详情" :row="detailRow" :columns="detailColumns">
|
|
|
+ <template v-for="col in detailColumns" :key="col.prop" #[`cell-${col.prop}`]="{ row, column }">
|
|
|
+ <slot v-if="col.slot" :name="col.slot" :row="row" :column="column" :index="0" />
|
|
|
+ </template>
|
|
|
+ </cwg-detail-popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
|
|
|
-
|
|
|
+import { getNoteText } from '@/utils/noteHelper';
|
|
|
+import useUserStore from "@/stores/use-user-store";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
+const userStore = useUserStore();
|
|
|
+const { locale } = useI18n();
|
|
|
const props = defineProps({
|
|
|
/**
|
|
|
* 表格列配置(columns 数组中每一项是一个列配置对象)
|
|
|
@@ -193,7 +210,6 @@ const props = defineProps({
|
|
|
// 总计行第一列的默认文本
|
|
|
summaryText: { type: String, default: '总计' },
|
|
|
})
|
|
|
-
|
|
|
const emit = defineEmits([
|
|
|
'selection-change',
|
|
|
'action-click',
|
|
|
@@ -209,6 +225,9 @@ const tableData = ref([])
|
|
|
const selectedItems = ref([])
|
|
|
const detailVisible = ref(false)
|
|
|
const detailItems = ref([])
|
|
|
+// 替换原来的 detailItems 相关定义
|
|
|
+const detailRow = ref(null)
|
|
|
+const detailColumns = ref([])
|
|
|
const pagination = ref({
|
|
|
current: 1,
|
|
|
pageSize: props.defaultPageSize,
|
|
|
@@ -444,20 +463,16 @@ const toggleRowExpand = (rowIndex) => {
|
|
|
emit('expand-change', { rowIndex, expanded: expandedRows.value[key] })
|
|
|
}
|
|
|
// 打开详情弹窗(移动端使用)
|
|
|
+// 修改 openRowDetail
|
|
|
const openRowDetail = (row) => {
|
|
|
-
|
|
|
if (props.isPages) {
|
|
|
emit('go-pages', row)
|
|
|
} else {
|
|
|
- detailItems.value = props.columns
|
|
|
- .filter((column) => column && column.prop && column.label)
|
|
|
- .map((column) => ({
|
|
|
- label: column.label,
|
|
|
- value: String(formatCellValue(row[column.prop], column, row))
|
|
|
- }))
|
|
|
+ // 保存当前行和需要显示的列(有 prop 且有 label)
|
|
|
+ detailRow.value = { ...row, note: getNoteText(row, locale.value, userStore) }
|
|
|
+ detailColumns.value = props.columns.filter(col => col && col.prop && col.label)
|
|
|
detailVisible.value = true
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// ========== 数据加载 ==========
|
|
|
@@ -678,7 +693,7 @@ defineExpose({
|
|
|
.summary-row {
|
|
|
background-color: #fafafa;
|
|
|
font-weight: 600;
|
|
|
-
|
|
|
+
|
|
|
.uni-table-td {
|
|
|
border-top: 1px solid #ebeef5 !important;
|
|
|
position: sticky;
|