@infly/ui 1.0.18 → 1.0.20
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/README.md +53 -43
- package/index.js +47 -33
- package/package.json +60 -29
- package/scripts/install-comp.js +13 -0
- package/src/Base/InflyCheckBox/InflyCheckBox.test.js +154 -0
- package/src/Base/InflyCheckBox/InflyCheckBox.vue +227 -0
- package/src/Base/InflyCheckBox/index.js +6 -0
- package/src/Base/InflyDialog/InflyDialog.test.js +122 -0
- package/src/Base/InflyDialog/InflyDialog.vue +111 -0
- package/src/Base/InflyDialog/index.js +6 -0
- package/src/Base/InflyForm/InflyForm.test.js +239 -0
- package/src/Base/InflyForm/InflyForm.vue +974 -0
- package/src/Base/InflyForm/index.js +6 -0
- package/src/Base/InflyInput/InflyInput.test.js +105 -0
- package/src/Base/InflyInput/InflyInput.vue +167 -0
- package/src/Base/InflyInput/index.js +6 -0
- package/src/Base/InflyList/InflyList.test.js +229 -0
- package/src/Base/InflyList/InflyList.vue +926 -0
- package/src/Base/InflyList/index.js +6 -0
- package/src/Business/BusinessSwitch/BusinessSwitch.test.js +250 -0
- package/src/Business/BusinessSwitch/BusinessSwitch.vue +115 -0
- package/src/Business/BusinessSwitch/index.js +6 -0
- package/src/Business/BusinessTag/BusinessTag.test.js +70 -0
- package/src/Business/BusinessTag/BusinessTag.vue +58 -0
- package/src/Business/BusinessTag/index.js +6 -0
- package/src/Business/InstitutionSelect/InstitutionSelect.test.js +281 -0
- package/src/Business/InstitutionSelect/InstitutionSelect.vue +768 -0
- package/src/Business/InstitutionSelect/index.js +6 -0
- package/src/utils/Uts.js +3 -0
- package/src/utils/ts-libs.test.js +31 -0
- package/styles/base.scss +755 -0
- package/styles/index.scss +202 -0
- package/styles/mixin.scss +19 -0
- package/styles/variables.scss +24 -0
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- packages\infly-ui\Business\ELForm\ELForm.vue 表单组件集合 -->
|
|
3
|
+
<div class="comp-InflyForm">
|
|
4
|
+
<slot name="prepend"></slot>
|
|
5
|
+
<div class="btn-list__wrap" :class="[`btn-list__wrap--${btnWrapDirection}`]">
|
|
6
|
+
<div
|
|
7
|
+
class="btn-list__item"
|
|
8
|
+
v-for="({ click, ...btnItem }, index) in visibleBtnList"
|
|
9
|
+
:key="`btn_${index}_${btnItem.name || btnItem.label || index}`"
|
|
10
|
+
>
|
|
11
|
+
<el-button size="mini" v-bind="btnItem" @click="handleBtnClick({ click, ...btnItem })">
|
|
12
|
+
{{ btnItem.name || btnItem.label }}
|
|
13
|
+
</el-button>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<el-form
|
|
17
|
+
:class="['infly-form__wrap', formClass, layoutClass]"
|
|
18
|
+
:model="formData"
|
|
19
|
+
:ref="formRef"
|
|
20
|
+
:size="$attrs.size || 'mini'"
|
|
21
|
+
:label-width="formLabelWidth"
|
|
22
|
+
:label-suffix="formLabelSuffix"
|
|
23
|
+
v-bind="$attrs"
|
|
24
|
+
@submit.native.prevent
|
|
25
|
+
>
|
|
26
|
+
<el-form-item
|
|
27
|
+
v-for="(
|
|
28
|
+
{
|
|
29
|
+
label,
|
|
30
|
+
name,
|
|
31
|
+
type,
|
|
32
|
+
options,
|
|
33
|
+
required,
|
|
34
|
+
isHide,
|
|
35
|
+
valuePrefix,
|
|
36
|
+
optionConfig,
|
|
37
|
+
mode,
|
|
38
|
+
formItemClass,
|
|
39
|
+
nowrap,
|
|
40
|
+
position,
|
|
41
|
+
__positionStyle,
|
|
42
|
+
radioType = 'el-radio',
|
|
43
|
+
__events__,
|
|
44
|
+
rules,
|
|
45
|
+
secTabList,
|
|
46
|
+
...otherAttributes
|
|
47
|
+
},
|
|
48
|
+
index
|
|
49
|
+
) in visibleFilterList"
|
|
50
|
+
:key="`form_item_${name || index}_${index}`"
|
|
51
|
+
:required="required"
|
|
52
|
+
:label="formItemLabel(label, type)"
|
|
53
|
+
:prop="Array.isArray(name) ? name.join(',') : name"
|
|
54
|
+
:label-width="calcLabelWidth(otherAttributes)"
|
|
55
|
+
:class="getFormItemClass({ type, nowrap, formItemClass, position })"
|
|
56
|
+
:style="__positionStyle"
|
|
57
|
+
:rules="rules"
|
|
58
|
+
>
|
|
59
|
+
<template v-if="isSecTabGroupType(type)">
|
|
60
|
+
<el-tabs v-model="activitySecTab" @tab-click="handleSecTabClick">
|
|
61
|
+
<el-tab-pane
|
|
62
|
+
v-for="{ filterList, buttonList, __events__, ...otherTabAttributes } in secTabList"
|
|
63
|
+
:key="otherTabAttributes.name"
|
|
64
|
+
v-bind="otherTabAttributes"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
class="infly-form__sec-tab-btns"
|
|
68
|
+
v-for="(btnItem, btnIndex) in buttonList"
|
|
69
|
+
:key="`sec_btn_${btnIndex}_${btnItem.name || btnIndex}`"
|
|
70
|
+
>
|
|
71
|
+
<el-button v-if="shouldShowEL(btnItem)" size="mini" v-bind="btnItem" @click="handleBtnClick(btnItem)">
|
|
72
|
+
<span :class="['btn__text', btnItem.className]">
|
|
73
|
+
{{ Uts.isFunction(btnItem.name) ? btnItem.name(formData) : btnItem.name }}
|
|
74
|
+
</span>
|
|
75
|
+
</el-button>
|
|
76
|
+
</div>
|
|
77
|
+
</el-tab-pane>
|
|
78
|
+
</el-tabs>
|
|
79
|
+
</template>
|
|
80
|
+
<!-- 编辑状态 -->
|
|
81
|
+
<template v-else-if="mode === 'edit' || (computedEdit && type && !isEditExcludeType(type))">
|
|
82
|
+
<BusinessSwitch v-if="isBusinessSwitchType(type)" v-bind="otherAttributes" v-on="__events__">
|
|
83
|
+
<template #content>
|
|
84
|
+
<div class="form__switch-text">
|
|
85
|
+
<InflyFormRenderCell
|
|
86
|
+
v-if="Uts.isFunction(__events__.render)"
|
|
87
|
+
:render-fn="__events__.render"
|
|
88
|
+
:value="formData[name]"
|
|
89
|
+
:form-data="formData"
|
|
90
|
+
/>
|
|
91
|
+
<template v-else>{{ formData[name] || "-" }}</template>
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
94
|
+
</BusinessSwitch>
|
|
95
|
+
<InstitutionSelect
|
|
96
|
+
v-else-if="isInstitutionSelectType(type)"
|
|
97
|
+
ref="InstitutionSelectRef"
|
|
98
|
+
v-model="formData[name]"
|
|
99
|
+
:formData="formData"
|
|
100
|
+
v-bind="otherAttributes"
|
|
101
|
+
v-on="__events__"
|
|
102
|
+
/>
|
|
103
|
+
<InflyCheckbox
|
|
104
|
+
v-else-if="isInflyCheckboxType(type)"
|
|
105
|
+
v-model="formData[name]"
|
|
106
|
+
:options="options"
|
|
107
|
+
v-bind="otherAttributes"
|
|
108
|
+
v-on="__events__"
|
|
109
|
+
/>
|
|
110
|
+
<InflyInput
|
|
111
|
+
v-else-if="isInflyInputType(type)"
|
|
112
|
+
v-model="formData[name]"
|
|
113
|
+
v-bind="{ ...otherAttributes, label, type }"
|
|
114
|
+
v-on="__events__"
|
|
115
|
+
/>
|
|
116
|
+
<el-radio-group
|
|
117
|
+
v-else-if="type === 'el-radio-group'"
|
|
118
|
+
v-model="formData[name]"
|
|
119
|
+
v-bind="otherAttributes"
|
|
120
|
+
v-on="__events__"
|
|
121
|
+
>
|
|
122
|
+
<component :is="radioType" v-for="option in options" :key="option.value" :label="option.value">
|
|
123
|
+
{{ __events__?.radioLabel?.(option) || option.name || option.label || "" }}
|
|
124
|
+
</component>
|
|
125
|
+
</el-radio-group>
|
|
126
|
+
<component
|
|
127
|
+
v-else-if="isDatePickerType(type)"
|
|
128
|
+
:is="type === 'el-time-picker' ? 'el-time-picker' : 'el-date-picker'"
|
|
129
|
+
:value="getDatePickerValue(name)"
|
|
130
|
+
:key="getFieldKey(name)"
|
|
131
|
+
@input="handleDatePickerInput($event, name)"
|
|
132
|
+
v-bind="type === 'el-time-picker' ? otherAttributes : { ...datePickerDefaults, ...otherAttributes, type }"
|
|
133
|
+
v-on="__events__"
|
|
134
|
+
/>
|
|
135
|
+
<el-select
|
|
136
|
+
v-else-if="type === 'el-select'"
|
|
137
|
+
v-model="formData[name]"
|
|
138
|
+
v-bind="otherAttributes"
|
|
139
|
+
v-on="__events__"
|
|
140
|
+
>
|
|
141
|
+
<el-option
|
|
142
|
+
v-for="option in options"
|
|
143
|
+
:key="getOptionValue(option, optionConfig)"
|
|
144
|
+
:label="getOptionLabel(option, optionConfig)"
|
|
145
|
+
:value="getOptionValue(option, optionConfig)"
|
|
146
|
+
/>
|
|
147
|
+
</el-select>
|
|
148
|
+
<el-upload v-else-if="type === 'el-upload'" v-bind="otherAttributes" v-on="otherAttributes">
|
|
149
|
+
<el-image
|
|
150
|
+
v-if="isUploadPictureList(otherAttributes) && formData[name]"
|
|
151
|
+
:src="formData[name]"
|
|
152
|
+
v-bind="otherAttributes.imgAtts"
|
|
153
|
+
/>
|
|
154
|
+
<template v-else-if="otherAttributes.drag">
|
|
155
|
+
<i class="el-icon-upload"></i>
|
|
156
|
+
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
157
|
+
</template>
|
|
158
|
+
<template v-else-if="otherAttributes.uploadBtn">
|
|
159
|
+
<el-button size="small" type="primary">点击上传</el-button>
|
|
160
|
+
</template>
|
|
161
|
+
<template v-else>
|
|
162
|
+
<i class="standard-upload_icon el-icon-plus avatar-uploader-icon"></i>
|
|
163
|
+
<div class="el-upload__text">点击上传</div>
|
|
164
|
+
</template>
|
|
165
|
+
<!-- XSS 风险:确保 tips 内容已转义或来自可信数据源 -->
|
|
166
|
+
<div v-if="otherAttributes.tips" class="el-upload__tip" slot="tip" v-html="otherAttributes.tips"></div>
|
|
167
|
+
</el-upload>
|
|
168
|
+
<!-- 支持自定义customRender插槽,当type为'customRender'时显示 -->
|
|
169
|
+
<slot
|
|
170
|
+
v-else-if="type === 'customRender'"
|
|
171
|
+
name="customRender"
|
|
172
|
+
:item="{ label, name, type, options, required, isHide, __events__, ...otherAttributes }"
|
|
173
|
+
></slot>
|
|
174
|
+
</template>
|
|
175
|
+
<!-- 非编辑状态显示 -->
|
|
176
|
+
<template v-else>
|
|
177
|
+
<div v-if="type === 'daterange' || type === 'datetimerange'">
|
|
178
|
+
{{ getDateRangeDisplay(name) }}
|
|
179
|
+
</div>
|
|
180
|
+
<el-image
|
|
181
|
+
v-else-if="type === 'el-upload' && isUploadPictureList(otherAttributes) && formData[name]"
|
|
182
|
+
:src="formData[name]"
|
|
183
|
+
v-bind="otherAttributes.imgAtts"
|
|
184
|
+
/>
|
|
185
|
+
<div v-else-if="type === 'router-link'">
|
|
186
|
+
<router-link v-bind="otherAttributes">{{ formData[name] }}</router-link>
|
|
187
|
+
</div>
|
|
188
|
+
<!-- 自定义render函数渲染,支持返回字符串(v-html)或VNode(JSX/h) -->
|
|
189
|
+
<InflyFormRenderCell
|
|
190
|
+
v-else-if="type === 'render' || Uts.isFunction(__events__?.render)"
|
|
191
|
+
:render-fn="__events__.render"
|
|
192
|
+
:value="formData[name]"
|
|
193
|
+
:form-data="formData"
|
|
194
|
+
/>
|
|
195
|
+
<!-- 统一的默认值渲染(支持 el-tag 和普通 div) -->
|
|
196
|
+
<component
|
|
197
|
+
v-else
|
|
198
|
+
:is="type === 'el-tag' ? 'el-tag' : 'div'"
|
|
199
|
+
:type="
|
|
200
|
+
type === 'el-tag'
|
|
201
|
+
? getTagType({ prop: name, options, propValueField: otherAttributes.propValueField })
|
|
202
|
+
: undefined
|
|
203
|
+
"
|
|
204
|
+
v-bind="type === 'el-tag' ? otherAttributes : {}"
|
|
205
|
+
>
|
|
206
|
+
{{ defaultValueRender({ name, type, valuePrefix, label }) }}
|
|
207
|
+
</component>
|
|
208
|
+
</template>
|
|
209
|
+
</el-form-item>
|
|
210
|
+
<div
|
|
211
|
+
v-if="Uts.notEmptyArray(filterList)"
|
|
212
|
+
:class="['btn-list__wrap--bottom', btnWrapClass]"
|
|
213
|
+
:style="{ '--btn-left': computedBtnLeft }"
|
|
214
|
+
>
|
|
215
|
+
<div
|
|
216
|
+
v-for="({ isShow, isHide, ...btnItem }, index) in formOptBtnList"
|
|
217
|
+
:key="`opt_btn_${index}_${btnItem.label || btnItem.name || index}`"
|
|
218
|
+
>
|
|
219
|
+
<el-button
|
|
220
|
+
v-if="shouldShowEL({ isShow, isHide })"
|
|
221
|
+
size="mini"
|
|
222
|
+
v-bind="btnItem"
|
|
223
|
+
@click="handleBtnClick(btnItem)"
|
|
224
|
+
>
|
|
225
|
+
{{ btnItem.name || btnItem.label }}
|
|
226
|
+
</el-button>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
</el-form>
|
|
230
|
+
<slot name="append"></slot>
|
|
231
|
+
</div>
|
|
232
|
+
</template>
|
|
233
|
+
|
|
234
|
+
<script>
|
|
235
|
+
import { MessageBox, Message, Loading } from "element-ui";
|
|
236
|
+
import Uts from "../../utils/Uts.js";
|
|
237
|
+
import { exportFile } from "@infly/ts-libs";
|
|
238
|
+
|
|
239
|
+
// ─── 模块级常量 ────────────────────────────────────────────────────────────────
|
|
240
|
+
// 提升到模块顶层,避免每次 computed/render 时重复分配内存
|
|
241
|
+
|
|
242
|
+
/** visibleFilterList 中不归类为事件的函数 key */
|
|
243
|
+
const NON_EVENT_FUNCTION_KEYS = new Set(["isHide", "isShow"]);
|
|
244
|
+
/** el-upload 用 onXxx 回调属性而非 emit,整体走 v-bind 更稳妥 */
|
|
245
|
+
const KEEP_FUNC_COMPONENT_TYPES = new Set(["el-upload"]);
|
|
246
|
+
|
|
247
|
+
/** 日期选择器固定默认配置,冻结对象保证引用永远稳定 */
|
|
248
|
+
const DATE_PICKER_DEFAULTS = Object.freeze({
|
|
249
|
+
unlinkPanels: true,
|
|
250
|
+
rangeSeparator: "至",
|
|
251
|
+
startPlaceholder: "开始日期",
|
|
252
|
+
endPlaceholder: "结束日期",
|
|
253
|
+
valueFormat: "yyyy-MM-dd"
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
/** existModuleType 条件对象,避免每次 computed 重算时创建新引用 */
|
|
257
|
+
const MODULE_TYPE_CONDITION = Object.freeze({ type: "module" });
|
|
258
|
+
|
|
259
|
+
// 用 Set 替代模板中 Uts.contain([...], type) 的内联数组字面量,
|
|
260
|
+
// 将 O(n) 线性查找变为 O(1) 哈希查找,同时消除每次渲染的数组分配
|
|
261
|
+
const EDIT_EXCLUDE_TYPES = new Set(["text", "render"]);
|
|
262
|
+
const BUSINESS_SWITCH_TYPES = new Set(["BusinessSwitch", "business-switch"]);
|
|
263
|
+
const INSTITUTION_SELECT_TYPES = new Set(["InstitutionSelect", "institution-select"]);
|
|
264
|
+
const INFLY_CHECKBOX_TYPES = new Set(["InflyCheckBox", "infly-checkbox"]);
|
|
265
|
+
const INFLY_INPUT_TYPES = new Set(["InflyInput", "infly-input", "el-autocomplete", "textarea", "infly-input-number"]);
|
|
266
|
+
const DATE_PICKER_TYPES = new Set(["daterange", "datetimerange", "datetime", "date", "month", "year", "el-time-picker"]);
|
|
267
|
+
const SUPPORTED_LAYOUT_TYPES = new Set(["inline", "inline-seamless", "compact"]);
|
|
268
|
+
const SUPPORTED_POSITION_TYPES = new Set(["left", "right", "full"]);
|
|
269
|
+
const INTERNAL_TABGROUP_TYPE = "tabgroup";
|
|
270
|
+
// ───────────────────────────────────────────────────────────────────────────────
|
|
271
|
+
|
|
272
|
+
export default {
|
|
273
|
+
name: "InflyForm",
|
|
274
|
+
inheritAttrs: false,
|
|
275
|
+
components: {
|
|
276
|
+
InflyFormRenderCell: {
|
|
277
|
+
props: {
|
|
278
|
+
renderFn: { type: Function, required: true },
|
|
279
|
+
value: { default: undefined },
|
|
280
|
+
formData: { type: Object, default: () => ({}) }
|
|
281
|
+
},
|
|
282
|
+
render(createElement) {
|
|
283
|
+
const result = this.renderFn(this.value, this.formData);
|
|
284
|
+
if (typeof result === "string") {
|
|
285
|
+
// XSS 风险:确保 renderFn 返回值已转义或来自可信数据源
|
|
286
|
+
return createElement("div", { domProps: { innerHTML: result } });
|
|
287
|
+
}
|
|
288
|
+
return result || createElement("span");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
props: {
|
|
293
|
+
formClass: { type: String, default: "" },
|
|
294
|
+
layout: {
|
|
295
|
+
type: [String, Array],
|
|
296
|
+
default: "",
|
|
297
|
+
validator: (value) => {
|
|
298
|
+
const layoutList = Array.isArray(value) ? value : [value];
|
|
299
|
+
return layoutList.every((item) => !item || SUPPORTED_LAYOUT_TYPES.has(item));
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
formData: { type: Object, required: true, default: () => ({}) },
|
|
303
|
+
formRef: { type: String, default: "formRef" },
|
|
304
|
+
btnList: { type: Array, default: () => [] },
|
|
305
|
+
filterList: { type: Array, default: () => [] },
|
|
306
|
+
reqParams: { type: Object, default: () => ({}) },
|
|
307
|
+
hideSearchBtn: { type: Boolean, default: false },
|
|
308
|
+
hideResetBtn: { type: Boolean, default: true },
|
|
309
|
+
isEdit: { type: Boolean, default: null },
|
|
310
|
+
optBtnList: { type: Array, default: () => [] },
|
|
311
|
+
btnWrapDirection: { type: String, default: "row" },
|
|
312
|
+
btnWrapClass: { type: String, default: "" },
|
|
313
|
+
baseButtonsLeft: { type: String, default: "420px" },
|
|
314
|
+
emptyStr: { type: String, default: "-" },
|
|
315
|
+
request: { type: Function, default: null }
|
|
316
|
+
},
|
|
317
|
+
data() {
|
|
318
|
+
const [firstSecTab] = this.getVisibleSecTabList();
|
|
319
|
+
const { name: firstSecTabName } = firstSecTab || {};
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
originFormData: Uts.copyObj(this.formData),
|
|
323
|
+
activitySecTab: firstSecTabName
|
|
324
|
+
};
|
|
325
|
+
},
|
|
326
|
+
created() {
|
|
327
|
+
this.initRangeFieldValues();
|
|
328
|
+
},
|
|
329
|
+
computed: {
|
|
330
|
+
/**
|
|
331
|
+
* 底部操作按钮列表。computed 化后可响应 hideSearchBtn / hideResetBtn / optBtnList prop 动态变化;
|
|
332
|
+
* 在 data() 中快照只能取到初始值。
|
|
333
|
+
*/
|
|
334
|
+
formOptBtnList() {
|
|
335
|
+
return [
|
|
336
|
+
{
|
|
337
|
+
label: "查询",
|
|
338
|
+
type: "primary",
|
|
339
|
+
size: "mini",
|
|
340
|
+
isHide: this.hideSearchBtn,
|
|
341
|
+
btnEvent: "initData",
|
|
342
|
+
plain: true
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
label: "重置",
|
|
346
|
+
type: "success",
|
|
347
|
+
size: "mini",
|
|
348
|
+
isHide: this.hideResetBtn,
|
|
349
|
+
btnEvent: this.resetFormData,
|
|
350
|
+
plain: true
|
|
351
|
+
},
|
|
352
|
+
...this.optBtnList
|
|
353
|
+
];
|
|
354
|
+
},
|
|
355
|
+
/**
|
|
356
|
+
* 标准化并过滤出应该显示的表单项列表
|
|
357
|
+
* 1. 标准化:如果没有 name 但有 prop,则使用 prop 作为 name
|
|
358
|
+
* 2. 过滤:排除 isHide 为 true 的项
|
|
359
|
+
* 3. 分离:将函数类型的属性归类到 events,其他归类到普通属性
|
|
360
|
+
*/
|
|
361
|
+
visibleFilterList() {
|
|
362
|
+
return this.withPositionRows(this.getVisibleFilterList());
|
|
363
|
+
},
|
|
364
|
+
formLabelWidth() {
|
|
365
|
+
// 直接计算,避免循环依赖
|
|
366
|
+
return this.$attrs.labelWidth || this.$attrs["label-width"] || "80px";
|
|
367
|
+
},
|
|
368
|
+
// 计算底部按钮距离左侧的距离
|
|
369
|
+
computedBtnLeft() {
|
|
370
|
+
const labelWidth = this.formLabelWidth;
|
|
371
|
+
return `calc(${labelWidth} + ${this.baseButtonsLeft})`;
|
|
372
|
+
},
|
|
373
|
+
computedEdit() {
|
|
374
|
+
const { query = {} } = this.$route || {};
|
|
375
|
+
const { mode } = query;
|
|
376
|
+
|
|
377
|
+
if (Uts.isBoolean(this.isEdit)) {
|
|
378
|
+
return this.isEdit;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return mode === "edit" || !mode;
|
|
382
|
+
},
|
|
383
|
+
existModuleType() {
|
|
384
|
+
const moduleList = Uts.filterObjByCondition(this.getFlattenFilterList() || [], MODULE_TYPE_CONDITION) || [];
|
|
385
|
+
return moduleList.length > 0;
|
|
386
|
+
},
|
|
387
|
+
/** 原始 label-suffix 配置值,兼容 kebab-case 和 camelCase */
|
|
388
|
+
rawLabelSuffix() {
|
|
389
|
+
return this.$attrs["label-suffix"] || this.$attrs["labelSuffix"] || "";
|
|
390
|
+
},
|
|
391
|
+
formLabelSuffix() {
|
|
392
|
+
if (this.existModuleType) {
|
|
393
|
+
return "";
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return this.rawLabelSuffix;
|
|
397
|
+
},
|
|
398
|
+
/**
|
|
399
|
+
* 过滤出应该显示的按钮列表
|
|
400
|
+
*/
|
|
401
|
+
visibleBtnList() {
|
|
402
|
+
return this.btnList.filter((btnItem) => this.shouldShowEL(btnItem));
|
|
403
|
+
},
|
|
404
|
+
/**
|
|
405
|
+
* 日期选择器默认配置(返回模块级冻结常量,引用永远稳定)
|
|
406
|
+
*/
|
|
407
|
+
datePickerDefaults() {
|
|
408
|
+
return DATE_PICKER_DEFAULTS;
|
|
409
|
+
},
|
|
410
|
+
layoutClass() {
|
|
411
|
+
const layoutList = Array.isArray(this.layout) ? this.layout : [this.layout];
|
|
412
|
+
const classes = layoutList.filter(Boolean).map((item) => `standard-form--${item}`);
|
|
413
|
+
if (this.hasPositionedItems) {
|
|
414
|
+
classes.push("standard-form--positioned");
|
|
415
|
+
}
|
|
416
|
+
return classes;
|
|
417
|
+
},
|
|
418
|
+
hasPositionedItems() {
|
|
419
|
+
return this.visibleFilterList.some((item) => SUPPORTED_POSITION_TYPES.has(String(item.position || "").trim()));
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
methods: {
|
|
423
|
+
initRangeFieldValues() {
|
|
424
|
+
// 为数组形式的 name(日期范围字段)初始化联合 key,确保 el-form-item :prop 校验能找到值
|
|
425
|
+
this.getFlattenFilterList().forEach((item) => {
|
|
426
|
+
const { name } = item;
|
|
427
|
+
|
|
428
|
+
if (!Array.isArray(name)) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const [startField, endField] = name;
|
|
433
|
+
const startValue = this.formData[startField];
|
|
434
|
+
const endValue = this.formData[endField];
|
|
435
|
+
this.$set(this.formData, name.join(","), startValue && endValue ? [startValue, endValue] : undefined);
|
|
436
|
+
});
|
|
437
|
+
},
|
|
438
|
+
getFlattenFilterList(list = this.filterList) {
|
|
439
|
+
return (list || []).reduce((result, item) => {
|
|
440
|
+
result.push(item);
|
|
441
|
+
if (Uts.notEmptyArray(item && item.filterList)) {
|
|
442
|
+
result.push(...this.getFlattenFilterList(item.filterList));
|
|
443
|
+
}
|
|
444
|
+
return result;
|
|
445
|
+
}, []);
|
|
446
|
+
},
|
|
447
|
+
getVisibleSecTabList() {
|
|
448
|
+
return (this.filterList || []).filter((item) => item && item.type === "secTab" && this.shouldShowEL(item));
|
|
449
|
+
},
|
|
450
|
+
getActiveSecTab(secTabList = []) {
|
|
451
|
+
return secTabList.find((item) => item.name === this.activitySecTab) || secTabList[0];
|
|
452
|
+
},
|
|
453
|
+
createSecTabGroupItem(secTabList = []) {
|
|
454
|
+
return {
|
|
455
|
+
type: INTERNAL_TABGROUP_TYPE,
|
|
456
|
+
name: INTERNAL_TABGROUP_TYPE,
|
|
457
|
+
label: "",
|
|
458
|
+
labelWidth: "0",
|
|
459
|
+
secTabList,
|
|
460
|
+
__events__: {}
|
|
461
|
+
};
|
|
462
|
+
},
|
|
463
|
+
appendActiveSecTabFilters(result, activeSecTab = {}) {
|
|
464
|
+
const activeFilterList = activeSecTab.filterList || [];
|
|
465
|
+
|
|
466
|
+
activeFilterList.forEach((filterItem) => {
|
|
467
|
+
const normalizedItem = this.normalizeVisibleFilterItem(filterItem);
|
|
468
|
+
if (normalizedItem) {
|
|
469
|
+
result.push(normalizedItem);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
},
|
|
473
|
+
getVisibleFilterList() {
|
|
474
|
+
const secTabList = this.getVisibleSecTabList().map((item) => this.normalizeFilterItem(item));
|
|
475
|
+
const activeSecTab = this.getActiveSecTab(secTabList);
|
|
476
|
+
let hasInsertedSecTabGroup = false;
|
|
477
|
+
|
|
478
|
+
return (this.filterList || []).reduce((result, item) => {
|
|
479
|
+
const { type } = item || {};
|
|
480
|
+
|
|
481
|
+
if (type === "secTab") {
|
|
482
|
+
if (!hasInsertedSecTabGroup && Uts.notEmptyArray(secTabList)) {
|
|
483
|
+
hasInsertedSecTabGroup = true;
|
|
484
|
+
result.push(this.createSecTabGroupItem(secTabList));
|
|
485
|
+
this.appendActiveSecTabFilters(result, activeSecTab);
|
|
486
|
+
}
|
|
487
|
+
return result;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const normalizedItem = this.normalizeVisibleFilterItem(item);
|
|
491
|
+
if (normalizedItem) {
|
|
492
|
+
result.push(normalizedItem);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return result;
|
|
496
|
+
}, []);
|
|
497
|
+
},
|
|
498
|
+
normalizeVisibleFilterItem(item = {}) {
|
|
499
|
+
if (!this.shouldShowEL(item)) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return this.normalizeFilterItem(item);
|
|
504
|
+
},
|
|
505
|
+
normalizeFilterItem(item = {}) {
|
|
506
|
+
const { name, prop, type } = item;
|
|
507
|
+
const events = {};
|
|
508
|
+
const attributes = {};
|
|
509
|
+
|
|
510
|
+
Object.keys(item).forEach((key) => {
|
|
511
|
+
const value = item[key];
|
|
512
|
+
|
|
513
|
+
if (this.isEventAttribute({ key, value, type })) {
|
|
514
|
+
events[key] = value;
|
|
515
|
+
} else {
|
|
516
|
+
attributes[key] = value;
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
return {
|
|
521
|
+
...attributes,
|
|
522
|
+
name: name || prop || "",
|
|
523
|
+
__events__: events
|
|
524
|
+
};
|
|
525
|
+
},
|
|
526
|
+
getNormalizedPosition({ position, type } = {}) {
|
|
527
|
+
const normalizedPosition = String(position || "").trim();
|
|
528
|
+
if (SUPPORTED_POSITION_TYPES.has(normalizedPosition)) {
|
|
529
|
+
return normalizedPosition;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
return type === INTERNAL_TABGROUP_TYPE ? "full" : "";
|
|
533
|
+
},
|
|
534
|
+
withPositionRows(list = []) {
|
|
535
|
+
if (!list.some((item) => this.getNormalizedPosition(item))) {
|
|
536
|
+
return list;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
let leftRow = 1;
|
|
540
|
+
let rightRow = 1;
|
|
541
|
+
let nextFullRow = 1;
|
|
542
|
+
|
|
543
|
+
return list.map((item) => {
|
|
544
|
+
const normalizedPosition = this.getNormalizedPosition(item);
|
|
545
|
+
if (!normalizedPosition) {
|
|
546
|
+
return item;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (normalizedPosition === "full") {
|
|
550
|
+
const row = Math.max(leftRow, rightRow, nextFullRow);
|
|
551
|
+
leftRow = row + 1;
|
|
552
|
+
rightRow = row + 1;
|
|
553
|
+
nextFullRow = row + 1;
|
|
554
|
+
return { ...item, __positionStyle: { gridRow: `${row}` } };
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const row = normalizedPosition === "left" ? leftRow : rightRow;
|
|
558
|
+
if (normalizedPosition === "left") {
|
|
559
|
+
leftRow += 1;
|
|
560
|
+
} else {
|
|
561
|
+
rightRow += 1;
|
|
562
|
+
}
|
|
563
|
+
nextFullRow = Math.max(nextFullRow, row + 1);
|
|
564
|
+
|
|
565
|
+
return { ...item, __positionStyle: { gridRow: `${row}` } };
|
|
566
|
+
});
|
|
567
|
+
},
|
|
568
|
+
isEventAttribute({ key, value, type }) {
|
|
569
|
+
return Uts.isFunction(value) && !NON_EVENT_FUNCTION_KEYS.has(key) && !KEEP_FUNC_COMPONENT_TYPES.has(type);
|
|
570
|
+
},
|
|
571
|
+
handleSecTabClick(tab) {
|
|
572
|
+
const tabName = tab.name;
|
|
573
|
+
const originalTabConfig = this.getVisibleSecTabList().find((item) => item.name === tabName) || {};
|
|
574
|
+
const emitParams = {
|
|
575
|
+
...originalTabConfig,
|
|
576
|
+
tabName,
|
|
577
|
+
name: tabName,
|
|
578
|
+
activitySecTab: tabName
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
this.activitySecTab = tabName;
|
|
582
|
+
this.$emit("secTabChange", emitParams);
|
|
583
|
+
this.$emit("sec-tab-change", emitParams);
|
|
584
|
+
},
|
|
585
|
+
/**
|
|
586
|
+
* 通用显示判断方法
|
|
587
|
+
* @param {Boolean|Function} condition - 显示/隐藏条件
|
|
588
|
+
* @param {Object} context - 上下文数据
|
|
589
|
+
* @param {Boolean} isShowCondition - true 表示是 isShow,false 表示是 isHide
|
|
590
|
+
* @returns {Boolean} - 是否显示
|
|
591
|
+
*/
|
|
592
|
+
shouldShow(condition, context = this.formData, isShowCondition = false) {
|
|
593
|
+
if (condition === undefined) {
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const result = Uts.isFunction(condition) ? condition(context) : condition;
|
|
598
|
+
return isShowCondition ? result : !result;
|
|
599
|
+
},
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* 判断按钮是否应该显示
|
|
603
|
+
* @param {Object} config - 按钮配置对象 { isShow, isHide }
|
|
604
|
+
* @returns {Boolean} - 是否显示
|
|
605
|
+
*/
|
|
606
|
+
shouldShowEL({ isShow, isHide }) {
|
|
607
|
+
// 优先判断 isShow
|
|
608
|
+
if (isShow !== undefined) {
|
|
609
|
+
return this.shouldShow(isShow, this.formData, true);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// 其次判断 isHide
|
|
613
|
+
if (isHide !== undefined) {
|
|
614
|
+
return this.shouldShow(isHide, this.formData, false);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return true;
|
|
618
|
+
},
|
|
619
|
+
isUploadPictureList(otherAttributes = {}) {
|
|
620
|
+
const listType = otherAttributes.listType || otherAttributes["list-type"] || "text";
|
|
621
|
+
return listType === "picture" || listType === "picture-card";
|
|
622
|
+
},
|
|
623
|
+
/**
|
|
624
|
+
* 获取表单项的类名
|
|
625
|
+
*/
|
|
626
|
+
getFormItemClass({ type, nowrap, formItemClass, position }) {
|
|
627
|
+
const normalizedPosition = String(position || "").trim();
|
|
628
|
+
return [
|
|
629
|
+
"standard-form__item",
|
|
630
|
+
type && `standard-form__item--${type}`,
|
|
631
|
+
nowrap && "standard-form__item--nowrap",
|
|
632
|
+
SUPPORTED_POSITION_TYPES.has(normalizedPosition) && `standard-form__item--position-${normalizedPosition}`,
|
|
633
|
+
formItemClass
|
|
634
|
+
];
|
|
635
|
+
},
|
|
636
|
+
/**
|
|
637
|
+
* 获取选项的值
|
|
638
|
+
* @param {Object} option - 选项对象
|
|
639
|
+
* @param {Object} optionConfig - 选项配置
|
|
640
|
+
* @returns {String|Number} - 选项值
|
|
641
|
+
*/
|
|
642
|
+
getOptionValue(option, optionConfig = {}) {
|
|
643
|
+
const { valueKey } = optionConfig;
|
|
644
|
+
return valueKey ? option[valueKey] : option.value;
|
|
645
|
+
},
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* 获取选项的标签
|
|
649
|
+
* @param {Object} option - 选项对象
|
|
650
|
+
* @param {Object} optionConfig - 选项配置
|
|
651
|
+
* @returns {String} - 选项标签
|
|
652
|
+
*/
|
|
653
|
+
getOptionLabel(option, optionConfig = {}) {
|
|
654
|
+
const { labelKey, labelRender } = optionConfig;
|
|
655
|
+
|
|
656
|
+
if (labelRender && typeof labelRender === "function") {
|
|
657
|
+
return labelRender(option);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
return labelKey ? option[labelKey] : option.label || option.name;
|
|
661
|
+
},
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* 获取字段显示值(优先显示 _str 字段)
|
|
665
|
+
* @param {Object} params - 参数对象
|
|
666
|
+
* @param {String} params.name - 字段名
|
|
667
|
+
* @param {String} params.type - 字段类型
|
|
668
|
+
* @param {String} params.valuePrefix - 值前缀
|
|
669
|
+
* @param {String} params.label - 字段标签
|
|
670
|
+
* @returns {String|Number} - 显示值
|
|
671
|
+
*/
|
|
672
|
+
defaultValueRender({ name, type, valuePrefix = "", label = "" }) {
|
|
673
|
+
const strValue = this.formData[`${name}_str`];
|
|
674
|
+
const normalValue = this.formData[name];
|
|
675
|
+
const defaultValue = strValue || normalValue;
|
|
676
|
+
|
|
677
|
+
if (Uts.isNumber(defaultValue)) {
|
|
678
|
+
return defaultValue;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (type === "module" || !label || (!valuePrefix && !defaultValue && !this.emptyStr)) {
|
|
682
|
+
return "";
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (!defaultValue && defaultValue !== 0) {
|
|
686
|
+
return this.emptyStr;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
return `${valuePrefix}${defaultValue}`;
|
|
690
|
+
},
|
|
691
|
+
/**
|
|
692
|
+
* 获取标签类型
|
|
693
|
+
* @param {Object} atts - 属性对象
|
|
694
|
+
* @returns {String} - 标签类型
|
|
695
|
+
*/
|
|
696
|
+
getTagType(atts = {}) {
|
|
697
|
+
const { options = [], prop = "", propValueField = prop.replace("_str", "") } = atts;
|
|
698
|
+
const [option] = Uts.filterObjByCondition(options, { value: this.formData[propValueField] }) || [];
|
|
699
|
+
const { tagType = "" } = option || {};
|
|
700
|
+
return tagType;
|
|
701
|
+
},
|
|
702
|
+
/**
|
|
703
|
+
* 获取表单项标签文本
|
|
704
|
+
* @param {String} label - 标签文本
|
|
705
|
+
* @param {String} type - 表单项类型
|
|
706
|
+
* @returns {String} - 处理后的标签文本
|
|
707
|
+
*/
|
|
708
|
+
formItemLabel(label = "", type = "text") {
|
|
709
|
+
if (!label) {
|
|
710
|
+
return "";
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (this.existModuleType && this.rawLabelSuffix && type !== "module") {
|
|
714
|
+
return `${label}${this.rawLabelSuffix}`;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return label;
|
|
718
|
+
},
|
|
719
|
+
/**
|
|
720
|
+
* 计算表单项的标签宽度
|
|
721
|
+
* @param {Object} otherAttributes - 其他属性对象
|
|
722
|
+
* @returns {String} - 标签宽度
|
|
723
|
+
*/
|
|
724
|
+
calcLabelWidth(otherAttributes = {}) {
|
|
725
|
+
// 优先使用每项配置的 labelWidth,其次复用已缓存的 formLabelWidth computed(避免重复读 $attrs)
|
|
726
|
+
return otherAttributes.labelWidth || otherAttributes["label-width"] || this.formLabelWidth;
|
|
727
|
+
},
|
|
728
|
+
/**
|
|
729
|
+
* 重置表单数据
|
|
730
|
+
*/
|
|
731
|
+
resetFormData() {
|
|
732
|
+
// 通过事件通知父组件重置数据
|
|
733
|
+
if (Uts.isArray(this.$refs.InstitutionSelectRef)) {
|
|
734
|
+
this.$refs.InstitutionSelectRef.forEach((refItem) => {
|
|
735
|
+
if (Uts.isFunction(refItem.onDelete)) {
|
|
736
|
+
refItem.onDelete();
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
this.$emit("reset-form", Uts.copyObj(this.originFormData));
|
|
741
|
+
},
|
|
742
|
+
/**
|
|
743
|
+
* 获取表单实例
|
|
744
|
+
*/
|
|
745
|
+
getFormInstance() {
|
|
746
|
+
return this.$refs[this.formRef];
|
|
747
|
+
},
|
|
748
|
+
validate(callback) {
|
|
749
|
+
const form = this.getFormInstance();
|
|
750
|
+
if (!form) return Promise.reject(new Error("Form ref not found"));
|
|
751
|
+
return form.validate(callback);
|
|
752
|
+
},
|
|
753
|
+
clearValidate(props) {
|
|
754
|
+
const form = this.getFormInstance();
|
|
755
|
+
if (form) form.clearValidate(props);
|
|
756
|
+
},
|
|
757
|
+
validateField(props, callback) {
|
|
758
|
+
const form = this.getFormInstance();
|
|
759
|
+
if (form) form.validateField(props, callback);
|
|
760
|
+
},
|
|
761
|
+
// ─── 类型判断方法(供模板调用,使用模块级 Set,O(1) 查找)─────────────────────
|
|
762
|
+
isEditExcludeType(type) {
|
|
763
|
+
return EDIT_EXCLUDE_TYPES.has(type);
|
|
764
|
+
},
|
|
765
|
+
isBusinessSwitchType(type) {
|
|
766
|
+
return BUSINESS_SWITCH_TYPES.has(type);
|
|
767
|
+
},
|
|
768
|
+
isInstitutionSelectType(type) {
|
|
769
|
+
return INSTITUTION_SELECT_TYPES.has(type);
|
|
770
|
+
},
|
|
771
|
+
isInflyCheckboxType(type) {
|
|
772
|
+
return INFLY_CHECKBOX_TYPES.has(type);
|
|
773
|
+
},
|
|
774
|
+
isInflyInputType(type) {
|
|
775
|
+
return INFLY_INPUT_TYPES.has(type);
|
|
776
|
+
},
|
|
777
|
+
isDatePickerType(type) {
|
|
778
|
+
return DATE_PICKER_TYPES.has(type);
|
|
779
|
+
},
|
|
780
|
+
isSecTabGroupType(type) {
|
|
781
|
+
return type === INTERNAL_TABGROUP_TYPE;
|
|
782
|
+
},
|
|
783
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
784
|
+
/**
|
|
785
|
+
* 按钮点击事件处理
|
|
786
|
+
* @param {Object} btnItem - 按钮配置对象
|
|
787
|
+
*/
|
|
788
|
+
handleBtnClick(btnItem = {}) {
|
|
789
|
+
const {
|
|
790
|
+
click,
|
|
791
|
+
btnEvent = click,
|
|
792
|
+
exportUrl,
|
|
793
|
+
exportFileName,
|
|
794
|
+
exportFunc,
|
|
795
|
+
exportMethod,
|
|
796
|
+
dealParams,
|
|
797
|
+
...otherBtnParams
|
|
798
|
+
} = btnItem;
|
|
799
|
+
|
|
800
|
+
// 列表里面查询用到的请求参数,一般与导出参数一致
|
|
801
|
+
const { page, pagesize, ...exportParams } = this.reqParams;
|
|
802
|
+
|
|
803
|
+
// 处理函数类型的按钮事件
|
|
804
|
+
if (Uts.isFunction(btnEvent)) {
|
|
805
|
+
btnEvent(btnItem, this.formData);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// 处理字符串类型的按钮事件
|
|
810
|
+
if (Uts.isString(btnEvent)) {
|
|
811
|
+
if (btnEvent === "submit") {
|
|
812
|
+
this.validate((valid) => {
|
|
813
|
+
if (valid) {
|
|
814
|
+
this.$emit("submit", btnItem);
|
|
815
|
+
} else {
|
|
816
|
+
console.log("error submit!!");
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
this.$emit(btnEvent, btnItem);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// 处理导出功能
|
|
826
|
+
if (exportUrl) {
|
|
827
|
+
const request = this.resolveExportRequest(exportFunc);
|
|
828
|
+
if (!request) {
|
|
829
|
+
const error = new Error("InflyForm export request is not configured");
|
|
830
|
+
Message.error(error.message);
|
|
831
|
+
this.$emit("export-request-error", error, btnItem);
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
exportFile({
|
|
836
|
+
url: exportUrl,
|
|
837
|
+
fileName: exportFileName,
|
|
838
|
+
params: Uts.isFunction(dealParams) ? dealParams(exportParams, this.formData) : exportParams,
|
|
839
|
+
request,
|
|
840
|
+
reqMethod: exportMethod,
|
|
841
|
+
message: Message,
|
|
842
|
+
messageBox: MessageBox,
|
|
843
|
+
loading: Loading,
|
|
844
|
+
...otherBtnParams
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
|
|
849
|
+
resolveExportRequest(exportFunc) {
|
|
850
|
+
return exportFunc || this.request || this.$axios || null;
|
|
851
|
+
},
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* 处理数组形式的字段名
|
|
855
|
+
* @param {String|Array} name - 字段名或字段名数组
|
|
856
|
+
* @returns {String} - 处理后的字段名
|
|
857
|
+
*/
|
|
858
|
+
getFieldKey(name) {
|
|
859
|
+
return Array.isArray(name) ? name.join(",") : name;
|
|
860
|
+
},
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* 获取日期选择器的值
|
|
864
|
+
* @param {String|Array} name - 字段名或字段名数组
|
|
865
|
+
* @param {String} type - 日期选择器类型
|
|
866
|
+
* @returns {*} - 日期选择器的值
|
|
867
|
+
*/
|
|
868
|
+
getDatePickerValue(name) {
|
|
869
|
+
if (!Array.isArray(name)) {
|
|
870
|
+
return this.formData[name];
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
const [startField, endField] = name;
|
|
874
|
+
const startValue = this.formData[startField];
|
|
875
|
+
const endValue = this.formData[endField];
|
|
876
|
+
return startValue && endValue ? [startValue, endValue] : undefined;
|
|
877
|
+
},
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* 处理日期选择器输入
|
|
881
|
+
* @param {*} value - 日期选择器的值
|
|
882
|
+
* @param {String|Array} name - 字段名或字段名数组
|
|
883
|
+
* @param {String} type - 日期选择器类型
|
|
884
|
+
*/
|
|
885
|
+
handleDatePickerInput(value, name) {
|
|
886
|
+
if (!Array.isArray(name)) {
|
|
887
|
+
this.$set(this.formData, name, value);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const [startField, endField] = name;
|
|
892
|
+
const [startValue = "", endValue = ""] = value || [];
|
|
893
|
+
|
|
894
|
+
this.$set(this.formData, startField, startValue);
|
|
895
|
+
this.$set(this.formData, endField, endValue);
|
|
896
|
+
this.$set(this.formData, name.join(","), value || "");
|
|
897
|
+
},
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* 获取日期范围显示文本(非编辑状态)
|
|
901
|
+
* @param {String|Array} name - 字段名或字段名数组
|
|
902
|
+
* @returns {String} - 显示文本
|
|
903
|
+
*/
|
|
904
|
+
getDateRangeDisplay(name) {
|
|
905
|
+
if (Array.isArray(name)) {
|
|
906
|
+
const [startField, endField] = name;
|
|
907
|
+
const startValue = this.formData[startField];
|
|
908
|
+
const endValue = this.formData[endField];
|
|
909
|
+
|
|
910
|
+
if (startValue && endValue) {
|
|
911
|
+
return `${startValue} 至 ${endValue}`;
|
|
912
|
+
}
|
|
913
|
+
return "";
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
return this.formData[name] || "";
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
</script>
|
|
921
|
+
|
|
922
|
+
<style lang="scss" scoped>
|
|
923
|
+
.comp-InflyForm {
|
|
924
|
+
position: relative;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
.infly-form__wrap {
|
|
928
|
+
.el-form .el-form-item.el-form-item--mini {
|
|
929
|
+
margin-bottom: 18px;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.form__switch-text {
|
|
933
|
+
display: inline-block;
|
|
934
|
+
white-space: normal;
|
|
935
|
+
overflow-wrap: break-word;
|
|
936
|
+
word-break: break-all;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
.infly-form__sec-tab-btns {
|
|
940
|
+
text-align: right;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
.btn-list__wrap {
|
|
945
|
+
z-index: 100;
|
|
946
|
+
position: absolute;
|
|
947
|
+
top: 0;
|
|
948
|
+
right: 0;
|
|
949
|
+
width: 140px;
|
|
950
|
+
text-align: right;
|
|
951
|
+
|
|
952
|
+
&--row {
|
|
953
|
+
display: flex;
|
|
954
|
+
width: auto;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
&--bottom {
|
|
958
|
+
display: flex;
|
|
959
|
+
margin-left: 8px;
|
|
960
|
+
|
|
961
|
+
& .el-button {
|
|
962
|
+
margin-right: 8px;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
.btn-list__item {
|
|
967
|
+
margin-bottom: 8px;
|
|
968
|
+
|
|
969
|
+
& + .btn-list__item {
|
|
970
|
+
margin-left: 12px;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
</style>
|