wangshaoping 2 months ago
parent
commit
90a063a4b6
  1. 20
      io.sc.platform.core.frontend/src/platform/components/grid/Top.vue
  2. 1
      io.sc.platform.core.frontend/src/platform/components/grid/extra/advanced-query/AdvancedQuery.vue
  3. 2
      io.sc.platform.core.frontend/src/platform/components/grid/ts/GridTools.ts
  4. 15
      io.sc.platform.core.frontend/src/platform/components/grid/ts/Init.ts
  5. 5
      io.sc.platform.core.frontend/src/platform/components/grid/ts/types/TableType.ts
  6. 7
      io.sc.platform.core.frontend/src/views/likm/Grid.vue

20
io.sc.platform.core.frontend/src/platform/components/grid/Top.vue

@ -92,17 +92,12 @@ const queryFormColsNumComputed = computed(() => {
const handleQueryFormShowField = () => { const handleQueryFormShowField = () => {
tools.table.queryFormDisplayFields = []; tools.table.queryFormDisplayFields = [];
if (tools.table.moreQueryStatus) { if (tools.table.moreQueryStatus) {
tools.props.queryFormFields.forEach((item: any) => { tools.table.queryFormDisplayFields = [...tools.table.queryFormFields];
tools.table.queryFormDisplayFields.push(item);
item.showIf = () => {
return true;
};
});
} else { } else {
// //
const rowColsNum = queryFormColsNumComputed.value * (tools.props.queryFormRowNum || 1); const rowColsNum = queryFormColsNumComputed.value * (tools.props.queryFormRowNum || 1);
let currRowColsNum = 0; let currRowColsNum = 0;
tools.props.queryFormFields.forEach((item: any) => { tools.table.queryFormFields.forEach((item: any) => {
if (Tools.hasOwnProperty(item, 'colSpan')) { if (Tools.hasOwnProperty(item, 'colSpan')) {
currRowColsNum += item.colSpan; currRowColsNum += item.colSpan;
} else { } else {
@ -110,13 +105,6 @@ const handleQueryFormShowField = () => {
} }
if (currRowColsNum <= rowColsNum) { if (currRowColsNum <= rowColsNum) {
tools.table.queryFormDisplayFields.push(item); tools.table.queryFormDisplayFields.push(item);
item.showIf = (form) => {
return true;
};
} else {
item.showIf = (form) => {
return false;
};
} }
}); });
} }
@ -166,7 +154,7 @@ const handleToolbarActions = () => {
const rowColsNum = queryFormColsNumComputed.value * (tools.props.queryFormRowNum || 1); const rowColsNum = queryFormColsNumComputed.value * (tools.props.queryFormRowNum || 1);
let currRowColsNum = 0; let currRowColsNum = 0;
let showQueryFormFieldNum = 0; let showQueryFormFieldNum = 0;
tools.props.queryFormFields.forEach((item: any) => { tools.table.queryFormFields.forEach((item: any) => {
if (Tools.hasOwnProperty(item, 'colSpan')) { if (Tools.hasOwnProperty(item, 'colSpan')) {
currRowColsNum += item.colSpan; currRowColsNum += item.colSpan;
} else { } else {
@ -176,7 +164,7 @@ const handleToolbarActions = () => {
showQueryFormFieldNum += 1; showQueryFormFieldNum += 1;
} }
}); });
if (showQueryFormFieldNum < tools.props.queryFormFields.length) { if (showQueryFormFieldNum < tools.table.queryFormFields.length) {
moreQueryShow = true; moreQueryShow = true;
} }
tools.props.toolbarActions.forEach((btn: any, index) => { tools.props.toolbarActions.forEach((btn: any, index) => {

1
io.sc.platform.core.frontend/src/platform/components/grid/extra/advanced-query/AdvancedQuery.vue

@ -19,6 +19,7 @@ const buildOptions = () => {
...item, ...item,
label: undefined, // label label: undefined, // label
name: undefined, // name name: undefined, // name
showIf: true, // showIf
type: typeConversion(item['type']), // type: typeConversion(item['type']), //
}, },
}; };

2
io.sc.platform.core.frontend/src/platform/components/grid/ts/GridTools.ts

@ -105,6 +105,7 @@ export class GridTools {
} }
const columns = Init.initColumn(props.columns, props); const columns = Init.initColumn(props.columns, props);
const queryFormFields = Init.initQueryFormFields(props.queryFormFields);
this.table = reactive({ this.table = reactive({
originalColumns: [...props.columns], originalColumns: [...props.columns],
@ -114,6 +115,7 @@ export class GridTools {
moreQueryStatus: false, moreQueryStatus: false,
advancedQueryStatus: false, advancedQueryStatus: false,
advancedQueryModelValue: undefined, advancedQueryModelValue: undefined,
queryFormFields: queryFormFields,
queryFormDisplayFields: [], queryFormDisplayFields: [],
componentRef: { componentRef: {
getTableRef: () => {}, getTableRef: () => {},

15
io.sc.platform.core.frontend/src/platform/components/grid/ts/Init.ts

@ -196,6 +196,21 @@ export class Init {
}; };
} }
/**
* showIf = false
* @param fields
*/
public static initQueryFormFields(fields: Array<any>) {
return fields.filter((field) => {
if (!Tools.hasOwnProperty(field, 'showIf')) {
return true;
} else if (typeof field['showIf'] === 'boolean' && field['showIf'] === true) {
return true;
}
return false;
});
}
/** /**
* *
* @param columns * @param columns

5
io.sc.platform.core.frontend/src/platform/components/grid/ts/types/TableType.ts

@ -33,6 +33,11 @@ export type TableType = {
* *
*/ */
advancedQueryModelValue?: object, advancedQueryModelValue?: object,
/**
* Form showIf = false
*/
queryFormFields: Array<any>;
/**
/** /**
* Form * Form
*/ */

7
io.sc.platform.core.frontend/src/views/likm/Grid.vue

@ -5,7 +5,12 @@
:fetch-data-url="Environment.apiContextPath('/api/system/user')" :fetch-data-url="Environment.apiContextPath('/api/system/user')"
:pageable="false" :pageable="false"
:toolbar-actions="['query', 'reset']" :toolbar-actions="['query', 'reset']"
:query-form-fields="[{ name: 'lastModifyDate', label: $t('lastModifyDate'), type: 'w-date-range' }]" :advanced-query="true"
:query-form-fields="[
{ name: 'lastModifyDate', label: $t('lastModifyDate'), type: 'w-date-range' },
{ name: 'loginName', label: $t('loginName'), type: 'w-text', showIf: true },
{ name: 'userName', label: $t('userName'), type: 'w-text' },
]"
:columns="[ :columns="[
{ name: 'loginName', label: $t('loginName') }, { name: 'loginName', label: $t('loginName') },
{ name: 'userName', label: $t('userName') }, { name: 'userName', label: $t('userName') },

Loading…
Cancel
Save