Browse Source

修复部分问题

main
likunming 5 months ago
parent
commit
190c3d5f14
  1. 23
      io.sc.platform.core.frontend/src/platform/components/grid/GridAppendContent.vue
  2. 27
      io.sc.platform.core.frontend/src/platform/components/grid/GridAppendRow.vue
  3. 27
      io.sc.platform.core.frontend/src/platform/components/grid/GridBody.vue
  4. 12
      io.sc.platform.core.frontend/src/platform/components/grid/GridConfig.vue
  5. 32
      io.sc.platform.core.frontend/src/platform/components/grid/GridHeader.vue
  6. 24
      io.sc.platform.core.frontend/src/platform/components/grid/GridTd.vue
  7. 4
      io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue
  8. 51
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue
  9. 4
      io.sc.platform.core.frontend/src/platform/components/grid/css/grid.css
  10. 42
      io.sc.platform.core.frontend/src/platform/components/grid/ts/grid.ts

23
io.sc.platform.core.frontend/src/platform/components/grid/GridAppendContent.vue

@ -0,0 +1,23 @@
<template>
<!-- <template v-if="typeof value === 'object' && value.componentType && col.value.bindModelValue">
<component :is="col.value.componentType" v-bind="col.value.attrs" v-model="props.getRow(table.rows, row[props.rowKey], false)[col.name]"></component>
</template>
<template v-else-if="col.value && typeof col.value === 'object' && col.value.componentType">
<component :is="col.value.componentType" v-bind="col.value.attrs"></component>
</template>
<template v-else>
<span v-dompurify-html="!Tools.isEmpty(col.value) ? col.value : ''"></span>
</template> -->
111
</template>
<script setup lang="ts">
const props = defineProps({
value: {
type: [Object, String, Number],
default: () => {
return '';
},
},
});
</script>

27
io.sc.platform.core.frontend/src/platform/components/grid/GridAppendRow.vue

@ -0,0 +1,27 @@
<template>
<q-tr v-for="(appendRow, rowIndex) in props.grid.props.appendRows" :key="rowIndex" :no-hover="true" :class="''">
<q-td v-for="(col, colIndex) in appendRow" :key="colIndex" :rowspan="col['rowSpan'] ? col['rowSpan'] : 1" :colspan="col['colSpan'] ? col['colSpan'] : 1">
<template v-if="typeof col['value'] === 'function'">
<GridAppendContent :value="col.value({ grid: props.grid, rows: props.grid.getRows() })"></GridAppendContent>
</template>
<template v-else>
<span v-dompurify-html="!Tools.isEmpty(col['value']) ? col['value'] : ''"></span>
</template>
</q-td>
</q-tr>
</template>
<script setup lang="ts">
import { Tools } from '@/platform';
import GridAppendContent from './GridAppendContent.vue';
const props = defineProps({
grid: {
//
type: Object,
default: () => {
return {};
},
},
});
</script>

27
io.sc.platform.core.frontend/src/platform/components/grid/GridBody.vue

