@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.
Files changed (145) hide show
  1. package/package.json +68 -0
  2. package/src/JztBackTop/index.vue +255 -0
  3. package/src/JztButtonList/index.vue +88 -0
  4. package/src/JztChart/index.vue +95 -0
  5. package/src/JztCharts/index.vue +317 -0
  6. package/src/JztClassTabs/index.vue +156 -0
  7. package/src/JztDateSelect/dateSelect.vue +186 -0
  8. package/src/JztDateSelect/dateType.vue +54 -0
  9. package/src/JztDateSelect/index.ts +135 -0
  10. package/src/JztDateSelect/interface/index.ts +13 -0
  11. package/src/JztDialog/index.vue +249 -0
  12. package/src/JztEllipsisTooltip/index.vue +61 -0
  13. package/src/JztEmpty/index.vue +45 -0
  14. package/src/JztErrorPage/403.vue +30 -0
  15. package/src/JztErrorPage/404.vue +19 -0
  16. package/src/JztErrorPage/500.vue +18 -0
  17. package/src/JztErrorPage/assets/401.png +0 -0
  18. package/src/JztErrorPage/assets/403.png +0 -0
  19. package/src/JztErrorPage/assets/404.png +0 -0
  20. package/src/JztErrorPage/assets/500.png +0 -0
  21. package/src/JztErrorPage/index.scss +35 -0
  22. package/src/JztErrorPage/index.vue +35 -0
  23. package/src/JztFilePreview/components/pdfViewer.vue +221 -0
  24. package/src/JztFilePreview/hooks/useImageMethod.ts +256 -0
  25. package/src/JztFilePreview/index.scss +171 -0
  26. package/src/JztFilePreview/index.vue +68 -0
  27. package/src/JztFilePreview/interface/index.ts +18 -0
  28. package/src/JztFilePreview/previewFile.vue +371 -0
  29. package/src/JztFormGrid/README.md +520 -0
  30. package/src/JztFormGrid/components/formItem.vue +209 -0
  31. package/src/JztFormGrid/components/formItemValue.vue +384 -0
  32. package/src/JztFormGrid/components/showDetailForm.vue +172 -0
  33. package/src/JztFormGrid/index.scss +60 -0
  34. package/src/JztFormGrid/index.vue +513 -0
  35. package/src/JztFormGrid/interface/index.ts +106 -0
  36. package/src/JztGrid/components/GridItem.vue +68 -0
  37. package/src/JztGrid/index.vue +179 -0
  38. package/src/JztGrid/interface/index.ts +6 -0
  39. package/src/JztImportExcel/assets/delete.png +0 -0
  40. package/src/JztImportExcel/index.scss +46 -0
  41. package/src/JztImportExcel/index.vue +430 -0
  42. package/src/JztImportExcel/interface/index.ts +25 -0
  43. package/src/JztLabelTitle/index.vue +65 -0
  44. package/src/JztLeftRightMode/components/CollapseButton.vue +80 -0
  45. package/src/JztLeftRightMode/components/LeftCard.vue +203 -0
  46. package/src/JztLeftRightMode/components/LeftLayout.vue +173 -0
  47. package/src/JztLeftRightMode/components/RightHeader.vue +186 -0
  48. package/src/JztLeftRightMode/components/RightLayout.vue +235 -0
  49. package/src/JztLeftRightMode/components/RightTableHeader.vue +43 -0
  50. package/src/JztLeftRightMode/hooks/useCollapse.ts +17 -0
  51. package/src/JztLeftRightMode/hooks/useDefaultProps.ts +19 -0
  52. package/src/JztLeftRightMode/hooks/useLeftLayout.ts +201 -0
  53. package/src/JztLeftRightMode/hooks/useMode.ts +20 -0
  54. package/src/JztLeftRightMode/hooks/usePrevNext.ts +60 -0
  55. package/src/JztLeftRightMode/hooks/useRightLayout.ts +215 -0
  56. package/src/JztLeftRightMode/hooks/useSlots.ts +15 -0
  57. package/src/JztLeftRightMode/index.ts +3 -0
  58. package/src/JztLeftRightMode/index.vue +494 -0
  59. package/src/JztLeftRightMode/types/index.ts +457 -0
  60. package/src/JztLoading/fullScreen.ts +45 -0
  61. package/src/JztLoading/index.scss +67 -0
  62. package/src/JztLoading/index.vue +18 -0
  63. package/src/JztLogin/components/LoginFooter.vue +17 -0
  64. package/src/JztLogin/components/LoginForm.vue +99 -0
  65. package/src/JztLogin/hooks/useLogin.ts +186 -0
  66. package/src/JztLogin/index.scss +142 -0
  67. package/src/JztLogin/index.vue +31 -0
  68. package/src/JztLogin/interface/index.ts +47 -0
  69. package/src/JztNumericalRange/index.vue +81 -0
  70. package/src/JztPageCard/comm/datePicker.vue +151 -0
  71. package/src/JztPageCard/comm/details.vue +60 -0
  72. package/src/JztPageCard/comm/export.vue +24 -0
  73. package/src/JztPageCard/comm/tabs.vue +94 -0
  74. package/src/JztPageCard/comm/tooltip.vue +31 -0
  75. package/src/JztPageCard/index.vue +287 -0
  76. package/src/JztPagination/index.vue +70 -0
  77. package/src/JztProductInfo/components/imagePreview.vue +275 -0
  78. package/src/JztProductInfo/components/qxUnique.vue +101 -0
  79. package/src/JztProductInfo/components/records.vue +265 -0
  80. package/src/JztProductInfo/hooks/useParams.ts +143 -0
  81. package/src/JztProductInfo/hooks/useQxUnique.tsx +466 -0
  82. package/src/JztProductInfo/images/defaultProduct.png +0 -0
  83. package/src/JztProductInfo/index.ts +116 -0
  84. package/src/JztProductInfo/index.vue +108 -0
  85. package/src/JztProductInfo/interface/index.ts +15 -0
  86. package/src/JztQueryDetailTable/index.scss +100 -0
  87. package/src/JztQueryDetailTable/index.vue +400 -0
  88. package/src/JztQueryDetailTable/interface/index.ts +10 -0
  89. package/src/JztQueryTable/QueryTable /345/212/237/350/203/275.md" +1580 -0
  90. package/src/JztQueryTable/README.md +567 -0
  91. package/src/JztQueryTable/components/ColSetting.vue +67 -0
  92. package/src/JztQueryTable/components/ColumnsSetting.vue +404 -0
  93. package/src/JztQueryTable/components/ColumnsSetting1.vue +220 -0
  94. package/src/JztQueryTable/components/DeployToAccountLevelSetting.vue +351 -0
  95. package/src/JztQueryTable/components/Pagination.vue +54 -0
  96. package/src/JztQueryTable/components/TableColumn.vue +109 -0
  97. package/src/JztQueryTable/const.ts +1 -0
  98. package/src/JztQueryTable/hooks/useQueryTable.ts +194 -0
  99. package/src/JztQueryTable/hooks/useSelection.ts +47 -0
  100. package/src/JztQueryTable/hooks/useTableSetting.ts +197 -0
  101. package/src/JztQueryTable/hooks/useTemplate.ts +127 -0
  102. package/src/JztQueryTable/index.scss +91 -0
  103. package/src/JztQueryTable/index.vue +1445 -0
  104. package/src/JztQueryTable/interface/index.ts +185 -0
  105. package/src/JztRegionSelect/index.vue +134 -0
  106. package/src/JztSearchForm/components/SearchFormItem.vue +473 -0
  107. package/src/JztSearchForm/index.vue +530 -0
  108. package/src/JztSearchForm/interface/index.ts +100 -0
  109. package/src/JztSelectFilter/index.scss +63 -0
  110. package/src/JztSelectFilter/index.vue +110 -0
  111. package/src/JztSelectTable/index.vue +257 -0
  112. package/src/JztTable/index.scss +72 -0
  113. package/src/JztTable/index.vue +353 -0
  114. package/src/JztTable/interface/index.ts +1 -0
  115. package/src/JztTime/comm/agencySelect.vue +112 -0
  116. package/src/JztTime/comm/collapseRow.vue +132 -0
  117. package/src/JztTime/comm/dateSelect.vue +292 -0
  118. package/src/JztTime/comm/deptSelect.vue +193 -0
  119. package/src/JztTime/comm/typeSelect.vue +97 -0
  120. package/src/JztTime/index.ts +216 -0
  121. package/src/JztTime/index.vue +303 -0
  122. package/src/JztTime/interface/index.ts +23 -0
  123. package/src/JztTreeFilter/index.scss +44 -0
  124. package/src/JztTreeFilter/index.vue +177 -0
  125. package/src/JztUploadFile/interface/index.ts +21 -0
  126. package/src/JztUploadFile/multiple.scss +215 -0
  127. package/src/JztUploadFile/multiple.vue +318 -0
  128. package/src/JztUploadFile/single.scss +226 -0
  129. package/src/JztUploadFile/single.vue +274 -0
  130. package/src/JztUploadImg/Img.vue +294 -0
  131. package/src/JztUploadImg/Imgs.vue +411 -0
  132. package/src/JztUploadImg/index.scss +138 -0
  133. package/src/JztUploadImg/interface/index.ts +22 -0
  134. package/src/SelectIcon/index.scss +39 -0
  135. package/src/SelectIcon/index.vue +106 -0
  136. package/src/SvgIcon/index.vue +22 -0
  137. package/src/hooks/useAuthButtons.ts +58 -0
  138. package/src/hooks/useFormByUserType.ts +90 -0
  139. package/src/hooks/useTableEvents.ts +30 -0
  140. package/src/hooks/useUploadFileHook.ts +262 -0
  141. package/src/index.ts +91 -0
  142. package/src/typings/global.d.ts +101 -0
  143. package/src/utils/index.ts +107 -0
  144. package/src/utils/tree.ts +57 -0
  145. package/tsconfig.json +45 -0
