Browse Source

组件属性重命名及拆分属性

main
likunming 1 year ago
parent
commit
b2c0df1de8
  1. 68
      io.sc.platform.core.frontend/src/platform/components/grid/TreeGridRow.vue
  2. 26
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue
  3. 4
      io.sc.platform.core.frontend/src/platform/components/panel/WInfoPanel.vue
  4. 5
      io.sc.platform.core.frontend/src/views/likm/TreeGrid.vue

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

@ -6,52 +6,82 @@
<span :style="`width:${27 * props.level}px;`"></span> <span :style="`width:${27 * props.level}px;`"></span>
<!--展开按钮--> <!--展开按钮-->
<q-btn <q-btn
v-if="data.children && data.children.length > 0" v-if="props_.row.children && props_.row.children.length > 0"
flat flat
size="16px" size="16px"
dense dense
padding="0px 0px" padding="0px 0px"
:icon="data.expand ? 'bi-dash' : 'bi-plus'" :icon="props_.row.expand ? 'bi-dash' : 'bi-plus'"
@click="data.expand = !data.expand" @click="props_.row.expand = !props_.row.expand"
/> />
<!--展开按钮占位符--> <!--展开按钮占位符-->
<span v-else style="width: 27px"></span> <span v-else style="width: 27px"></span>
<!--选择框--> <!--选择框-->
<q-checkbox v-model="data.selected" flat size="40px" dense /> <q-checkbox v-model="props_.row.selected" flat size="40px" dense />
<!--文件夹图标--> <!--文件夹图标-->
<q-icon v-if="data.children && data.children.length > 0" :name="data.expand ? 'folder_open' : 'folder'" color="amber" size="20px" class="px-1"></q-icon> <q-icon v-if="props_.row.children && props_.row.children.length > 0" :name="'folder'" color="amber" size="20px" class="px-1"></q-icon>
<!--文件图标--> <!--文件图标-->
<q-icon v-else name="bi-file-earmark" size="16px" class="px-1"></q-icon> <q-icon v-else name="note" size="20px" class="px-1"></q-icon>
</div> </div>
</q-td> </q-td>
<q-td v-for="col in cols" :key="col.name" :style="{ 'padding-left': '7px' }"> <q-td v-for="(col, index) in props_.cols" :key="col.name" :style="{ 'padding-left': '7px' }">
<div class="flex flex-nowrap items-center"> <div class="flex flex-nowrap items-center">
<div v-dompurify-html="col.format ? col.format(data[col.name], data) : col.value"></div> <template v-if="col.name === '_sortNo_'">
{{ index + 1 }}
</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>
{{ col.value }}
</template>
</div> </div>
</q-td> </q-td>
</q-tr> </q-tr>
<template v-for="child in data.children" :key="child.id"> <template v-for="child in props_.row.children" :key="child.id">
<TreeGridRow v-if="data.expand" :cols="cols" :data="child" :level="props.level + 1"></TreeGridRow> <TreeGridRow v-if="props_.row.expand" :props="propsHandler(child)" :columns-map="columnsMap" :level="props.level + 1"></TreeGridRow>
</template> </template>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const props = defineProps({ const props = defineProps({
level: { type: Number, default: 0 }, level: { type: Number, default: 0 },
cols: { props: {
type: Array, type: Object,
default: () => { default: () => {
return []; return {};
}, },
}, },
data: { columnsMap: {
type: Object, type: Map,
default: () => { default: () => {
return {}; return new Map();
}, },
}, },
}); });
const cols = props.cols;
const data = props.data;
console.info('cols===============', cols); const props_ = { ...props.props };
const propsHandler = (child) => {
const cols = <any>[];
props_.cols.forEach((col) => {
if (props.columnsMap.get(col.name) && props.columnsMap.get(col.name).format) {
cols.push({ ...col, value: props.columnsMap.get(col.name).format(child[col.name]) });
} else {
cols.push({ ...col, value: child[col.name] });
}
});
return {
key: child.id,
row: child,
pageIndex: props.props.pageIndex,
__trClass: props.props.__trClass,
cols: cols,
colsMap: props.props.colsMap,
rowIndex: props.props.rowIndex,
color: props.props.color,
dark: props.props.dark,
dense: props.props.dense,
selected: props.props.selected,
expand: props.props.expand,
};
};
</script> </script>

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