@ -33,7 +33,7 @@
@drop="draggableComputed ? onDrop($event, scope) : () => {}" @drop="draggableComputed ? onDrop($event, scope) : () => {}"
@dragstart="draggableComputed ? onDragStart($event, scope) : () => {}" @dragstart="draggableComputed ? onDragStart($event, scope) : () => {}"
> >
<q-td v-if="table.checkboxSelection" class="text-center" style="padding: 0; width: 50px"> <q-td v-if="table.checkboxSelection && props.grid.props.selectedMode !== selectedMode.none" class="text-center" style="padding: 0; width: 50px">
<q-checkbox <q-checkbox
v-model="props.getRow(table.rows, scope.row[props.rowKeyName], false)[table.tickedField]" v-model="props.getRow(table.rows, scope.row[props.rowKeyName], false)[table.tickedField]"
flat flat
@ -54,6 +54,7 @@
></GridTd> ></GridTd>
</template> </template>
</q-tr> </q-tr>
<GridAppendRow v-if="showAppendRowsComputed" :grid="props.grid"></GridAppendRow>
<GridEditToolbar <GridEditToolbar
:grid="props.grid" :grid="props.grid"
:url="props.url" :url="props.url"
@ -73,6 +74,7 @@ import { draggableImage, draggableMode, selectedMode } from './ts/grid';
import TreeGridRow from './TreeGridRow.vue'; import TreeGridRow from './TreeGridRow.vue';
import GridTd from './GridTd.vue'; import GridTd from './GridTd.vue';
import GridEditToolbar from './GridEditToolbar.vue'; import GridEditToolbar from './GridEditToolbar.vue';
import GridAppendRow from './GridAppendRow.vue';
const trRef = ref(); const trRef = ref();
const props = defineProps({ const props = defineProps({
@ -178,6 +180,27 @@ const setTreeRowComponentRef = (el, row) => {
} }
}; };
const checkLastRow = (row) => {
if (props.grid.props.tree && row['expand'] && !Tools.isEmpty(row.children) && row.children.length > 0) {
const childrenLastRow = row.children[row.children.length - 1];
if (childrenLastRow['expand'] && !Tools.isEmpty(childrenLastRow.children) && childrenLastRow.children.length > 0) {
return checkLastRow(childrenLastRow);
} else {
return childrenLastRow[props.rowKeyName] === props.scope.row[props.rowKeyName];
}
} else {
return row[props.rowKeyName] === props.scope.row[props.rowKeyName];
}
};
const showAppendRowsComputed = computed(() => {
if (Array.isArray(props.grid.props.appendRows) && props.grid.props.appendRows.length > 0) {
const lastRow = table.rows[table.rows.length - 1];
return checkLastRow(lastRow);
}
return false;
});
const draggableComputed = computed(() => { const draggableComputed = computed(() => {
if ( if (
props.grid.props.draggable && props.grid.props.draggable &&
@ -333,7 +356,7 @@ const onDrop = (e, scope) => {
updateData.push(toRaw(item)); updateData.push(toRaw(item));
} }
}); });
if (props.grid.props.draggable === draggableMode.remote && updateData.length > 0) { if (props.grid.props.draggable === draggableMode.server && updateData.length > 0) {
// 访 // 访
updates(updateData, () => {}); updates(updateData, () => {});
} }

12
io.sc.platform.core.frontend/src/platform/components/grid/GridConfig.vue

@ -56,7 +56,7 @@
@click=" @click="
() => { () => {
table.checkboxSelection = true; table.checkboxSelection = true;
grid.stickyHeaderColumn(100); grid.refreshStyle(100);
} }
" "
/> />
@ -69,7 +69,7 @@
@click=" @click="
() => { () => {
table.checkboxSelection = false; table.checkboxSelection = false;
grid.stickyHeaderColumn(100); grid.refreshStyle(100);
} }
" "
/> />
@ -95,7 +95,7 @@
() => { () => {
table.columns[0].hidden = false; table.columns[0].hidden = false;
table.sortNo = true; table.sortNo = true;
grid.stickyHeaderColumn(100); grid.refreshStyle(100);
} }
" "
/> />
@ -109,7 +109,7 @@
() => { () => {
table.columns[0].hidden = true; table.columns[0].hidden = true;
table.sortNo = false; table.sortNo = false;
grid.stickyHeaderColumn(100); grid.refreshStyle(100);
} }
" "
/> />
@ -183,7 +183,7 @@
:options="stickyOptions" :options="stickyOptions"
@update:model-value=" @update:model-value="
() => { () => {
grid.stickyHeaderColumn(500); grid.refreshStyle(500);
} }
" "
> >
@ -204,7 +204,7 @@
dense dense
@update:model-value=" @update:model-value="
() => { () => {
grid.stickyHeaderColumn(100); grid.refreshStyle(100);
} }
" "
/> />

32
io.sc.platform.core.frontend/src/platform/components/grid/GridHeader.vue

@ -2,14 +2,20 @@
<template v-if="columnTitleState.columnTitleRowNum > 1"> <template v-if="columnTitleState.columnTitleRowNum > 1">
<q-tr v-for="(r, rIndex) in columnTitleState.columnTitleArr" :key="rIndex"> <q-tr v-for="(r, rIndex) in columnTitleState.columnTitleArr" :key="rIndex">
<q-th <q-th
v-if="rIndex === 0 && props.selection === 'multiple' && table.checkboxSelection && !props.grid.props.tree" v-if="
rIndex === 0 &&
props.selection === 'multiple' &&
table.checkboxSelection &&
!props.grid.props.tree &&
props.grid.props.selectedMode !== selectedMode.none
"
:rowspan="columnTitleState.columnTitleRowNum" :rowspan="columnTitleState.columnTitleRowNum"
:style="moreColumnTitleTableSelectionStyle" :style="moreColumnTitleTableSelectionStyle"
> >
<q-checkbox v-model="table.allTicked" flat :dense="props.denseHeader" @update:model-value="allTickedUpdateFun" /> <q-checkbox v-model="table.allTicked" flat :dense="props.denseHeader" @update:model-value="allTickedUpdateFun" />
</q-th> </q-th>
<q-th <q-th
v-else-if="rIndex === 0 && table.checkboxSelection && !props.grid.props.tree" v-else-if="rIndex === 0 && table.checkboxSelection && !props.grid.props.tree && props.grid.props.selectedMode !== selectedMode.none"
:rowspan="columnTitleState.columnTitleRowNum" :rowspan="columnTitleState.columnTitleRowNum"
:style="moreColumnTitleTableSelectionStyle" :style="moreColumnTitleTableSelectionStyle"
></q-th> ></q-th>
@ -35,19 +41,21 @@
</q-th> </q-th>
</q-tr> </q-tr>
<q-tr v-if="table.rows.length === 0" :style="props.noDataTrHeightStyle" class="noDataTr"> <q-tr v-if="table.rows.length === 0" :style="props.noDataTrHeightStyle" class="noDataTr">
<q-td :colspan="props.noDataTrColspan" align="center" valian="middle"><q-icon size="2em" name="info" />{{ $t('tip.noData') }}</q-td> <q-td :colspan="props.noDataTrColspan" align="center" valian="middle" style="border-bottom-width: 0px"
><q-icon size="2em" name="info" />{{ $t('tip.noData') }}</q-td
>
</q-tr> </q-tr>
</template> </template>
<template v-else> <template v-else>
<q-tr :props="scope"> <q-tr :props="scope">
<q-th <q-th
v-if="props.selection === 'multiple' && table.checkboxSelection && !props.grid.props.tree" v-if="props.selection === 'multiple' && table.checkboxSelection && !props.grid.props.tree && props.grid.props.selectedMode !== selectedMode.none"
:style="props.grid.props.tree ? '' : 'padding: 0; min-width: 50px;width: 50px;max-width:50px'" :style="props.grid.props.tree ? '' : 'padding: 0; min-width: 50px;width: 50px;max-width:50px'"
> >
<q-checkbox v-model="table.allTicked" flat :dense="props.denseHeader" @update:model-value="allTickedUpdateFun" <q-checkbox v-model="table.allTicked" flat :dense="props.denseHeader" @update:model-value="allTickedUpdateFun"
/></q-th> /></q-th>
<q-th <q-th
v-else-if="table.checkboxSelection && !props.grid.props.tree" v-else-if="table.checkboxSelection && !props.grid.props.tree && props.grid.props.selectedMode !== selectedMode.none"
:style="props.grid.props.tree ? '' : 'padding: 0; min-width: 50px;width: 50px;max-width:50px'" :style="props.grid.props.tree ? '' : 'padding: 0; min-width: 50px;width: 50px;max-width:50px'"
></q-th> ></q-th>
<template v-for="col in scope.cols" :key="col.name"> <template v-for="col in scope.cols" :key="col.name">
@ -63,13 +71,16 @@
</template> </template>
</q-tr> </q-tr>
<q-tr v-if="table.rows.length === 0" :style="props.noDataTrHeightStyle" class="noDataTr"> <q-tr v-if="table.rows.length === 0" :style="props.noDataTrHeightStyle" class="noDataTr">
<q-td :colspan="props.noDataTrColspan" align="center" valian="middle"><q-icon size="2em" name="info" />{{ $t('tip.noData') }}</q-td> <q-td :colspan="props.noDataTrColspan" align="center" valian="middle" style="border-bottom-width: 0px"
><q-icon size="2em" name="info" />{{ $t('tip.noData') }}</q-td
>
</q-tr> </q-tr>
</template> </template>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Tools } from '@/platform'; import { Tools } from '@/platform';
import { computed, inject, reactive } from 'vue'; import { computed, inject, reactive } from 'vue';
import { selectedMode } from './ts/grid.ts';
const props = defineProps({ const props = defineProps({
grid: { grid: {
@ -163,11 +174,11 @@ const moreColumnTitleTableSelectionStyle = computed(() => {
const moreColumnTitleTableSortNoStyle = computed(() => { const moreColumnTitleTableSortNoStyle = computed(() => {
if (table.checkboxSelection && table.sortNo && table.stickyNum > 0) { if (table.checkboxSelection && table.sortNo && table.stickyNum > 0) {
return 'z-index: 3;position: sticky;left: var(--columnWidth-1-1);width: 50px;min-width:50px;max-width:50px;'; return 'font-weight: bold;z-index: 3;position: sticky;left: var(--columnWidth-1-1);width: 50px;min-width:50px;max-width:50px;';
} else if (table.sortNo && table.stickyNum > 0) { } else if (table.sortNo && table.stickyNum > 0) {
return 'z-index: 3;position: sticky;left: 0px;width: 50px;min-width:50px;max-width:50px;'; return 'font-weight: bold;z-index: 3;position: sticky;left: 0px;width: 50px;min-width:50px;max-width:50px;';
} }
return 'width: 50px;min-width:50px;max-width:50px;'; return 'font-weight: bold;width: 50px;min-width:50px;max-width:50px;';
}); });
const allTickedUpdateFun = (value, evt) => { const allTickedUpdateFun = (value, evt) => {
@ -371,6 +382,9 @@ const thStyleHandler = (c: any, scope: any) => {
} }
} }
} }
if (c['name'] === table.columns[table.columns.length - 1]['name']) {
style += 'border-right-width: 0px;';
}
return style; return style;
}; };

24
io.sc.platform.core.frontend/src/platform/components/grid/GridTd.vue

@ -1,9 +1,11 @@
<template> <template>
<q-td <q-td
v-if="rowSpanIsFirstComputed"
:key="col.name" :key="col.name"
:props="scope" :props="scope"
:title="col.classes?.indexOf('truncate') > -1 && !Tools.isEmpty(value) && typeof value !== 'object' ? value : ''" :title="col.classes?.indexOf('truncate') > -1 && !Tools.isEmpty(value) && typeof value !== 'object' ? value : ''"
:class="props.grid.props.selectedMode === selectedMode.cell ? tdClassComputed : ''" :class="props.grid.props.selectedMode === selectedMode.cell ? tdClassComputed : ''"
:rowspan="rowSpanComputed"
@click=" @click="
() => { () => {
if (table && props.grid.props.selectedMode === selectedMode.cell) { if (table && props.grid.props.selectedMode === selectedMode.cell) {
@ -89,6 +91,28 @@ const getComponentRef = () => {
return componentRef.value; return componentRef.value;
}; };
const rowSpanComputed = computed(() => {
if (Object.keys(table.mergeRecords).length > 0) {
const column = table.mergeRecords[props.col['name']];
if (column && column[props.scope['row'][props.col['name']]].length > 1) {
return column[props.scope['row'][props.col['name']]].length;
}
}
return 1;
});
const rowSpanIsFirstComputed = computed(() => {
if (Object.keys(table.mergeRecords).length > 0) {
const column = table.mergeRecords[props.col['name']];
if (props.col['name'] === '_sortNo_') {
return true;
} else if (column && column[props.scope['row'][props.col['name']]].length > 1) {
return props.scope['row'][props.rowKeyName] === column[props.scope['row'][props.col['name']]][0];
}
}
return true;
});
const tdClassComputed = computed(() => { const tdClassComputed = computed(() => {
const tdClass = <any>[]; const tdClass = <any>[];
if (props.grid.props.selectedMode === selectedMode.cell) { if (props.grid.props.selectedMode === selectedMode.cell) {

4
io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue

@ -731,7 +731,7 @@ const onDrop = (e, dataRow) => {
resetOrder(e, table.dragRecords, table.rows, dataRow); resetOrder(e, table.dragRecords, table.rows, dataRow);
// //
if (props.grid.props.draggable === draggableMode.remote && updateOrderData?.length > 0) { if (props.grid.props.draggable === draggableMode.server && updateOrderData?.length > 0) {
props.updates(updateOrderData); props.updates(updateOrderData);
} }
@ -739,7 +739,7 @@ const onDrop = (e, dataRow) => {
}; };
const click = (evt, row, rowIndex) => { const click = (evt, row, rowIndex) => {
if (table.bodyEditStatus === 'none') { if (table.bodyEditStatus === 'none' && props.grid.props.selectedMode !== selectedMode.none) {
if (!evt.ctrlKey) { if (!evt.ctrlKey) {
props.grid.clearSelected(); props.grid.clearSelected();
} }

51
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -123,7 +123,7 @@ import GridBody from './GridBody.vue';
import GridPagination from './GridPagination.vue'; import GridPagination from './GridPagination.vue';
import GridEditor from './GridEditor.vue'; import GridEditor from './GridEditor.vue';
import GridView from './GridView.vue'; import GridView from './GridView.vue';
import { selectedMode as selectedMode_ } from './ts/grid.ts'; import { selectedMode as selectedMode_, getMergeColumns, sortByProperties } from './ts/grid.ts';
import { columnDefaultProps } from './ts/grid.ts'; import { columnDefaultProps } from './ts/grid.ts';
@ -177,6 +177,13 @@ const props = defineProps({
foreignKey: { type: String, default: 'parent' }, // foreignKey: { type: String, default: 'parent' }, //
refreshData: { type: Boolean, default: false }, // primaryKey refreshData: { type: Boolean, default: false }, // primaryKey
dbClickOperation: { type: String, default: 'view' }, // nameclickexpand()none() dbClickOperation: { type: String, default: 'view' }, // nameclickexpand()none()
appendRows: {
//
type: Array,
default: () => {
return [];
},
},
sortBy: { sortBy: {
type: Array, type: Array,
default: () => { default: () => {
@ -321,7 +328,8 @@ const rawColumns = ref(props.columns);
const tableColumnsMap = ref(arrayToMap('name', rawColumns.value)); const tableColumnsMap = ref(arrayToMap('name', rawColumns.value));
const rowKey_ = '_rowKey_'; // UUID const rowKey_ = '_rowKey_'; // UUID
const queryFormFieldsMap = arrayToMap('name', props.queryFormFields); const queryFormFieldsMap = arrayToMap('name', props.queryFormFields);
const tableColumns = ref(columnDefaultProps(rawColumns.value)); const tableColumns = ref(columnDefaultProps(rawColumns.value, props.sortNo));
const mergeColumns = getMergeColumns(tableColumns.value);
const url = { const url = {
dataUrl: props.dataUrl, dataUrl: props.dataUrl,
fetchDataUrl: props.fetchDataUrl, fetchDataUrl: props.fetchDataUrl,
@ -338,7 +346,7 @@ watch(
() => props.columns, () => props.columns,
(newVal, oldVal) => { (newVal, oldVal) => {
rawColumns.value = newVal; rawColumns.value = newVal;
tableColumns.value = columnDefaultProps(rawColumns.value); tableColumns.value = columnDefaultProps(rawColumns.value, props.sortNo);
table.columns = tableColumns.value; table.columns = tableColumns.value;
if (tableColumns.value && tableColumns.value.length > rawColumns.value.length) { if (tableColumns.value && tableColumns.value.length > rawColumns.value.length) {
headerRef.value?.handlerMoreRowColumnTitle(); headerRef.value?.handlerMoreRowColumnTitle();
@ -382,6 +390,7 @@ const table = reactive({
inFullscreen: false, // inFullscreen: false, //
bodyEditStatus: 'none', // none()rowEdit()rowsEdit() bodyEditStatus: 'none', // none()rowEdit()rowsEdit()
cellSelected: {}, // cellSelected: {}, //
mergeRecords: {}, //
}); });
provide('table', table); provide('table', table);
@ -559,7 +568,7 @@ const tableFullscreenFun = (value) => {
}; };
const rowClick = (evt: any, row: any, index: any) => { const rowClick = (evt: any, row: any, index: any) => {
if (table.bodyEditStatus === 'none') { if (table.bodyEditStatus === 'none' && props.selectedMode !== selectedMode_.none) {
// checkboxcheckboxcheckbox // checkboxcheckboxcheckbox
if (!evt.ctrlKey) { if (!evt.ctrlKey) {
clearSelected(); clearSelected();
@ -574,7 +583,7 @@ const rowClick = (evt: any, row: any, index: any) => {
} }
}; };
const rowDbClick = (evt, row, index) => { const rowDbClick = (evt, row, index) => {
if (table.bodyEditStatus === 'none') { if (table.bodyEditStatus === 'none' && props.selectedMode !== selectedMode_.none) {
if (props.onRowDbClick) { if (props.onRowDbClick) {
emit('rowDbClick', { grid: instance, evt, row, index }); emit('rowDbClick', { grid: instance, evt, row, index });
} else if (props.dbClickOperation === 'view') { } else if (props.dbClickOperation === 'view') {
@ -618,13 +627,7 @@ const onResize = () => {
} }
}; };
type CriteriaType = {
fieldName: string;
operator: OperatorTypeEnum;
value: any;
};
let queryCriteria = { ...props.queryCriteria }; let queryCriteria = { ...props.queryCriteria };
const buildCriteria = (value, fieldName) => { const buildCriteria = (value, fieldName) => {
const queryOperator = queryFormFieldsMap.get(fieldName)['queryOperator']; const queryOperator = queryFormFieldsMap.get(fieldName)['queryOperator'];
if (!Tools.isEmpty(queryOperator)) { if (!Tools.isEmpty(queryOperator)) {
@ -879,9 +882,15 @@ const initRowDataExtraProperty = (rowData) => {
* @param rows 数据行集合 * @param rows 数据行集合
*/ */
const setRowDataExtraProperty = (rows: []) => { const setRowDataExtraProperty = (rows: []) => {
if (mergeColumns.length > 0 && !props.tree) {
//
table.mergeRecords = {};
sortByProperties(rows, mergeColumns);
}
if (rows && rows.length > 0) { if (rows && rows.length > 0) {
rows.forEach((item: any, index) => { rows.forEach((item: any, index) => {
initRowDataExtraProperty(item); initRowDataExtraProperty(item);
addMergeRecords(item);
if (item[rowDataExtraPropertyName.ticked] === true) { if (item[rowDataExtraPropertyName.ticked] === true) {
item[rowDataExtraPropertyName.tickedCount] = 1; item[rowDataExtraPropertyName.tickedCount] = 1;
} else if (item[rowDataExtraPropertyName.tickedCount] === false) { } else if (item[rowDataExtraPropertyName.tickedCount] === false) {
@ -921,6 +930,26 @@ const setOldValue = (rowData) => {
} }
}); });
}; };
/**
* name: { 上海: [2,4], 北京: [3,5,1] }
* desc: { 天安门: [5,1] }
*/
const addMergeRecords = (rowData) => {
if (mergeColumns.length > 0 && !props.tree) {
mergeColumns.forEach((columnName) => {
const tmpArr = [rowData[rowDataExtraPropertyName.rowKey]];
if (table.mergeRecords[columnName]) {
if (table.mergeRecords[columnName][rowData[columnName]]) {
table.mergeRecords[columnName][rowData[columnName]].push(rowData[rowDataExtraPropertyName.rowKey]);
} else {
table.mergeRecords[columnName][rowData[columnName]] = tmpArr;
}
} else {
table.mergeRecords[columnName] = { [rowData[columnName]]: tmpArr };
}
});
}
};
watchEffect(() => { watchEffect(() => {
url.dataUrl = props.dataUrl; url.dataUrl = props.dataUrl;

4
io.sc.platform.core.frontend/src/platform/components/grid/css/grid.css

@ -6,7 +6,6 @@
} }
.w-grid .q-table__top { .w-grid .q-table__top {
padding: var(--tableTopPadding) var(--tableTopPadding); padding: var(--tableTopPadding) var(--tableTopPadding);
border-bottom: 0px !important;
} }
.w-grid .q-table__middle .q-table th { .w-grid .q-table__middle .q-table th {
padding: var(--tableHeaderPadding) 8px; padding: var(--tableHeaderPadding) 8px;
@ -16,7 +15,7 @@
border-bottom-width: 1px; border-bottom-width: 1px;
} }
.w-grid .q-table__middle .q-table th:last-child { .w-grid .q-table__middle .q-table th:last-child {
border-right-width: 0px; border-right-width: 1px;
} }
.w-grid .q-table__middle .q-table td { .w-grid .q-table__middle .q-table td {
height: var(--tableBodyHeight); height: var(--tableBodyHeight);
@ -56,7 +55,6 @@
border-style: solid; border-style: solid;
border-left-width: 1px; border-left-width: 1px;
border-right-width: 1px; border-right-width: 1px;
border-top-width: 1px;
border-bottom-width: 1px; border-bottom-width: 1px;
} }

42
io.sc.platform.core.frontend/src/platform/components/grid/ts/grid.ts

@ -1,14 +1,17 @@
import { Tools, t } from '@/platform'; import { Tools, t } from '@/platform';
// 拖拽排序模式
export const draggableMode = { export const draggableMode = {
local: 'local', local: 'local', // 本地排序
remote: 'server', server: 'server', // 服务端排序
}; };
export const draggableImage = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' %3E%3Cpath /%3E%3C/svg%3E`; export const draggableImage = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' %3E%3Cpath /%3E%3C/svg%3E`;
// 选择模式
export const selectedMode = { export const selectedMode = {
row: 'row', none: 'none', // 不允许选择
cell: 'cell', row: 'row', // 行选择
cell: 'cell', // 单元格选择
}; };
// 列样式处理 // 列样式处理
@ -53,10 +56,10 @@ const childrenHandler = (item: any, gridColumns: any) => {
}; };
// 列的默认属性 // 列的默认属性
export const columnDefaultProps = (columns: any, sortNo: boolean = true) => { export const columnDefaultProps = (columns: any, sortNo: boolean) => {
const gridColumns = <any>[]; const gridColumns = <any>[];
if (columns && columns.length > 0) { if (columns && columns.length > 0) {
gridColumns.push({ name: '_sortNo_', align: 'center', label: t('rownum'), field: '_sortNo_', hidden: sortNo }); gridColumns.push({ name: '_sortNo_', align: 'center', label: t('rownum'), field: '_sortNo_', hidden: sortNo ? false : true });
columns.forEach((item: any) => { columns.forEach((item: any) => {
childrenHandler(item, gridColumns); childrenHandler(item, gridColumns);
}); });
@ -64,3 +67,30 @@ export const columnDefaultProps = (columns: any, sortNo: boolean = true) => {
} }
return []; return [];
}; };
// 获取所有需要合并的列名
export const getMergeColumns = (columns) => {
const columnNames = <any>[];
if (columns && columns.length > 0) {
columns.forEach((item) => {
if (Tools.hasOwnProperty(item, 'autoMerge') && item['autoMerge']) {
columnNames.push(item['name']);
}
});
}
return columnNames;
};
export const sortByProperties = (arr, properties) => {
return arr.sort((a, b) => {
for (const prop of properties) {
if (a[prop] < b[prop]) {
return -1;
}
if (a[prop] > b[prop]) {
return 1;
}
}
return 0;
});
};

Loading…
Cancel
Save