star-horse-lowcode 2.7.63 → 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 +1 -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 +19 -19
- package/dist/types/index.d.ts +7 -7
- package/eslint.config.js +37 -0
- package/index.html +14 -0
- package/package-lock.json +8276 -0
- package/package.json +4 -4
- 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,458 @@
|
|
|
1
|
+
<script setup lang="ts" name="StarHorseForm">
|
|
2
|
+
import {
|
|
3
|
+
inject,
|
|
4
|
+
nextTick,
|
|
5
|
+
onActivated,
|
|
6
|
+
onBeforeUnmount,
|
|
7
|
+
onDeactivated,
|
|
8
|
+
onMounted,
|
|
9
|
+
PropType,
|
|
10
|
+
ref,
|
|
11
|
+
ShallowReactive,
|
|
12
|
+
unref,
|
|
13
|
+
watch,
|
|
14
|
+
} from "vue";
|
|
15
|
+
import {ApiUrls} from "@/components/types/ApiUrls";
|
|
16
|
+
import {error, success, warning} from "@/utils/message";
|
|
17
|
+
import {postRequest} from "@/api/star_horse_apis";
|
|
18
|
+
import {closeLoad, formFieldMapping, isJson, load, loadById,} from "@/api/star_horse_utils";
|
|
19
|
+
import {DialogProps} from "@/components/types/DialogProps";
|
|
20
|
+
import {BatchFieldInfo, FieldInfo, PageFieldInfo,} from "@/components/types/PageFieldInfo";
|
|
21
|
+
import StarHorseFormItem from "@/components/comp/StarHorseFormItem.vue";
|
|
22
|
+
import piniaInstance from "@/store";
|
|
23
|
+
import {useSelfOperationStore} from "@/store/SelfOperation";
|
|
24
|
+
import {SelectOption} from "@/components/types/SearchProps";
|
|
25
|
+
import {Config} from "@/api/settings";
|
|
26
|
+
|
|
27
|
+
const props = defineProps({
|
|
28
|
+
compUrl: {type: Object as PropType<ApiUrls>},
|
|
29
|
+
fieldList: {type: Object as PropType<PageFieldInfo>, required: true},
|
|
30
|
+
batchName: {type: String, default: "batchDataList"},
|
|
31
|
+
batchFieldName: {type: String, default: "batchFieldList"},
|
|
32
|
+
outerFormData: {type: Object as PropType<any>},
|
|
33
|
+
primaryKey: {type: [String, Object] as PropType<string | any>},
|
|
34
|
+
globalCondition: {type: Object},
|
|
35
|
+
rules: {type: Object},
|
|
36
|
+
formSize: {type: String, default: Config.compSize},
|
|
37
|
+
labelPosition: {type: String, default: "left"},
|
|
38
|
+
typeModel: {type: String},
|
|
39
|
+
dynamicForm: {type: Boolean, default: false},
|
|
40
|
+
|
|
41
|
+
selectData: {
|
|
42
|
+
type: Array<SelectOption>,
|
|
43
|
+
default: () => {
|
|
44
|
+
return [
|
|
45
|
+
{name: "正常", value: "1"},
|
|
46
|
+
{name: "禁用", value: "2"},
|
|
47
|
+
];
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
let userOperation = useSelfOperationStore(piniaInstance);
|
|
52
|
+
//刷新事件,数据已加载事件,导出数据更新数据
|
|
53
|
+
const emits = defineEmits([
|
|
54
|
+
"refresh",
|
|
55
|
+
"dataLoaded",
|
|
56
|
+
"exportData",
|
|
57
|
+
"removeRow",
|
|
58
|
+
"addRow",
|
|
59
|
+
"inited",
|
|
60
|
+
]);
|
|
61
|
+
const starHorseFormRef = ref(null);
|
|
62
|
+
const dataForm = ref<any>({});
|
|
63
|
+
// source:{type:Number,default:1},
|
|
64
|
+
const source = ref<number>(1);
|
|
65
|
+
//更新外面传进来的数据
|
|
66
|
+
|
|
67
|
+
const exportData = () => {
|
|
68
|
+
emits("exportData", dataForm.value);
|
|
69
|
+
};
|
|
70
|
+
//向外实时导出数据
|
|
71
|
+
|
|
72
|
+
const closeDialog = inject("closeDialog") as Function;
|
|
73
|
+
let dialogOperation = inject("dialogOperation") as ShallowReactive<any>;
|
|
74
|
+
const dialogProps = inject<DialogProps>("dialogProps", {});
|
|
75
|
+
const formFields = inject("formFields", {}) as ShallowReactive<any>;
|
|
76
|
+
|
|
77
|
+
const loadData = async () => {
|
|
78
|
+
if (!props.compUrl || !props.compUrl.loadByIdUrl || !dialogProps.ids) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
await nextTick();
|
|
82
|
+
let id = Array.isArray(dialogProps?.ids)
|
|
83
|
+
? dialogProps.ids[0]
|
|
84
|
+
: dialogProps?.ids;
|
|
85
|
+
let objData;
|
|
86
|
+
let params = props.globalCondition || {};
|
|
87
|
+
//如果是Json 对象
|
|
88
|
+
if (isJson(id)) {
|
|
89
|
+
params = {...params, ...id};
|
|
90
|
+
objData = await loadById(props.compUrl?.loadByIdUrl!, "", params);
|
|
91
|
+
} else {
|
|
92
|
+
objData = await loadById(props.compUrl?.loadByIdUrl!, id, params);
|
|
93
|
+
}
|
|
94
|
+
let data = formFieldMapping(props.fieldList);
|
|
95
|
+
dataForm.value = objData;
|
|
96
|
+
//如果是动态表单
|
|
97
|
+
if (props.dynamicForm) {
|
|
98
|
+
for (let i in params) {
|
|
99
|
+
let temp = params[i];
|
|
100
|
+
if (!temp.subTabFlag) {
|
|
101
|
+
let subTemp = {...objData};
|
|
102
|
+
delete subTemp[temp.tableName];
|
|
103
|
+
dataForm.value[temp.tableName] = [subTemp];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
let mapping = data.mappingFields;
|
|
108
|
+
if (mapping) {
|
|
109
|
+
for (let index in mapping) {
|
|
110
|
+
let temp = mapping[index];
|
|
111
|
+
if (!Object.keys(objData).includes(temp.name)) {
|
|
112
|
+
dataForm.value[temp.name] = dataForm.value[temp.alias];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
let actions = data.actions;
|
|
117
|
+
if (actions && actions.length > 0) {
|
|
118
|
+
for (let index in actions) {
|
|
119
|
+
let temp = actions[index];
|
|
120
|
+
// let tempFunc: any = objData;
|
|
121
|
+
if (temp.actionNames == "change") {
|
|
122
|
+
temp.actions(objData);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
nextTick(() => {
|
|
127
|
+
emits("dataLoaded", objData);
|
|
128
|
+
checkActionRelation();
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 加载了数据,检查是否有数据联动的相关方法
|
|
133
|
+
*/
|
|
134
|
+
const checkActionRelation = () => {
|
|
135
|
+
for (let key in formFields) {
|
|
136
|
+
let temp = formFields[key];
|
|
137
|
+
let preps = temp?.preps;
|
|
138
|
+
|
|
139
|
+
if (preps?.actions) {
|
|
140
|
+
temp.preps["actions"](dataForm.value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const merge = (type: string) => {
|
|
145
|
+
starHorseFormRef.value!.validate((result: boolean) => {
|
|
146
|
+
if (!result) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
doMerge(type);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* 对状态名称赋值
|
|
154
|
+
*/
|
|
155
|
+
const assignStatusName = () => {
|
|
156
|
+
if (dataForm.value.statusCode) {
|
|
157
|
+
let sData = props.selectData.find(
|
|
158
|
+
(item: any) => item.value === dataForm.value.statusCode,
|
|
159
|
+
);
|
|
160
|
+
if (sData) {
|
|
161
|
+
dataForm.value["statusName"] = sData.name;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let batchFields = props.fieldList?.batchFieldList || [];
|
|
165
|
+
batchFields?.forEach((item: BatchFieldInfo) => {
|
|
166
|
+
if (dataForm.value[item.batchName]) {
|
|
167
|
+
for (
|
|
168
|
+
let index = 0;
|
|
169
|
+
index < dataForm.value[item.batchName]?.length;
|
|
170
|
+
index++
|
|
171
|
+
) {
|
|
172
|
+
let temp = dataForm.value[item.batchName][index];
|
|
173
|
+
let sData = props.selectData.find(
|
|
174
|
+
(sitem: any) => sitem.value === temp.statusCode,
|
|
175
|
+
);
|
|
176
|
+
if (sData) {
|
|
177
|
+
dataForm.value[item.batchName][index]["statusName"] = sData.name;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
const mergeDraft = (type: string) => {
|
|
184
|
+
doMerge(type);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const analysisSameToParentField = (): Array<string> => {
|
|
188
|
+
let batchName: Array<string> = [];
|
|
189
|
+
let batchFields = props.fieldList?.batchFieldList ||[];
|
|
190
|
+
const analysis = (batchFields: BatchFieldInfo[]) => {
|
|
191
|
+
batchFields?.forEach((item: BatchFieldInfo) => {
|
|
192
|
+
if (false === item.subFormFlag || "N" == item.subFormFlag) {
|
|
193
|
+
batchName.push(item.batchName);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
//单独定义的批量属性
|
|
198
|
+
analysis(batchFields);
|
|
199
|
+
//嵌入fieldList里的批量属性
|
|
200
|
+
let fieldList = props.fieldList?.fieldList || [];
|
|
201
|
+
const arrayFieldList = (fieldList: FieldInfo[]) => {
|
|
202
|
+
for (let index in fieldList) {
|
|
203
|
+
let temp: any = fieldList[index];
|
|
204
|
+
if (temp instanceof Array) {
|
|
205
|
+
arrayFieldList(temp);
|
|
206
|
+
} else if (temp.batchFieldList) {
|
|
207
|
+
analysis(temp.batchFieldList);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
arrayFieldList(fieldList);
|
|
212
|
+
return batchName;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const doMerge = (type: string) => {
|
|
216
|
+
assignStatusName();
|
|
217
|
+
let tempForm: any = [];
|
|
218
|
+
let tempDatas: any = JSON.parse(JSON.stringify(dataForm.value));
|
|
219
|
+
let mergeUrl = props.compUrl?.mergeUrl;
|
|
220
|
+
let flag = true;
|
|
221
|
+
//单独批量数据和嵌入fieldList 里的批量数据
|
|
222
|
+
//原则上只支持1个批量表格,多个存在数据对称问题
|
|
223
|
+
let sameBatchNames = analysisSameToParentField();
|
|
224
|
+
if (sameBatchNames?.length > 0) {
|
|
225
|
+
flag = false;
|
|
226
|
+
mergeUrl = props.compUrl?.batchMergeUrl;
|
|
227
|
+
tempForm = [];
|
|
228
|
+
sameBatchNames.forEach((batchName: string) => {
|
|
229
|
+
let batchDatas = tempDatas[batchName];
|
|
230
|
+
delete tempDatas[batchName];
|
|
231
|
+
for (let i in batchDatas) {
|
|
232
|
+
//保留第一条数据的ID
|
|
233
|
+
if (parseInt(i) > 0) {
|
|
234
|
+
delete tempDatas[props.primaryKey];
|
|
235
|
+
}
|
|
236
|
+
let temp = {...tempDatas, ...batchDatas[i]};
|
|
237
|
+
tempForm.push(temp);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
let dydata: any = {
|
|
242
|
+
relationTables: props.globalCondition,
|
|
243
|
+
};
|
|
244
|
+
//props.globalCondition 有属性不是子表,需要额外封装
|
|
245
|
+
|
|
246
|
+
if (flag) {
|
|
247
|
+
tempForm = dataForm.value;
|
|
248
|
+
dydata["dataMap"] = tempForm;
|
|
249
|
+
} else {
|
|
250
|
+
dydata["dataListsMap"] = tempForm;
|
|
251
|
+
}
|
|
252
|
+
// console.log(sameBatchNames, tempForm, dydata);
|
|
253
|
+
load("数据处理中");
|
|
254
|
+
//dynamicForm 如果为true 表示动态表单,动态表单需额外封装数据对象
|
|
255
|
+
let formData = props.dynamicForm ? dydata : tempForm;
|
|
256
|
+
postRequest(mergeUrl!, formData)
|
|
257
|
+
.then((res) => {
|
|
258
|
+
closeLoad();
|
|
259
|
+
if (res.data.code != 0) {
|
|
260
|
+
warning(res.data.cnMessage);
|
|
261
|
+
return;
|
|
262
|
+
} else {
|
|
263
|
+
success(res.data.cnMessage);
|
|
264
|
+
}
|
|
265
|
+
emits("refresh", formData, res.data);
|
|
266
|
+
resetForm();
|
|
267
|
+
if (type == "close") {
|
|
268
|
+
closeDialog();
|
|
269
|
+
}
|
|
270
|
+
dialogProps.ids = -1;
|
|
271
|
+
//关闭弹窗
|
|
272
|
+
})
|
|
273
|
+
.catch((err) => {
|
|
274
|
+
error("接口调用异常" + err);
|
|
275
|
+
})
|
|
276
|
+
.finally(() => {
|
|
277
|
+
closeLoad();
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
const resetForm = () => {
|
|
281
|
+
dataForm.value = formFieldMapping(props.fieldList)?.defaultDatas;
|
|
282
|
+
let data = unref(props.outerFormData);
|
|
283
|
+
if (Object.keys(data||{}).length > 0) {
|
|
284
|
+
dataForm.value = {...dataForm.value, ...data};
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* 返回表单数据
|
|
289
|
+
*/
|
|
290
|
+
const getFormData = () => {
|
|
291
|
+
return dataForm;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* 设置表单数据
|
|
295
|
+
* @param data
|
|
296
|
+
*/
|
|
297
|
+
const setFormData = (data: any) => {
|
|
298
|
+
let mappingData = formFieldMapping(props.fieldList);
|
|
299
|
+
let defaultDatas = mappingData.defaultDatas;
|
|
300
|
+
dataForm.value = {...defaultDatas, ...data};
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* 更新数据
|
|
304
|
+
* @param data
|
|
305
|
+
*/
|
|
306
|
+
const updateFormData = (data: any) => {
|
|
307
|
+
dataForm.value = {...dataForm.value, ...data};
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* 列表添加行数据
|
|
311
|
+
* @param row
|
|
312
|
+
*/
|
|
313
|
+
const addRow = (row: any) => {
|
|
314
|
+
emits("addRow", row);
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* 列表删除行数据
|
|
318
|
+
* @param row
|
|
319
|
+
*/
|
|
320
|
+
const removeRow = (row: any) => {
|
|
321
|
+
emits("removeRow", row);
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* 记录当前表单的信息
|
|
325
|
+
*/
|
|
326
|
+
const recordFieldInfo = async () => {
|
|
327
|
+
await nextTick();
|
|
328
|
+
userOperation.init(props.fieldList, dataForm, starHorseFormRef);
|
|
329
|
+
await nextTick();
|
|
330
|
+
emits("inited");
|
|
331
|
+
};
|
|
332
|
+
const tableListRef = ref<any>([]);
|
|
333
|
+
onActivated(() => {
|
|
334
|
+
recordFieldInfo();
|
|
335
|
+
});
|
|
336
|
+
onDeactivated(() => {
|
|
337
|
+
// userOperation.clearAll();
|
|
338
|
+
});
|
|
339
|
+
onBeforeUnmount(() => {
|
|
340
|
+
userOperation.clearAll();
|
|
341
|
+
});
|
|
342
|
+
onMounted(() => {
|
|
343
|
+
recordFieldInfo();
|
|
344
|
+
});
|
|
345
|
+
watch(
|
|
346
|
+
() => dataForm.value,
|
|
347
|
+
() => {
|
|
348
|
+
exportData();
|
|
349
|
+
},
|
|
350
|
+
{immediate: false, deep: true},
|
|
351
|
+
);
|
|
352
|
+
watch(
|
|
353
|
+
() => props.outerFormData,
|
|
354
|
+
(val: any) => {
|
|
355
|
+
if (val) {
|
|
356
|
+
resetForm();
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
{immediate: true, deep: true},
|
|
360
|
+
);
|
|
361
|
+
watch(
|
|
362
|
+
() => dialogOperation,
|
|
363
|
+
(val: any) => {
|
|
364
|
+
const handlers: any = {
|
|
365
|
+
merge: () => merge(val.type),
|
|
366
|
+
mergeDraft: () => mergeDraft(val.type),
|
|
367
|
+
resetForm: () => resetForm(),
|
|
368
|
+
};
|
|
369
|
+
handlers[val.funcName]?.();
|
|
370
|
+
dialogOperation.funcName = "";
|
|
371
|
+
dialogOperation["type"] = "";
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
immediate: false,
|
|
375
|
+
deep: true,
|
|
376
|
+
},
|
|
377
|
+
);
|
|
378
|
+
watch(
|
|
379
|
+
() => dialogProps.ids,
|
|
380
|
+
(val) => {
|
|
381
|
+
console.log("ids", val);
|
|
382
|
+
if (!val || val == -1) {
|
|
383
|
+
source.value = 1;
|
|
384
|
+
setFormData(dataForm.value);
|
|
385
|
+
} else {
|
|
386
|
+
source.value = 2;
|
|
387
|
+
loadData();
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
immediate: true,
|
|
392
|
+
deep: true,
|
|
393
|
+
},
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
defineExpose({
|
|
397
|
+
merge,
|
|
398
|
+
mergeDraft,
|
|
399
|
+
resetForm,
|
|
400
|
+
setFormData,
|
|
401
|
+
getFormData,
|
|
402
|
+
updateFormData,
|
|
403
|
+
starHorseFormRef,
|
|
404
|
+
tableListRef,
|
|
405
|
+
});
|
|
406
|
+
</script>
|
|
407
|
+
<template>
|
|
408
|
+
<el-scrollbar height="100%">
|
|
409
|
+
<el-form
|
|
410
|
+
:model="dataForm"
|
|
411
|
+
:size="formSize"
|
|
412
|
+
:rules="rules"
|
|
413
|
+
:scroll-to-error="true"
|
|
414
|
+
:scroll-into-view-options="true"
|
|
415
|
+
:inline-message="false"
|
|
416
|
+
:status-icon="true"
|
|
417
|
+
:label-position="labelPosition"
|
|
418
|
+
require-asterisk-position="right"
|
|
419
|
+
label-width="auto"
|
|
420
|
+
class="data-form"
|
|
421
|
+
ref="starHorseFormRef"
|
|
422
|
+
>
|
|
423
|
+
<star-horse-form-item
|
|
424
|
+
:primaryKey="primaryKey"
|
|
425
|
+
:compUrl="compUrl"
|
|
426
|
+
:fieldList="fieldList"
|
|
427
|
+
:rules="rules"
|
|
428
|
+
:compSize="formSize"
|
|
429
|
+
v-model:dataForm="dataForm"
|
|
430
|
+
:source="source"
|
|
431
|
+
@addRow="addRow"
|
|
432
|
+
@removeRow="removeRow"
|
|
433
|
+
:batchName="batchName"
|
|
434
|
+
:batchFieldName="batchFieldName"
|
|
435
|
+
/>
|
|
436
|
+
</el-form>
|
|
437
|
+
</el-scrollbar>
|
|
438
|
+
<el-form-item v-if="typeModel == 'form'" :size="formSize">
|
|
439
|
+
<el-button
|
|
440
|
+
@click="merge"
|
|
441
|
+
style="
|
|
442
|
+
background: var(--star-horse-style);
|
|
443
|
+
color: var(--star-horse-white);
|
|
444
|
+
"
|
|
445
|
+
>
|
|
446
|
+
<star-horse-icon
|
|
447
|
+
icon-class="save"
|
|
448
|
+
style="color: var(--star-horse-white)"
|
|
449
|
+
/>
|
|
450
|
+
提交
|
|
451
|
+
</el-button>
|
|
452
|
+
<el-button @click="resetForm" link>
|
|
453
|
+
<star-horse-icon icon-class="undo"/>
|
|
454
|
+
重置
|
|
455
|
+
</el-button>
|
|
456
|
+
</el-form-item>
|
|
457
|
+
</template>
|
|
458
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup lang="ts" name="StarHorseFormItem">
|
|
2
|
+
import { Config } from "@/api/settings";
|
|
3
|
+
import { compKey } from "@/api/system";
|
|
4
|
+
import { ApiUrls } from "@/components/types/ApiUrls";
|
|
5
|
+
import { PageFieldInfo } from "@/components/types/PageFieldInfo";
|
|
6
|
+
import { ModelRef, PropType } from "vue";
|
|
7
|
+
|
|
8
|
+
defineProps({
|
|
9
|
+
compUrl: { type: Object as PropType<ApiUrls> },
|
|
10
|
+
fieldList: { type: Object as PropType<PageFieldInfo | any>, required: true },
|
|
11
|
+
objectName: { type: String },
|
|
12
|
+
subFormFlag: { type: String, default: "N" },
|
|
13
|
+
// 数据索引
|
|
14
|
+
dataIndex: { type: Number, default: -1 },
|
|
15
|
+
// 父节点名称
|
|
16
|
+
propPrefix: { type: String, default: "" },
|
|
17
|
+
batchName: { type: String, default: "batchDataList" },
|
|
18
|
+
batchFieldName: { type: String, default: "batchFieldList" },
|
|
19
|
+
primaryKey: { type: [String, Object] as PropType<string | any> },
|
|
20
|
+
compSize: { type: String, default: Config.compSize },
|
|
21
|
+
rules: { type: Object },
|
|
22
|
+
source: { type: Number, default: 1 },
|
|
23
|
+
});
|
|
24
|
+
const dataForm: ModelRef<any> = defineModel("dataForm");
|
|
25
|
+
const checkItemType = (item: any) => {
|
|
26
|
+
if (Array.isArray(item)) {
|
|
27
|
+
return "box-item";
|
|
28
|
+
} else if (item.cardList?.length > 0) {
|
|
29
|
+
return "card-item";
|
|
30
|
+
} else if (item.collapseList?.length > 0) {
|
|
31
|
+
return "collapse-item";
|
|
32
|
+
} else if (item.dytableList?.length > 0) {
|
|
33
|
+
return "dytable-item";
|
|
34
|
+
} else if (item.tabList?.length > 0 || item.batchFieldList?.length > 0) {
|
|
35
|
+
return "tab-item";
|
|
36
|
+
} else {
|
|
37
|
+
return "other-item";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
</script>
|
|
41
|
+
<template>
|
|
42
|
+
<template
|
|
43
|
+
v-for="(item, index) in fieldList.fieldList"
|
|
44
|
+
:key="compKey(item, index, false, 'form')"
|
|
45
|
+
>
|
|
46
|
+
<component
|
|
47
|
+
:Key="compKey(item, index, true)"
|
|
48
|
+
:is="checkItemType(item)"
|
|
49
|
+
:primary-key="primaryKey"
|
|
50
|
+
:item="item"
|
|
51
|
+
:rules="rules"
|
|
52
|
+
:batchFieldName="batchFieldName"
|
|
53
|
+
:batchName="batchName"
|
|
54
|
+
:compSize="compSize"
|
|
55
|
+
:compUrl="compUrl"
|
|
56
|
+
:subFormFlag="subFormFlag"
|
|
57
|
+
:source="source"
|
|
58
|
+
:objectName="objectName"
|
|
59
|
+
:dataIndex="dataIndex"
|
|
60
|
+
:propPrefix="propPrefix"
|
|
61
|
+
v-model:dataForm="dataForm"
|
|
62
|
+
:parentPreps="fieldList.preps"
|
|
63
|
+
/>
|
|
64
|
+
</template>
|
|
65
|
+
<table-item
|
|
66
|
+
:primary-key="primaryKey"
|
|
67
|
+
:item="fieldList"
|
|
68
|
+
:rules="rules"
|
|
69
|
+
:batchFieldName="batchFieldName"
|
|
70
|
+
:batchName="batchName"
|
|
71
|
+
:compSize="compSize"
|
|
72
|
+
:compUrl="compUrl"
|
|
73
|
+
:subFormFlag="subFormFlag"
|
|
74
|
+
:source="source"
|
|
75
|
+
:objectName="objectName"
|
|
76
|
+
:dataIndex="dataIndex"
|
|
77
|
+
:propPrefix="propPrefix"
|
|
78
|
+
v-model:dataForm="dataForm"
|
|
79
|
+
:parentPreps="fieldList.preps"
|
|
80
|
+
/>
|
|
81
|
+
</template>
|
|
82
|
+
<style lang="scss" scoped></style>
|