diff --git a/src/control/dashboard/dashboard.tsx b/src/control/dashboard/dashboard.tsx index 30fe70e8f00cd1e39166d61d0344ab12eea6f8f9..fb69f59724fb5358188f22f717424ac5e65a586e 100644 --- a/src/control/dashboard/dashboard.tsx +++ b/src/control/dashboard/dashboard.tsx @@ -4,6 +4,7 @@ import { defineComponent, getCurrentInstance, h, + isReactive, PropType, reactive, Ref, @@ -104,10 +105,12 @@ export const DashboardControl = defineComponent({ const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`); - c.evt.on('onCreated', () => { + c.evt.on('onInitPortlets', () => { // 数据看板成员state响应式 Object.values(c.portlets).forEach(portlet => { - portlet.state = reactive(portlet.state); + if (!isReactive(portlet.state)) { + portlet.state = reactive(portlet.state); + } }); }); diff --git a/src/control/dashboard/portlet/filter-portlet/filter-portlet-design/filter-portlet-design.tsx b/src/control/dashboard/portlet/filter-portlet/filter-portlet-design/filter-portlet-design.tsx index e8690f97126915850342d16130f0a7db901da0c8..234888e86168cbd0f46e64037bfaa5d837b6bb78 100644 --- a/src/control/dashboard/portlet/filter-portlet/filter-portlet-design/filter-portlet-design.tsx +++ b/src/control/dashboard/portlet/filter-portlet/filter-portlet-design/filter-portlet-design.tsx @@ -2,10 +2,14 @@ import { defineComponent, reactive, ref, VNode, PropType, Ref } from 'vue'; import type { FormRules } from 'element-plus'; import { useNamespace } from '@ibiz-template/vue3-util'; -import { IDBFilterPortletPart, IDBPortletPart } from '@ibiz/model-core'; +import { + IAppPortlet, + IDBFilterPortletPart, + IDBPortletPart, +} from '@ibiz/model-core'; import { clone } from '@ibiz-template/core'; import './filter-portlet-design.scss'; -import { IModalData } from '@ibiz-template/runtime'; +import { getEffectiveCtrl, IModalData } from '@ibiz-template/runtime'; // 表单绘制数据 interface IFormData { @@ -35,7 +39,8 @@ export const IBizFilterPortletDesign = defineComponent({ required: true, }, filter: { type: Object as PropType }, - items: { type: Array as PropType }, + items: { type: Array as PropType, default: () => [] }, + dashboardStyle: { type: String }, dismiss: { type: Function as PropType<(_data?: IModalData) => void>, required: true, @@ -75,7 +80,11 @@ export const IBizFilterPortletDesign = defineComponent({ const model: Ref = ref(); - let allFilters: IDBFilterPortletPart[] = []; + let appPortlets: IAppPortlet[] = []; + + let allFilters: IAppPortlet[] = []; + + const portletParams: Ref = ref({}); const schemaFields: Ref = ref([]); @@ -84,20 +93,21 @@ export const IBizFilterPortletDesign = defineComponent({ const conditionMap: Map = new Map(); - const getFilters = (): IDBFilterPortletPart[] => { - let result: IDBFilterPortletPart[] = []; + const checkBoxList: Ref = ref([]); + + const getFilters = (): IAppPortlet[] => { + let result: IAppPortlet[] = []; const app = ibiz.hub.getApp(props.context.srfappid); - if (app.model.appPortlets) { - result = app.model.appPortlets - .filter(x => { - if (x.control) { - return ( - x.control.controlType === 'PORTLET' && - (x.control as IDBFilterPortletPart).portletType === 'FILTER' - ); - } - }) - .map(x => x.control!); + appPortlets = app.model.appPortlets || []; + if (appPortlets.length > 0) { + result = appPortlets.filter(x => { + if (x.control) { + return ( + x.control.controlType === 'PORTLET' && + (x.control as IDBFilterPortletPart).portletType === 'FILTER' + ); + } + }); } return result; }; @@ -119,6 +129,15 @@ export const IBizFilterPortletDesign = defineComponent({ schemaFields.value = jsonSchemaMap.get(appDataEntityId)!; }; + const initCheckBox = () => { + checkBoxList.value = getEffectiveCtrl( + model.value!.id!, + props.items, + props.context, + props.dashboardStyle, + ); + }; + const init = async () => { allFilters = getFilters(); // 默认选中所有项 @@ -127,22 +146,28 @@ export const IBizFilterPortletDesign = defineComponent({ } if (props.filter) { const item = allFilters.find(x => x.id === props.filter!.model.id); - model.value = clone(item); - formData.title = props.filter.config.srftitle; - const selectAll = props.filter.filterConfig.scope === 'all'; - if (!selectAll) { - formData.selectAll = false; - formData.items = props.filter.filterConfig.scopedata.split(','); + if (item) { + model.value = clone(item.control as IDBFilterPortletPart); + formData.title = props.filter.config.srftitle; + portletParams.value = item.portletParams || {}; + const selectAll = props.filter.filterConfig.scope === 'all'; + if (!selectAll) { + formData.selectAll = false; + formData.items = props.filter.filterConfig.scopedata.split(','); + } + condition.value = props.filter.searchConds; } - condition.value = props.filter.searchConds; } if (!model.value && allFilters.length > 0) { - model.value = clone(allFilters[0]); + model.value = clone(allFilters[0].control!); formData.title = model.value.title || ''; + portletParams.value = allFilters[0].portletParams || {}; } if (model.value) { await getJsonSchema(model.value.appDataEntityId); + initCheckBox(); } + loaded.value = true; }; @@ -154,17 +179,24 @@ export const IBizFilterPortletDesign = defineComponent({ result.scope = 'all'; } else { result.scope = 'custom'; - result.scopedata = formData.items.join(','); + const selectKeys: string[] = []; + checkBoxList.value.forEach((item: IData) => { + if (formData.items.includes(item.id)) { + selectKeys.push(item.id); + } + }); + result.scopedata = selectKeys.join(','); + } + if (Object.keys(portletParams.value).length > 0) { + result.scopetag = portletParams.value.filtergroup; } - // if (model.value && (model.value as IData).userTag) { - // result.scopetag = (model.value as IData).userTag; - // } return result; }; // 处理列表项点击 const handleListItemClick = ( item: IDBFilterPortletPart, + data: IData, disabled: boolean, ) => { if (disabled) { @@ -172,6 +204,7 @@ export const IBizFilterPortletDesign = defineComponent({ } model.value = clone(item); formData.title = item.title || ''; + portletParams.value = data; getJsonSchema(item.appDataEntityId); if (conditionMap.has(item.appDataEntityId!)) { condition.value = conditionMap.get(item.appDataEntityId!)!; @@ -228,7 +261,9 @@ export const IBizFilterPortletDesign = defineComponent({ } return (
    - {allFilters.map((item: IDBFilterPortletPart) => { + {allFilters.map((portlet: IAppPortlet) => { + const item = portlet.control! as IDBFilterPortletPart; + const data = portlet.portletParams || {}; let disabled = false; if (props.filter && props.filter.id !== item.id) { disabled = true; @@ -241,7 +276,7 @@ export const IBizFilterPortletDesign = defineComponent({ ns.is('actvie', item.id === model.value?.id), ]} title={item.title} - onClick={() => handleListItemClick(item, disabled)} + onClick={() => handleListItemClick(item, data, disabled)} > {item.title} @@ -253,17 +288,18 @@ export const IBizFilterPortletDesign = defineComponent({ // 绘制复选框 const renderCheckBoxGroup = () => { - if (!props.items) { + if (!checkBoxList.value) { return; } - const onlyAdd = props.items.length > 0 && formData.items.length === 1; + const onlyAdd = + checkBoxList.value.length > 0 && formData.items.length === 1; return ( - {props.items.map((item: IData) => { + {checkBoxList.value.map((item: IData) => { return {item.title}; })} diff --git a/src/control/dashboard/portlet/filter-portlet/filter-portlet.tsx b/src/control/dashboard/portlet/filter-portlet/filter-portlet.tsx index f2a771d197dc6287b75891c9a65bb9c359e5143d..e153a5f42b22554a248fcb11abc5444aea25edb9 100644 --- a/src/control/dashboard/portlet/filter-portlet/filter-portlet.tsx +++ b/src/control/dashboard/portlet/filter-portlet/filter-portlet.tsx @@ -1,6 +1,6 @@ /* eslint-disable vue/no-mutating-props */ import { useNamespace } from '@ibiz-template/vue3-util'; -import { defineComponent, h, nextTick, PropType, ref } from 'vue'; +import { defineComponent, h, PropType } from 'vue'; import { IDBFilterPortletPart } from '@ibiz/model-core'; import { FilterPortletController, @@ -25,20 +25,13 @@ export const FilterPortlet = defineComponent({ }, setup(props) { const c = props.controller; - const loaded = ref(true); const ns = useNamespace( `portlet-${props.modelData.portletType?.toLowerCase()}`, ); // 重置 const handleReset = async () => { - const result = await c.resetFilter(); - if (result) { - loaded.value = false; - nextTick(() => { - loaded.value = true; - }); - } + await c.resetFilter(); }; // 查询 @@ -82,13 +75,10 @@ export const FilterPortlet = defineComponent({ }); }; - return { ns, loaded, handleReset, handleSearch, renderFilter }; + return { ns, handleReset, handleSearch, renderFilter }; }, render() { - if (!this.loaded) { - return; - } const classArr: string[] = [ this.ns.b(), this.ns.m(this.modelData.codeName), diff --git a/src/control/dashboard/portlet/portlet-layout/portlet-layout.scss b/src/control/dashboard/portlet/portlet-layout/portlet-layout.scss index 7a70d1dd6228d3bbd8b5789c4fb319450992af57..4ae60c51b94f41c14d6248a69a4e343938f79baf 100644 --- a/src/control/dashboard/portlet/portlet-layout/portlet-layout.scss +++ b/src/control/dashboard/portlet/portlet-layout/portlet-layout.scss @@ -62,6 +62,11 @@ $portlet-layout: ( height: 100%; } } + + // 高亮 + @include when(hight-light) { + border: 2px solid getCssVar(color, warning, light, active); + } } // 头部样式 diff --git a/src/control/dashboard/portlet/portlet-layout/portlet-layout.tsx b/src/control/dashboard/portlet/portlet-layout/portlet-layout.tsx index 145bac5827c5baf238f0278eab2b2f5fce7c1780..feed087cb0d0d1edf3980735002d47a02d7c932e 100644 --- a/src/control/dashboard/portlet/portlet-layout/portlet-layout.tsx +++ b/src/control/dashboard/portlet/portlet-layout/portlet-layout.tsx @@ -67,7 +67,13 @@ export const PortletLayout = defineComponent({ render() { const { model, state } = this.controller; return ( -
    +
    {this.isShowHeader && (