提交 9ce561db 编写于 作者: ibizdev's avatar ibizdev

zhujiamin 发布系统代码 [TrainSys,网页端]

上级 cedbc94f
......@@ -13,13 +13,13 @@
"dependencies": {
"@floating-ui/dom": "^1.0.11",
"@ibiz-template/command": "^0.0.1-beta.50",
"@ibiz-template/controller": "^0.0.1-beta.81",
"@ibiz-template/core": "^0.0.1-beta.81",
"@ibiz-template/model": "^0.0.1-beta.81",
"@ibiz-template/runtime": "^0.0.1-beta.81",
"@ibiz-template/service": "^0.0.1-beta.81",
"@ibiz-template/theme": "^0.0.1-beta.81",
"@ibiz-template/vue-util": "^0.0.1-beta.81",
"@ibiz-template/controller": "^0.0.1-beta.82",
"@ibiz-template/core": "^0.0.1-beta.82",
"@ibiz-template/model": "^0.0.1-beta.82",
"@ibiz-template/runtime": "^0.0.1-beta.82",
"@ibiz-template/service": "^0.0.1-beta.82",
"@ibiz-template/theme": "^0.0.1-beta.82",
"@ibiz-template/vue-util": "^0.0.1-beta.82",
"@ibiz/dynamic-model-api": "^2.1.17",
"@riophae/vue-treeselect": "^0.4.0",
"dayjs": "^1.11.7",
......
此差异已折叠。
......@@ -13,6 +13,7 @@ import {
defineComponent,
getCurrentInstance,
onMounted,
onUnmounted,
PropType,
Ref,
ref,
......@@ -20,6 +21,7 @@ import {
} from 'vue';
import { AppMenuController } from '@ibiz-template/controller';
import '@ibiz-template/theme/style/components/widgets/app-menu/app-menu.scss';
import { AppCounter, CounterService } from '@ibiz-template/service';
/**
* 递归生成菜单数据,递给 antd 的 Menu 组件
*
......@@ -34,6 +36,7 @@ function getMenus(items: AppMenuItemModel[]): IData[] {
key: item.source.id,
label: item.label,
image: item.image,
counterId: item.counterId,
};
if (item.children) {
data.children = getMenus(item.children);
......@@ -54,6 +57,7 @@ function renderMenuItem(
collapseChange: boolean,
ns: Namespace,
c: AppMenuController,
counterData: IData,
) {
if (!c.menuItemsState[menu.key].visible) {
return;
......@@ -62,6 +66,12 @@ function renderMenuItem(
<i-menu-item class={ns.e('item')} name={menu.key}>
<app-icon class={ns.e('icon')} icon={menu.image}></app-icon>
{menu.label}
{typeof counterData[menu.counterId] === 'number' ? (
<i-badge
class={ns.e('counter')}
count={counterData[menu.counterId]}
></i-badge>
) : null}
</i-menu-item>
) : (
<i-tooltip
......@@ -73,6 +83,12 @@ function renderMenuItem(
<i-menu-item class={ns.e('item')} name={menu.key}>
<app-icon class={ns.e('icon')} icon={menu.image}></app-icon>
{!menu.image ? menu.label.slice(0, 1) : null}
{typeof counterData[menu.counterId] === 'number' ? (
<i-badge
class={ns.e('counter')}
count={counterData[menu.counterId]}
></i-badge>
) : null}
</i-menu-item>
</i-tooltip>
);
......@@ -90,13 +106,22 @@ function renderDropDownMenuItem(
collapseChange: boolean,
ns: Namespace,
c: AppMenuController,
counterData: IData,
) {
if (!c.menuItemsState[menu.key].visible) {
return;
}
return (
<i-dropdown-item class={ns.be('submenu', 'item')} name={menu.key}>
<i-menu-item name={menu.key}>{menu.label}</i-menu-item>
<i-menu-item name={menu.key}>
{menu.label}
{typeof counterData[menu.counterId] === 'number' ? (
<i-badge
class={ns.e('counter')}
count={counterData[menu.counterId]}
></i-badge>
) : null}
</i-menu-item>
</i-dropdown-item>
);
}
......@@ -114,6 +139,7 @@ function renderSubmenu(
collapseChange: boolean,
ns: Namespace,
c: AppMenuController,
counterData: IData,
) {
if (!c.menuItemsState[subMenu.key].visible) {
return;
......@@ -126,9 +152,9 @@ function renderSubmenu(
</template>
{subMenu.children.map((item: IData) => {
if (item.children) {
return renderSubmenu(false, item, collapseChange, ns, c);
return renderSubmenu(false, item, collapseChange, ns, c, counterData);
}
return renderMenuItem(item, collapseChange, ns, c);
return renderMenuItem(item, collapseChange, ns, c, counterData);
})}
</i-submenu>
) : (
......@@ -148,9 +174,22 @@ function renderSubmenu(
<i-dropdown-menu class={ns.be('submenu', 'list')} slot='list'>
{subMenu.children.map((item: IData) => {
if (item.children) {
return renderSubmenu(false, item, collapseChange, ns, c);
return renderSubmenu(
false,
item,
collapseChange,
ns,
c,
counterData,
);
}
return renderDropDownMenuItem(item, collapseChange, ns, c);
return renderDropDownMenuItem(
item,
collapseChange,
ns,
c,
counterData,
);
})}
</i-dropdown-menu>
</i-dropdown>
......@@ -175,6 +214,9 @@ export const AppMenu = defineComponent({
const defaultOpens: Ref<string[]> = ref([]);
// 路由对象
const route = proxy.$route;
// 计数器数据
let counter: AppCounter | null = null;
const counterData = ref<IData>({});
c.nerve.self.evt.on('created', () => {
menus.value = getMenus(c.model.items);
......@@ -261,7 +303,7 @@ export const AppMenu = defineComponent({
},
);
onMounted(() => {
onMounted(async () => {
// 默认激活的菜单项
const defaultActiveMenuItem = c.model.allItems.find(item => {
return (
......@@ -286,9 +328,25 @@ export const AppMenu = defineComponent({
});
}
updateMenu();
// 计数器相关
const CounterRef = c.model.source.getPSAppCounterRef();
if (CounterRef) {
counter = await CounterService.getCounterByRef(
CounterRef,
props.context,
);
counter.onChange(data => {
counterData.value = data;
});
}
});
onUnmounted(() => {
counter?.destroy();
});
return { menus, c, onClick, ns, defaultActive, defaultOpens };
return { menus, c, onClick, ns, defaultActive, defaultOpens, counterData };
},
render() {
return (
......@@ -309,9 +367,16 @@ export const AppMenu = defineComponent({
this.collapseChange,
this.ns,
this.c,
this.counterData,
);
}
return renderMenuItem(item, this.collapseChange, this.ns, this.c);
return renderMenuItem(
item,
this.collapseChange,
this.ns,
this.c,
this.counterData,
);
})}
</i-menu>
);
......
......@@ -651,54 +651,54 @@
dependencies:
qx-util "^0.4.8"
"@ibiz-template/controller@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/controller/-/controller-0.0.1-beta.81.tgz#5fc9aa0d6f93395565c47dc916b3abcfa61b63b5"
integrity sha512-b8p9ud5F+aX0n/5gcHLROa+u9GgTmgqmJiIbV/1noRQrnlNWoPkWCC3ImxYPtNDT1dMxEsYoI4lymIbNi9yDEg==
"@ibiz-template/controller@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/controller/-/controller-0.0.1-beta.82.tgz#593a0efd887db6f923e245d279dddf4cf8baf6ca"
integrity sha512-Eo/ja4bFBz8i+aatC6wkQiMiYkTEmpu+aGqvq3XIJs0q0H3b5epMsspYWI4vu/o1u2Qmb8dkLsXKU29QRDdT5g==
dependencies:
async-validator "^4.2.5"
dayjs "^1.11.5"
"@ibiz-template/core@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/core/-/core-0.0.1-beta.81.tgz#729646bb0211520fc418c0c17435fce84268ac1e"
integrity sha512-P/vhtmEJd1vE92KJZeAHPPvaFoHI9Cl/hVatcQhU5o/mgXJHCjkB4wgMDqGPaJMyI7LQodw3MT6Fs3+9M3jz0w==
"@ibiz-template/core@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/core/-/core-0.0.1-beta.82.tgz#9ee90429b3100b462f43900001a28988446604f4"
integrity sha512-WnPe2FBZ5DUhrhVoI6JrhSl6sjkGLVn/7OVj0g4dmp1DhXwoOrbWjW+Ogr/p7kSV/LyRC4g1sRXk/tb9V4dPAA==
dependencies:
axios "^1.2.1"
loglevel "^1.8.0"
pluralize "^8.0.0"
qs "^6.11.0"
"@ibiz-template/model@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/model/-/model-0.0.1-beta.81.tgz#64d528dcf0f6fc220e647d3eae4e052b6179428c"
integrity sha512-Dj90m2Pn7FirAH8Na2/2Hd89hVl0qZw8id8I/qu7y7x1tQDeOLN6D80mbwrbCUsxgyg7niWyk3i/SP3EB0giiQ==
"@ibiz-template/model@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/model/-/model-0.0.1-beta.82.tgz#3bebf980965d237da02251d3181c1bafbe467d2a"
integrity sha512-Zn8pvpi/fq8qo1p/0NjMmu0D7nojCH3EAjifybdLe/+h700UTT0bfPOI6vlk8csVkYgkzI8Ds/RC6kb+EcDhXw==
dependencies:
"@ibiz/dynamic-model-api" "^2.1.17"
pluralize "^8.0.0"
"@ibiz-template/runtime@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/runtime/-/runtime-0.0.1-beta.81.tgz#3d229d13187d613c9a43255e85b084543b4bc10a"
integrity sha512-sRIOZfPz54VgPT04tzQ08RNdkEGDegfzLiwJu4ig9JvZTKECKmZLACbPS8wtKA/0kau5vLA6cQWKZTvcufN9Eg==
"@ibiz-template/runtime@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/runtime/-/runtime-0.0.1-beta.82.tgz#b0591f99ae6c77946f885695304468cce29af23a"
integrity sha512-Tx50eIcsliwh0x4C1DIjY4VEu8gmXFzmfDxVQxA9oWyB+I3sQA0Cn+G87NjgCnDWWQsV/iGXnC9430hO4X264g==
dependencies:
"@ibiz-template/command" "^0.0.1-beta.50"
qs "^6.11.0"
"@ibiz-template/service@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/service/-/service-0.0.1-beta.81.tgz#e5ab0c19976a24689385dbcb3d5d01f496069cd3"
integrity sha512-0BY0Jv99KsZV00PHcPSvMkMYn0fRCFLUKfLTq6bFvjwjXykJCft1KVHA4acXHVJCgRlv9c0az36AN14QwhE5iw==
"@ibiz-template/service@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/service/-/service-0.0.1-beta.82.tgz#f55458d818cbfb3691444f718e10c8486322e7ea"
integrity sha512-gd5Okom1MwfTClItV4ekECu6bPZq3HV3fsfmM/R6Qe6KD4VDEqwORca8r1VRYP1eE1s/mTonXnoyy154vC9aIg==
"@ibiz-template/theme@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/theme/-/theme-0.0.1-beta.81.tgz#1b79592c345956c37a5fd5ca85ba0e80832c3400"
integrity sha512-ulgZQ0VoUCZmLvbd+ihxg9GgdKEjQT321jOxrQDyX5cCen4VQfFkSlvitj3az7IOYDVgEp0+zXuTQfo0z9CQHw==
"@ibiz-template/theme@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/theme/-/theme-0.0.1-beta.82.tgz#e3ec9371d833ddc79d0b2cff43fe2ba15bc8ff97"
integrity sha512-PAvZkfgtD+AVSIXaLywhhpErMbW6eRkcBGnJIdlQSj52C3dgRgXkDkRW9DTRPInntMTe4LGUMMytYdjV4216QA==
"@ibiz-template/vue-util@^0.0.1-beta.81":
version "0.0.1-beta.81"
resolved "http://npm.zhr.icu:4873/@ibiz-template/vue-util/-/vue-util-0.0.1-beta.81.tgz#bd0faed3bc60a7c616e52ced40d38a5649472aca"
integrity sha512-IAfDtDbLIvIxSJ35wb5xEX3cM4BaPYy3ScRikGqEs+4SwJJ/l2pTQJxPXS5v6Nvez4+D/RnaMfzvnmICStG7Wg==
"@ibiz-template/vue-util@^0.0.1-beta.82":
version "0.0.1-beta.82"
resolved "http://npm.zhr.icu:4873/@ibiz-template/vue-util/-/vue-util-0.0.1-beta.82.tgz#cd8bf58d5c5d836d64d610d44612cfa868f36541"
integrity sha512-L2IqYp/LQCPLpi5N870l+1phRQKXx2flxEObyKON0HtoBSvh99HrYPsJJb1AtrOEIagVVVVGBSLVx+cnIb7Bjw==
"@ibiz/dynamic-model-api@^2.1.17":
version "2.1.17"
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册