|
|
@ -1,7 +1,8 @@ |
|
|
|
<template> |
|
|
|
<q-tr |
|
|
|
ref="trRef" |
|
|
|
:class="row[table.selectedField] ? 'selected ' : ''" |
|
|
|
:no-hover="!props.grid.props.cellSelected ? false : true" |
|
|
|
:class="row[table.selectedField] && !props.grid.props.cellSelected ? 'selected' : ''" |
|
|
|
:draggable="draggableComputed" |
|
|
|
@click.stop.prevent="click($event, row, props.rowIndex)" |
|
|
|
@dblclick.stop.prevent="dbClick($event, row, props.rowIndex)" |
|
|
@ -10,7 +11,22 @@ |
|
|
|
@drop="draggableComputed ? onDrop($event, row) : () => {}" |
|
|
|
@dragstart="draggableComputed ? onDragStart($event, row) : () => {}" |
|
|
|
> |
|
|
|
<q-td class="nowrap text-nowrap"> |
|
|
|
<q-td |
|
|
|
:class="props.grid.props.cellSelected ? firstTdClassComputed : 'nowrap text-nowrap'" |
|
|
|
@click=" |
|
|
|
() => { |
|
|
|
if (table && props.grid.props.cellSelected) { |
|
|
|
table['cellSelected'] = { |
|
|
|
row: toRaw(props.row), |
|
|
|
rowKey: props.row[props.rowKey], |
|
|
|
primaryKey: props.row[props.grid.props.primaryKey], |
|
|
|
colName: cols[0]['name'], |
|
|
|
value: cols[0]['value'], |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
" |
|
|
|
> |
|
|
|
<div ref="tdDivRef" class="flex flex-nowrap items-center h-full w-full" style="flex-wrap: nowrap"> |
|
|
|
<!--层级占位符--> |
|
|
|
<span :style="`width:${24 * props.level}px;`"></span> |
|
|
@ -65,9 +81,22 @@ |
|
|
|
<template v-for="(col, index) in cols" :key="col.name"> |
|
|
|
<q-td |
|
|
|
v-if="index > 0" |
|
|
|
:class="col.__thClass + ' ' + col.classes" |
|
|
|
:class="props.grid.props.cellSelected ? tdClassComputed(col) : col.__thClass + ' ' + col.classes" |
|
|
|
:title="col.classes?.indexOf('truncate') > -1 && col.value && typeof col.value !== 'object' ? col.value : ''" |
|
|
|
:style="col.style" |
|
|
|
@click=" |
|
|
|
() => { |
|
|
|
if (table && props.grid.props.cellSelected) { |
|
|
|
table['cellSelected'] = { |
|
|
|
row: toRaw(props.row), |
|
|
|
rowKey: props.row[props.rowKey], |
|
|
|
primaryKey: props.row[props.grid.props.primaryKey], |
|
|
|
colName: col['name'], |
|
|
|
value: col['value'], |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
" |
|
|
|
> |
|
|
|
<template v-if="!Tools.isEmpty(col['type']) && ((isSelectedRowComputed && table.bodyEditStatus === 'rowEdit') || table.bodyEditStatus === 'rowsEdit')"> |
|
|
|
<component |
|
|
@ -132,7 +161,7 @@ |
|
|
|
import { ref, computed, inject, toRaw } from 'vue'; |
|
|
|
import { Tools, NotifyManager } from '@/platform'; |
|
|
|
import GridEditToolbar from './GridEditToolbar.vue'; |
|
|
|
import { draggableImage } from './ts/grid'; |
|
|
|
import { draggableImage, draggableMode } from './ts/grid'; |
|
|
|
|
|
|
|
const trRef = ref(); |
|
|
|
const tdDivRef = ref(); |
|
|
@ -236,10 +265,40 @@ const style = { |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
const firstTdClassComputed = computed(() => { |
|
|
|
const tdClass = <any>['nowrap', 'text-nowrap']; |
|
|
|
if (props.grid.props.cellSelected) { |
|
|
|
tdClass.push('cellSelected_hover'); |
|
|
|
} |
|
|
|
if (table && table['cellSelected'] && Tools.hasOwnProperty(table['cellSelected'], 'colName')) { |
|
|
|
if (table['cellSelected']['colName'] === props.cols[0]['name'] && table['cellSelected']['rowKey'] === props.row[props.rowKey]) { |
|
|
|
tdClass.push('cellSelected'); |
|
|
|
} |
|
|
|
} |
|
|
|
return tdClass; |
|
|
|
}); |
|
|
|
const tdClassComputed = computed(() => { |
|
|
|
return (col) => { |
|
|
|
let tdClass = col.__thClass + ' ' + col.classes; |
|
|
|
if (props.grid.props.cellSelected) { |
|
|
|
tdClass += ' cellSelected_hover'; |
|
|
|
} |
|
|
|
if (table && table['cellSelected'] && Tools.hasOwnProperty(table['cellSelected'], 'colName')) { |
|
|
|
if (table['cellSelected']['colName'] === col['name'] && table['cellSelected']['rowKey'] === props.row[props.rowKey]) { |
|
|
|
tdClass += ' cellSelected'; |
|
|
|
} |
|
|
|
} |
|
|
|
return tdClass; |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
const draggableComputed = computed(() => { |
|
|
|
if (typeof props.grid.props.draggable === 'boolean' && props.grid.props.draggable && table.bodyEditStatus === 'none') { |
|
|
|
return true; |
|
|
|
} else if (typeof props.grid.props.draggable === 'string' && props.grid.props.draggable === 'local' && table.bodyEditStatus === 'none') { |
|
|
|
if ( |
|
|
|
props.grid.props.draggable && |
|
|
|
typeof props.grid.props.draggable === 'string' && |
|
|
|
!Tools.isEmpty(draggableMode[props.grid.props.draggable]) && |
|
|
|
table.bodyEditStatus === 'none' |
|
|
|
) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
@ -672,7 +731,7 @@ const onDrop = (e, dataRow) => { |
|
|
|
resetOrder(e, table.dragRecords, table.rows, dataRow); |
|
|
|
|
|
|
|
// 请求后端更新排序 |
|
|
|
if (typeof props.grid.props.draggable === 'boolean' && props.grid.props.draggable && updateOrderData?.length > 0) { |
|
|
|
if (props.grid.props.draggable === draggableMode.remote && updateOrderData?.length > 0) { |
|
|
|
props.updates(updateOrderData); |
|
|
|
} |
|
|
|
|
|
|
|