@@ -0,0 +1,209 @@
1
+ <template>
2
+ <el-col :span="item.span || 12" :class="border ? 'border-col' : ''">
3
+ <div v-if="item?.outerRender" class="mb13">
4
+ <component :is="item?.outerRender" />
5
+ </div>
6
+ <!---->
7
+ <showDetailForm
8
+ v-else-if="isDetail"
9
+ :item="item"
10
+ :ruleForm="ruleForm"
11
+ :infoEmptyText="infoEmptyText"
12
+ :border="border"
13
+ :showOverflowTooltip="showOverflowTooltip"
14
+ >
15
+ <template #[item.slotName] :key="item.prop + index + '_template_' + childIndex">
16
+ <slot :name="item.slotName"></slot>
17
+ </template>
18
+ </showDetailForm>
19
+ <!-- v-else -->
20
+ <el-form-item
21
+ v-else
22
+ v-bind="item.formItemProps"
23
+ :prop="String(item.prop)"
24
+ :rules="item.rules"
25
+ style="width: 100%"
26
+ :class="item.className ? item.className : ''"
27
+ :label-width="item.labelWidth ?? 'auto'"
28
+ >
29
+ <template #label>
30
+ <el-space :size="4" style="height: 100% !important">
31
+ <component v-if="item?.labelRender" :is="item?.labelRender" />
32
+ <span v-else-if="item.prop !== 'submitBtn' && item.label" class="flx-left-center" style="height: 100%">
33
+ <span class="label-text">
34
+ {{ `${item.label}` }}
35
+ </span>
36
+ <!-- <span>:</span> -->
37
+ </span>
38
+ <el-tooltip v-if="item.tooltip" effect="dark" :content="item.tooltip" placement="top">
39
+ <el-icon><Warning /></el-icon>
40
+ </el-tooltip>
41
+ </el-space>
42
+ </template>
43
+ <div v-if="item.prop === 'submitBtn' && !isShow">
44
+ <template v-for="(btnItem, index) in item.btnLList" :key="index">
45
+ <el-button
46
+ v-if="btnItem.hideFun ? !btnItem.hideFun(btnItem) : true"
47
+ class="table-top-btn"
48
+ :text="false"
49
+ :type="btnItem.type || 'default'"
50
+ :loading="btnItem.loading"
51
+ :icon="btnItem.icon || ''"
52
+ :plain="btnItem.plain"
53
+ @click="formOperationFn(btnItem)"
54
+ >
55
+ {{ btnItem.text }}
56
+ </el-button>
57
+ </template>
58
+ </div>
59
+ <template v-else-if="item.prop !== 'submitBtn'">
60
+ <span v-if="item.slotName">
61
+ <slot :name="item.slotName" />
62
+ </span>
63
+ <div v-else-if="isShow" class="contentText flx-left-center">
64
+ <template v-if="!item.el">
65
+ {{ formatValue(ruleForm[item.prop as string]) ?? infoEmptyText }}
66
+ </template>
67
+ <template v-if="['el-checkbox-group', 'el-radio-group', 'el-select', 'el-select-v2'].includes(item.el!)">
68
+ {{ formatValue(getItemData(item, ruleForm[item.prop as string])) ?? infoEmptyText }}
69
+ </template>
70
+ <template v-else-if="!item.el?.includes('el-')">
71
+ <formItemValue :query-item="{ ...item, props: { ...item.props, isShow: true } }" :search-param="ruleForm" />
72
+ </template>
73
+ <template v-else-if="item.el == 'el-date-picker'">
74
+ {{ ruleForm[item.prop as string]?.[0] || infoEmptyText }}
75
+ <span class="ml8 mr8">至</span>
76
+ {{ ruleForm[item.prop as string]?.[1] || infoEmptyText }}
77
+ </template>
78
+ <template v-else-if="item.render">
79
+ <component :is="item.render" />
80
+ </template>
81
+ <template v-else>
82
+ {{ formatValue(ruleForm[item.prop as string]) ?? infoEmptyText }}
83
+ </template>
84
+ </div>
85
+ <formItemValue v-else :query-item="item" :search-param="ruleForm" @getCascaderValue="getCascaderValue" />
86
+ </template>
87
+ </el-form-item>
88
+ </el-col>
89
+ </template>
90
+ <script setup lang="ts" name="SearchForm">
91
+ import { computed, ref, reactive, inject } from 'vue'
92
+ import { FormItemsProps } from '../interface/index'
93
+ import formItemValue from './formItemValue.vue'
94
+ import showDetailForm from './showDetailForm.vue'
95
+ import { formatValue } from '@jzt-spd/utils'
96
+ interface ProTableProps {
97
+ showOverflowTooltip?: boolean // 是否显示超出部分提示
98
+ item: FormItemsProps // 搜索参数
99
+ ruleForm?: { [key: string]: any } // 搜索参数
100
+ isShow?: boolean // 是否是查看模式
101
+ disabled?: boolean // 是否表单禁用
102
+ formProps?: Record<string, any>
103
+ infoEmptyText?: string
104
+ border?: boolean // 是否显示边框
105
+ isDetail?: boolean
106
+ }
107
+
108
+ // 默认值
109
+ const props = withDefaults(defineProps<ProTableProps>(), {
110
+ // item: () => ({}),
111
+ ruleForm: () => ({}),
112
+ isShow: false, // 是否是查看模式
113
+ infoEmptyText: '-',
114
+ border: false
115
+ })
116
+
117
+ const emit = defineEmits(['formOperationFn', 'update:form', 'getCascaderValue'])
118
+ const enumMap = inject('fromEnumMap', ref(new Map()))
119
+ // 操作列点击操作
120
+ const formOperationFn = (item: any) => {
121
+ emit('formOperationFn', item)
122
+ }
123
+ // 获取每一项的数据
124
+ const getItemData = (formItemOptions: FormItemsProps, value: string | number | (string | number)[]) => {
125
+ const fieldNames = {
126
+ label: formItemOptions.fieldNames?.label ?? 'label',
127
+ value: formItemOptions.fieldNames?.value ?? 'value'
128
+ }
129
+ const enumData = enumMap.value.get(formItemOptions.prop) || formItemOptions.options
130
+ const enumList = formItemOptions.enum || []
131
+ const enumArray = enumData || enumList || {}
132
+ if (formItemOptions.props?.multiple || formItemOptions.el === 'el-checkbox-group') {
133
+ if ((value as (string | number)[])?.length) {
134
+ return (value as (string | number)[])
135
+ .map(valueItem => {
136
+ const findItem = enumArray?.find?.(item => item[fieldNames.value] === valueItem)
137
+ return findItem?.[fieldNames.label]
138
+ })
139
+ .join(', ')
140
+ }
141
+ return value
142
+ }
143
+ // const enumArray = enumData || enumList || {}
144
+ const findItem = enumArray?.find?.(item => item[fieldNames.value] === value)
145
+ return findItem?.[fieldNames.label] || value
146
+ }
147
+ // 获取getCascader数据
148
+ const getCascaderValue = (queryItem, isClear: boolean = false) => {
149
+ if (queryItem.cascader && queryItem.cascader.length) {
150
+ emit('getCascaderValue', queryItem, isClear)
151
+ }
152
+ }
153
+ </script>
154
+
155
+ <style lang="scss" scoped>
156
+ .contentText {
157
+ color: var(--el-text-color-primary);
158
+ line-height: 22px;
159
+ word-break: break-all;
160
+ width: 100%;
161
+ }
162
+ :deep(.el-textarea__inner) {
163
+ word-break: break-all;
164
+ }
165
+
166
+ .label-text {
167
+ max-width: 106px;
168
+ line-height: 20px;
169
+ text-align: right;
170
+ // margin-right: 3px;
171
+ }
172
+
173
+ .el-form-item {
174
+ width: 100%;
175
+ padding: 0 8px;
176
+ }
177
+
178
+ .el-col.border-col {
179
+ border-right: 1px solid #ebeef5;
180
+ border-bottom: 1px solid #ebeef5;
181
+ padding: 0;
182
+ background: #f5f7fa !important;
183
+ &:nth-last-child(1) {
184
+ border-radius: 0 0 6px 0;
185
+ overflow: hidden;
186
+ }
187
+
188
+ .label-text {
189
+ max-width: 130px;
190
+ padding-left: 12px;
191
+ line-height: 20px;
192
+ margin: 8px 0;
193
+ }
194
+ .el-form-item {
195
+ margin-bottom: 0 !important;
196
+ padding: 0;
197
+ }
198
+ :deep(.el-form-item__content) {
199
+ height: 100%;
200
+ background-color: #fff;
201
+ padding: 8px 0;
202
+ }
203
+ .contentText {
204
+ height: 100%;
205
+ // background-color: #fff;
206
+ padding-left: 10px;
207
+ }
208
+ }
209
+ </style>
@@ -0,0 +1,384 @@
1
+ <template>
2
+ <div class="flx-left-center" style="width: 100%">
3
+ <div v-if="queryItem.el && !queryItem.el.includes('el-')" style="width: 100%">
4
+ <!-- 自定义组件:文件、图片上传 -->
5
+ <div v-if="queryItem.el && queryItem.el.includes('JztUpload')" style="width: 100%">
6
+ <!-- 顶部tips -->
7
+ <component :is="queryItem?.props?.topTipsRender" style="font-size: 12px" />
8
+ <!-- !-- 单图片上传 多图片上传-->
9
+ <component
10
+ :is="CusComponent[queryItem.el]"
11
+ v-model:image-url="_searchParam[queryItem?.key ?? handleProp(queryItem.prop!)]"
12
+ v-model:file-list="_searchParam[queryItem?.key ?? handleProp(queryItem.prop!)]"
13
+ v-bind="{
14
+ ...handleSearchProps,
15
+ listType: queryItem?.props?.listType
16
+ }"
17
+ @getOcrData="queryItem?.props?.getOcrData"
18
+ >
19
+ <template #upload-left>
20
+ <component #upload-left :is="queryItem?.props.uploadLeftRender" />
21
+ </template>
22
+ <template #tip v-if="queryItem?.props?.tipsRender">
23
+ <component #tip :is="queryItem?.props.tipsRender" />
24
+ </template>
25
+ </component>
26
+ </div>
27
+ <!-- 自定义组件:JztNumericalRange、JztRegionSelect -->
28
+ <component
29
+ v-else
30
+ :is="CusComponent[queryItem?.el]"
31
+ v-bind="{
32
+ ...handleSearchProps,
33
+ ...placeholder,
34
+ searchParam: _searchParam,
35
+ clearable,
36
+ filterable
37
+ }"
38
+ v-model.trim="_searchParam[queryItem?.key ?? handleProp(queryItem.prop!)]"
39
+ :queryItem="queryItem"
40
+ :disabled="queryItem?.props?.disabled"
41
+ style="width: 100%"
42
+ ></component>
43
+ </div>
44
+ <component
45
+ v-else
46
+ :ref="'SelectTreeRef'"
47
+ :is="queryItem?.render ?? `${queryItem.el}`"
48
+ v-bind="{
49
+ ...handleSearchProps,
50
+ ...placeholder,
51
+ searchParam: _searchParam,
52
+ clearable,
53
+ filterable
54
+ }"
55
+ v-on="handleEvents"
56
+ v-model.trim="_searchParam[queryItem?.key ?? handleProp(queryItem.prop!)]"
57
+ :data="queryItem.el === 'el-tree-select' ? queryItemEnum : []"
58
+ :options="['el-cascader', 'el-select-v2'].includes(queryItem.el!) ? queryItemEnum : []"
59
+ style="width: 100%"
60
+ :disabled="queryItem?.props?.disabled || (queryItem.disabledFn && queryItem.disabledFn(_searchParam))"
61
+ @change="onChangeValue"
62
+ @focus="setOptionWidth"
63
+ >
64
+ <template v-if="queryItem?.el === 'el-tree-select' && queryItem?.hasCheckbox" #header>
65
+ <div class="flx-left-center">
66
+ <div class="flx-left-center mr20">
67
+ <el-checkbox v-model="checkedAll" @change="changeCheck" style="margin-right: 8px"></el-checkbox>
68
+ <span>全选</span>
69
+ </div>
70
+ <div class="flx-left-center mr20">
71
+ <el-checkbox v-model="checkedInverse" @change="changeInverse" style="margin-right: 8px"></el-checkbox>
72
+ <span>反选</span>
73
+ </div>
74
+ </div>
75
+ </template>
76
+ <template v-if="queryItem.el === 'el-cascader'" #default="{ data }">
77
+ <span>{{ data[fieldNames.label] }}</span>
78
+ </template>
79
+ <template #default v-else-if="queryItem.el === 'el-select'">
80
+ <component
81
+ :is="`el-option`"
82
+ v-for="(col, index) in queryItemEnum"
83
+ :key="index"
84
+ :label="col[fieldNames.label]"
85
+ :value="col[fieldNames.value]"
86
+ :style="{ width: selectOptionWidth }"
87
+ ></component>
88
+ </template>
89
+ <template #default v-else-if="queryItem.el === 'el-radio-group'">
90
+ <component
91
+ :is="`el-radio`"
92
+ v-for="(col, index) in queryItemEnum"
93
+ :key="index"
94
+ :label="col[fieldNames.label]"
95
+ :value="col[fieldNames.value]"
96
+ ></component>
97
+ </template>
98
+ <template #default v-else-if="queryItem.el === 'el-checkbox-group'">
99
+ <component
100
+ :is="`el-checkbox`"
101
+ v-for="(col, index) in queryItemEnum"
102
+ :key="index"
103
+ :label="col[fieldNames.label]"
104
+ :value="col[fieldNames.value]"
105
+ ></component>
106
+ </template>
107
+ <template #default v-else>
108
+ <slot></slot>
109
+ </template>
110
+ </component>
111
+
112
+ <div v-if="queryItem.rightRender">
113
+ <component :is="queryItem.rightRender" v-bind="{ searchParam: _searchParam }" />
114
+ </div>
115
+ </div>
116
+ </template>
117
+
118
+ <script setup lang="ts" name="SearchFormItem">
119
+ import { computed, inject, ref, defineComponent, nextTick, watch } from 'vue'
120
+ import { handleProp } from '../../utils/index'
121
+ import { FormItemsProps } from '../interface/index'
122
+ import JztUploadImg from '../../JztUploadImg/Img.vue'
123
+ import JztUploadMultipleImgs from '../../JztUploadImg/Imgs.vue'
124
+ import JztUploadMultipleFiles from '../../JztUploadFile/multiple.vue'
125
+ import JztUploadSingleFile from '../../JztUploadFile/single.vue'
126
+ import JztNumericalRange from '../../JztNumericalRange/index.vue'
127
+ import JztRegionSelect from '../../JztRegionSelect/index.vue'
128
+
129
+ import JztTable from '../../JztTable/index.vue'
130
+ import { isArray, sessionGetPrecision } from '@jzt-spd/utils'
131
+ import { getEnabledChildValues, disableRootNodesByDepth } from '../../utils/tree'
132
+
133
+ interface SearchFormItem {
134
+ queryItem: FormItemsProps
135
+ searchParam: { [key: string]: any }
136
+ }
137
+
138
+ const CusComponent = defineComponent({
139
+ JztUploadImg: JztUploadImg,
140
+ JztUploadMultipleImgs: JztUploadMultipleImgs,
141
+ JztUploadMultipleFiles: JztUploadMultipleFiles,
142
+ JztUploadSingleFile: JztUploadSingleFile,
143
+ JztTable: JztTable,
144
+ JztNumericalRange: JztNumericalRange,
145
+ JztRegionSelect
146
+ })
147
+
148
+ const props = defineProps<SearchFormItem>()
149
+
150
+ // Re receive SearchParam
151
+ const _searchParam = computed(() => props.searchParam)
152
+
153
+ // 判断 fieldNames 设置 label && value && children 的 key 值
154
+ const fieldNames = computed(() => {
155
+ return {
156
+ label: props.queryItem.fieldNames?.label ?? 'label',
157
+ value: props.queryItem.fieldNames?.value ?? 'value',
158
+ children: props.queryItem.fieldNames?.children ?? 'children'
159
+ }
160
+ })
161
+
162
+ // 接收 enumMap (el 为 select-v2 需单独处理 enumData)
163
+ const enumMap = inject('fromEnumMap', ref(new Map()))
164
+ const queryItemEnum = computed(() => {
165
+ // 首先会选择options的数据
166
+ // if (props.queryItem.options && props.queryItem.options.length)
167
+ // return props.queryItem.options;
168
+ const enumOptions1 = props.queryItem.enum || props.queryItem.options
169
+ let enumOptions = enumOptions1
170
+ const treeLevel = props.queryItem?.allowCheckLevel || 0
171
+ if (enumOptions && isArray(enumOptions) && enumOptions.length) {
172
+ if (props.queryItem?.el === 'el-tree-select' && treeLevel) {
173
+ enumOptions = disableRootNodesByDepth(enumOptions1, treeLevel)
174
+ }
175
+ return enumOptions
176
+ }
177
+ let enumData1 = enumMap.value.get(props.queryItem.prop)
178
+ let enumData2 = enumMap.value.get(props.queryItem?.enumKey)
179
+ let enumData = enumData1 || enumData2 || []
180
+ if (enumData && isArray(enumData) && props.queryItem?.el === 'el-tree-select') {
181
+ enumData = disableRootNodesByDepth(enumData, treeLevel)
182
+ }
183
+ if (!enumData) return []
184
+ if (props.queryItem.el === 'el-select-v2' && props.queryItem.fieldNames) {
185
+ enumData = enumData.map((item: { [key: string]: any }) => {
186
+ return {
187
+ ...item,
188
+ label: item[fieldNames.value.label],
189
+ value: item[fieldNames.value.value]
190
+ }
191
+ })
192
+ }
193
+ return enumData
194
+ })
195
+ // 所有树形可选的子节点id 集合
196
+ const treeAllIds = ref<string[] | number[]>([])
197
+ //获取所有树形可选的子节点id
198
+ function getTreeAllEnabledIds() {
199
+ if (props.queryItem?.el === 'el-tree-select') {
200
+ const valueKey = fieldNames.value.value as string
201
+ const allIds = getEnabledChildValues(queryItemEnum.value, valueKey)
202
+ treeAllIds.value = allIds || []
203
+ }
204
+ }
205
+
206
+ watch(
207
+ () => queryItemEnum.value,
208
+ newValue => {
209
+ if (newValue && newValue.length) {
210
+ getTreeAllEnabledIds()
211
+ } else {
212
+ treeAllIds.value = []
213
+ }
214
+ },
215
+ { immediate: true, deep: true }
216
+ )
217
+
218
+ // 处理透传的 searchProps (el 为 tree-select、cascader 的时候需要给下默认 label && value && children)
219
+ const handleSearchProps = computed(() => {
220
+ const label = fieldNames.value.label
221
+ const value = fieldNames.value.value
222
+ const children = fieldNames.value.children
223
+ const searchEl = props.queryItem.el
224
+ let searchProps = props.queryItem?.props ?? {}
225
+ if (searchEl === 'el-tree-select') {
226
+ searchProps = {
227
+ ...searchProps,
228
+ props: { ...searchProps, label, children },
229
+ nodeKey: value,
230
+ showCheckbox: searchProps.showCheckbox !== false
231
+ }
232
+ }
233
+ if (searchEl === 'el-cascader') {
234
+ searchProps = {
235
+ ...searchProps,
236
+ props: { ...searchProps, label, value, children }
237
+ }
238
+ }
239
+
240
+ if (searchEl === 'el-input-number') {
241
+ const precision = searchProps.precision === true ? sessionGetPrecision() : searchProps.precision
242
+ searchProps = {
243
+ ...searchProps,
244
+ ...(precision ? { precision: precision } : {})
245
+ }
246
+ }
247
+
248
+ return searchProps
249
+ })
250
+
251
+ // 处理默认 placeholder
252
+ const placeholder = computed(() => {
253
+ const search = props.queryItem
254
+ if (['datetimerange', 'daterange', 'monthrange'].includes(search?.props?.type) || search?.props?.isRange) {
255
+ return {
256
+ rangeSeparator: search?.props?.rangeSeparator ?? '至',
257
+ startPlaceholder: search?.props?.startPlaceholder ?? '开始时间',
258
+ endPlaceholder: search?.props?.endPlaceholder ?? '结束时间'
259
+ }
260
+ }
261
+ const placeholder = search?.props?.placeholder ?? (search?.el?.includes('input') ? '请输入' : '请选择')
262
+ return { placeholder }
263
+ })
264
+
265
+ // 是否有清除按钮-默认有组件没有
266
+ const clearable = computed(() => {
267
+ const itemProps = props.queryItem?.props || {}
268
+ return (itemProps && itemProps?.clearable) ?? true
269
+ })
270
+
271
+ // 是否有多选-默认有
272
+ const filterable = computed(() => {
273
+ const itemProps = props.queryItem?.props || {}
274
+ return (itemProps && itemProps?.filterable) ?? true
275
+ // if (props.queryItem.el && ['el-select', 'el-select-v2'].includes(props.queryItem.el)) {
276
+ // return props.queryItem?.props?.filterable ?? true
277
+ // } else {
278
+ // return false
279
+ // }
280
+ })
281
+ // 处理动态事件绑定
282
+ const handleEvents = computed(() => {
283
+ const events = {}
284
+ const searchEvents = props.queryItem?.events ?? {}
285
+
286
+ // 将事件配置转换为事件监听器
287
+ Object.keys(searchEvents).forEach(eventName => {
288
+ if (typeof searchEvents[eventName] === 'function') {
289
+ events[`${eventName.charAt(0).toUpperCase() + eventName.slice(1)}`] = searchEvents[eventName]
290
+ }
291
+ })
292
+
293
+ return events
294
+ })
295
+ const isFirst = ref(true)
296
+ // 定义 emit 事件
297
+ const emit = defineEmits(['getCascaderValue'])
298
+ // 监听值变化
299
+ watch(
300
+ () => _searchParam.value[props.queryItem.prop],
301
+ (newValue, oldValue) => {
302
+ if (newValue === oldValue) return
303
+ const queryItem = props.queryItem
304
+ if (props.queryItem?.cascader && _searchParam.value[props.queryItem.prop]) {
305
+ if (isFirst.value && !queryItem.isSetFirstValue) {
306
+ isFirst.value = false
307
+ return
308
+ }
309
+ emit('getCascaderValue', queryItem)
310
+ }
311
+ },
312
+ { immediate: true, deep: true }
313
+ )
314
+
315
+ const onChangeValue = (val: any) => {
316
+ const queryItem = props.queryItem
317
+ emit('getCascaderValue', queryItem, true)
318
+ if (props.queryItem?.el == 'el-tree-select') {
319
+ const ids = _searchParam.value?.[props.queryItem.prop] || []
320
+ props.queryItem.change && props.queryItem.change({ value: ids })
321
+ checkedAll.value = ids?.length === treeAllIds.value?.length
322
+ return
323
+ }
324
+ // 控件change事件
325
+ if (queryItemEnum.value && queryItemEnum.value.length) {
326
+ const value = fieldNames.value.value
327
+ const optionsItem = queryItemEnum.value.filter(item => item[value] === val)
328
+ props.queryItem.change &&
329
+ props.queryItem.change({
330
+ value: val,
331
+ optionsItem: optionsItem[0]
332
+ })
333
+ } else {
334
+ props.queryItem.change && props.queryItem.change({ value: val })
335
+ }
336
+ }
337
+ const selectOptionWidth = ref()
338
+ // 设置select组件下拉框宽度
339
+ const setOptionWidth = event => {
340
+ nextTick(() => {
341
+ selectOptionWidth.value = event.srcElement.offsetWidth + 30 + 'px'
342
+ })
343
+ }
344
+
345
+ const checkedAll = ref(false)
346
+ const checkedInverse = ref(false)
347
+ const SelectTreeRef = ref()
348
+
349
+ // 全选 取消全选(
350
+ const changeCheck = () => {
351
+ nextTick(() => {
352
+ checkedInverse.value = false
353
+ // const valueKey = fieldNames.value.value as string
354
+ if (checkedAll.value) {
355
+ // 获取非禁用的子节点集合
356
+ const allIds = treeAllIds.value // getEnabledChildValues(queryItemEnum.value, valueKey)
357
+ SelectTreeRef.value!.setCheckedKeys(allIds, true)
358
+ _searchParam.value[props.queryItem.prop] = allIds || []
359
+ onChangeValue(allIds)
360
+ } else {
361
+ SelectTreeRef.value!.setCheckedKeys([], true) // 1. 选中的数组 2. true:只设置选中的叶子节点, 默认值是 false.
362
+ _searchParam.value[props.queryItem.prop] = []
363
+ onChangeValue([])
364
+ }
365
+ })
366
+ }
367
+ // 反选 取消全选
368
+ const changeInverse = () => {
369
+ checkedAll.value = false
370
+ // const valueKey = fieldNames.value.value as string
371
+ const vals = _searchParam.value[props.queryItem.prop] || []
372
+ const allIds = treeAllIds.value // getEnabledChildValues(queryItemEnum.value, valueKey)
373
+ const ids = allIds.filter(item => !vals.includes(item))
374
+ if (ids.length == allIds.length) {
375
+ // 反向判断勾选
376
+ checkedAll.value = true
377
+ }
378
+ nextTick(() => {
379
+ SelectTreeRef.value!.setCheckedKeys(ids, true)
380
+ _searchParam.value[props.queryItem.prop] = ids || []
381
+ onChangeValue(ids)
382
+ })
383
+ }
384
+ </script>