增加admin管理帐号和项目的界面--初步实现
This commit is contained in:
Generated
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
import type { Store } from '../store';
|
||||
import type { PropType } from 'vue';
|
||||
import type { DefaultRow, Sort, SummaryMethod } from '../table/defaults';
|
||||
export interface TableFooter<T extends DefaultRow> {
|
||||
fixed: string;
|
||||
store: Store<T>;
|
||||
summaryMethod: SummaryMethod<T>;
|
||||
sumText: string;
|
||||
border: boolean;
|
||||
defaultSort: Sort;
|
||||
}
|
||||
declare const _default: import("vue").DefineComponent<{
|
||||
fixed: {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
};
|
||||
store: {
|
||||
required: true;
|
||||
type: PropType<TableFooter<any>["store"]>;
|
||||
};
|
||||
summaryMethod: PropType<TableFooter<any>["summaryMethod"]>;
|
||||
sumText: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
defaultSort: {
|
||||
type: PropType<TableFooter<any>["defaultSort"]>;
|
||||
default: () => {
|
||||
prop: string;
|
||||
order: string;
|
||||
};
|
||||
};
|
||||
}, {
|
||||
ns: {
|
||||
namespace: import("vue").ComputedRef<string>;
|
||||
b: (blockSuffix?: string) => string;
|
||||
e: (element?: string) => string;
|
||||
m: (modifier?: string) => string;
|
||||
be: (blockSuffix?: string, element?: string) => string;
|
||||
em: (element?: string, modifier?: string) => string;
|
||||
bm: (blockSuffix?: string, modifier?: string) => string;
|
||||
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
|
||||
is: {
|
||||
(name: string, state: boolean | undefined): string;
|
||||
(name: string): string;
|
||||
};
|
||||
cssVar: (object: Record<string, string>) => Record<string, string>;
|
||||
cssVarName: (name: string) => string;
|
||||
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
||||
cssVarBlockName: (name: string) => string;
|
||||
};
|
||||
onScrollableChange: (layout: import("../table-layout").default<any>) => void;
|
||||
onColumnsChange: (layout: import("../table-layout").default<any>) => void;
|
||||
getCellClasses: (columns: import("../table-column/defaults").TableColumnCtx<any>[], cellIndex: number) => string[];
|
||||
getCellStyles: (column: import("../table-column/defaults").TableColumnCtx<any>, cellIndex: number) => import("vue").CSSProperties | undefined;
|
||||
columns: import("vue").ComputedRef<import("../table-column/defaults").TableColumnCtx<DefaultRow>[]>;
|
||||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
fixed: {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
};
|
||||
store: {
|
||||
required: true;
|
||||
type: PropType<TableFooter<any>["store"]>;
|
||||
};
|
||||
summaryMethod: PropType<TableFooter<any>["summaryMethod"]>;
|
||||
sumText: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
defaultSort: {
|
||||
type: PropType<TableFooter<any>["defaultSort"]>;
|
||||
default: () => {
|
||||
prop: string;
|
||||
order: string;
|
||||
};
|
||||
};
|
||||
}>>, {
|
||||
fixed: string;
|
||||
border: boolean;
|
||||
defaultSort: Sort;
|
||||
}>;
|
||||
export default _default;
|
||||
Generated
Vendored
+104
@@ -0,0 +1,104 @@
|
||||
import { defineComponent, inject, h } from 'vue';
|
||||
import useLayoutObserver from '../layout-observer.mjs';
|
||||
import { TABLE_INJECTION_KEY } from '../tokens.mjs';
|
||||
import useStyle from './style-helper.mjs';
|
||||
import { useNamespace } from '../../../../hooks/use-namespace/index.mjs';
|
||||
|
||||
var TableFooter = defineComponent({
|
||||
name: "ElTableFooter",
|
||||
props: {
|
||||
fixed: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
store: {
|
||||
required: true,
|
||||
type: Object
|
||||
},
|
||||
summaryMethod: Function,
|
||||
sumText: String,
|
||||
border: Boolean,
|
||||
defaultSort: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
prop: "",
|
||||
order: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
const parent = inject(TABLE_INJECTION_KEY);
|
||||
const ns = useNamespace("table");
|
||||
const { getCellClasses, getCellStyles, columns } = useStyle(props);
|
||||
const { onScrollableChange, onColumnsChange } = useLayoutObserver(parent);
|
||||
return {
|
||||
ns,
|
||||
onScrollableChange,
|
||||
onColumnsChange,
|
||||
getCellClasses,
|
||||
getCellStyles,
|
||||
columns
|
||||
};
|
||||
},
|
||||
render() {
|
||||
const { columns, getCellStyles, getCellClasses, summaryMethod, sumText } = this;
|
||||
const data = this.store.states.data.value;
|
||||
let sums = [];
|
||||
if (summaryMethod) {
|
||||
sums = summaryMethod({
|
||||
columns,
|
||||
data
|
||||
});
|
||||
} else {
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = sumText;
|
||||
return;
|
||||
}
|
||||
const values = data.map((item) => Number(item[column.property]));
|
||||
const precisions = [];
|
||||
let notNumber = true;
|
||||
values.forEach((value) => {
|
||||
if (!Number.isNaN(+value)) {
|
||||
notNumber = false;
|
||||
const decimal = `${value}`.split(".")[1];
|
||||
precisions.push(decimal ? decimal.length : 0);
|
||||
}
|
||||
});
|
||||
const precision = Math.max.apply(null, precisions);
|
||||
if (!notNumber) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr);
|
||||
if (!Number.isNaN(+value)) {
|
||||
return Number.parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
} else {
|
||||
sums[index] = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
return h(h("tfoot", [
|
||||
h("tr", {}, [
|
||||
...columns.map((column, cellIndex) => h("td", {
|
||||
key: cellIndex,
|
||||
colspan: column.colSpan,
|
||||
rowspan: column.rowSpan,
|
||||
class: getCellClasses(columns, cellIndex),
|
||||
style: getCellStyles(column, cellIndex)
|
||||
}, [
|
||||
h("div", {
|
||||
class: ["cell", column.labelClassName]
|
||||
}, [sums[cellIndex]])
|
||||
]))
|
||||
])
|
||||
]));
|
||||
}
|
||||
});
|
||||
|
||||
export { TableFooter as default };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
declare function useMapState(): {
|
||||
leftFixedLeafCount: import("vue").ComputedRef<number>;
|
||||
rightFixedLeafCount: import("vue").ComputedRef<number>;
|
||||
columnsCount: import("vue").ComputedRef<number>;
|
||||
leftFixedCount: import("vue").ComputedRef<number>;
|
||||
rightFixedCount: import("vue").ComputedRef<number>;
|
||||
columns: import("vue").ComputedRef<import("element-plus").TableColumnCtx<import("../table/defaults").DefaultRow>[]>;
|
||||
};
|
||||
export default useMapState;
|
||||
Generated
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
import { inject, computed } from 'vue';
|
||||
import { TABLE_INJECTION_KEY } from '../tokens.mjs';
|
||||
|
||||
function useMapState() {
|
||||
const table = inject(TABLE_INJECTION_KEY);
|
||||
const store = table == null ? void 0 : table.store;
|
||||
const leftFixedLeafCount = computed(() => {
|
||||
var _a;
|
||||
return (_a = store == null ? void 0 : store.states.fixedLeafColumnsLength.value) != null ? _a : 0;
|
||||
});
|
||||
const rightFixedLeafCount = computed(() => {
|
||||
var _a;
|
||||
return (_a = store == null ? void 0 : store.states.rightFixedColumns.value.length) != null ? _a : 0;
|
||||
});
|
||||
const columnsCount = computed(() => {
|
||||
var _a;
|
||||
return (_a = store == null ? void 0 : store.states.columns.value.length) != null ? _a : 0;
|
||||
});
|
||||
const leftFixedCount = computed(() => {
|
||||
var _a;
|
||||
return (_a = store == null ? void 0 : store.states.fixedColumns.value.length) != null ? _a : 0;
|
||||
});
|
||||
const rightFixedCount = computed(() => {
|
||||
var _a;
|
||||
return (_a = store == null ? void 0 : store.states.rightFixedColumns.value.length) != null ? _a : 0;
|
||||
});
|
||||
return {
|
||||
leftFixedLeafCount,
|
||||
rightFixedLeafCount,
|
||||
columnsCount,
|
||||
leftFixedCount,
|
||||
rightFixedCount,
|
||||
columns: computed(() => {
|
||||
var _a;
|
||||
return (_a = store == null ? void 0 : store.states.columns.value) != null ? _a : [];
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export { useMapState as default };
|
||||
//# sourceMappingURL=mapState-helper.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mapState-helper.mjs","sources":["../../../../../../../packages/components/table/src/table-footer/mapState-helper.ts"],"sourcesContent":["import { computed, inject } from 'vue'\nimport { TABLE_INJECTION_KEY } from '../tokens'\n\nfunction useMapState() {\n const table = inject(TABLE_INJECTION_KEY)\n const store = table?.store\n const leftFixedLeafCount = computed(() => {\n return store?.states.fixedLeafColumnsLength.value ?? 0\n })\n const rightFixedLeafCount = computed(() => {\n return store?.states.rightFixedColumns.value.length ?? 0\n })\n const columnsCount = computed(() => {\n return store?.states.columns.value.length ?? 0\n })\n const leftFixedCount = computed(() => {\n return store?.states.fixedColumns.value.length ?? 0\n })\n const rightFixedCount = computed(() => {\n return store?.states.rightFixedColumns.value.length ?? 0\n })\n\n return {\n leftFixedLeafCount,\n rightFixedLeafCount,\n columnsCount,\n leftFixedCount,\n rightFixedCount,\n columns: computed(() => store?.states.columns.value ?? []),\n }\n}\n\nexport default useMapState\n"],"names":[],"mappings":";;;AAEA,SAAS,WAAW,GAAG;AACvB,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC5C,EAAE,MAAM,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;AACrD,EAAE,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM;AAC5C,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,KAAK,KAAK,IAAI,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I,YAAY;AAChB,IAAI,cAAc;AAClB,IAAI,eAAe;AACnB,IAAI,OAAO,EAAE,QAAQ,CAAC,MAAM;AAC5B,MAAM,IAAI,EAAE,CAAC;AACb,MAAM,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1F,KAAK,CAAC;AACN,GAAG,CAAC;AACJ;;;;"}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import type { TableColumnCtx } from '../table-column/defaults';
|
||||
import type { DefaultRow } from '../table/defaults';
|
||||
import type { TableFooter } from '.';
|
||||
declare function useStyle<T extends DefaultRow>(props: TableFooter<T>): {
|
||||
getCellClasses: (columns: TableColumnCtx<T>[], cellIndex: number) => string[];
|
||||
getCellStyles: (column: TableColumnCtx<T>, cellIndex: number) => import("vue").CSSProperties | undefined;
|
||||
columns: import("vue").ComputedRef<TableColumnCtx<DefaultRow>[]>;
|
||||
};
|
||||
export default useStyle;
|
||||
Generated
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
import { getFixedColumnsClass, getFixedColumnOffset, ensurePosition } from '../util.mjs';
|
||||
import useMapState from './mapState-helper.mjs';
|
||||
import { useNamespace } from '../../../../hooks/use-namespace/index.mjs';
|
||||
|
||||
function useStyle(props) {
|
||||
const { columns } = useMapState();
|
||||
const ns = useNamespace("table");
|
||||
const getCellClasses = (columns2, cellIndex) => {
|
||||
const column = columns2[cellIndex];
|
||||
const classes = [
|
||||
ns.e("cell"),
|
||||
column.id,
|
||||
column.align,
|
||||
column.labelClassName,
|
||||
...getFixedColumnsClass(ns.b(), cellIndex, column.fixed, props.store)
|
||||
];
|
||||
if (column.className) {
|
||||
classes.push(column.className);
|
||||
}
|
||||
if (!column.children) {
|
||||
classes.push(ns.is("leaf"));
|
||||
}
|
||||
return classes;
|
||||
};
|
||||
const getCellStyles = (column, cellIndex) => {
|
||||
const fixedStyle = getFixedColumnOffset(cellIndex, column.fixed, props.store);
|
||||
ensurePosition(fixedStyle, "left");
|
||||
ensurePosition(fixedStyle, "right");
|
||||
return fixedStyle;
|
||||
};
|
||||
return {
|
||||
getCellClasses,
|
||||
getCellStyles,
|
||||
columns
|
||||
};
|
||||
}
|
||||
|
||||
export { useStyle as default };
|
||||
//# sourceMappingURL=style-helper.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"style-helper.mjs","sources":["../../../../../../../packages/components/table/src/table-footer/style-helper.ts"],"sourcesContent":["import { useNamespace } from '@element-plus/hooks'\nimport {\n ensurePosition,\n getFixedColumnOffset,\n getFixedColumnsClass,\n} from '../util'\nimport useMapState from './mapState-helper'\n\nimport type { TableColumnCtx } from '../table-column/defaults'\nimport type { DefaultRow } from '../table/defaults'\nimport type { TableFooter } from '.'\n\nfunction useStyle<T extends DefaultRow>(props: TableFooter<T>) {\n const { columns } = useMapState()\n const ns = useNamespace('table')\n\n const getCellClasses = (columns: TableColumnCtx<T>[], cellIndex: number) => {\n const column = columns[cellIndex]\n const classes = [\n ns.e('cell'),\n column.id,\n column.align,\n column.labelClassName,\n ...getFixedColumnsClass(ns.b(), cellIndex, column.fixed, props.store),\n ]\n if (column.className) {\n classes.push(column.className)\n }\n if (!column.children) {\n classes.push(ns.is('leaf'))\n }\n return classes\n }\n\n const getCellStyles = (column: TableColumnCtx<T>, cellIndex: number) => {\n const fixedStyle = getFixedColumnOffset(\n cellIndex,\n column.fixed,\n props.store\n )\n ensurePosition(fixedStyle, 'left')\n ensurePosition(fixedStyle, 'right')\n return fixedStyle\n }\n\n return {\n getCellClasses,\n getCellStyles,\n columns,\n }\n}\n\nexport default useStyle\n"],"names":[],"mappings":";;;;AAOA,SAAS,QAAQ,CAAC,KAAK,EAAE;AACzB,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CAAC;AACpC,EAAE,MAA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