@kp-ui/lowcode-pc-v2 0.0.1
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.
- package/_virtual/_plugin-vue_export-helper.js +8 -0
- package/assets/styles/style.css +471 -0
- package/core/src/components/common/render/Debugger.js +7 -0
- package/core/src/components/common/render/Debugger.vue_vue_type_script_setup_true_lang.js +43 -0
- package/core/src/components/common/render/LowcodeRenderProvider.js +5 -0
- package/core/src/components/common/render/LowcodeRenderProvider.vue_vue_type_script_setup_true_lang.js +49 -0
- package/core/src/components/common/render/RenderWidgetList.js +5 -0
- package/core/src/components/common/render/RenderWidgetList.vue_vue_type_script_setup_true_lang.js +52 -0
- package/core/src/components/common/render/usePageContext.js +238 -0
- package/core/src/components/property-editor/propertyRegister.js +29 -0
- package/core/src/constants/EditorTypeEnum.js +9 -0
- package/core/src/constants/WidgetTypeEnum.js +15 -0
- package/core/src/constants/index.js +10 -0
- package/core/src/hooks/useAppRef.js +46 -0
- package/core/src/hooks/useFactoryRender.js +60 -0
- package/core/src/hooks/useField.js +430 -0
- package/core/src/hooks/useFieldRules.js +66 -0
- package/core/src/hooks/useLowcode.js +144 -0
- package/core/src/hooks/usePagination.js +23 -0
- package/core/src/hooks/useRemoteData.js +113 -0
- package/core/src/hooks/useSelect.js +137 -0
- package/core/src/hooks/useWebMCP.js +50 -0
- package/core/src/lang/en-US.js +658 -0
- package/core/src/lang/en-US_extension.js +23 -0
- package/core/src/lang/en-US_render.js +36 -0
- package/core/src/lang/zh-CN.js +717 -0
- package/core/src/lang/zh-CN_extension.js +18 -0
- package/core/src/lang/zh-CN_render.js +36 -0
- package/core/src/store/useTableColumnStore.js +37 -0
- package/core/src/utils/format.js +40 -0
- package/core/src/utils/getWidgetCompontent.js +27 -0
- package/core/src/utils/i18n.js +38 -0
- package/core/src/utils/smart-vue-i18n/index.js +79 -0
- package/core/src/utils/transformPx.js +9 -0
- package/core/src/utils/useEmitter.js +24 -0
- package/core/src/utils/util.js +61 -0
- package/install.js +16 -0
- package/package.json +39 -0
- package/src/components/public/ActionButtonListRender.js +51 -0
- package/src/components/public/ActionButtonListRender.vue_vue_type_script_lang.js +126 -0
- package/src/components/public/ConfigView/CustomPageRender.js +5 -0
- package/src/components/public/ConfigView/CustomPageRender.vue_vue_type_script_setup_true_lang.js +38 -0
- package/src/components/public/CustomerModal/CustomerModal.js +5 -0
- package/src/components/public/CustomerModal/CustomerModal.vue_vue_type_script_setup_true_lang.js +138 -0
- package/src/components/public/CustomerModal/useCustomerModal.js +23 -0
- package/src/components/public/DataTableColumnDialog.js +7 -0
- package/src/components/public/DataTableColumnDialog.vue_vue_type_script_setup_true_name_DataTableColumnDialog_lang.js +330 -0
- package/src/hooks/useTableWidget.js +317 -0
- package/src/render/index.js +7 -0
- package/src/render/index.vue_vue_type_script_setup_true_lang.js +69 -0
- package/src/schemas/defaults/field.js +72 -0
- package/src/widgets/advanced/code-editor/index.js +7 -0
- package/src/widgets/advanced/code-editor/index.vue_vue_type_script_setup_true_lang.js +45 -0
- package/src/widgets/advanced/code-editor/schema.js +26 -0
- package/src/widgets/advanced/custom-render/index.js +5 -0
- package/src/widgets/advanced/custom-render/index.vue_vue_type_script_setup_true_lang.js +54 -0
- package/src/widgets/advanced/custom-render/schema.js +19 -0
- package/src/widgets/advanced/data-table/index.js +7 -0
- package/src/widgets/advanced/data-table/index.vue_vue_type_script_setup_true_lang.js +132 -0
- package/src/widgets/advanced/data-table/schema.js +108 -0
- package/src/widgets/advanced/file-upload/index.js +7 -0
- package/src/widgets/advanced/file-upload/index.vue_vue_type_script_setup_true_lang.js +166 -0
- package/src/widgets/advanced/file-upload/schema.js +35 -0
- package/src/widgets/advanced/rich-editor/index.js +7 -0
- package/src/widgets/advanced/rich-editor/index.vue_vue_type_script_setup_true_lang.js +56 -0
- package/src/widgets/advanced/rich-editor/schema.js +28 -0
- package/src/widgets/advanced/tree/index.js +7 -0
- package/src/widgets/advanced/tree/index.vue_vue_type_script_setup_true_lang.js +74 -0
- package/src/widgets/advanced/tree/schema.js +28 -0
- package/src/widgets/advanced/tree-select/index.js +5 -0
- package/src/widgets/advanced/tree-select/index.vue_vue_type_script_setup_true_lang.js +100 -0
- package/src/widgets/advanced/tree-select/schema.js +34 -0
- package/src/widgets/base/button/index.js +5 -0
- package/src/widgets/base/button/index.vue_vue_type_script_setup_true_lang.js +42 -0
- package/src/widgets/base/button/schema.js +33 -0
- package/src/widgets/base/button-list/index.js +7 -0
- package/src/widgets/base/button-list/index.vue_vue_type_script_setup_true_lang.js +41 -0
- package/src/widgets/base/button-list/schema.js +29 -0
- package/src/widgets/base/cascader/index.js +5 -0
- package/src/widgets/base/cascader/index.vue_vue_type_script_setup_true_lang.js +65 -0
- package/src/widgets/base/cascader/schema.js +31 -0
- package/src/widgets/base/checkbox/index.js +5 -0
- package/src/widgets/base/checkbox/index.vue_vue_type_script_setup_true_lang.js +61 -0
- package/src/widgets/base/checkbox/schema.js +25 -0
- package/src/widgets/base/color/index.js +7 -0
- package/src/widgets/base/color/index.vue_vue_type_script_setup_true_lang.js +50 -0
- package/src/widgets/base/color/schema.js +22 -0
- package/src/widgets/base/date/index.js +5 -0
- package/src/widgets/base/date/index.vue_vue_type_script_setup_true_lang.js +43 -0
- package/src/widgets/base/date/schema.js +32 -0
- package/src/widgets/base/date-range/index.js +5 -0
- package/src/widgets/base/date-range/index.vue_vue_type_script_setup_true_lang.js +44 -0
- package/src/widgets/base/date-range/schema.js +32 -0
- package/src/widgets/base/divider/index.js +5 -0
- package/src/widgets/base/divider/index.vue_vue_type_script_setup_true_lang.js +40 -0
- package/src/widgets/base/divider/schema.js +26 -0
- package/src/widgets/base/html/index.js +7 -0
- package/src/widgets/base/html/index.vue_vue_type_script_setup_true_lang.js +33 -0
- package/src/widgets/base/html/schema.js +25 -0
- package/src/widgets/base/input/index.js +5 -0
- package/src/widgets/base/input/index.vue_vue_type_script_setup_true_lang.js +78 -0
- package/src/widgets/base/input/schema.js +37 -0
- package/src/widgets/base/number/index.js +5 -0
- package/src/widgets/base/number/index.vue_vue_type_script_setup_true_lang.js +52 -0
- package/src/widgets/base/number/schema.js +31 -0
- package/src/widgets/base/radio/index.js +5 -0
- package/src/widgets/base/radio/index.vue_vue_type_script_setup_true_lang.js +61 -0
- package/src/widgets/base/radio/schema.js +26 -0
- package/src/widgets/base/rate/index.js +5 -0
- package/src/widgets/base/rate/index.vue_vue_type_script_setup_true_lang.js +52 -0
- package/src/widgets/base/rate/schema.js +24 -0
- package/src/widgets/base/select/index.js +7 -0
- package/src/widgets/base/select/index.vue_vue_type_script_setup_true_lang.js +94 -0
- package/src/widgets/base/select/schema.js +34 -0
- package/src/widgets/base/slider/index.js +5 -0
- package/src/widgets/base/slider/index.vue_vue_type_script_setup_true_lang.js +37 -0
- package/src/widgets/base/slider/schema.js +26 -0
- package/src/widgets/base/static-text/index.js +7 -0
- package/src/widgets/base/static-text/index.vue_vue_type_script_setup_true_lang.js +24 -0
- package/src/widgets/base/static-text/schema.js +28 -0
- package/src/widgets/base/switch/index.js +5 -0
- package/src/widgets/base/switch/index.vue_vue_type_script_setup_true_lang.js +40 -0
- package/src/widgets/base/switch/schema.js +25 -0
- package/src/widgets/base/textarea/index.js +7 -0
- package/src/widgets/base/textarea/index.vue_vue_type_script_setup_true_lang.js +50 -0
- package/src/widgets/base/textarea/schema.js +30 -0
- package/src/widgets/base/time/index.js +7 -0
- package/src/widgets/base/time/index.vue_vue_type_script_setup_true_lang.js +47 -0
- package/src/widgets/base/time/schema.js +33 -0
- package/src/widgets/base/time-range/index.js +7 -0
- package/src/widgets/base/time-range/index.vue_vue_type_script_setup_true_lang.js +48 -0
- package/src/widgets/base/time-range/schema.js +31 -0
- package/src/widgets/containers/box/index-render.js +7 -0
- package/src/widgets/containers/box/index-render.vue_vue_type_script_setup_true_lang.js +39 -0
- package/src/widgets/containers/box/schema.js +29 -0
- package/src/widgets/containers/collapse/index-render.js +8 -0
- package/src/widgets/containers/collapse/index-render.vue_vue_type_script_setup_true_lang.js +49 -0
- package/src/widgets/containers/collapse/schema.js +25 -0
- package/src/widgets/containers/dialog/index-render.js +5 -0
- package/src/widgets/containers/dialog/index-render.vue_vue_type_script_setup_true_lang.js +107 -0
- package/src/widgets/containers/dialog/schema.js +38 -0
- package/src/widgets/containers/form/index-render.js +7 -0
- package/src/widgets/containers/form/index-render.vue_vue_type_script_setup_true_lang.js +46 -0
- package/src/widgets/containers/form/schema.js +33 -0
- package/src/widgets/containers/grid/index-render.js +7 -0
- package/src/widgets/containers/grid/index-render.vue_vue_type_script_setup_true_lang.js +56 -0
- package/src/widgets/containers/grid/schema.js +22 -0
- package/src/widgets/containers/grid-col/index-render.js +7 -0
- package/src/widgets/containers/grid-col/index-render.vue_vue_type_script_setup_true_lang.js +46 -0
- package/src/widgets/containers/grid-col/schema.js +27 -0
- package/src/widgets/containers/list/index-render.js +7 -0
- package/src/widgets/containers/list/index-render.vue_vue_type_script_setup_true_lang.js +189 -0
- package/src/widgets/containers/list/schema.js +46 -0
- package/src/widgets/containers/space/index-render.js +7 -0
- package/src/widgets/containers/space/index-render.vue_vue_type_script_setup_true_lang.js +57 -0
- package/src/widgets/containers/space/schema.js +25 -0
- package/src/widgets/containers/tab/index-render.js +5 -0
- package/src/widgets/containers/tab/index-render.vue_vue_type_script_setup_true_lang.js +81 -0
- package/src/widgets/containers/tab/schema.js +32 -0
- package/src/widgets/containers/tab-pane/index-render.js +5 -0
- package/src/widgets/containers/tab-pane/index-render.vue_vue_type_script_setup_true_lang.js +37 -0
- package/src/widgets/containers/tab-pane/schema.js +31 -0
- package/src/widgets/render.js +165 -0
- package/src/widgets/template/SecondaryPage/index-render.js +7 -0
- package/src/widgets/template/SecondaryPage/index-render.vue_vue_type_script_setup_true_lang.js +63 -0
- package/src/widgets/template/SecondaryPage/schema.js +68 -0
- package/src/widgets/widgetTypes.js +52 -0
- package/src/widgets/wrapper/form-item-wrapper.js +7 -0
- package/src/widgets/wrapper/form-item-wrapper.vue_vue_type_script_setup_true_lang.js +90 -0
- package/stats.html +4949 -0
- package/types/pc/install.d.ts +11 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { usePagination } from "./usePagination.js";
|
|
2
|
+
import { computed, ref, watch } from "vue";
|
|
3
|
+
import { useExecFunction } from "tmgc2-share";
|
|
4
|
+
import { debounce } from "lodash-es";
|
|
5
|
+
import _asyncToGenerator from "@oxc-project/runtime/helpers/asyncToGenerator";
|
|
6
|
+
//#region ../core/src/hooks/useRemoteData.ts
|
|
7
|
+
function useRemoteData({ widget, onLoaded, formConfig }) {
|
|
8
|
+
var _widget$dataSource;
|
|
9
|
+
const loading = ref(false);
|
|
10
|
+
const data = ref([]);
|
|
11
|
+
const { pagination, getPagination, setPagination } = usePagination((_widget$dataSource = widget.dataSource) === null || _widget$dataSource === void 0 || (_widget$dataSource = _widget$dataSource.pagination) === null || _widget$dataSource === void 0 ? void 0 : _widget$dataSource.pageSize);
|
|
12
|
+
const { execHttpFunction } = useExecFunction();
|
|
13
|
+
const dataSource = computed(() => (widget === null || widget === void 0 ? void 0 : widget.dataSource) || {});
|
|
14
|
+
const autoLoad = computed(() => {
|
|
15
|
+
var _widget$dataSource2;
|
|
16
|
+
return (_widget$dataSource2 = widget.dataSource) === null || _widget$dataSource2 === void 0 || (_widget$dataSource2 = _widget$dataSource2.remote) === null || _widget$dataSource2 === void 0 ? void 0 : _widget$dataSource2.autoLoad;
|
|
17
|
+
});
|
|
18
|
+
const isRemote = computed(() => dataSource.value.type === "remote");
|
|
19
|
+
const httpMethod = computed(() => {
|
|
20
|
+
var _dataSource$value$rem;
|
|
21
|
+
const http = (_dataSource$value$rem = dataSource.value.remote) === null || _dataSource$value$rem === void 0 ? void 0 : _dataSource$value$rem.httpMethod;
|
|
22
|
+
if (http) {
|
|
23
|
+
var _formConfig$value$ser;
|
|
24
|
+
return ((_formConfig$value$ser = formConfig.value.serveList) === null || _formConfig$value$ser === void 0 ? void 0 : _formConfig$value$ser[http]) || null;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
});
|
|
28
|
+
const loadingPage = computed(() => {
|
|
29
|
+
var _dataSource$value;
|
|
30
|
+
return (_dataSource$value = dataSource.value) === null || _dataSource$value === void 0 ? void 0 : _dataSource$value.loadingPage;
|
|
31
|
+
});
|
|
32
|
+
const initPager = () => {
|
|
33
|
+
var _widget$dataSource3;
|
|
34
|
+
setPagination({
|
|
35
|
+
current: 1,
|
|
36
|
+
pageSize: (_widget$dataSource3 = widget.dataSource) === null || _widget$dataSource3 === void 0 || (_widget$dataSource3 = _widget$dataSource3.pagination) === null || _widget$dataSource3 === void 0 ? void 0 : _widget$dataSource3.pageSize,
|
|
37
|
+
total: 0,
|
|
38
|
+
totalPage: 0
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const loadData = function() {
|
|
42
|
+
var _ref = _asyncToGenerator(function* () {
|
|
43
|
+
if (!isRemote.value) {
|
|
44
|
+
data.value = dataSource.value.data || [];
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (loading.value) return;
|
|
48
|
+
loading.value = true;
|
|
49
|
+
if (pagination.value.current === 1) initPager();
|
|
50
|
+
try {
|
|
51
|
+
if (!httpMethod.value) {
|
|
52
|
+
loading.value = false;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const { dataHandlerCode, dataReqHandlerCode, http } = httpMethod.value;
|
|
56
|
+
const params = loadingPage.value ? {
|
|
57
|
+
page: pagination.value.current,
|
|
58
|
+
pageSize: pagination.value.pageSize
|
|
59
|
+
} : {};
|
|
60
|
+
const result = yield execHttpFunction({
|
|
61
|
+
http,
|
|
62
|
+
dataHandlerCode,
|
|
63
|
+
dataReqHandlerCode
|
|
64
|
+
}, { data: params });
|
|
65
|
+
if (!result) {
|
|
66
|
+
loading.value = false;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (loadingPage.value) {
|
|
70
|
+
pagination.value.total = result.total || 0;
|
|
71
|
+
pagination.value.totalPage = result.totalPage || 0;
|
|
72
|
+
}
|
|
73
|
+
data.value = result.list;
|
|
74
|
+
onLoaded === null || onLoaded === void 0 || onLoaded(result);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.error("remote data load error:", err);
|
|
77
|
+
} finally {
|
|
78
|
+
loading.value = false;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return function loadData() {
|
|
82
|
+
return _ref.apply(this, arguments);
|
|
83
|
+
};
|
|
84
|
+
}();
|
|
85
|
+
const loadMore = debounce(() => {
|
|
86
|
+
if (pagination.value.totalPage === pagination.value.current) return;
|
|
87
|
+
pagination.value.current += 1;
|
|
88
|
+
}, 500);
|
|
89
|
+
const refresh = () => {
|
|
90
|
+
pagination.value.current = 1;
|
|
91
|
+
};
|
|
92
|
+
watch(() => [pagination.value.current, pagination.value.pageSize], () => {
|
|
93
|
+
loadData();
|
|
94
|
+
});
|
|
95
|
+
watch(() => [autoLoad.value, httpMethod.value], ([val, val1]) => {
|
|
96
|
+
if (val || val1) loadData();
|
|
97
|
+
}, { immediate: true });
|
|
98
|
+
return {
|
|
99
|
+
getPagination,
|
|
100
|
+
setPagination,
|
|
101
|
+
loadData,
|
|
102
|
+
refresh,
|
|
103
|
+
autoLoad,
|
|
104
|
+
loading,
|
|
105
|
+
data,
|
|
106
|
+
pagination,
|
|
107
|
+
isRemote,
|
|
108
|
+
loadingPage,
|
|
109
|
+
loadMore
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { useRemoteData };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { useRemoteData } from "./useRemoteData.js";
|
|
2
|
+
import { computed, ref, unref } from "vue";
|
|
3
|
+
import _objectSpread from "@oxc-project/runtime/helpers/objectSpread2";
|
|
4
|
+
import { cloneDeep, isArray } from "lodash-es";
|
|
5
|
+
//#region ../core/src/hooks/useSelect.ts
|
|
6
|
+
function findInArray(arrayObject, element) {
|
|
7
|
+
if (!Array.isArray(arrayObject)) return -1;
|
|
8
|
+
let foundIdx = -1;
|
|
9
|
+
arrayObject.forEach((aItem, aIdx) => {
|
|
10
|
+
if (aItem === element) foundIdx = aIdx;
|
|
11
|
+
});
|
|
12
|
+
return foundIdx;
|
|
13
|
+
}
|
|
14
|
+
function useSelect({ widget, designState, fieldModel, formConfig }) {
|
|
15
|
+
const keyword = ref({ val: "" });
|
|
16
|
+
const apiResult = ref({ list: [] });
|
|
17
|
+
const onLoaded = (result) => {
|
|
18
|
+
const data = result.data || {};
|
|
19
|
+
if (data) apiResult.value = isArray(data) ? { list: [...unref(apiResult).list, ...data] } : _objectSpread(_objectSpread({}, data), {}, { list: [...unref(apiResult).list, ...data.list] });
|
|
20
|
+
};
|
|
21
|
+
const { loadData, loadMore, refresh, data, pager, loading } = useRemoteData({
|
|
22
|
+
widget,
|
|
23
|
+
designState,
|
|
24
|
+
onLoaded,
|
|
25
|
+
formConfig
|
|
26
|
+
});
|
|
27
|
+
const mapping = computed(() => {
|
|
28
|
+
var _widget$dataSource;
|
|
29
|
+
return (widget === null || widget === void 0 || (_widget$dataSource = widget.dataSource) === null || _widget$dataSource === void 0 ? void 0 : _widget$dataSource.mapping) || {};
|
|
30
|
+
});
|
|
31
|
+
const labelKey = computed(() => {
|
|
32
|
+
var _mapping$value;
|
|
33
|
+
return ((_mapping$value = mapping.value) === null || _mapping$value === void 0 ? void 0 : _mapping$value.labelField) || "label";
|
|
34
|
+
});
|
|
35
|
+
const valueKey = computed(() => {
|
|
36
|
+
var _mapping$value2;
|
|
37
|
+
return ((_mapping$value2 = mapping.value) === null || _mapping$value2 === void 0 ? void 0 : _mapping$value2.valueField) || "value";
|
|
38
|
+
});
|
|
39
|
+
const childrenKey = computed(() => {
|
|
40
|
+
var _mapping$value3;
|
|
41
|
+
return ((_mapping$value3 = mapping.value) === null || _mapping$value3 === void 0 ? void 0 : _mapping$value3.childrenField) || "children";
|
|
42
|
+
});
|
|
43
|
+
const fieldNames = computed(() => ({
|
|
44
|
+
label: unref(labelKey) || "label",
|
|
45
|
+
value: unref(valueKey) || "value",
|
|
46
|
+
children: unref(childrenKey) || "children"
|
|
47
|
+
}));
|
|
48
|
+
const filterOption = (inputValue, option) => {
|
|
49
|
+
var _option$labelKey$valu;
|
|
50
|
+
return String((_option$labelKey$valu = option[labelKey.value]) !== null && _option$labelKey$valu !== void 0 ? _option$labelKey$valu : "").toLowerCase().includes(inputValue.toLowerCase());
|
|
51
|
+
};
|
|
52
|
+
const remoteQuery = (_keyword) => {
|
|
53
|
+
if (!widget.props.showSearch) return;
|
|
54
|
+
if (designState) return;
|
|
55
|
+
keyword.value.val = _keyword;
|
|
56
|
+
};
|
|
57
|
+
const selectOps = computed(() => {
|
|
58
|
+
var _apiResult$value;
|
|
59
|
+
const showSearch = true;
|
|
60
|
+
const useServer = widget.props.showSearch;
|
|
61
|
+
return {
|
|
62
|
+
loading: loading.value,
|
|
63
|
+
showSearch,
|
|
64
|
+
fieldNames: unref(fieldNames),
|
|
65
|
+
onPopupScroll: loadMore,
|
|
66
|
+
onSearch: remoteQuery,
|
|
67
|
+
filterOption: !useServer && filterOption,
|
|
68
|
+
listHeight: 240,
|
|
69
|
+
options: cloneDeep(((_apiResult$value = apiResult.value) === null || _apiResult$value === void 0 ? void 0 : _apiResult$value.list) || [])
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
const getOptionItems = () => {
|
|
73
|
+
return data.value || [];
|
|
74
|
+
};
|
|
75
|
+
const getSelectedItem = () => {
|
|
76
|
+
const list = getOptionItems();
|
|
77
|
+
const vk = valueKey.value;
|
|
78
|
+
if (isArray(fieldModel.value)) return list.filter((item) => findInArray(fieldModel.value, item[vk]) !== -1);
|
|
79
|
+
return list.find((item) => item[vk] == fieldModel.value);
|
|
80
|
+
};
|
|
81
|
+
const optionLabel = computed(() => {
|
|
82
|
+
if (fieldModel.value === null) return "";
|
|
83
|
+
let resultContent = "";
|
|
84
|
+
const vk = valueKey.value;
|
|
85
|
+
const lk = labelKey.value;
|
|
86
|
+
(data.value || []).forEach((oItem) => {
|
|
87
|
+
if (oItem[vk] === fieldModel.value || findInArray(fieldModel.value, oItem[vk]) !== -1) resultContent = resultContent === "" ? oItem[lk] : resultContent + " " + oItem[lk];
|
|
88
|
+
});
|
|
89
|
+
return resultContent;
|
|
90
|
+
});
|
|
91
|
+
const disableOption = (optionValue) => {
|
|
92
|
+
const optionList = data.value || [];
|
|
93
|
+
const vk = valueKey.value;
|
|
94
|
+
optionList.forEach((opt) => {
|
|
95
|
+
if (opt[vk] === optionValue) opt.disabled = true;
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const enableOption = (optionValue) => {
|
|
99
|
+
const optionList = data.value || [];
|
|
100
|
+
const vk = valueKey.value;
|
|
101
|
+
optionList.forEach((opt) => {
|
|
102
|
+
if (opt[vk] === optionValue) opt.disabled = false;
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
selectDefineExpose: {
|
|
107
|
+
loadOptions: loadData,
|
|
108
|
+
initOptionItems: loadData,
|
|
109
|
+
getSelectedItem,
|
|
110
|
+
disableOption,
|
|
111
|
+
clearOptionItems: loadData,
|
|
112
|
+
enableOption,
|
|
113
|
+
getOptionItems,
|
|
114
|
+
keyword: unref(keyword)
|
|
115
|
+
},
|
|
116
|
+
fieldNames,
|
|
117
|
+
data,
|
|
118
|
+
loadData,
|
|
119
|
+
loadMore,
|
|
120
|
+
refresh,
|
|
121
|
+
disableOption,
|
|
122
|
+
clearOptionItems: loadData,
|
|
123
|
+
childrenKey,
|
|
124
|
+
valueKey,
|
|
125
|
+
labelKey,
|
|
126
|
+
optionLabel,
|
|
127
|
+
filterOption,
|
|
128
|
+
keyword,
|
|
129
|
+
pager,
|
|
130
|
+
loading,
|
|
131
|
+
selectOps,
|
|
132
|
+
initOptionItems: loadData,
|
|
133
|
+
getOptionItems
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { useSelect };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region ../core/src/hooks/useWebMCP.ts
|
|
2
|
+
/**
|
|
3
|
+
* WebMCP 规范注册 Hooks
|
|
4
|
+
* @param context 低代码渲染上下文
|
|
5
|
+
*/
|
|
6
|
+
var useWebMCP = (context) => {
|
|
7
|
+
const registerWebMCPTools = () => {
|
|
8
|
+
window.__LOWCODE_MCP_TOOLS__ = {
|
|
9
|
+
context,
|
|
10
|
+
getPageData: () => {
|
|
11
|
+
var _context$formDataMode;
|
|
12
|
+
return ((_context$formDataMode = context.formDataModel) === null || _context$formDataMode === void 0 ? void 0 : _context$formDataMode.value) || {};
|
|
13
|
+
},
|
|
14
|
+
setPageData: (data) => {
|
|
15
|
+
var _context$formDataMode2;
|
|
16
|
+
if (((_context$formDataMode2 = context.formDataModel) === null || _context$formDataMode2 === void 0 ? void 0 : _context$formDataMode2.value) && data) {
|
|
17
|
+
Object.assign(context.formDataModel.value, data);
|
|
18
|
+
return "表单数据已更新";
|
|
19
|
+
}
|
|
20
|
+
return "更新失败:上下文或数据无效";
|
|
21
|
+
},
|
|
22
|
+
getWidgetsInfo: () => {
|
|
23
|
+
var _context$widgetRefLis;
|
|
24
|
+
return Array.from(((_context$widgetRefLis = context.widgetRefList) === null || _context$widgetRefLis === void 0 || (_context$widgetRefLis = _context$widgetRefLis.value) === null || _context$widgetRefLis === void 0 ? void 0 : _context$widgetRefLis.keys()) || []);
|
|
25
|
+
},
|
|
26
|
+
getFormJson: () => {
|
|
27
|
+
var _context$designer;
|
|
28
|
+
const designer = (_context$designer = context.designer) === null || _context$designer === void 0 ? void 0 : _context$designer.value;
|
|
29
|
+
if (designer) return {
|
|
30
|
+
widgetList: designer.widgetList,
|
|
31
|
+
formConfig: designer.formConfig
|
|
32
|
+
};
|
|
33
|
+
return null;
|
|
34
|
+
},
|
|
35
|
+
setFormJson: (formJson) => {
|
|
36
|
+
var _context$designer2;
|
|
37
|
+
const designer = (_context$designer2 = context.designer) === null || _context$designer2 === void 0 ? void 0 : _context$designer2.value;
|
|
38
|
+
if (designer) {
|
|
39
|
+
designer.loadFormJson(formJson);
|
|
40
|
+
designer.emitHistoryChange();
|
|
41
|
+
return "表单 JSON 已导入";
|
|
42
|
+
}
|
|
43
|
+
return "导入失败:设计器上下文不存在";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
return { registerWebMCPTools };
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { useWebMCP };
|