From f014bebaa13625be93ffed30c5a35df69aee78c6 Mon Sep 17 00:00:00 2001 From: likunming Date: Fri, 26 Apr 2024 17:08:50 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0w-echarts=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=202=E3=80=81=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=97=B6=E8=AE=BE=E7=BD=AE=E4=BA=86=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98=203=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=86=85=E7=BD=AEquery=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E8=8B=A5=E5=AD=98=E5=9C=A8=E9=9A=90=E8=97=8F=E7=9A=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E8=87=AA=E5=8A=A8=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E6=9B=B4=E5=A4=9A=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=8C=E5=90=8C=E6=97=B6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=B0=86=E6=9F=A5=E8=AF=A2=E6=8C=89=E9=92=AE=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=8C=89=E9=92=AE=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/components/echarts/WEcharts.vue | 80 +++++++++++++++++++ .../src/platform/components/grid/WGrid.vue | 76 ++++++++++++++---- .../src/platform/components/index.ts | 5 ++ .../platform/components/toolbar/WToolbar.vue | 8 ++ .../src/platform/index.ts | 1 + 5 files changed, 154 insertions(+), 16 deletions(-) create mode 100644 io.sc.platform.core.frontend/src/platform/components/echarts/WEcharts.vue diff --git a/io.sc.platform.core.frontend/src/platform/components/echarts/WEcharts.vue b/io.sc.platform.core.frontend/src/platform/components/echarts/WEcharts.vue new file mode 100644 index 00000000..e43399d7 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/echarts/WEcharts.vue @@ -0,0 +1,80 @@ + + + diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue index b8c0b26a..436a99b4 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue +++ b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue @@ -854,19 +854,39 @@ const expandFun = (arr, treeExpand) => { }); }; +const screenCols = { xs: 1, sm: 2, md: 3, lg: 4, xl: 6 }; +const queryFormColsNumComputed = computed(() => { + if (typeof props.queryFormColsNum === 'number' && props.queryFormColsNum > 0) { + return props.queryFormColsNum; + } else if (typeof props.queryFormColsNum === 'object') { + const screen = { ...screenCols, ...props.queryFormColsNum }; + return screen[$q.screen.name]; + } + return screenCols[$q.screen.name]; +}); + // 处理toobar const buttons_ = ref([]); -const handleChildrenBtn = (arr) => { +const handleChildrenBtn = (arr, moreQueryShow) => { const tempArr = []; for (let i = 0; i < arr.length; i++) { const btn = arr[i]; if (Array.isArray(btn) && btn.length > 0) { - const handleResult = handleChildrenBtn(btn); + const handleResult = handleChildrenBtn(btn, moreQueryShow); if (handleResult && handleResult.length > 0) { tempArr.push(handleResult); } } else if (typeof btn === 'string' && buttonObj[btn]) { - tempArr.push(buttonObj[btn]); + if (btn === buttonObj.query.name && i === 0) { + // 查询按钮为第一个时,追加更多查询时直接追加到查询按钮当前所在下标的后面一个,不能追加为数组,否则按钮组取第一个为 QBtnDropdown 左边按钮时取到的是一个数组,会报错。 + // ['query', 'reset'] + tempArr.push(buttonObj[btn]); + tempArr.push(buttonObj[buttonObj.moreQuery.name]); + } else if (btn === buttonObj.query.name) { + tempArr.push([buttonObj[btn], buttonObj[buttonObj.moreQuery.name]]); + } else { + tempArr.push(buttonObj[btn]); + } } else if (typeof btn === 'object' && btn.extend && buttonObj[btn.extend]) { tempArr.push({ ...buttonObj[btn.extend], ...btn, _click: buttonObj[btn.extend].click }); } else { @@ -877,11 +897,33 @@ const handleChildrenBtn = (arr) => { }; const handleToolbarActions = () => { buttons_.value.splice(0, buttons_.value.length); + // 处理查询按钮,符合条件时给其追加更多查询按钮 + let moreQueryShow = false; + const rowColsNum = queryFormColsNumComputed.value * (props.queryFormRowNum || 1); + let currRowColsNum = 0; + let showQueryFormFieldNum = 0; + props.queryFormFields.forEach((item: any) => { + if (Tools.hasOwnProperty(item, 'colSpan')) { + currRowColsNum += item.colSpan; + } else { + currRowColsNum += 1; + } + if (currRowColsNum <= rowColsNum) { + showQueryFormFieldNum += 1; + } + }); + if (showQueryFormFieldNum < props.queryFormFields.length) { + moreQueryShow = true; + } props.toolbarActions.forEach((btn: any, index) => { if (typeof btn === 'string' && buttonObj[btn]) { - buttons_.value.push(buttonObj[btn]); + if (btn === buttonObj.query.name && moreQueryShow) { + buttons_.value.push([buttonObj[btn], buttonObj[buttonObj.moreQuery.name]]); + } else { + buttons_.value.push(buttonObj[btn]); + } } else if (Array.isArray(btn) && btn.length > 0) { - buttons_.value.push(handleChildrenBtn(btn)); + buttons_.value.push(handleChildrenBtn(btn, moreQueryShow)); } else if (typeof btn === 'object' && btn.extend && buttonObj[btn.extend]) { // 继承内置按钮 buttons_.value.push({ ...buttonObj[btn.extend], ...btn, _click: buttonObj[btn.extend].click }); @@ -1338,16 +1380,18 @@ const buildQueryCriterias = (reqParams) => { urlSearchParams.append('criteria', JSON.stringify(queryCriteria)); } if (queryFormRef.value) { - const queryFormData = queryFormRef.value.getData(); - Object.keys(queryFormData).forEach((item) => { - if (!isEmpty(queryFormData[item])) { - const criteria = { - fieldName: item, - operator: queryFormFieldsMap.get(item).queryOperator || OperatorTypeEnum.contains, - value: queryFormData[item], - }; - urlSearchParams.append('criteria', JSON.stringify(criteria)); - } + nextTick(() => { + const queryFormData = queryFormRef.value.getData(); + Object.keys(queryFormData).forEach((item) => { + if (!isEmpty(queryFormData[item])) { + const criteria = { + fieldName: item, + operator: queryFormFieldsMap.get(item).queryOperator || OperatorTypeEnum.contains, + value: queryFormData[item], + }; + urlSearchParams.append('criteria', JSON.stringify(criteria)); + } + }); }); } return urlSearchParams; @@ -2227,7 +2271,7 @@ const handlerQueryFormShowField = () => { }); } else { // 一行应该显示的字段个数 - const rowColsNum = (Tools.isUndefinedOrNull(queryFormRef.value) ? 4 : queryFormRef.value.getColsNum()) * (props.queryFormRowNum || 1); + const rowColsNum = queryFormColsNumComputed.value * (props.queryFormRowNum || 1); let currRowColsNum = 0; props.queryFormFields.forEach((item: any) => { if (Tools.hasOwnProperty(item, 'colSpan')) { diff --git a/io.sc.platform.core.frontend/src/platform/components/index.ts b/io.sc.platform.core.frontend/src/platform/components/index.ts index fda76f29..ed9ea57f 100644 --- a/io.sc.platform.core.frontend/src/platform/components/index.ts +++ b/io.sc.platform.core.frontend/src/platform/components/index.ts @@ -46,6 +46,8 @@ import WTreeGrid from './tree/WTreeGrid.vue'; import WWorkflowAction from './workflow/WWorkflowAction.vue'; import WSelectAssigneeDialog from './workflow/WSelectAssigneeDialog.vue'; +import WEcharts from './echarts/WEcharts.vue'; + export default { install: (app: App) => { app.component('WPlatformPage', WPlatformPage); @@ -93,6 +95,8 @@ export default { app.component('WWorkflowAction', WWorkflowAction); app.component('WSelectAssigneeDialog', WSelectAssigneeDialog); + + app.component('WEcharts', WEcharts); }, }; @@ -130,6 +134,7 @@ export { WTreeGrid, WWorkflowAction, WSelectAssigneeDialog, + WEcharts, }; export { PlatformIconEnum } from './utils'; diff --git a/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue b/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue index e2e3a619..796e2d01 100644 --- a/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue +++ b/io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue @@ -483,6 +483,14 @@ const buttonClick = async (button) => {