@fecp/designer 5.5.5 → 5.5.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.
Files changed (99) hide show
  1. package/es/_virtual/app.mjs +5 -0
  2. package/es/_virtual/app2.mjs +4 -0
  3. package/es/designer/package.json.mjs +1 -1
  4. package/es/designer/src/api/index.mjs +30 -31
  5. package/es/designer/src/components/DocumentParam.vue.mjs +5 -3
  6. package/es/designer/src/components/RiskSchemeDialog.vue2.mjs +5 -3
  7. package/es/designer/src/components/TemplateDialog.vue.mjs +5 -3
  8. package/es/designer/src/layout/header/index.vue.mjs +4 -2
  9. package/es/designer/src/layout/index.vue.mjs +6 -4
  10. package/es/designer/src/packages/advancedFilter/ValueInput.vue2.mjs +6 -3
  11. package/es/designer/src/packages/dataLinkage/index.vue.mjs +0 -3
  12. package/es/designer/src/packages/dialog/index.vue.mjs +6 -4
  13. package/es/designer/src/packages/dialog/index.vue2.mjs +6 -4
  14. package/es/designer/src/packages/dialogGlobal/index.vue.mjs +9 -7
  15. package/es/designer/src/packages/dialogGlobal/index.vue2.mjs +9 -7
  16. package/es/designer/src/packages/eventFlow/dialog/action/Dialog.vue.mjs +5 -3
  17. package/es/designer/src/packages/eventFlow/dialog/action/TableChildSelection.vue2.mjs +5 -3
  18. package/es/designer/src/packages/form/components/ComponentPreviewWrapper.vue.mjs +5 -3
  19. package/es/designer/src/packages/form/components/DefaultValueEditor.vue.mjs +2 -2
  20. package/es/designer/src/packages/form/property/contract.vue.mjs +5 -3
  21. package/es/designer/src/packages/form/property/subTable.vue.mjs +5 -3
  22. package/es/designer/src/packages/form/property/widgets.vue.mjs +6 -4
  23. package/es/designer/src/packages/prod/index.vue.mjs +5 -3
  24. package/es/designer/src/packages/table/headerBtn.vue.mjs +1 -4
  25. package/es/designer/src/utils/optionLoader.mjs +9 -7
  26. package/es/designer.css +214 -185
  27. package/es/node_modules/element-china-category-data/dist/app.mjs +77 -0
  28. package/es/packages/mobile/index.mjs +4 -0
  29. package/es/packages/mobile/src/components/all.mjs +4 -0
  30. package/es/packages/mobile/src/components/form/checkboxGroup/CheckboxGroup.vue.mjs +2 -2
  31. package/es/packages/mobile/src/components/form/fieldCheckbox/FieldCheckbox.vue.mjs +29 -25
  32. package/es/packages/mobile/src/components/form/fieldIndustry/FieldIndustry.vue.mjs +195 -0
  33. package/es/packages/mobile/src/components/form/fieldIndustry/index.mjs +10 -0
  34. package/es/packages/mobile/src/components/form/fieldPicker/FieldPicker.vue.mjs +3 -25
  35. package/es/packages/mobile/src/components/form/fieldRadio/FieldRadio.vue.mjs +34 -7
  36. package/es/packages/mobile/src/components/form/fieldSubTitle/FieldSubTitle.vue.mjs +27 -0
  37. package/es/packages/mobile/src/components/form/fieldSubTitle/index.mjs +10 -0
  38. package/es/packages/mobile/src/components/form/radioGroup/RadioGroup.vue.mjs +1 -1
  39. package/es/packages/mobile/src/components/navigation/actionBar/ActionBar.vue.mjs +35 -16
  40. package/es/packages/mobile/src/components/navigation/tabbar/Tabbar.vue.mjs +2 -1
  41. package/es/packages/mobile/src/utils/common.mjs +28 -0
  42. package/es/packages/mobile/src/utils/datasource.mjs +354 -0
  43. package/es/packages/mobile/src/utils/optionUtil.mjs +63 -40
  44. package/es/packages/mobile/src/utils/parseRouteParams.mjs +41 -0
  45. package/es/packages/vue/src/components/dialog/DialogRenderer.vue2.mjs +1 -1
  46. package/es/packages/vue/src/components/forms/text/Text.vue.mjs +1 -1
  47. package/es/packages/vue/src/components/table/TableColumn.vue.mjs +1 -1
  48. package/es/packages/vue/src/composables/usePageEvents.mjs +1 -1
  49. package/es/packages/vue/src/utils/datasource.mjs +1 -1
  50. package/lib/_virtual/app.js +5 -0
  51. package/lib/_virtual/app2.js +4 -0
  52. package/lib/designer/package.json.js +1 -1
  53. package/lib/designer/src/api/index.js +30 -31
  54. package/lib/designer/src/components/DocumentParam.vue.js +4 -2
  55. package/lib/designer/src/components/RiskSchemeDialog.vue2.js +4 -2
  56. package/lib/designer/src/components/TemplateDialog.vue.js +4 -2
  57. package/lib/designer/src/layout/header/index.vue.js +3 -1
  58. package/lib/designer/src/layout/index.vue.js +5 -3
  59. package/lib/designer/src/packages/advancedFilter/ValueInput.vue2.js +5 -2
  60. package/lib/designer/src/packages/dataLinkage/index.vue.js +0 -3
  61. package/lib/designer/src/packages/dialog/index.vue.js +5 -3
  62. package/lib/designer/src/packages/dialog/index.vue2.js +5 -3
  63. package/lib/designer/src/packages/dialogGlobal/index.vue.js +8 -6
  64. package/lib/designer/src/packages/dialogGlobal/index.vue2.js +8 -6
  65. package/lib/designer/src/packages/eventFlow/dialog/action/Dialog.vue.js +4 -2
  66. package/lib/designer/src/packages/eventFlow/dialog/action/TableChildSelection.vue2.js +4 -2
  67. package/lib/designer/src/packages/form/components/ComponentPreviewWrapper.vue.js +4 -2
  68. package/lib/designer/src/packages/form/components/DefaultValueEditor.vue.js +2 -2
  69. package/lib/designer/src/packages/form/property/contract.vue.js +4 -2
  70. package/lib/designer/src/packages/form/property/subTable.vue.js +4 -2
  71. package/lib/designer/src/packages/form/property/widgets.vue.js +5 -3
  72. package/lib/designer/src/packages/prod/index.vue.js +4 -2
  73. package/lib/designer/src/packages/table/headerBtn.vue.js +1 -4
  74. package/lib/designer/src/utils/optionLoader.js +9 -7
  75. package/lib/designer.css +214 -185
  76. package/lib/node_modules/element-china-category-data/dist/app.js +77 -0
  77. package/lib/packages/mobile/index.js +48 -44
  78. package/lib/packages/mobile/src/components/all.js +48 -44
  79. package/lib/packages/mobile/src/components/form/checkboxGroup/CheckboxGroup.vue.js +2 -2
  80. package/lib/packages/mobile/src/components/form/fieldCheckbox/FieldCheckbox.vue.js +28 -24
  81. package/lib/packages/mobile/src/components/form/fieldIndustry/FieldIndustry.vue.js +195 -0
  82. package/lib/packages/mobile/src/components/form/fieldIndustry/index.js +10 -0
  83. package/lib/packages/mobile/src/components/form/fieldPicker/FieldPicker.vue.js +2 -24
  84. package/lib/packages/mobile/src/components/form/fieldRadio/FieldRadio.vue.js +33 -6
  85. package/lib/packages/mobile/src/components/form/fieldSubTitle/FieldSubTitle.vue.js +27 -0
  86. package/lib/packages/mobile/src/components/form/fieldSubTitle/index.js +10 -0
  87. package/lib/packages/mobile/src/components/form/radioGroup/RadioGroup.vue.js +1 -1
  88. package/lib/packages/mobile/src/components/navigation/actionBar/ActionBar.vue.js +34 -15
  89. package/lib/packages/mobile/src/components/navigation/tabbar/Tabbar.vue.js +2 -1
  90. package/lib/packages/mobile/src/utils/common.js +28 -0
  91. package/lib/packages/mobile/src/utils/datasource.js +354 -0
  92. package/lib/packages/mobile/src/utils/optionUtil.js +64 -41
  93. package/lib/packages/mobile/src/utils/parseRouteParams.js +41 -0
  94. package/lib/packages/vue/src/components/dialog/DialogRenderer.vue2.js +1 -1
  95. package/lib/packages/vue/src/components/forms/text/Text.vue.js +1 -1
  96. package/lib/packages/vue/src/components/table/TableColumn.vue.js +1 -1
  97. package/lib/packages/vue/src/composables/usePageEvents.js +1 -1
  98. package/lib/packages/vue/src/utils/datasource.js +1 -1
  99. package/package.json +1 -1