@ -2,21 +2,21 @@
<div> <div>
<q-table <q-table
ref="tableRef" ref="tableRef"
v-bind="attrs"
v-model:pagination="table.pagination" v-model:pagination="table.pagination"
v-model:selected="table.selected" v-model:selected="table.selected"
:flat="true" flat
binary-state-sort binary-state-sort
:selection="'single'" selection="single"
:separator="'cell'" separator="cell"
:no-data-label="table.noDataLabel"
:loading-label="table.loadingLabel"
:rows="table.rows" :rows="table.rows"
:columns="extractTableColumns" :columns="extractTableColumns"
:rows-per-page-options="pagination.rowsPerPage && table.refHeightWidth.middleWidth > 600 ? table.pagination.rowsPerPageOptions : []" :rows-per-page-options="pagination.rowsPerPage && table.refHeightWidth.middleWidth > 600 ? table.pagination.rowsPerPageOptions : []"
:loading="table.loading" :loading="table.loading"
:no-data-label="table.noDataLabel"
:loading-label="table.loadingLabel"
:class="tableClassComputed" :class="tableClassComputed"
:table-style="tableHeightComputed" :table-style="tableHeightComputed"
v-bind="attrs"
@request="onRequest" @request="onRequest"
@fullscreen="tableFullscreenFun" @fullscreen="tableFullscreenFun"
> >
@ -88,7 +88,7 @@
</template> </template>
<template #body="scope"> <template #body="scope">
<template v-if="tree"> <template v-if="tree">
<TreeGridRow :cols="scope.cols" :data="scope.row"></TreeGridRow> <TreeGridRow :props="scope" :columns-map="tableColumnsMap"></TreeGridRow>
</template> </template>
<q-tr v-else :props="scope" @click="rowClick($el, scope.row, scope.rowIndex)" @dblclick="rowDbClick($el, scope.row, scope.rowIndex)"> <q-tr v-else :props="scope" @click="rowClick($el, scope.row, scope.rowIndex)" @dblclick="rowDbClick($el, scope.row, scope.rowIndex)">
<q-td v-if="!attrs.selection || attrs.selection !== 'none'" class="text-center" style="padding: 0; width: 50px"> <q-td v-if="!attrs.selection || attrs.selection !== 'none'" class="text-center" style="padding: 0; width: 50px">
@ -110,8 +110,8 @@
<template v-if="col.name === '_sortNo_'"> <template v-if="col.name === '_sortNo_'">
{{ scope.rowIndex + 1 }} {{ scope.rowIndex + 1 }}
</template> </template>
<template v-else-if="col.value && typeof col.value === 'object' && col.value.componentsType"> <template v-else-if="col.value && typeof col.value === 'object' && col.value.componentType">
<component :is="col.value.componentsType" v-bind="col.value.attrs"></component> <component :is="col.value.componentType" v-bind="col.value.attrs"></component>
</template> </template>
<template v-else> <template v-else>
{{ col.value }} {{ col.value }}
@ -123,8 +123,8 @@
<template v-if="col.name === '_sortNo_'"> <template v-if="col.name === '_sortNo_'">
{{ scope.rowIndex + 1 }} {{ scope.rowIndex + 1 }}
</template> </template>
<template v-else-if="col.value && typeof col.value === 'object' && col.value.componentsType"> <template v-else-if="col.value && typeof col.value === 'object' && col.value.componentType">
<component :is="col.value.componentsType" v-bind="col.value.attrs"></component> <component :is="col.value.componentType" v-bind="col.value.attrs"></component>
</template> </template>
<template v-else> <template v-else>
{{ col.value }} {{ col.value }}
@ -205,6 +205,10 @@ const tableHeadBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.headBgCol
const tableBorderColor = gc.theme?.grid?.borderColor || 'rgba(0, 0, 0, 0.12)'; const tableBorderColor = gc.theme?.grid?.borderColor || 'rgba(0, 0, 0, 0.12)';
const stickyBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.stickyBgColor || '#ffffff'; const stickyBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.stickyBgColor || '#ffffff';
const aaa = (a) => {
console.info('a============', a);
return '111';
};
const props = defineProps({ const props = defineProps({
height: { type: Number, default: 0 }, // height: { type: Number, default: 0 }, //
title: { type: String, default: '' }, // title: { type: String, default: '' }, //

4
io.sc.platform.core.frontend/src/platform/components/panel/WInfoPanel.vue

@ -7,8 +7,8 @@
<template v-for="(tdItem, tdIndex) in trItem as any" :key="tdIndex"> <template v-for="(tdItem, tdIndex) in trItem as any" :key="tdIndex">
<td :class="labelAlignClassComputed">{{ tdItem.label }}</td> <td :class="labelAlignClassComputed">{{ tdItem.label }}</td>
<td :class="valueAlignClassComputed"> <td :class="valueAlignClassComputed">
<template v-if="tdItem.value && typeof tdItem.value === 'object' && tdItem.value.componentsType"> <template v-if="tdItem.value && typeof tdItem.value === 'object' && tdItem.value.componentType">
<component :is="tdItem.value.componentsType" v-bind="tdItem.value.attrs"></component> <component :is="tdItem.value.componentType" v-bind="tdItem.value.attrs"></component>
</template> </template>
<template v-else> <template v-else>
{{ tdItem.value }} {{ tdItem.value }}

5
io.sc.platform.core.frontend/src/views/likm/TreeGrid.vue

@ -87,7 +87,6 @@ const testGrid = {
{ {
name: 'name', name: 'name',
label: '菜单名称', label: '菜单名称',
// style: 'width:100%',
format: (val, row) => { format: (val, row) => {
return t(val); return t(val);
}, },
@ -97,7 +96,7 @@ const testGrid = {
label: '图标', label: '图标',
format: (val, row) => { format: (val, row) => {
return { return {
componentsType: 'q-icon', componentType: 'q-icon',
attrs: { attrs: {
name: val, name: val,
size: 'sm', size: 'sm',
@ -113,7 +112,7 @@ const testGrid = {
align: 'center', align: 'center',
format: (val, row) => { format: (val, row) => {
return { return {
componentsType: 'q-icon', componentType: 'q-icon',
attrs: { attrs: {
name: val ? IconEnum.是状态 : IconEnum.否状态, name: val ? IconEnum.是状态 : IconEnum.否状态,
color: val ? 'green' : 'red', color: val ? 'green' : 'red',

Loading…
Cancel
Save