star-horse-lowcode 2.7.62 → 2.7.65
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/.env.development +3 -0
- package/.env.production +3 -0
- package/.eslintrc-auto-import.json +77 -0
- package/.gitignore +27 -0
- package/.idea/.gitignore +5 -0
- package/.idea/MarsCodeWorkspaceAppSettings.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/modules.xml +8 -0
- package/.idea/testcode.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/watcherTasks.xml +4 -0
- package/.idea/workspace.xml +207 -0
- package/.npmignore +21 -0
- package/.prettierignore +26 -0
- package/README.md +2 -0
- package/auto-imports.d.ts +137 -0
- package/components.d.ts +189 -0
- package/dist/assets/index.css +1 -1
- package/dist/index.es.js +941 -720
- package/dist/types/index.d.ts +8 -8
- package/eslint.config.js +37 -0
- package/index.html +14 -0
- package/package-lock.json +8276 -0
- package/package.json +6 -6
- package/prettier.config.js +20 -0
- package/public/logo.svg +660 -0
- package/src/App.vue +11 -0
- package/src/api/date_utils.ts +219 -0
- package/src/api/finger_utils.ts +71 -0
- package/src/api/form_utils.ts +281 -0
- package/src/api/jquery.min.js +2 -0
- package/src/api/pcas-code.json +1 -0
- package/src/api/settings.ts +81 -0
- package/src/api/star_horse_apis.ts +196 -0
- package/src/api/star_horse_utils.ts +797 -0
- package/src/api/system.ts +351 -0
- package/src/api/user_func.ts +147 -0
- package/src/api/valid_utils.ts +165 -0
- package/src/assets/css/index.scss +908 -0
- package/src/assets/icons.css +574 -0
- package/src/assets/star-horse-icons.woff +0 -0
- package/src/components/comp/ShDynamicForm.vue +160 -0
- package/src/components/comp/ShForm.vue +30 -0
- package/src/components/comp/ShTableListColumn.vue +61 -0
- package/src/components/comp/StarHorseDataSelector.vue +139 -0
- package/src/components/comp/StarHorseDataView.vue +110 -0
- package/src/components/comp/StarHorseDataViewItems.vue +61 -0
- package/src/components/comp/StarHorseDataViewTable.vue +102 -0
- package/src/components/comp/StarHorseDialog.vue +383 -0
- package/src/components/comp/StarHorseDraggable.vue +401 -0
- package/src/components/comp/StarHorseForm.vue +458 -0
- package/src/components/comp/StarHorseFormItem.vue +82 -0
- package/src/components/comp/StarHorseFormList.vue +516 -0
- package/src/components/comp/StarHorseFormTable.vue +56 -0
- package/src/components/comp/StarHorseIcon.vue +76 -0
- package/src/components/comp/StarHorseItem.vue +302 -0
- package/src/components/comp/StarHorseJsonEditor.vue +115 -0
- package/src/components/comp/StarHorsePopover.vue +66 -0
- package/src/components/comp/StarHorseSearchComp.vue +253 -0
- package/src/components/comp/StarHorseStaticTable.vue +395 -0
- package/src/components/comp/StarHorseTableColumn.vue +249 -0
- package/src/components/comp/StarHorseTableComp.vue +1193 -0
- package/src/components/comp/StarHorseTableViewColumn.vue +61 -0
- package/src/components/comp/StarHorseTree.vue +494 -0
- package/src/components/comp/index.ts +22 -0
- package/src/components/comp/items/UTableColumn.vue +65 -0
- package/src/components/comp/items/boxItem.vue +98 -0
- package/src/components/comp/items/callitem.ts +9 -0
- package/src/components/comp/items/cardItem.vue +152 -0
- package/src/components/comp/items/collapseItem.vue +134 -0
- package/src/components/comp/items/dytableItem.vue +135 -0
- package/src/components/comp/items/otherItem.vue +65 -0
- package/src/components/comp/items/tabItem.vue +155 -0
- package/src/components/comp/items/tabPanelItem.vue +110 -0
- package/src/components/comp/items/tableColumn.vue +129 -0
- package/src/components/comp/items/tableItem.vue +97 -0
- package/src/components/comp/items/tablebtn.vue +158 -0
- package/src/components/comp/items/viewBoxItem.vue +55 -0
- package/src/components/comp/items/viewCardItem.vue +47 -0
- package/src/components/comp/items/viewCollapseItem.vue +71 -0
- package/src/components/comp/items/viewDytableItem.vue +77 -0
- package/src/components/comp/items/viewOtherItem.vue +55 -0
- package/src/components/comp/items/viewTabItem.vue +77 -0
- package/src/components/comp/items/viewTabPanelItem.vue +54 -0
- package/src/components/comp/items/viewTableItem.vue +74 -0
- package/src/components/comp/selfcomp.ts +9 -0
- package/src/components/comp/utils/DataPicker.vue +302 -0
- package/src/components/comp/utils/DataTag.vue +51 -0
- package/src/components/cron/Crontab-Day.vue +230 -0
- package/src/components/cron/Crontab-Hour.vue +165 -0
- package/src/components/cron/Crontab-Min.vue +166 -0
- package/src/components/cron/Crontab-Month.vue +166 -0
- package/src/components/cron/Crontab-Result.vue +615 -0
- package/src/components/cron/Crontab-Second.vue +185 -0
- package/src/components/cron/Crontab-Week.vue +208 -0
- package/src/components/cron/Crontab-Year.vue +183 -0
- package/src/components/cron/Crontab.vue +474 -0
- package/src/components/enums/ModuleEnums.ts +10 -0
- package/src/components/enums/ServiceEnums.ts +18 -0
- package/src/components/formcomp/container/box-container.vue +162 -0
- package/src/components/formcomp/container/callitem.ts +9 -0
- package/src/components/formcomp/container/card-container.vue +170 -0
- package/src/components/formcomp/container/collapse-container.vue +133 -0
- package/src/components/formcomp/container/dytable-col.vue +448 -0
- package/src/components/formcomp/container/dytable-container.vue +57 -0
- package/src/components/formcomp/container/dytableUtils.ts +358 -0
- package/src/components/formcomp/container/group-box-container.vue +331 -0
- package/src/components/formcomp/container/index.ts +6 -0
- package/src/components/formcomp/container/tab-container.vue +153 -0
- package/src/components/formcomp/container/table-container.vue +249 -0
- package/src/components/formcomp/items/allitem.ts +9 -0
- package/src/components/formcomp/items/area-item.vue +116 -0
- package/src/components/formcomp/items/audio-item.vue +163 -0
- package/src/components/formcomp/items/autocomplete-item.vue +118 -0
- package/src/components/formcomp/items/barcode-item.vue +87 -0
- package/src/components/formcomp/items/base-json-item.vue +207 -0
- package/src/components/formcomp/items/button-item.vue +228 -0
- package/src/components/formcomp/items/cascade-item.vue +113 -0
- package/src/components/formcomp/items/checkbox-item.vue +97 -0
- package/src/components/formcomp/items/color-item.vue +70 -0
- package/src/components/formcomp/items/cron-item.vue +115 -0
- package/src/components/formcomp/items/datetime-item.vue +99 -0
- package/src/components/formcomp/items/depart-item.vue +51 -0
- package/src/components/formcomp/items/dialog-input-item.vue +207 -0
- package/src/components/formcomp/items/divider-item.vue +66 -0
- package/src/components/formcomp/items/html-item.vue +65 -0
- package/src/components/formcomp/items/htmleditor-item.vue +104 -0
- package/src/components/formcomp/items/icon-item.vue +195 -0
- package/src/components/formcomp/items/image-item.vue +247 -0
- package/src/components/formcomp/items/index.ts +44 -0
- package/src/components/formcomp/items/input-item.vue +150 -0
- package/src/components/formcomp/items/json-array-item.vue +67 -0
- package/src/components/formcomp/items/json-item.vue +66 -0
- package/src/components/formcomp/items/markdown-item.vue +77 -0
- package/src/components/formcomp/items/number-item.vue +94 -0
- package/src/components/formcomp/items/number-range-item.vue +278 -0
- package/src/components/formcomp/items/page-select-item.vue +407 -0
- package/src/components/formcomp/items/password-item.vue +71 -0
- package/src/components/formcomp/items/qrcode-item.vue +84 -0
- package/src/components/formcomp/items/radio-item.vue +112 -0
- package/src/components/formcomp/items/rate-item.vue +68 -0
- package/src/components/formcomp/items/select-item.vue +133 -0
- package/src/components/formcomp/items/signature-item.vue +216 -0
- package/src/components/formcomp/items/slider-item.vue +68 -0
- package/src/components/formcomp/items/starhorse-form-item.vue +334 -0
- package/src/components/formcomp/items/switch-item.vue +77 -0
- package/src/components/formcomp/items/tag-item.vue +77 -0
- package/src/components/formcomp/items/text-item.vue +75 -0
- package/src/components/formcomp/items/textarea-item.vue +85 -0
- package/src/components/formcomp/items/time-item.vue +77 -0
- package/src/components/formcomp/items/time-picker-item.vue +74 -0
- package/src/components/formcomp/items/transfer-item.vue +93 -0
- package/src/components/formcomp/items/tselect-item.vue +121 -0
- package/src/components/formcomp/items/unknown-item.vue +51 -0
- package/src/components/formcomp/items/upload-item.vue +189 -0
- package/src/components/formcomp/items/user-item.vue +177 -0
- package/src/components/formcomp/items/usercomp-item.vue +85 -0
- package/src/components/formcomp/items/view-markdown-item.vue +77 -0
- package/src/components/formcomp/utils/EditDataDialog.vue +67 -0
- package/src/components/formcomp/utils/FieldList.vue +125 -0
- package/src/components/formcomp/utils/ItemRelationEventUtils.ts +284 -0
- package/src/components/help.vue +31 -0
- package/src/components/menu/MenuItem.vue +95 -0
- package/src/components/menu/SubMenu.vue +68 -0
- package/src/components/menu/SubSystemMenu.vue +142 -0
- package/src/components/register.ts +24 -0
- package/src/components/system/ContentMenu.vue +260 -0
- package/src/components/system/StarHorseButtonList.vue +344 -0
- package/src/components/system/StarHorseMenu.vue +97 -0
- package/src/components/system/StarHorseSvg.vue +62 -0
- package/src/components/system/SystemComp.ts +9 -0
- package/src/components/system/index.ts +4 -0
- package/src/components/types/ApiUrls.ts +168 -0
- package/src/components/types/BtnAction.ts +51 -0
- package/src/components/types/BtnAuth.ts +43 -0
- package/src/components/types/CompInfo.ts +81 -0
- package/src/components/types/DialogProps.ts +55 -0
- package/src/components/types/DyCompField.ts +23 -0
- package/src/components/types/DynamicNode.ts +42 -0
- package/src/components/types/MenusInfo.ts +45 -0
- package/src/components/types/PageFieldInfo.ts +530 -0
- package/src/components/types/PageProps.ts +25 -0
- package/src/components/types/Params.ts +93 -0
- package/src/components/types/RuleType.ts +10 -0
- package/src/components/types/SearchProps.ts +42 -0
- package/src/components/types/ShortKey.ts +30 -0
- package/src/components/types/StarHorseType.ts +18 -0
- package/src/components/types/index.ts +15 -0
- package/src/config/element.ts +15 -0
- package/src/config/styles.ts +4 -0
- package/src/index.ts +98 -0
- package/src/install.ts +33 -0
- package/src/lang/en_US.ts +81 -0
- package/src/lang/index.ts +35 -0
- package/src/lang/zh_CN.ts +84 -0
- package/src/main.ts +57 -0
- package/src/plugins/AblesPlugin.ts +618 -0
- package/src/plugins/registerCompPlugin.ts +15 -0
- package/src/sample/test.vue +9 -0
- package/src/store/ButtonPermission.ts +101 -0
- package/src/store/ConsumerView.ts +52 -0
- package/src/store/ContinusConfig.ts +78 -0
- package/src/store/CopyerOperation.ts +74 -0
- package/src/store/DesignForm.ts +481 -0
- package/src/store/DesignPage.ts +59 -0
- package/src/store/DynamicForm.ts +241 -0
- package/src/store/GlobalConfig.ts +90 -0
- package/src/store/SelfOperation.ts +95 -0
- package/src/store/UserInfo.ts +88 -0
- package/src/store/index.ts +6 -0
- package/src/theme/localStorge.ts +16 -0
- package/src/theme/theme.ts +27 -0
- package/src/utils/FieldOperationUtils.ts +91 -0
- package/src/utils/auth.ts +83 -0
- package/src/utils/message.ts +69 -0
- package/src/utils/preview.ts +125 -0
- package/tsconfig.json +39 -0
- package/tsconfig.node.json +10 -0
- package/vite-env.d.ts +16 -0
- package/vite.config.ts +162 -0
- package/yarn.lock +4627 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<script setup lang="ts" name="StarHorseSearchComp">
|
|
2
|
+
import { Config } from "@/api/settings";
|
|
3
|
+
import { isJson, searchMatchList } from "@/api/star_horse_utils";
|
|
4
|
+
import { ApiUrls } from "@/components/types/ApiUrls";
|
|
5
|
+
import { SearchParams } from "@/components/types/Params";
|
|
6
|
+
import { SearchFields, SelectOption } from "@/components/types/SearchProps";
|
|
7
|
+
import piniaInstance from "@/store";
|
|
8
|
+
import { useGlobalConfigStore } from "@/store/GlobalConfig";
|
|
9
|
+
import { analysisSearchData } from "@/utils/preview";
|
|
10
|
+
import { computed, nextTick, onMounted, PropType, ref } from "vue";
|
|
11
|
+
|
|
12
|
+
let matchTypeList = ref<SelectOption[]>();
|
|
13
|
+
let sarchIcon = ref<string>("search_down");
|
|
14
|
+
let defaultSearch = ref<boolean>(true);
|
|
15
|
+
let tips = ref<string>("更多查询");
|
|
16
|
+
let showTips = ref<boolean>(true);
|
|
17
|
+
const emits = defineEmits(["searchData"]);
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
dialogInput: { type: Boolean, default: false },
|
|
20
|
+
mutComp: { type: Boolean, default: false },
|
|
21
|
+
compUrl: { type: Object as PropType<ApiUrls> },
|
|
22
|
+
formData: { type: Object as PropType<SearchFields>, required: true },
|
|
23
|
+
defaultCondition: { type: Array<SearchParams> },
|
|
24
|
+
});
|
|
25
|
+
let configStore = useGlobalConfigStore(piniaInstance);
|
|
26
|
+
let compSize = computed(
|
|
27
|
+
() => configStore.configFormInfo?.inputSize || Config.compSize,
|
|
28
|
+
);
|
|
29
|
+
let searchForm = ref<any>({});
|
|
30
|
+
|
|
31
|
+
const createSearchParams = (formData: any) => {
|
|
32
|
+
return analysisSearchData(searchForm.value, formData);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 解析默认值
|
|
36
|
+
*/
|
|
37
|
+
const analysisDefaultValue = () => {
|
|
38
|
+
let defaultDatas: any = {};
|
|
39
|
+
props.formData?.fieldList?.forEach((item: any) => {
|
|
40
|
+
if (item.defaultValue) {
|
|
41
|
+
if (isJson(item.defaultValue)) {
|
|
42
|
+
for (let key in item.defaultValue) {
|
|
43
|
+
defaultDatas[key] = item.defaultValue[key];
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
defaultDatas[item.fieldName] = item.defaultValue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return defaultDatas;
|
|
51
|
+
};
|
|
52
|
+
const dataSearch = (val: string | null) => {
|
|
53
|
+
if (val === "reset") {
|
|
54
|
+
searchForm.value = { ...analysisDefaultValue() };
|
|
55
|
+
}
|
|
56
|
+
let searchDatas = createSearchParams(props.formData?.fieldList);
|
|
57
|
+
//如果一个页面(包括引入的页面)出现多个此组件,不能走消息总线,
|
|
58
|
+
// 默认查询条件,如果设置,在每次的查询中都会带上
|
|
59
|
+
if (props.defaultCondition) {
|
|
60
|
+
searchDatas.push(...props.defaultCondition);
|
|
61
|
+
}
|
|
62
|
+
emits("searchData", searchDatas);
|
|
63
|
+
};
|
|
64
|
+
const searchArea = () => {
|
|
65
|
+
if (defaultSearch.value) {
|
|
66
|
+
tips.value = "更多查询";
|
|
67
|
+
sarchIcon.value = "search_up";
|
|
68
|
+
} else {
|
|
69
|
+
tips.value = "收起";
|
|
70
|
+
sarchIcon.value = "search_down";
|
|
71
|
+
}
|
|
72
|
+
defaultSearch.value = !defaultSearch.value;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* 设置查询值
|
|
76
|
+
* @param data
|
|
77
|
+
*/
|
|
78
|
+
const setData = (data: any) => {
|
|
79
|
+
if (data) {
|
|
80
|
+
searchForm.value = { ...searchForm.value, ...data };
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const init = async () => {
|
|
84
|
+
matchTypeList.value = searchMatchList();
|
|
85
|
+
searchForm.value = { ...analysisDefaultValue() };
|
|
86
|
+
await nextTick();
|
|
87
|
+
//没有隐藏的查询属性,则隐藏掉展开图标
|
|
88
|
+
let fdata = props.formData?.fieldList?.find((item) => !item.defaultVisible);
|
|
89
|
+
if (!fdata && props.formData?.fieldList?.length > 0) {
|
|
90
|
+
showTips.value = false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
onMounted(() => {
|
|
95
|
+
init();
|
|
96
|
+
});
|
|
97
|
+
defineExpose({
|
|
98
|
+
searchForm,
|
|
99
|
+
setData,
|
|
100
|
+
createSearchParams,
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
103
|
+
<template>
|
|
104
|
+
<div class="search_content">
|
|
105
|
+
<el-form class="search_area" :size="compSize" v-if="formData?.fieldList">
|
|
106
|
+
<template v-for="item in formData.fieldList" v-if="defaultSearch">
|
|
107
|
+
<el-form-item
|
|
108
|
+
:size="compSize"
|
|
109
|
+
:label="item.label"
|
|
110
|
+
v-if="item.defaultVisible"
|
|
111
|
+
:prop="item.fieldName"
|
|
112
|
+
>
|
|
113
|
+
<template
|
|
114
|
+
v-if="(!item.type || item.type == 'input') && !item.disabled"
|
|
115
|
+
:span="6"
|
|
116
|
+
>
|
|
117
|
+
<el-select
|
|
118
|
+
:size="compSize"
|
|
119
|
+
style="width: 90px !important; height: 100%; padding-top: 2px"
|
|
120
|
+
v-model="item['matchType']"
|
|
121
|
+
clearable
|
|
122
|
+
filterable
|
|
123
|
+
>
|
|
124
|
+
<el-option
|
|
125
|
+
v-for="sitem in matchTypeList"
|
|
126
|
+
:value="sitem.value"
|
|
127
|
+
:label="sitem.name"
|
|
128
|
+
:key="sitem.value"
|
|
129
|
+
/> </el-select
|
|
130
|
+
>
|
|
131
|
+
</template>
|
|
132
|
+
<star-horse-item
|
|
133
|
+
v-model:data-form="searchForm"
|
|
134
|
+
:compSize="compSize"
|
|
135
|
+
:item="item"
|
|
136
|
+
:source="4"
|
|
137
|
+
@dataSearch="dataSearch"
|
|
138
|
+
/>
|
|
139
|
+
</el-form-item>
|
|
140
|
+
</template>
|
|
141
|
+
<template v-for="item in formData?.fieldList" v-else>
|
|
142
|
+
<el-form-item
|
|
143
|
+
:size="compSize"
|
|
144
|
+
:label="item.label"
|
|
145
|
+
:prop="item.fieldName"
|
|
146
|
+
>
|
|
147
|
+
<template v-if="(!item.type || item.type == 'input') && !item.disabled" :span="6">
|
|
148
|
+
<el-select
|
|
149
|
+
:size="compSize"
|
|
150
|
+
style="width: 90px !important; height: 100%; padding-top: 2px"
|
|
151
|
+
v-model="item['matchType']"
|
|
152
|
+
clearable
|
|
153
|
+
filterable
|
|
154
|
+
>
|
|
155
|
+
<el-option
|
|
156
|
+
v-for="sitem in matchTypeList"
|
|
157
|
+
:value="sitem.value"
|
|
158
|
+
:label="sitem.name"
|
|
159
|
+
:key="sitem.value"
|
|
160
|
+
/> </el-select
|
|
161
|
+
>
|
|
162
|
+
</template>
|
|
163
|
+
<star-horse-item
|
|
164
|
+
v-model:data-form="searchForm"
|
|
165
|
+
:compSize="compSize"
|
|
166
|
+
:item="item"
|
|
167
|
+
:source="4"
|
|
168
|
+
@dataSearch="dataSearch"
|
|
169
|
+
>
|
|
170
|
+
</star-horse-item>
|
|
171
|
+
</el-form-item>
|
|
172
|
+
</template>
|
|
173
|
+
<el-form-item style="vertical-align: middle; align-items: center">
|
|
174
|
+
<div class="search_btn">
|
|
175
|
+
<el-button
|
|
176
|
+
@click="dataSearch"
|
|
177
|
+
style="
|
|
178
|
+
background: var(--star-horse-style);
|
|
179
|
+
color: var(--star-horse-white);
|
|
180
|
+
"
|
|
181
|
+
:size="compSize"
|
|
182
|
+
>
|
|
183
|
+
<star-horse-icon
|
|
184
|
+
icon-class="search"
|
|
185
|
+
size="16px"
|
|
186
|
+
color="var(--star-horse-white)"
|
|
187
|
+
/>
|
|
188
|
+
查询
|
|
189
|
+
</el-button>
|
|
190
|
+
<el-button @click="dataSearch('reset')" link :size="compSize">
|
|
191
|
+
<star-horse-icon
|
|
192
|
+
icon-class="reset"
|
|
193
|
+
size="16px"
|
|
194
|
+
color="var(--star-horse-disable)"
|
|
195
|
+
/>
|
|
196
|
+
重置
|
|
197
|
+
</el-button>
|
|
198
|
+
<el-tooltip :content="tips" v-if="showTips">
|
|
199
|
+
<el-button text @click="searchArea" :size="compSize">
|
|
200
|
+
<star-horse-icon
|
|
201
|
+
:icon-class="sarchIcon"
|
|
202
|
+
size="20px"
|
|
203
|
+
color="var(--star-horse-style)"
|
|
204
|
+
/>
|
|
205
|
+
</el-button>
|
|
206
|
+
</el-tooltip>
|
|
207
|
+
</div>
|
|
208
|
+
</el-form-item>
|
|
209
|
+
</el-form>
|
|
210
|
+
</div>
|
|
211
|
+
</template>
|
|
212
|
+
<style lang="scss" scoped>
|
|
213
|
+
:deep(.el-form-item) {
|
|
214
|
+
width: auto; // 强制设置为自动宽度
|
|
215
|
+
margin-right: 8px !important; // 添加右侧间距
|
|
216
|
+
flex-shrink: 0; // 防止收缩
|
|
217
|
+
margin-bottom: 0 !important;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.el-form-item,
|
|
221
|
+
.el-form-item-small {
|
|
222
|
+
margin-bottom: 0 !important;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
:deep(.el-form-item__label):last-child {
|
|
226
|
+
max-width: 5px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.search_content {
|
|
230
|
+
display: flex;
|
|
231
|
+
flex-direction: column;
|
|
232
|
+
flex: 1;
|
|
233
|
+
|
|
234
|
+
.search_area {
|
|
235
|
+
display: flex;
|
|
236
|
+
flex-wrap: wrap;
|
|
237
|
+
flex-direction: row;
|
|
238
|
+
flex: 1;
|
|
239
|
+
justify-content: left;
|
|
240
|
+
flex-shrink: 0;
|
|
241
|
+
gap: 12px; // 新增间隔控制
|
|
242
|
+
align-items: center; // 新增垂直对齐方式
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.search_btn {
|
|
246
|
+
margin-left: 10px;
|
|
247
|
+
display: flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
justify-content: center;
|
|
250
|
+
vertical-align: middle;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
</style>
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
<script lang="ts" setup name="StarHorseStaticTable">
|
|
2
|
+
import { onMounted, PropType, reactive, ref, unref } from "vue";
|
|
3
|
+
import { commonParseCodeToName } from "@/api/star_horse_utils";
|
|
4
|
+
import Sortable from "sortablejs";
|
|
5
|
+
import { warning } from "@/utils/message";
|
|
6
|
+
import { Config } from "@/api/settings";
|
|
7
|
+
import { compKey } from "@/api/system";
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
//主键
|
|
11
|
+
primaryKey: {
|
|
12
|
+
type: [String, Object] as PropType<string | any>,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
//列名
|
|
16
|
+
fieldList: { type: Object, required: true },
|
|
17
|
+
//格式化方法
|
|
18
|
+
dataFormat: { type: Function, default: null },
|
|
19
|
+
//按钮大小
|
|
20
|
+
compSize: { type: String, default: Config.compSize },
|
|
21
|
+
//弹窗模式
|
|
22
|
+
dialogInput: { type: Boolean, default: false },
|
|
23
|
+
//默认表格高度
|
|
24
|
+
height: { type: String, default: "100%" },
|
|
25
|
+
//默认是否展开所有子节点
|
|
26
|
+
expand: { type: Boolean, default: false },
|
|
27
|
+
showBatchField: { type: Boolean, default: false },
|
|
28
|
+
//是否运行选择父级节点
|
|
29
|
+
allowSelectParent: { type: Boolean, default: true },
|
|
30
|
+
//标题
|
|
31
|
+
title: { type: String },
|
|
32
|
+
|
|
33
|
+
dataList: { type: Array },
|
|
34
|
+
});
|
|
35
|
+
// const emits = defineEmits(["selectItem"]);
|
|
36
|
+
const multipleSelection = ref<any>([]);
|
|
37
|
+
const shStaticTableCompRef = ref();
|
|
38
|
+
let staticDataList = ref<any>([]);
|
|
39
|
+
let toolFields = reactive<Array<any>>([]);
|
|
40
|
+
const getIds = () => {
|
|
41
|
+
let selectDatas = unref(multipleSelection);
|
|
42
|
+
let ids: any = [];
|
|
43
|
+
for (let key in selectDatas) {
|
|
44
|
+
let temp = selectDatas[key];
|
|
45
|
+
ids.push(temp[props.primaryKey]);
|
|
46
|
+
}
|
|
47
|
+
return ids;
|
|
48
|
+
};
|
|
49
|
+
const init = async () => {
|
|
50
|
+
moveColumn();
|
|
51
|
+
reCreateData();
|
|
52
|
+
if (props.dataList) {
|
|
53
|
+
setData(props.dataList);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//监听外面传入数据的变化
|
|
57
|
+
const assignData = (dataList: Array<any>) => {
|
|
58
|
+
for (let key in dataList) {
|
|
59
|
+
let temp: any = dataList[key];
|
|
60
|
+
if (temp instanceof Array) {
|
|
61
|
+
toolFields.push(...temp);
|
|
62
|
+
} else if (temp.tabList?.length > 0) {
|
|
63
|
+
for (let skey in temp.tabList) {
|
|
64
|
+
let stemp = temp.tabList[skey];
|
|
65
|
+
if (stemp["fieldList"]) {
|
|
66
|
+
toolFields.push(...stemp["fieldList"]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
toolFields.push(temp);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const reCreateData = () => {
|
|
75
|
+
toolFields = [];
|
|
76
|
+
let tempList = props.fieldList["fieldList"];
|
|
77
|
+
if (tempList) {
|
|
78
|
+
assignData(tempList);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const moveColumn = () => {
|
|
83
|
+
const tbody = document.querySelector(
|
|
84
|
+
".sh-columns .el-table__body-wrapper tbody",
|
|
85
|
+
) as HTMLElement | null;
|
|
86
|
+
if (tbody) {
|
|
87
|
+
Sortable.create(tbody, {
|
|
88
|
+
handle: ".move",
|
|
89
|
+
animation: 200,
|
|
90
|
+
ghostClass: "ghost",
|
|
91
|
+
onEnd(event: any) {
|
|
92
|
+
const { oldIndex, newIndex } = event;
|
|
93
|
+
//删除并获取当前行
|
|
94
|
+
const currRow = props.fieldList?.fieldList.splice(oldIndex, 1)[0];
|
|
95
|
+
//再拖动结束位置插入当前行
|
|
96
|
+
props.fieldList?.fieldList.splice(newIndex, 0, currRow);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 检查是否可以选择父节点
|
|
104
|
+
* @param val
|
|
105
|
+
*/
|
|
106
|
+
const checkParent = (val: any) => {
|
|
107
|
+
if (props.allowSelectParent) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
let flag = false;
|
|
111
|
+
for (let i in val) {
|
|
112
|
+
let item = val[i];
|
|
113
|
+
if (item["children"] && item["children"].length > 0) {
|
|
114
|
+
flag = true;
|
|
115
|
+
shStaticTableCompRef.value.toggleRowSelection(item, false);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (flag) {
|
|
119
|
+
warning("非叶子节点不能选择");
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
};
|
|
124
|
+
const handleSelectionChange = (val: any) => {
|
|
125
|
+
if (!checkParent(val)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
//如果是弹出选择,只能选择一条数据
|
|
129
|
+
if (props.dialogInput) {
|
|
130
|
+
if (val.length <= 1) {
|
|
131
|
+
multipleSelection.value = val;
|
|
132
|
+
} else {
|
|
133
|
+
let ids = multipleSelection.value.map(
|
|
134
|
+
(item: any) => item[props.primaryKey],
|
|
135
|
+
) as Array<any>;
|
|
136
|
+
let datas = val.filter(
|
|
137
|
+
(item: any) => !ids.includes(item[props.primaryKey]),
|
|
138
|
+
);
|
|
139
|
+
let data = multipleSelection.value[0];
|
|
140
|
+
shStaticTableCompRef.value?.toggleRowSelection(data, true);
|
|
141
|
+
multipleSelection.value = datas;
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
multipleSelection.value = val;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
onMounted(() => {
|
|
148
|
+
init();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const getRowIdentity = (row: any) => {
|
|
152
|
+
let arr = props.primaryKey?.split(".");
|
|
153
|
+
if (arr?.length > 1) {
|
|
154
|
+
let temp = row;
|
|
155
|
+
for (let i in arr) {
|
|
156
|
+
temp = temp[arr[i]];
|
|
157
|
+
}
|
|
158
|
+
return temp;
|
|
159
|
+
}
|
|
160
|
+
return props.primaryKey ? row[props.primaryKey] : "";
|
|
161
|
+
};
|
|
162
|
+
const dataFormat = (row: any, column: any, cellValue: any, _index: number) => {
|
|
163
|
+
cellValue = commonParseCodeToName(column.property, cellValue);
|
|
164
|
+
return null == props.dataFormat
|
|
165
|
+
? cellValue
|
|
166
|
+
: props.dataFormat(column.property, cellValue, row);
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* 单选选择行
|
|
170
|
+
* @param row
|
|
171
|
+
* @param _column
|
|
172
|
+
* @param _evt
|
|
173
|
+
*/
|
|
174
|
+
const selectRow = (row: any, _column: any, _evt: any) => {
|
|
175
|
+
if (!checkParent(row)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (multipleSelection.value.length > 0) {
|
|
179
|
+
for (let valueElement of multipleSelection.value) {
|
|
180
|
+
shStaticTableCompRef.value.toggleRowSelection(valueElement);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const selected = multipleSelection.value?.some(
|
|
184
|
+
(item: any) => item[props.primaryKey] === row[props.primaryKey],
|
|
185
|
+
);
|
|
186
|
+
if (!selected) {
|
|
187
|
+
multipleSelection.value.push(row);
|
|
188
|
+
shStaticTableCompRef.value?.toggleRowSelection(row);
|
|
189
|
+
} else {
|
|
190
|
+
multipleSelection.value = multipleSelection.value.filter((item: any) => {
|
|
191
|
+
return item[props.primaryKey] !== row[props.primaryKey];
|
|
192
|
+
});
|
|
193
|
+
shStaticTableCompRef.value?.toggleRowSelection(row, false);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* 列表赋值
|
|
198
|
+
* @param data
|
|
199
|
+
*/
|
|
200
|
+
const setData = (data: any) => {
|
|
201
|
+
staticDataList.value = data;
|
|
202
|
+
};
|
|
203
|
+
//导出方法和变量
|
|
204
|
+
defineExpose({
|
|
205
|
+
getIds,
|
|
206
|
+
setData,
|
|
207
|
+
});
|
|
208
|
+
</script>
|
|
209
|
+
<template>
|
|
210
|
+
<div class="table-comp">
|
|
211
|
+
<div
|
|
212
|
+
style="
|
|
213
|
+
display: flex;
|
|
214
|
+
justify-content: space-between;
|
|
215
|
+
width: 100%;
|
|
216
|
+
border-bottom: var(--star-horse-style) 1px solid;
|
|
217
|
+
"
|
|
218
|
+
v-if="!dialogInput"
|
|
219
|
+
>
|
|
220
|
+
<div class="tb_title">
|
|
221
|
+
<star-horse-icon
|
|
222
|
+
icon-class="info"
|
|
223
|
+
size="14px"
|
|
224
|
+
style="font-weight: bold; color: var(--star-horse-style)"
|
|
225
|
+
/>
|
|
226
|
+
{{ title }}
|
|
227
|
+
</div>
|
|
228
|
+
<div class="flex items-center flex-row-reverse">
|
|
229
|
+
<el-popover
|
|
230
|
+
trigger="click"
|
|
231
|
+
:popper-style="{ width: 'unset !important' }"
|
|
232
|
+
placement="left-end"
|
|
233
|
+
>
|
|
234
|
+
<template #reference>
|
|
235
|
+
<el-icon class="star-page-icon" style="cursor: pointer">
|
|
236
|
+
<el-tooltip content="显示/隐藏列">
|
|
237
|
+
<Tools />
|
|
238
|
+
</el-tooltip>
|
|
239
|
+
</el-icon>
|
|
240
|
+
</template>
|
|
241
|
+
<el-table
|
|
242
|
+
class="sh-columns"
|
|
243
|
+
ref="table"
|
|
244
|
+
:data="toolFields"
|
|
245
|
+
:strip="true"
|
|
246
|
+
:fit="true"
|
|
247
|
+
:highlight-current-row="true"
|
|
248
|
+
max-height="400px"
|
|
249
|
+
row-key="prop"
|
|
250
|
+
style="width: 100%"
|
|
251
|
+
:size="compSize"
|
|
252
|
+
border
|
|
253
|
+
>
|
|
254
|
+
<el-table-column prop="" label="排序" width="60">
|
|
255
|
+
<el-tag class="move" style="cursor: move" :size="compSize">
|
|
256
|
+
<el-icon style="cursor: move">
|
|
257
|
+
<Sort />
|
|
258
|
+
</el-icon>
|
|
259
|
+
</el-tag>
|
|
260
|
+
</el-table-column>
|
|
261
|
+
<el-table-column
|
|
262
|
+
prop="label"
|
|
263
|
+
label="列名"
|
|
264
|
+
:show-overflow-tooltip="true"
|
|
265
|
+
>
|
|
266
|
+
<template #default="scope">
|
|
267
|
+
<el-tag
|
|
268
|
+
round
|
|
269
|
+
:effect="scope.row.listVisible ? 'dark' : 'light'"
|
|
270
|
+
>
|
|
271
|
+
{{ scope.row.label }}
|
|
272
|
+
</el-tag>
|
|
273
|
+
</template>
|
|
274
|
+
</el-table-column>
|
|
275
|
+
<el-table-column prop="listVisible" label="显示/隐藏" width="100">
|
|
276
|
+
<template #default="scope">
|
|
277
|
+
<el-switch
|
|
278
|
+
v-model="scope.row.listVisible"
|
|
279
|
+
:size="compSize"
|
|
280
|
+
:active-value="true"
|
|
281
|
+
:inactive-value="false"
|
|
282
|
+
/>
|
|
283
|
+
</template>
|
|
284
|
+
</el-table-column>
|
|
285
|
+
</el-table>
|
|
286
|
+
</el-popover>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
<el-table
|
|
291
|
+
ref="shStaticTableCompRef"
|
|
292
|
+
:data="staticDataList"
|
|
293
|
+
@selection-change="handleSelectionChange"
|
|
294
|
+
@row-click="selectRow"
|
|
295
|
+
:row-key="getRowIdentity"
|
|
296
|
+
:stripe="true"
|
|
297
|
+
:fit="true"
|
|
298
|
+
:max-height="height"
|
|
299
|
+
:highlight-current-row="true"
|
|
300
|
+
:default-expand-all="expand"
|
|
301
|
+
:row-style="{
|
|
302
|
+
height: '30px',
|
|
303
|
+
}"
|
|
304
|
+
:cell-style="{
|
|
305
|
+
height: '30px',
|
|
306
|
+
'font-size': '12px',
|
|
307
|
+
}"
|
|
308
|
+
:header-cell-style="{
|
|
309
|
+
background: '#f2f2f2',
|
|
310
|
+
color: '#707070',
|
|
311
|
+
'font-size': '13px',
|
|
312
|
+
'background-image':
|
|
313
|
+
'-webkit-gradient(linear,left 0,left 100%,from(#f8f8f8),to(#ececec))',
|
|
314
|
+
}"
|
|
315
|
+
border
|
|
316
|
+
>
|
|
317
|
+
<el-table-column
|
|
318
|
+
type="selection"
|
|
319
|
+
align="center"
|
|
320
|
+
fixed="left"
|
|
321
|
+
:reserve-selection="true"
|
|
322
|
+
>
|
|
323
|
+
</el-table-column>
|
|
324
|
+
<template
|
|
325
|
+
v-for="item in fieldList['fieldList']"
|
|
326
|
+
:Key="compKey(item, item.id)"
|
|
327
|
+
>
|
|
328
|
+
<template v-if="Array.isArray(item)">
|
|
329
|
+
<star-horse-table-column
|
|
330
|
+
:data-format="dataFormat"
|
|
331
|
+
:cellEditable="fieldList['tableCellEditabled']"
|
|
332
|
+
:item="sitem"
|
|
333
|
+
:key="compKey(sitem, key)"
|
|
334
|
+
v-for="(sitem, key) in item"
|
|
335
|
+
/>
|
|
336
|
+
</template>
|
|
337
|
+
<template v-else-if="item.tabList?.length > 0">
|
|
338
|
+
<star-horse-table-column
|
|
339
|
+
:data-format="dataFormat"
|
|
340
|
+
:cellEditable="fieldList['tableCellEditabled']"
|
|
341
|
+
:item="sitem"
|
|
342
|
+
:key="compKey(sitem, key)"
|
|
343
|
+
v-for="(sitem, key) in item.tabList.fieldList"
|
|
344
|
+
/>
|
|
345
|
+
</template>
|
|
346
|
+
<star-horse-table-column
|
|
347
|
+
v-else
|
|
348
|
+
:cellEditable="fieldList['tableCellEditabled']"
|
|
349
|
+
:data-format="dataFormat"
|
|
350
|
+
:item="item"
|
|
351
|
+
/>
|
|
352
|
+
</template>
|
|
353
|
+
<template
|
|
354
|
+
v-if="showBatchField"
|
|
355
|
+
v-for="item in fieldList['batchFieldList']"
|
|
356
|
+
:key="compKey(item, item.batchName)"
|
|
357
|
+
>
|
|
358
|
+
<star-horse-table-column :data-format="dataFormat" :item="item" />
|
|
359
|
+
</template>
|
|
360
|
+
</el-table>
|
|
361
|
+
</div>
|
|
362
|
+
</template>
|
|
363
|
+
<style lang="scss" scoped>
|
|
364
|
+
.warning-row {
|
|
365
|
+
background: #8f8f8f;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.table-comp {
|
|
369
|
+
height: 100%;
|
|
370
|
+
display: flex;
|
|
371
|
+
flex: 1;
|
|
372
|
+
flex-direction: column;
|
|
373
|
+
overflow: auto;
|
|
374
|
+
|
|
375
|
+
.el-table {
|
|
376
|
+
flex: 1;
|
|
377
|
+
overflow: auto;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
:deep(.el-table__cell) {
|
|
382
|
+
padding: 0;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
:deep(th.el-table__cell:first-child) {
|
|
386
|
+
padding: 5px 0;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.tb_title {
|
|
390
|
+
display: flex;
|
|
391
|
+
align-items: center;
|
|
392
|
+
flex: 1;
|
|
393
|
+
color: var(--star-horse-style);
|
|
394
|
+
}
|
|
395
|
+
</style>
|