@@ -11,9 +11,9 @@
11
11
  /* empty css */
12
12
  /* empty css */
13
13
  /* empty css */
14
- import { useAttrs, ref, watch, computed, createBlock, openBlock, unref, mergeProps, isRef, createSlots, withCtx, createVNode, withModifiers } from "vue";
14
+ import { useAttrs, ref, computed, watch, createBlock, openBlock, unref, mergeProps, isRef, createSlots, withCtx, createVNode, withModifiers } from "vue";
15
15
  import { MobileField } from "../field/index.mjs";
16
- import { getOptions } from "../../../utils/optionUtil.mjs";
16
+ import "../../../utils/optionUtil.mjs";
17
17
  import { Picker } from "../../../../node_modules/vant/es/picker/index.mjs";
18
18
  import { Popup } from "../../../../node_modules/vant/es/popup/index.mjs";
19
19
  import { Icon } from "../../../../node_modules/vant/es/icon/index.mjs";
@@ -68,30 +68,8 @@ const _sfc_main = {
68
68
  emits: ["update:modelValue"],
69
69
  setup(__props, { emit: __emit }) {
70
70
  const props = __props;
71
- const attrs = useAttrs();
71
+ useAttrs();
72
72
  const finalOptions = ref([]);
73
- getOptions({
74
- ...attrs,
75
- staticOptions: props.pickerOptions,
76
- optionsFieldNames: props.treeOptionsFieldNames
77
- }).then((data) => {
78
- finalOptions.value = data;
79
- });
80
- watch(
81
- () => props.pickerOptions,
82
- () => {
83
- getOptions({
84
- ...attrs,
85
- staticOptions: props.pickerOptions,
86
- optionsFieldNames: props.treeOptionsFieldNames
87
- }).then((data) => {
88
- finalOptions.value = data;
89
- });
90
- },
91
- {
92
- deep: true
93
- }
94
- );
95
73
  const fieldTextValue = ref("");
96
74
  const showPicker = ref(false);
97
75
  const emit = __emit;
@@ -1,7 +1,8 @@
1
- import { getCurrentInstance, useAttrs, ref, computed, createBlock, openBlock, unref, mergeProps, isRef, withCtx, createElementBlock, toDisplayString } from "vue";
1
+ import { getCurrentInstance, useAttrs, ref, watch, computed, createBlock, openBlock, unref, mergeProps, isRef, withCtx, createElementBlock, toDisplayString } from "vue";
2
2
  import { MobileField } from "../field/index.mjs";
3
3
  import { getOptions } from "../../../utils/optionUtil.mjs";
4
4
  import { MobileRadioGroup } from "../radioGroup/index.mjs";
5
+ import { cloneDeep } from "../../../utils/common.mjs";
5
6
  const _hoisted_1 = { key: 1 };
6
7
  const _sfc_main = {
7
8
  __name: "FieldRadio",
@@ -17,20 +18,46 @@ const _sfc_main = {
17
18
  readonly: {
18
19
  type: Boolean,
19
20
  default: false
21
+ },
22
+ dataSources: {
23
+ type: Array,
24
+ default: () => []
25
+ },
26
+ formData: {
27
+ type: Object,
28
+ default: () => {
29
+ }
30
+ },
31
+ fields: {
32
+ type: Array,
33
+ default: () => []
20
34
  }
21
35
  },
22
36
  emits: ["update:modelValue"],
23
37
  setup(__props, { emit: __emit }) {
24
38
  const currentInstance = getCurrentInstance();
25
- currentInstance.proxy;
39
+ const ctx = currentInstance.proxy;
26
40
  const props = __props;
27
41
  useAttrs();
28
42
  const finalOptions = ref([]);
29
- getOptions({
30
- ...props.optionConfig
31
- }).then((data) => {
32
- finalOptions.value = data;
33
- });
43
+ watch(
44
+ () => cloneDeep(props.optionConfig),
45
+ (val) => {
46
+ getOptions({
47
+ ctx,
48
+ dataSources: props.dataSources,
49
+ formData: props.formData,
50
+ fields: props.fields,
51
+ ...props.optionConfig
52
+ }).then((data) => {
53
+ finalOptions.value = data;
54
+ });
55
+ },
56
+ {
57
+ deep: true,
58
+ immediate: true
59
+ }
60
+ );
34
61
  const emit = __emit;
35
62
  const compValue = computed({
36
63
  get: () => {
@@ -0,0 +1,27 @@
1
+ import { createElementBlock, openBlock, createElementVNode, toDisplayString } from "vue";
2
+ /* empty css */
3
+ import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const _hoisted_1 = { class: "fec-sub-title" };
5
+ const _hoisted_2 = { class: "fec-label-title" };
6
+ const _sfc_main = {
7
+ __name: "FieldSubTitle",
8
+ props: {
9
+ label: {
10
+ type: String,
11
+ default: ""
12
+ }
13
+ },
14
+ setup(__props) {
15
+ return (_ctx, _cache) => {
16
+ return openBlock(), createElementBlock("div", _hoisted_1, [
17
+ _cache[0] || (_cache[0] = createElementVNode("div", { class: "fec-label-line" }, null, -1)),
18
+ createElementVNode("div", _hoisted_2, toDisplayString(__props.label), 1),
19
+ _cache[1] || (_cache[1] = createElementVNode("div", { class: "fec-label-line-query" }, null, -1))
20
+ ]);
21
+ };
22
+ }
23
+ };
24
+ const _FieldSubTitle = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-91f26588"]]);
25
+ export {
26
+ _FieldSubTitle as default
27
+ };
@@ -0,0 +1,10 @@
1
+ import _FieldSubTitle from "./FieldSubTitle.vue.mjs";
2
+ import install from "../../../utils/install.mjs";
3
+ const MobileFieldSubTitle = install.withInstall(
4
+ "MobileFieldSubTitle",
5
+ _FieldSubTitle
6
+ );
7
+ export {
8
+ MobileFieldSubTitle,
9
+ MobileFieldSubTitle as default
10
+ };
@@ -17,7 +17,7 @@ const _sfc_main = {
17
17
  fieldNames: {
18
18
  type: Object,
19
19
  default: {
20
- text: "text",
20
+ text: "label",
21
21
  value: "value",
22
22
  disabled: "disabled"
23
23
  }
@@ -1,23 +1,42 @@
1
1
  /* empty css */
2
2
  /* empty css */
3
- import { createBlock, openBlock, normalizeProps, guardReactiveProps, createSlots, renderList, withCtx, renderSlot } from "vue";
3
+ /* empty css */
4
+ /* empty css */
5
+ /* empty css */
6
+ /* empty css */
7
+ /* empty css */
8
+ import { createBlock, openBlock, withCtx, createElementBlock, Fragment, renderList } from "vue";
9
+ /* empty css */
4
10
  import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
5
11
  import { ActionBar } from "../../../../node_modules/vant/es/action-bar/index.mjs";
6
- const _sfc_main = {};
7
- function _sfc_render(_ctx, _cache) {
8
- const _component_van_action_bar = ActionBar;
9
- return openBlock(), createBlock(_component_van_action_bar, normalizeProps(guardReactiveProps(_ctx.$attrs)), createSlots({ _: 2 }, [
10
- renderList(_ctx.$slots, (item, key) => {
11
- return {
12
- name: key,
13
- fn: withCtx(() => [
14
- renderSlot(_ctx.$slots, key)
15
- ])
16
- };
17
- })
18
- ]), 1040);
19
- }
20
- const _ActionBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
12
+ import { ActionBarButton } from "../../../../node_modules/vant/es/action-bar-button/index.mjs";
13
+ const _sfc_main = {
14
+ __name: "ActionBar",
15
+ props: {
16
+ actionBarOptions: {
17
+ type: Array,
18
+ default: []
19
+ }
20
+ },
21
+ setup(__props) {
22
+ return (_ctx, _cache) => {
23
+ const _component_van_action_bar_button = ActionBarButton;
24
+ const _component_van_action_bar = ActionBar;
25
+ return openBlock(), createBlock(_component_van_action_bar, { "safe-area-inset-bottom": "" }, {
26
+ default: withCtx(() => [
27
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.actionBarOptions, (item) => {
28
+ return openBlock(), createBlock(_component_van_action_bar_button, {
29
+ type: item.type,
30
+ text: item.text
31
+ }, null, 8, ["type", "text"]);
32
+ }), 256))
33
+ ]),
34
+ _: 1
35
+ });
36
+ };
37
+ }
38
+ };
39
+ const _ActionBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-44eb199a"]]);
21
40
  export {
22
41
  _ActionBar as default
23
42
  };
@@ -36,7 +36,8 @@ const _sfc_main = {
36
36
  return openBlock(), createBlock(_component_van_tabbar, mergeProps(_ctx.$attrs, {
37
37
  modelValue: unref(activeName),
38
38
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(activeName) ? activeName.value = $event : null),
39
- fixed: false
39
+ fixed: false,
40
+ "safe-area-inset-bottom": ""
40
41
  }), {
41
42
  default: withCtx(() => [
42
43
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.tabbarOptions, (item) => {
@@ -0,0 +1,28 @@
1
+ import cloneDeep$1 from "../../../../node_modules/lodash-es/cloneDeep.mjs";
2
+ function cloneDeep(data) {
3
+ return cloneDeep$1(data);
4
+ }
5
+ function removeEmptyValues(data) {
6
+ if (typeof data !== "object" || data === null) {
7
+ return data;
8
+ }
9
+ if (Array.isArray(data)) {
10
+ return data.map((item) => removeEmptyValues(item)).filter((item) => {
11
+ return item !== null && item !== void 0 && item !== "";
12
+ });
13
+ }
14
+ const result = {};
15
+ for (const key in data) {
16
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
17
+ const value = removeEmptyValues(data[key]);
18
+ if (value !== null && value !== void 0 && value !== "") {
19
+ result[key] = value;
20
+ }
21
+ }
22
+ }
23
+ return result;
24
+ }
25
+ export {
26
+ cloneDeep,
27
+ removeEmptyValues
28
+ };
@@ -0,0 +1,354 @@
1
+ import { reactive } from "vue";
2
+ import { parseRouteParams } from "./parseRouteParams.mjs";
3
+ import "../../../../node_modules/element-plus/es/index.mjs";
4
+ /* empty css */
5
+ /* empty css */
6
+ /* empty css */
7
+ /* empty css */
8
+ import { ElLoading } from "../../../../node_modules/element-plus/es/components/loading/index.mjs";
9
+ import { ElMessage } from "../../../../node_modules/element-plus/es/components/message/index.mjs";
10
+ class DataSourceManager {
11
+ constructor(options = {}) {
12
+ this.templateId = options.templateId;
13
+ this.http = options.http;
14
+ this.params = options.params || {};
15
+ this.initSearchData = options.initSearchData || {};
16
+ this.dataSources = options.dataSources || [];
17
+ this.currentDataSourceId = options.currentDataSourceId;
18
+ this.pagination = options.pagination || false;
19
+ this.sortRules = reactive(options.sortRules || []);
20
+ this.originalSortRules = JSON.parse(
21
+ JSON.stringify(options.sortRules || [])
22
+ );
23
+ this.showSuccessMessage = options.showSuccessMessage || false;
24
+ this.loading = false;
25
+ this.error = null;
26
+ this.data = reactive({});
27
+ this.contextData = options.data || null;
28
+ this.fields = options.fields || [];
29
+ this.events = {
30
+ loaded: [],
31
+ error: []
32
+ };
33
+ this.LoadingInstance = {
34
+ target: null,
35
+ // 保存Loading实例
36
+ count: 0
37
+ };
38
+ }
39
+ /**
40
+ * 获取当前数据源配置
41
+ */
42
+ getCurrentDataSource() {
43
+ if (!this.currentDataSourceId || !this.dataSources.length) return null;
44
+ return this.dataSources.find((ds) => ds.id == this.currentDataSourceId);
45
+ }
46
+ /**
47
+ * 构建请求参数
48
+ */
49
+ buildRequestParams(extraParams = {}) {
50
+ const currentDs = this.getCurrentDataSource();
51
+ if (!currentDs) return {};
52
+ const params = { ...this.params };
53
+ if (this.templateId) {
54
+ params.tableId = this.templateId;
55
+ }
56
+ if (currentDs.params && Array.isArray(currentDs.params)) {
57
+ const parsedParams = parseRouteParams(
58
+ currentDs.params,
59
+ this.contextData,
60
+ this.fields
61
+ );
62
+ Object.assign(params, parsedParams);
63
+ }
64
+ if (this.pagination) {
65
+ params.pageNo = this.pagination.pageNo;
66
+ params.pageSize = this.pagination.pageSize;
67
+ }
68
+ if (this.sortRules && this.sortRules.length > 0) {
69
+ params.sortRules = JSON.stringify(this.sortRules);
70
+ }
71
+ return { ...this.initSearchData, ...params, ...extraParams };
72
+ }
73
+ /**
74
+ * 根据内容类型处理请求数据
75
+ */
76
+ prepareRequestData(params, contentType) {
77
+ switch (contentType) {
78
+ case "formData":
79
+ const formData = new FormData();
80
+ Object.keys(params).forEach((key) => {
81
+ formData.append(key, params[key]);
82
+ });
83
+ return formData;
84
+ case "formUrlencoded":
85
+ const urlencoded = new URLSearchParams();
86
+ Object.keys(params).forEach((key) => {
87
+ urlencoded.append(key, params[key]);
88
+ });
89
+ return urlencoded;
90
+ case "json":
91
+ default:
92
+ return JSON.stringify(params);
93
+ }
94
+ }
95
+ /**
96
+ * 获取请求配置
97
+ */
98
+ getRequestConfig() {
99
+ const currentDs = this.getCurrentDataSource();
100
+ if (!currentDs) return {};
101
+ const config = {
102
+ url: `/${currentDs.serverName}${currentDs.url}`,
103
+ method: currentDs.method
104
+ };
105
+ if (currentDs.contentType === "formData") {
106
+ config.headers = {
107
+ "Content-Type": "multipart/form-data"
108
+ };
109
+ } else if (currentDs.contentType === "formUrlencoded") {
110
+ config.headers = {
111
+ "Content-Type": "application/x-www-form-urlencoded"
112
+ };
113
+ } else {
114
+ config.headers = {
115
+ "Content-Type": "application/json"
116
+ };
117
+ }
118
+ return config;
119
+ }
120
+ /**
121
+ * 发起请求
122
+ */
123
+ async fetch(extraParams = {}) {
124
+ const currentDs = this.getCurrentDataSource();
125
+ if (!currentDs) {
126
+ console.warn("未找到当前数据源配置");
127
+ return;
128
+ }
129
+ if (!this.http) {
130
+ console.warn("未配置 HTTP 实例");
131
+ return;
132
+ }
133
+ this.loading = true;
134
+ this.error = null;
135
+ this.LoadingInstance.count++;
136
+ if (this.LoadingInstance.count === 1) {
137
+ this.LoadingInstance.target = ElLoading.service({
138
+ fullscreen: true,
139
+ lock: true,
140
+ text: "拼命加载中",
141
+ // spinner: loadingSvg,
142
+ background: "rgba(0, 0, 0, 0)",
143
+ customClass: "h-loading"
144
+ });
145
+ }
146
+ try {
147
+ const params = this.buildRequestParams(extraParams);
148
+ const requestConfig = this.getRequestConfig();
149
+ let response;
150
+ const { url, method } = requestConfig;
151
+ switch (method.toLowerCase()) {
152
+ case "get":
153
+ response = await this.http.get(url, { params });
154
+ break;
155
+ case "post":
156
+ if (currentDs.contentType === "formData") {
157
+ response = await this.http.postForm(url, params, requestConfig);
158
+ } else if (currentDs.contentType === "download") {
159
+ await this.http.download(url, params, requestConfig);
160
+ } else if (currentDs.contentType === "upload") {
161
+ response = await this.http.upload(url, params, requestConfig);
162
+ } else {
163
+ response = await this.http.post(url, params, requestConfig);
164
+ }
165
+ break;
166
+ case "put":
167
+ if (currentDs.contentType === "formData") {
168
+ response = await this.http.putForm(url, params, requestConfig);
169
+ } else {
170
+ response = await this.http.put(url, params, requestConfig);
171
+ }
172
+ break;
173
+ case "delete":
174
+ response = await this.http.delete(url, { params });
175
+ break;
176
+ default:
177
+ response = await this.http.get(url, { params });
178
+ }
179
+ if (response && typeof response === "object" && "code" in response) {
180
+ if (response.code == 0) {
181
+ const responseData = response.data;
182
+ const responseMessage = response.message;
183
+ if (this.pagination) {
184
+ this.data.list = (responseData == null ? void 0 : responseData.records) || responseData;
185
+ this.data.total = (responseData == null ? void 0 : responseData.total) || (responseData == null ? void 0 : responseData.length);
186
+ } else {
187
+ this.data = responseData;
188
+ }
189
+ this.emit("loaded", this.data);
190
+ if (this.showSuccessMessage && responseMessage) {
191
+ ElMessage.success(responseMessage);
192
+ }
193
+ return this.data;
194
+ } else {
195
+ this.error = response.message || "请求失败";
196
+ this.emit("error", this.error);
197
+ throw new Error(this.error);
198
+ }
199
+ } else {
200
+ const responseData = response;
201
+ if (this.pagination) {
202
+ this.data.list = (responseData == null ? void 0 : responseData.records) || responseData;
203
+ this.data.total = (responseData == null ? void 0 : responseData.total) || (responseData == null ? void 0 : responseData.length);
204
+ } else {
205
+ this.data = responseData;
206
+ }
207
+ this.emit("loaded", this.data);
208
+ return this.data;
209
+ }
210
+ } catch (err) {
211
+ this.error = err.message || "请求失败";
212
+ this.emit("error", err);
213
+ throw err;
214
+ } finally {
215
+ this.closeLoading();
216
+ }
217
+ }
218
+ /**
219
+ * 事件监听
220
+ */
221
+ on(event, callback) {
222
+ if (this.events[event]) {
223
+ this.events[event].push(callback);
224
+ }
225
+ }
226
+ /**
227
+ * 移除事件监听
228
+ */
229
+ off(event, callback) {
230
+ if (this.events[event]) {
231
+ const index = this.events[event].indexOf(callback);
232
+ if (index > -1) {
233
+ this.events[event].splice(index, 1);
234
+ }
235
+ }
236
+ }
237
+ /**
238
+ * 触发事件
239
+ */
240
+ emit(event, data) {
241
+ if (this.events[event]) {
242
+ this.events[event].forEach((callback) => {
243
+ callback(data);
244
+ });
245
+ }
246
+ }
247
+ /**
248
+ * 更新分页
249
+ */
250
+ updatePagination(pageNo, pageSize) {
251
+ this.pagination.pageNo = pageNo;
252
+ this.pagination.pageSize = pageSize;
253
+ }
254
+ /**
255
+ * 更新排序
256
+ */
257
+ updateSort(field, order) {
258
+ const existingIndex = this.sortRules.findIndex((rule) => rule.field === field);
259
+ if (!order) {
260
+ if (existingIndex > -1) {
261
+ this.sortRules.splice(existingIndex, 1);
262
+ }
263
+ } else {
264
+ if (existingIndex > -1) {
265
+ this.sortRules.splice(existingIndex, 1);
266
+ }
267
+ this.sortRules.unshift({ field, order });
268
+ }
269
+ }
270
+ /**
271
+ * 清空排序规则 - 重置为原始配置
272
+ */
273
+ clearSort() {
274
+ this.sortRules.splice(0, this.sortRules.length);
275
+ this.originalSortRules.forEach((rule) => {
276
+ this.sortRules.push({ ...rule });
277
+ });
278
+ }
279
+ /**
280
+ * 切换数据源
281
+ */
282
+ switchDataSource(dataSourceId) {
283
+ this.currentDataSourceId = dataSourceId;
284
+ }
285
+ /**
286
+ * 获取当前数据
287
+ */
288
+ getData() {
289
+ return this.data;
290
+ }
291
+ /**
292
+ * 获取加载状态
293
+ */
294
+ getLoading() {
295
+ return this.loading;
296
+ }
297
+ closeLoading() {
298
+ if (this.LoadingInstance.count > 0) {
299
+ this.LoadingInstance.count--;
300
+ }
301
+ if (this.LoadingInstance.count === 0 && this.LoadingInstance.target) {
302
+ this.LoadingInstance.target.close();
303
+ this.LoadingInstance.target = null;
304
+ }
305
+ }
306
+ /**
307
+ * 获取错误信息
308
+ */
309
+ getError() {
310
+ return this.error;
311
+ }
312
+ /**
313
+ * 获取分页信息
314
+ */
315
+ getPagination() {
316
+ return this.pagination;
317
+ }
318
+ /**
319
+ * 获取当前请求参数
320
+ */
321
+ getParams() {
322
+ return this.params;
323
+ }
324
+ /**
325
+ * 更新请求参数
326
+ */
327
+ updateParams(newParams) {
328
+ this.params = { ...this.params, ...newParams };
329
+ }
330
+ updateInitSearchData(newParams) {
331
+ this.initSearchData = newParams;
332
+ }
333
+ /**
334
+ * 清空请求参数
335
+ */
336
+ clearParams() {
337
+ this.params = {};
338
+ }
339
+ /**
340
+ * 销毁
341
+ */
342
+ destroy() {
343
+ this.events.loaded = [];
344
+ this.events.error = [];
345
+ }
346
+ }
347
+ function createDataSource(options = {}) {
348
+ return new DataSourceManager(options);
349
+ }
350
+ export {
351
+ DataSourceManager,
352
+ createDataSource,
353
+ DataSourceManager as default
354
+ };