@juzhenfe/page-model 3.17.5 → 3.17.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,6 +65,10 @@ export default class PageModelManager extends Reflections {
|
|
|
65
65
|
updatedChildrenConfig(): void;
|
|
66
66
|
registerChildManager(managerName: any, manager: TableManager | SearchFormManager | TopTabsManager | FormManager): void;
|
|
67
67
|
handleSubmit(): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* 上次请求数据
|
|
70
|
+
*/
|
|
71
|
+
lastReqData: any;
|
|
68
72
|
doGetDataRequest(): Promise<boolean>;
|
|
69
73
|
/**
|
|
70
74
|
* 处理表格数据
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
* 使用用户配置的汇总
|
|
3
3
|
*/
|
|
4
4
|
import TableManager from '../constructor';
|
|
5
|
-
import EventEmitter from '../../../utils/event-emitter';
|
|
6
|
-
/**
|
|
7
|
-
* 用户汇总配置修改事件
|
|
8
|
-
*/
|
|
9
|
-
declare const userSummaryConfigEmiter: EventEmitter<"change">;
|
|
10
|
-
export { userSummaryConfigEmiter };
|
|
11
5
|
export declare enum SummaryTypeEnum {
|
|
12
6
|
不展示 = 0,
|
|
13
7
|
求和 = 1,
|
|
@@ -18,4 +12,4 @@ export declare enum SummaryTypeEnum {
|
|
|
18
12
|
* @param tableManager
|
|
19
13
|
* @returns
|
|
20
14
|
*/
|
|
21
|
-
export declare function useUserSummary(tableManager: TableManager): boolean;
|
|
15
|
+
export declare function useUserSummary(tableManager: TableManager): () => boolean;
|
package/dist/index.es.js
CHANGED
|
@@ -3746,6 +3746,7 @@ const _PageModelManager = class extends Reflections {
|
|
|
3746
3746
|
__publicField(this, "staticData");
|
|
3747
3747
|
__publicField(this, "id", 0);
|
|
3748
3748
|
__publicField(this, "isTableFullscreen", false);
|
|
3749
|
+
__publicField(this, "lastReqData");
|
|
3749
3750
|
__publicField(this, "isTableSelecting", false);
|
|
3750
3751
|
__publicField(this, "loadingInstance");
|
|
3751
3752
|
__publicField(this, "authButtons", []);
|
|
@@ -3893,6 +3894,7 @@ const _PageModelManager = class extends Reflections {
|
|
|
3893
3894
|
if (typeof config.beforeGetRequest === "function") {
|
|
3894
3895
|
config.beforeGetRequest.call(this, reqData);
|
|
3895
3896
|
}
|
|
3897
|
+
this.lastReqData = reqData;
|
|
3896
3898
|
let reqResult = await _PageModelManager.request[method](
|
|
3897
3899
|
config.getUrl,
|
|
3898
3900
|
reqData
|
|
@@ -9034,42 +9036,46 @@ function useTableEls(originTableEls, tableManager) {
|
|
|
9034
9036
|
renderEls
|
|
9035
9037
|
};
|
|
9036
9038
|
}
|
|
9037
|
-
const userSummaryConfigEmiter = new EventEmitter();
|
|
9038
9039
|
var SummaryTypeEnum = /* @__PURE__ */ ((SummaryTypeEnum2) => {
|
|
9039
9040
|
SummaryTypeEnum2[SummaryTypeEnum2["\u4E0D\u5C55\u793A"] = 0] = "\u4E0D\u5C55\u793A";
|
|
9040
9041
|
SummaryTypeEnum2[SummaryTypeEnum2["\u6C42\u548C"] = 1] = "\u6C42\u548C";
|
|
9041
9042
|
SummaryTypeEnum2[SummaryTypeEnum2["\u603B\u6570"] = 2] = "\u603B\u6570";
|
|
9042
9043
|
return SummaryTypeEnum2;
|
|
9043
9044
|
})(SummaryTypeEnum || {});
|
|
9044
|
-
let isHijacked = false;
|
|
9045
|
-
let summaryResult = reactive([]);
|
|
9046
9045
|
function useUserSummary(tableManager) {
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
const
|
|
9056
|
-
|
|
9046
|
+
let isHijacked = false;
|
|
9047
|
+
let summaryResult = reactive([]);
|
|
9048
|
+
let currentTableColumns = [];
|
|
9049
|
+
let lastSummaryColumns = [];
|
|
9050
|
+
return function initSummary() {
|
|
9051
|
+
if (tableManager.tableProps.summaryMethod && !tableManager.tableProps._customSummary) {
|
|
9052
|
+
return false;
|
|
9053
|
+
}
|
|
9054
|
+
const currentRenderTableEls = tableManager.currentRenderTableEls;
|
|
9055
|
+
const isUsingSummary = tableManager.table.showSummary || currentRenderTableEls.filter((a) => a.prop).some((a) => a.showSummary != null);
|
|
9056
|
+
if (!isUsingSummary) {
|
|
9057
|
+
tableManager.tableProps.showSummary = false;
|
|
9058
|
+
tableManager.tableProps.summaryMethod = null;
|
|
9059
|
+
return false;
|
|
9060
|
+
}
|
|
9057
9061
|
tableManager.tableProps.showSummary = true;
|
|
9058
9062
|
tableManager.tableProps._customSummary = true;
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
let lastSummaryColumns = {};
|
|
9062
|
-
const getSummaryData = debounce(async () => {
|
|
9063
|
-
const summaryColumns = tableManager.currentRenderTableEls.filter((a) => a.showSummary != null && a.showSummary !== "").filter((a) => a.prop).map((a) => {
|
|
9063
|
+
const getSummaryEls = () => {
|
|
9064
|
+
return tableManager.currentRenderTableEls.filter((a) => a.showSummary != null && a.showSummary !== "").filter((a) => a.prop).map((a) => {
|
|
9064
9065
|
return {
|
|
9065
9066
|
prop: a.prop,
|
|
9066
9067
|
showSummary: a.showSummary
|
|
9067
9068
|
};
|
|
9068
9069
|
});
|
|
9070
|
+
};
|
|
9071
|
+
const summaryEls = getSummaryEls();
|
|
9072
|
+
const isServerSummary = tableManager.table.useServerSummary && typeof tableManager.table.serverSummaryFn === "function";
|
|
9073
|
+
const getSummaryData = debounce(async () => {
|
|
9074
|
+
const summaryColumns = lastSummaryColumns = getSummaryEls();
|
|
9069
9075
|
const reqResult = tableManager.table.serverSummaryFn.call(
|
|
9070
9076
|
tableManager,
|
|
9071
9077
|
summaryColumns,
|
|
9072
|
-
cloneDeep(
|
|
9078
|
+
cloneDeep(tableManager.manager.lastReqData),
|
|
9073
9079
|
currentTableColumns
|
|
9074
9080
|
);
|
|
9075
9081
|
const _result = await reqResult;
|
|
@@ -9079,17 +9085,14 @@ function useUserSummary(tableManager) {
|
|
|
9079
9085
|
}, 300);
|
|
9080
9086
|
if (isServerSummary) {
|
|
9081
9087
|
if (!isHijacked) {
|
|
9088
|
+
const config = tableManager.manager.config;
|
|
9082
9089
|
let _beforeGetRequest = config.beforeGetRequest;
|
|
9083
9090
|
config.beforeGetRequest = async function(reqParams) {
|
|
9084
9091
|
if (typeof _beforeGetRequest === "function") {
|
|
9085
9092
|
_beforeGetRequest.call(tableManager.manager, reqParams);
|
|
9086
9093
|
}
|
|
9087
|
-
lastSummaryColumns = reqParams;
|
|
9088
9094
|
getSummaryData();
|
|
9089
9095
|
};
|
|
9090
|
-
userSummaryConfigEmiter.on("change", () => {
|
|
9091
|
-
getSummaryData();
|
|
9092
|
-
});
|
|
9093
9096
|
isHijacked = true;
|
|
9094
9097
|
}
|
|
9095
9098
|
}
|
|
@@ -9098,9 +9101,12 @@ function useUserSummary(tableManager) {
|
|
|
9098
9101
|
data
|
|
9099
9102
|
}) {
|
|
9100
9103
|
if (!columns.length) {
|
|
9101
|
-
return
|
|
9104
|
+
return [];
|
|
9102
9105
|
}
|
|
9103
9106
|
if (isServerSummary) {
|
|
9107
|
+
if (currentTableColumns.length !== columns.length || currentTableColumns.map((a) => a.property).join(",") !== columns.map((a) => a.property).join(",") || getSummaryEls().map((a) => a.showSummary).join(",") !== lastSummaryColumns.map((a) => a.showSummary).join(",")) {
|
|
9108
|
+
getSummaryData();
|
|
9109
|
+
}
|
|
9104
9110
|
currentTableColumns = columns;
|
|
9105
9111
|
} else {
|
|
9106
9112
|
const _result = columns.map((column) => {
|
|
@@ -9171,13 +9177,7 @@ function useUserSummary(tableManager) {
|
|
|
9171
9177
|
);
|
|
9172
9178
|
});
|
|
9173
9179
|
};
|
|
9174
|
-
|
|
9175
|
-
tableManager.context.$refs.tableRef.doLayout();
|
|
9176
|
-
}, 20);
|
|
9177
|
-
} else {
|
|
9178
|
-
tableManager.tableProps.showSummary = false;
|
|
9179
|
-
tableManager.tableProps.summaryMethod = null;
|
|
9180
|
-
}
|
|
9180
|
+
};
|
|
9181
9181
|
}
|
|
9182
9182
|
const useExportForm = () => {
|
|
9183
9183
|
const exportFormRef = ref();
|
|
@@ -9479,13 +9479,14 @@ const _sfc_main$n = defineComponent({
|
|
|
9479
9479
|
});
|
|
9480
9480
|
const filteredUserEls = ref([]);
|
|
9481
9481
|
const renderedTableEls = ref();
|
|
9482
|
+
const initSummary = useUserSummary(tableManager);
|
|
9482
9483
|
function setTableEls() {
|
|
9483
9484
|
const result = useTableEls(table.value.els, tableManager);
|
|
9484
9485
|
filteredUserEls.value = result.filteredUserEls;
|
|
9485
9486
|
renderedTableEls.value = result.renderEls;
|
|
9486
9487
|
tableManager.updateCurrentFilterTableEls(cloneDeep(result.filteredUserEls));
|
|
9487
9488
|
tableManager.updateCurrentRenderTableEls(cloneDeep(result.renderEls));
|
|
9488
|
-
|
|
9489
|
+
initSummary();
|
|
9489
9490
|
}
|
|
9490
9491
|
tableUserConfigChangeEmiter.on("change", () => {
|
|
9491
9492
|
setTableEls();
|
|
@@ -9516,7 +9517,6 @@ const _sfc_main$n = defineComponent({
|
|
|
9516
9517
|
};
|
|
9517
9518
|
const onSaveColumns = async (columns) => {
|
|
9518
9519
|
const originColumns = table.value.els;
|
|
9519
|
-
let isSummaryChange = false;
|
|
9520
9520
|
const contents = columns.map((column) => {
|
|
9521
9521
|
const originColumnIndex = originColumns.findIndex((a) => a.label === column.label);
|
|
9522
9522
|
const item = {
|
|
@@ -9531,9 +9531,8 @@ const _sfc_main$n = defineComponent({
|
|
|
9531
9531
|
item.sum = Number(column.showSummary);
|
|
9532
9532
|
}
|
|
9533
9533
|
const renderColumn = filteredUserEls.value.find((a) => a.prop === column.prop);
|
|
9534
|
-
if (column.showSummary !== (renderColumn == null ? void 0 : renderColumn.showSummary))
|
|
9535
|
-
|
|
9536
|
-
}
|
|
9534
|
+
if (column.showSummary !== (renderColumn == null ? void 0 : renderColumn.showSummary))
|
|
9535
|
+
;
|
|
9537
9536
|
return item;
|
|
9538
9537
|
});
|
|
9539
9538
|
const userSetting = PageModelManager.userSetting;
|
|
@@ -9549,9 +9548,6 @@ const _sfc_main$n = defineComponent({
|
|
|
9549
9548
|
} catch (error) {
|
|
9550
9549
|
}
|
|
9551
9550
|
setTableEls();
|
|
9552
|
-
if (isSummaryChange) {
|
|
9553
|
-
userSummaryConfigEmiter.emit("change");
|
|
9554
|
-
}
|
|
9555
9551
|
};
|
|
9556
9552
|
const clearSelection = () => {
|
|
9557
9553
|
tableManager.clearSelection();
|
|
@@ -14895,7 +14891,7 @@ const defineEditableTable = function(config) {
|
|
|
14895
14891
|
};
|
|
14896
14892
|
var iconfont = "";
|
|
14897
14893
|
const name = "@juzhenfe/page-model";
|
|
14898
|
-
const version = "3.17.
|
|
14894
|
+
const version = "3.17.7";
|
|
14899
14895
|
const types = "dist/main.d.ts";
|
|
14900
14896
|
const main = "dist/index.umd.js";
|
|
14901
14897
|
const keywords = [
|