@jzt-packages/components 1.0.0
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/package.json +68 -0
- package/src/JztBackTop/index.vue +255 -0
- package/src/JztButtonList/index.vue +88 -0
- package/src/JztChart/index.vue +95 -0
- package/src/JztCharts/index.vue +317 -0
- package/src/JztClassTabs/index.vue +156 -0
- package/src/JztDateSelect/dateSelect.vue +186 -0
- package/src/JztDateSelect/dateType.vue +54 -0
- package/src/JztDateSelect/index.ts +135 -0
- package/src/JztDateSelect/interface/index.ts +13 -0
- package/src/JztDialog/index.vue +249 -0
- package/src/JztEllipsisTooltip/index.vue +61 -0
- package/src/JztEmpty/index.vue +45 -0
- package/src/JztErrorPage/403.vue +30 -0
- package/src/JztErrorPage/404.vue +19 -0
- package/src/JztErrorPage/500.vue +18 -0
- package/src/JztErrorPage/assets/401.png +0 -0
- package/src/JztErrorPage/assets/403.png +0 -0
- package/src/JztErrorPage/assets/404.png +0 -0
- package/src/JztErrorPage/assets/500.png +0 -0
- package/src/JztErrorPage/index.scss +35 -0
- package/src/JztErrorPage/index.vue +35 -0
- package/src/JztFilePreview/components/pdfViewer.vue +221 -0
- package/src/JztFilePreview/hooks/useImageMethod.ts +256 -0
- package/src/JztFilePreview/index.scss +171 -0
- package/src/JztFilePreview/index.vue +68 -0
- package/src/JztFilePreview/interface/index.ts +18 -0
- package/src/JztFilePreview/previewFile.vue +371 -0
- package/src/JztFormGrid/README.md +520 -0
- package/src/JztFormGrid/components/formItem.vue +209 -0
- package/src/JztFormGrid/components/formItemValue.vue +384 -0
- package/src/JztFormGrid/components/showDetailForm.vue +172 -0
- package/src/JztFormGrid/index.scss +60 -0
- package/src/JztFormGrid/index.vue +513 -0
- package/src/JztFormGrid/interface/index.ts +106 -0
- package/src/JztGrid/components/GridItem.vue +68 -0
- package/src/JztGrid/index.vue +179 -0
- package/src/JztGrid/interface/index.ts +6 -0
- package/src/JztImportExcel/assets/delete.png +0 -0
- package/src/JztImportExcel/index.scss +46 -0
- package/src/JztImportExcel/index.vue +430 -0
- package/src/JztImportExcel/interface/index.ts +25 -0
- package/src/JztLabelTitle/index.vue +65 -0
- package/src/JztLeftRightMode/components/CollapseButton.vue +80 -0
- package/src/JztLeftRightMode/components/LeftCard.vue +203 -0
- package/src/JztLeftRightMode/components/LeftLayout.vue +173 -0
- package/src/JztLeftRightMode/components/RightHeader.vue +186 -0
- package/src/JztLeftRightMode/components/RightLayout.vue +235 -0
- package/src/JztLeftRightMode/components/RightTableHeader.vue +43 -0
- package/src/JztLeftRightMode/hooks/useCollapse.ts +17 -0
- package/src/JztLeftRightMode/hooks/useDefaultProps.ts +19 -0
- package/src/JztLeftRightMode/hooks/useLeftLayout.ts +201 -0
- package/src/JztLeftRightMode/hooks/useMode.ts +20 -0
- package/src/JztLeftRightMode/hooks/usePrevNext.ts +60 -0
- package/src/JztLeftRightMode/hooks/useRightLayout.ts +215 -0
- package/src/JztLeftRightMode/hooks/useSlots.ts +15 -0
- package/src/JztLeftRightMode/index.ts +3 -0
- package/src/JztLeftRightMode/index.vue +494 -0
- package/src/JztLeftRightMode/types/index.ts +457 -0
- package/src/JztLoading/fullScreen.ts +45 -0
- package/src/JztLoading/index.scss +67 -0
- package/src/JztLoading/index.vue +18 -0
- package/src/JztLogin/components/LoginFooter.vue +17 -0
- package/src/JztLogin/components/LoginForm.vue +99 -0
- package/src/JztLogin/hooks/useLogin.ts +186 -0
- package/src/JztLogin/index.scss +142 -0
- package/src/JztLogin/index.vue +31 -0
- package/src/JztLogin/interface/index.ts +47 -0
- package/src/JztNumericalRange/index.vue +81 -0
- package/src/JztPageCard/comm/datePicker.vue +151 -0
- package/src/JztPageCard/comm/details.vue +60 -0
- package/src/JztPageCard/comm/export.vue +24 -0
- package/src/JztPageCard/comm/tabs.vue +94 -0
- package/src/JztPageCard/comm/tooltip.vue +31 -0
- package/src/JztPageCard/index.vue +287 -0
- package/src/JztPagination/index.vue +70 -0
- package/src/JztProductInfo/components/imagePreview.vue +275 -0
- package/src/JztProductInfo/components/qxUnique.vue +101 -0
- package/src/JztProductInfo/components/records.vue +265 -0
- package/src/JztProductInfo/hooks/useParams.ts +143 -0
- package/src/JztProductInfo/hooks/useQxUnique.tsx +466 -0
- package/src/JztProductInfo/images/defaultProduct.png +0 -0
- package/src/JztProductInfo/index.ts +116 -0
- package/src/JztProductInfo/index.vue +108 -0
- package/src/JztProductInfo/interface/index.ts +15 -0
- package/src/JztQueryDetailTable/index.scss +100 -0
- package/src/JztQueryDetailTable/index.vue +400 -0
- package/src/JztQueryDetailTable/interface/index.ts +10 -0
- package/src/JztQueryTable/QueryTable /345/212/237/350/203/275.md" +1580 -0
- package/src/JztQueryTable/README.md +567 -0
- package/src/JztQueryTable/components/ColSetting.vue +67 -0
- package/src/JztQueryTable/components/ColumnsSetting.vue +404 -0
- package/src/JztQueryTable/components/ColumnsSetting1.vue +220 -0
- package/src/JztQueryTable/components/DeployToAccountLevelSetting.vue +351 -0
- package/src/JztQueryTable/components/Pagination.vue +54 -0
- package/src/JztQueryTable/components/TableColumn.vue +109 -0
- package/src/JztQueryTable/const.ts +1 -0
- package/src/JztQueryTable/hooks/useQueryTable.ts +194 -0
- package/src/JztQueryTable/hooks/useSelection.ts +47 -0
- package/src/JztQueryTable/hooks/useTableSetting.ts +197 -0
- package/src/JztQueryTable/hooks/useTemplate.ts +127 -0
- package/src/JztQueryTable/index.scss +91 -0
- package/src/JztQueryTable/index.vue +1445 -0
- package/src/JztQueryTable/interface/index.ts +185 -0
- package/src/JztRegionSelect/index.vue +134 -0
- package/src/JztSearchForm/components/SearchFormItem.vue +473 -0
- package/src/JztSearchForm/index.vue +530 -0
- package/src/JztSearchForm/interface/index.ts +100 -0
- package/src/JztSelectFilter/index.scss +63 -0
- package/src/JztSelectFilter/index.vue +110 -0
- package/src/JztSelectTable/index.vue +257 -0
- package/src/JztTable/index.scss +72 -0
- package/src/JztTable/index.vue +353 -0
- package/src/JztTable/interface/index.ts +1 -0
- package/src/JztTime/comm/agencySelect.vue +112 -0
- package/src/JztTime/comm/collapseRow.vue +132 -0
- package/src/JztTime/comm/dateSelect.vue +292 -0
- package/src/JztTime/comm/deptSelect.vue +193 -0
- package/src/JztTime/comm/typeSelect.vue +97 -0
- package/src/JztTime/index.ts +216 -0
- package/src/JztTime/index.vue +303 -0
- package/src/JztTime/interface/index.ts +23 -0
- package/src/JztTreeFilter/index.scss +44 -0
- package/src/JztTreeFilter/index.vue +177 -0
- package/src/JztUploadFile/interface/index.ts +21 -0
- package/src/JztUploadFile/multiple.scss +215 -0
- package/src/JztUploadFile/multiple.vue +318 -0
- package/src/JztUploadFile/single.scss +226 -0
- package/src/JztUploadFile/single.vue +274 -0
- package/src/JztUploadImg/Img.vue +294 -0
- package/src/JztUploadImg/Imgs.vue +411 -0
- package/src/JztUploadImg/index.scss +138 -0
- package/src/JztUploadImg/interface/index.ts +22 -0
- package/src/SelectIcon/index.scss +39 -0
- package/src/SelectIcon/index.vue +106 -0
- package/src/SvgIcon/index.vue +22 -0
- package/src/hooks/useAuthButtons.ts +58 -0
- package/src/hooks/useFormByUserType.ts +90 -0
- package/src/hooks/useTableEvents.ts +30 -0
- package/src/hooks/useUploadFileHook.ts +262 -0
- package/src/index.ts +91 -0
- package/src/typings/global.d.ts +101 -0
- package/src/utils/index.ts +107 -0
- package/src/utils/tree.ts +57 -0
- package/tsconfig.json +45 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flx-left-center" style="width: 100%">
|
|
3
|
+
<div v-if="queryItem.search?.el && !queryItem.search?.el.includes('el-')" style="width: 100%">
|
|
4
|
+
<!-- JztNumericalRange JztDateType JztDateSelect-->
|
|
5
|
+
<component
|
|
6
|
+
:is="CusComponent[queryItem.search?.el]"
|
|
7
|
+
v-bind="{
|
|
8
|
+
...handleSearchProps,
|
|
9
|
+
...placeholder,
|
|
10
|
+
searchParam: _searchParam,
|
|
11
|
+
clearable,
|
|
12
|
+
filterable,
|
|
13
|
+
searchProp: queryItem.search
|
|
14
|
+
}"
|
|
15
|
+
v-model.trim="_searchParam[queryItem.search?.key ?? handleProp(queryItem.prop!)]"
|
|
16
|
+
:queryItem="queryItem"
|
|
17
|
+
style="width: 100%"
|
|
18
|
+
></component>
|
|
19
|
+
</div>
|
|
20
|
+
<div v-else-if="queryItem.search?.props?.showValue" class="sle">
|
|
21
|
+
{{ showParam?.[queryItem?.showProp || queryItem?.prop] }}
|
|
22
|
+
</div>
|
|
23
|
+
<component
|
|
24
|
+
v-else
|
|
25
|
+
:ref="'JztSelectTreeRef'"
|
|
26
|
+
:is="queryItem.search?.render ?? `${queryItem.search?.el}`"
|
|
27
|
+
collapse-tags
|
|
28
|
+
collapse-tags-tooltip
|
|
29
|
+
v-bind="{
|
|
30
|
+
...handleSearchProps,
|
|
31
|
+
...placeholder,
|
|
32
|
+
searchParam: _searchParam,
|
|
33
|
+
clearable,
|
|
34
|
+
filterable
|
|
35
|
+
}"
|
|
36
|
+
v-model="_searchParam[queryItem.search?.key ?? handleProp(queryItem.prop!)]"
|
|
37
|
+
:data="queryItem.search?.el === 'el-tree-select' ? queryItemEnum : []"
|
|
38
|
+
:options="['el-cascader', 'el-select-v2'].includes(queryItem.search?.el!) ? queryItemEnum : []"
|
|
39
|
+
style="width: 100%"
|
|
40
|
+
@change="onChangeValue"
|
|
41
|
+
@focus="setOptionWidth"
|
|
42
|
+
:teleported="teleported"
|
|
43
|
+
v-on="handleEvents"
|
|
44
|
+
@check="handleCheck"
|
|
45
|
+
:class="queryItem?.appendProps?.type === 'border' ? 'append-border-el' : 'append-primary-el'"
|
|
46
|
+
@keyup.enter="handleEnter"
|
|
47
|
+
@blur="handleInputBlur"
|
|
48
|
+
>
|
|
49
|
+
<template v-if="queryItem?.appendProps?.show" #append>
|
|
50
|
+
<el-button class="append-right-button" @click="handleSearch">查询</el-button>
|
|
51
|
+
</template>
|
|
52
|
+
<template v-if="queryItem?.search?.hasCheckbox && queryItem.search?.el === 'el-tree-select'" #header>
|
|
53
|
+
<div class="flx-left-center">
|
|
54
|
+
<div class="flx-left-center mr20">
|
|
55
|
+
<el-checkbox v-model="checkedAll" @change="changeCheck" style="margin-right: 8px"></el-checkbox>
|
|
56
|
+
<span>全选</span>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="flx-left-center mr20">
|
|
59
|
+
<el-checkbox v-model="checkedInverse" @change="changeInverse" style="margin-right: 8px"></el-checkbox>
|
|
60
|
+
<span>反选</span>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
<!-- teleported 这里需要处理成false,因为为了避免el-popover中的选择下拉数据后会自动触发关闭 -->
|
|
65
|
+
<template v-if="queryItem.search?.el === 'el-cascader'" #default="{ data }">
|
|
66
|
+
<span>{{ data[fieldNames.label] }}</span>
|
|
67
|
+
</template>
|
|
68
|
+
<template v-if="queryItem.search?.el === 'el-select'">
|
|
69
|
+
<component
|
|
70
|
+
:is="`el-option`"
|
|
71
|
+
v-for="(col, index) in queryItemEnum"
|
|
72
|
+
:key="index"
|
|
73
|
+
:label="col[fieldNames.label]"
|
|
74
|
+
:value="col[fieldNames.value]"
|
|
75
|
+
:style="{ width: selectOptionWidth }"
|
|
76
|
+
></component>
|
|
77
|
+
</template>
|
|
78
|
+
<template v-if="queryItem.search?.el === 'el-radio-group'">
|
|
79
|
+
<component
|
|
80
|
+
:is="`el-radio`"
|
|
81
|
+
v-for="(col, index) in queryItemEnum"
|
|
82
|
+
:key="index"
|
|
83
|
+
:label="col[fieldNames.label]"
|
|
84
|
+
:value="col[fieldNames.value]"
|
|
85
|
+
></component>
|
|
86
|
+
</template>
|
|
87
|
+
<template v-if="queryItem.search?.el === 'el-checkbox-group'">
|
|
88
|
+
<component
|
|
89
|
+
is="el-checkbox"
|
|
90
|
+
v-for="(col, index) in queryItemEnum"
|
|
91
|
+
:key="index"
|
|
92
|
+
:label="col[fieldNames.label]"
|
|
93
|
+
:value="col[fieldNames.value]"
|
|
94
|
+
></component>
|
|
95
|
+
</template>
|
|
96
|
+
<slot v-else></slot>
|
|
97
|
+
</component>
|
|
98
|
+
<div v-if="queryItem.rightRender">
|
|
99
|
+
<component :is="queryItem.rightRender" v-bind="{ searchParam: _searchParam }" />
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<script setup lang="ts" name="SearchFormItem">
|
|
105
|
+
import { computed, inject, ref, defineComponent, nextTick, watch } from 'vue'
|
|
106
|
+
import { handleProp } from '../../utils/index'
|
|
107
|
+
import { QueryItemsProps } from '../interface/index'
|
|
108
|
+
import { isArray, isEmpty } from '@jzt-spd/utils'
|
|
109
|
+
import JztNumericalRange from '../../JztNumericalRange/index.vue'
|
|
110
|
+
import JztDateType from '../../JztDateSelect/dateType.vue'
|
|
111
|
+
import JztDateSelect from '../../JztDateSelect/dateSelect.vue'
|
|
112
|
+
|
|
113
|
+
import { getEnabledChildValues, disableRootNodesByDepth } from '../../utils/tree'
|
|
114
|
+
|
|
115
|
+
const CusComponent = defineComponent({
|
|
116
|
+
JztNumericalRange: JztNumericalRange,
|
|
117
|
+
JztDateType: JztDateType,
|
|
118
|
+
JztDateSelect: JztDateSelect
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
interface SearchFormItem {
|
|
122
|
+
queryItem: QueryItemsProps
|
|
123
|
+
searchParam: { [key: string]: any }
|
|
124
|
+
teleported?: boolean
|
|
125
|
+
showParam?: { [key: string]: any } // 查看参数
|
|
126
|
+
}
|
|
127
|
+
const props = withDefaults(defineProps<SearchFormItem>(), {
|
|
128
|
+
teleported: true
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
// Re receive SearchParam
|
|
132
|
+
const _searchParam = computed(() => props.searchParam)
|
|
133
|
+
|
|
134
|
+
// 判断 fieldNames 设置 label && value && children 的 key 值
|
|
135
|
+
const fieldNames = computed(() => {
|
|
136
|
+
return {
|
|
137
|
+
label: props.queryItem.fieldNames?.label ?? 'label',
|
|
138
|
+
value: props.queryItem.fieldNames?.value ?? 'value',
|
|
139
|
+
children: props.queryItem.fieldNames?.children ?? 'children'
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const emit = defineEmits(['getCascaderValue', 'handleSearch', 'handleItemClear'])
|
|
144
|
+
// 接收 enumMap (el 为 select-v2 需单独处理 enumData)
|
|
145
|
+
const enumMap = inject('enumMap', ref(new Map()))
|
|
146
|
+
|
|
147
|
+
// 监听值变化 获取getCascader数据
|
|
148
|
+
watch(
|
|
149
|
+
() => _searchParam.value[props.queryItem.prop],
|
|
150
|
+
(val, oldValue) => {
|
|
151
|
+
if (props.queryItem?.cascader) {
|
|
152
|
+
const queryItem = props.queryItem
|
|
153
|
+
emit('getCascaderValue', queryItem)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (isEmpty(val) && oldValue) {
|
|
157
|
+
// 清空
|
|
158
|
+
emit('handleItemClear', props.queryItem)
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{ immediate: true, deep: true }
|
|
162
|
+
)
|
|
163
|
+
// 获取getCascader数据
|
|
164
|
+
const onChangeValue = val => {
|
|
165
|
+
if (props.queryItem?.cascader && props.queryItem?.cascader.length) {
|
|
166
|
+
const queryItem = props.queryItem
|
|
167
|
+
emit('getCascaderValue', queryItem, true)
|
|
168
|
+
}
|
|
169
|
+
if (props.queryItem?.search?.el == 'el-tree-select') {
|
|
170
|
+
const ids = _searchParam.value?.[props.queryItem.prop] || []
|
|
171
|
+
props.queryItem.change && props.queryItem.change({ value: ids })
|
|
172
|
+
checkedAll.value = ids?.length === treeAllIds.value?.length
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
// 控件change事件
|
|
176
|
+
if (queryItemEnum.value && queryItemEnum.value.length) {
|
|
177
|
+
const value = fieldNames.value.value
|
|
178
|
+
const label = fieldNames.value.label
|
|
179
|
+
if (props.queryItem?.search?.props?.multiple) {
|
|
180
|
+
// 多选
|
|
181
|
+
const optionsItems = [] as any[] // 整体item
|
|
182
|
+
const optionsLabels = [] as string[] // name item
|
|
183
|
+
queryItemEnum.value.forEach(item => {
|
|
184
|
+
if (val.includes(item[value])) {
|
|
185
|
+
optionsItems.push(item)
|
|
186
|
+
optionsLabels.push(item[label])
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
props.queryItem.change &&
|
|
190
|
+
props.queryItem.change({
|
|
191
|
+
value: val,
|
|
192
|
+
optionsItem: optionsItems,
|
|
193
|
+
optionsLabels: optionsLabels,
|
|
194
|
+
searchForm: _searchParam.value
|
|
195
|
+
})
|
|
196
|
+
} else {
|
|
197
|
+
// 单选]
|
|
198
|
+
const optionsItem = queryItemEnum.value.filter(item => {
|
|
199
|
+
return item[value] === val
|
|
200
|
+
})
|
|
201
|
+
props.queryItem.change &&
|
|
202
|
+
props.queryItem.change({
|
|
203
|
+
value: val,
|
|
204
|
+
optionsItem: optionsItem[0],
|
|
205
|
+
searchForm: _searchParam.value
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
props.queryItem.change && props.queryItem.change({ value: val, searchForm: _searchParam.value })
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const queryItemEnum = computed(() => {
|
|
214
|
+
const queryItem = props.queryItem
|
|
215
|
+
const enumOptions1 = queryItem.enum || queryItem?.options
|
|
216
|
+
let enumOptions = enumOptions1
|
|
217
|
+
const treeLevel = props.queryItem.search?.allowCheckLevel || 0
|
|
218
|
+
if (enumOptions && isArray(enumOptions) && enumOptions.length) {
|
|
219
|
+
if (props.queryItem.search?.el === 'el-tree-select' && treeLevel) {
|
|
220
|
+
enumOptions = disableRootNodesByDepth(enumOptions1, treeLevel)
|
|
221
|
+
}
|
|
222
|
+
return enumOptions
|
|
223
|
+
}
|
|
224
|
+
let enumData1 = enumMap.value.get(queryItem.prop)
|
|
225
|
+
let enumData2 = enumMap.value.get(queryItem?.enumKey)
|
|
226
|
+
let enumData = enumData1 || enumData2 || []
|
|
227
|
+
if (enumData && isArray(enumData) && props.queryItem.search?.el === 'el-tree-select') {
|
|
228
|
+
enumData = disableRootNodesByDepth(enumData, treeLevel)
|
|
229
|
+
}
|
|
230
|
+
if (!enumData) return []
|
|
231
|
+
if (queryItem.search?.el === 'el-select-v2' && queryItem.fieldNames) {
|
|
232
|
+
enumData = enumData.map((item: { [key: string]: any }) => {
|
|
233
|
+
return {
|
|
234
|
+
...item,
|
|
235
|
+
label: item[fieldNames.value.label],
|
|
236
|
+
value: item[fieldNames.value.value]
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
return enumData
|
|
241
|
+
})
|
|
242
|
+
// 所有树形可选的子节点id 集合
|
|
243
|
+
const treeAllIds = ref<string[] | number[]>([])
|
|
244
|
+
//获取所有树形可选的子节点id
|
|
245
|
+
function getTreeAllEnabledIds() {
|
|
246
|
+
if (props.queryItem.search?.el === 'el-tree-select') {
|
|
247
|
+
const valueKey = fieldNames.value.value as string
|
|
248
|
+
const allIds = getEnabledChildValues(queryItemEnum.value, valueKey)
|
|
249
|
+
treeAllIds.value = allIds || []
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
watch(
|
|
254
|
+
() => queryItemEnum.value,
|
|
255
|
+
newValue => {
|
|
256
|
+
if (newValue && newValue.length) {
|
|
257
|
+
getTreeAllEnabledIds()
|
|
258
|
+
} else {
|
|
259
|
+
treeAllIds.value = []
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
{ immediate: true, deep: true }
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
// 处理透传的 searchProps (el 为 tree-select、cascader 的时候需要给下默认 label && value && children)
|
|
266
|
+
const handleSearchProps = computed(() => {
|
|
267
|
+
const label = fieldNames.value.label
|
|
268
|
+
const value = fieldNames.value.value
|
|
269
|
+
const children = fieldNames.value.children
|
|
270
|
+
const searchEl = props.queryItem.search?.el
|
|
271
|
+
let searchProps = props.queryItem.search?.props ?? {}
|
|
272
|
+
if (searchEl === 'el-tree-select') {
|
|
273
|
+
searchProps = {
|
|
274
|
+
...searchProps,
|
|
275
|
+
props: { ...searchProps, label, children },
|
|
276
|
+
nodeKey: value,
|
|
277
|
+
showCheckbox: searchProps.showCheckbox !== false
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (searchEl === 'el-cascader') {
|
|
281
|
+
searchProps = {
|
|
282
|
+
...searchProps,
|
|
283
|
+
props: { ...searchProps, label, value, children }
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (searchEl === 'el-input-number') {
|
|
287
|
+
searchProps = {
|
|
288
|
+
...searchProps,
|
|
289
|
+
controls: false
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return searchProps
|
|
293
|
+
})
|
|
294
|
+
// 处理动态事件绑定
|
|
295
|
+
const handleEvents = computed(() => {
|
|
296
|
+
const events = {}
|
|
297
|
+
const searchEvents = props.queryItem.search?.events ?? {}
|
|
298
|
+
|
|
299
|
+
// 将事件配置转换为事件监听器
|
|
300
|
+
Object.keys(searchEvents).forEach(eventName => {
|
|
301
|
+
if (typeof searchEvents[eventName] === 'function') {
|
|
302
|
+
events[`${eventName.charAt(0).toUpperCase() + eventName.slice(1)}`] = searchEvents[eventName]
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
return events
|
|
307
|
+
})
|
|
308
|
+
// 回车事件
|
|
309
|
+
const handleEnter = () => {
|
|
310
|
+
// 是否开启回车搜索
|
|
311
|
+
if (!props.queryItem?.search?.isEnter) return
|
|
312
|
+
handleInputBlur()
|
|
313
|
+
emit('handleSearch')
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// 处理默认 placeholder
|
|
317
|
+
const placeholder = computed(() => {
|
|
318
|
+
const search = props.queryItem.search
|
|
319
|
+
if (['datetimerange', 'daterange', 'monthrange'].includes(search?.props?.type) || search?.props?.isRange) {
|
|
320
|
+
return {
|
|
321
|
+
rangeSeparator: search?.props?.rangeSeparator ?? '至',
|
|
322
|
+
startPlaceholder: search?.props?.startPlaceholder ?? '开始时间',
|
|
323
|
+
endPlaceholder: search?.props?.endPlaceholder ?? '结束时间'
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const placeholder = search?.props?.placeholder ?? (search?.el?.includes('input') ? '请输入' : '请选择')
|
|
327
|
+
return { placeholder }
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
// 是否有清除按钮-默认有组件没有
|
|
331
|
+
const clearable = computed(() => {
|
|
332
|
+
const search = props.queryItem.search
|
|
333
|
+
return search?.props?.clearable ?? true
|
|
334
|
+
})
|
|
335
|
+
// 是否有多选-默认有
|
|
336
|
+
const filterable = computed(() => {
|
|
337
|
+
const search = props.queryItem.search
|
|
338
|
+
return search?.props?.filterable ?? true
|
|
339
|
+
|
|
340
|
+
// if (props.queryItem.el && ['el-select', 'el-select-v2'].includes(props.queryItem.el)) {
|
|
341
|
+
// return props.queryItem?.props?.filterable ?? true
|
|
342
|
+
// } else {
|
|
343
|
+
// return false
|
|
344
|
+
// }
|
|
345
|
+
})
|
|
346
|
+
const selectOptionWidth = ref()
|
|
347
|
+
// 设置select组件下拉框宽度
|
|
348
|
+
const setOptionWidth = event => {
|
|
349
|
+
nextTick(() => {
|
|
350
|
+
if (props.queryItem?.search?.props?.multiple) {
|
|
351
|
+
selectOptionWidth.value = '100%'
|
|
352
|
+
} else {
|
|
353
|
+
selectOptionWidth.value = event.srcElement.offsetWidth + 30 + 'px'
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const checkedAll = ref(false)
|
|
359
|
+
const checkedInverse = ref(false)
|
|
360
|
+
const JztSelectTreeRef = ref()
|
|
361
|
+
|
|
362
|
+
// 全选 取消全选(
|
|
363
|
+
const changeCheck = () => {
|
|
364
|
+
console.log(JztSelectTreeRef.value)
|
|
365
|
+
|
|
366
|
+
nextTick(() => {
|
|
367
|
+
checkedInverse.value = false
|
|
368
|
+
// const valueKey = fieldNames.value.value as string
|
|
369
|
+
if (checkedAll.value) {
|
|
370
|
+
// 获取非禁用的子节点集合
|
|
371
|
+
const allIds = treeAllIds.value // getEnabledChildValues(queryItemEnum.value, valueKey)
|
|
372
|
+
JztSelectTreeRef.value!.setCheckedKeys(allIds, true)
|
|
373
|
+
_searchParam.value[props.queryItem.prop] = allIds || []
|
|
374
|
+
onChangeValue(allIds)
|
|
375
|
+
} else {
|
|
376
|
+
JztSelectTreeRef.value!.setCheckedKeys([], true) // 1. 选中的数组 2. true:只设置选中的叶子节点, 默认值是 false.
|
|
377
|
+
_searchParam.value[props.queryItem.prop] = []
|
|
378
|
+
onChangeValue([])
|
|
379
|
+
}
|
|
380
|
+
handleCheck()
|
|
381
|
+
})
|
|
382
|
+
}
|
|
383
|
+
// 反选 取消全选
|
|
384
|
+
const changeInverse = () => {
|
|
385
|
+
checkedAll.value = false
|
|
386
|
+
// const valueKey = fieldNames.value.value as string
|
|
387
|
+
const vals = _searchParam.value[props.queryItem.prop] || []
|
|
388
|
+
const allIds = treeAllIds.value // getEnabledChildValues(queryItemEnum.value, valueKey)
|
|
389
|
+
const ids = allIds.filter(item => !vals.includes(item))
|
|
390
|
+
if (ids.length == allIds.length) {
|
|
391
|
+
// 反向判断勾选
|
|
392
|
+
checkedAll.value = true
|
|
393
|
+
}
|
|
394
|
+
nextTick(() => {
|
|
395
|
+
JztSelectTreeRef.value!.setCheckedKeys(ids, true)
|
|
396
|
+
_searchParam.value[props.queryItem.prop] = ids || []
|
|
397
|
+
onChangeValue(ids)
|
|
398
|
+
handleCheck()
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// 注入父组件提供的方法
|
|
403
|
+
// const sendToParent = inject<(data: any) => void>('sendToParent')
|
|
404
|
+
|
|
405
|
+
// 处理选中事件
|
|
406
|
+
const handleCheck = () => {
|
|
407
|
+
// (leafOnly, includeHalfChecked) (非仅子节点,包含半选中节点数据)
|
|
408
|
+
const checkedNodes = JztSelectTreeRef.value?.getCheckedNodes(false, true) || []
|
|
409
|
+
// 过滤子节点,仅仅留下父节点
|
|
410
|
+
const parentNodes = checkedNodes.filter(item => !treeAllIds.value.includes(item.value))
|
|
411
|
+
console.log('所有选中父节点的完整路径:', parentNodes)
|
|
412
|
+
// if (sendToParent) {
|
|
413
|
+
// sendToParent({
|
|
414
|
+
// parentNodes: parentNodes
|
|
415
|
+
// })
|
|
416
|
+
// }
|
|
417
|
+
}
|
|
418
|
+
const handleSearch = () => {
|
|
419
|
+
emit('handleSearch')
|
|
420
|
+
}
|
|
421
|
+
// 输入框失焦时去除首尾空格(中间空格保留)
|
|
422
|
+
const handleInputBlur = () => {
|
|
423
|
+
const key = String(props.queryItem.search?.key ?? handleProp(String(props.queryItem.prop)))
|
|
424
|
+
const val = _searchParam.value[key]
|
|
425
|
+
if (typeof val === 'string') {
|
|
426
|
+
_searchParam.value[key] = val.trim()
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
/** 使用方法: 孙组件向父组件传递数据
|
|
430
|
+
const receivedData = ref<any[]>([])
|
|
431
|
+
// 提供回调函数给子孙组件
|
|
432
|
+
const handleDataFromGrandchild = (data: any) => {
|
|
433
|
+
receivedData.value = data.parentNodes
|
|
434
|
+
console.log('父组件收到数据:', data)
|
|
435
|
+
}
|
|
436
|
+
provide('sendToParent', handleDataFromGrandchild)
|
|
437
|
+
*/
|
|
438
|
+
</script>
|
|
439
|
+
<style lang="scss">
|
|
440
|
+
.el-select-dropdown__header {
|
|
441
|
+
padding: 4px 12px !important;
|
|
442
|
+
}
|
|
443
|
+
</style>
|
|
444
|
+
<style lang="scss" scoped>
|
|
445
|
+
.append-border-el {
|
|
446
|
+
padding: 0 0;
|
|
447
|
+
width: 100%;
|
|
448
|
+
:deep(.el-input__wrapper) {
|
|
449
|
+
border-radius: 4px 0 0 4px;
|
|
450
|
+
box-shadow: 0 0 0 1px var(--el-color-primary) inset;
|
|
451
|
+
}
|
|
452
|
+
.append-right-button {
|
|
453
|
+
background-color: #f6f8ff !important;
|
|
454
|
+
color: var(--el-color-primary) !important;
|
|
455
|
+
border: 1px solid var(--el-color-primary) !important;
|
|
456
|
+
// padding: 0 16px;
|
|
457
|
+
border-radius: 0 4px 4px 0;
|
|
458
|
+
margin: 0 -20px;
|
|
459
|
+
margin-left: -21px !important;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
.append-primary-el {
|
|
463
|
+
.append-right-button {
|
|
464
|
+
background-color: var(--el-color-primary) !important;
|
|
465
|
+
border-color: var(--el-color-primary) !important;
|
|
466
|
+
color: #fff !important;
|
|
467
|
+
border: transparent !important;
|
|
468
|
+
// padding: 0 16px;
|
|
469
|
+
border-radius: 0 4px 4px 0;
|
|
470
|
+
// margin-left: -1px;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
</style>
|