@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,404 @@
1
+ <template>
2
+ <JztDialog
3
+ title="列配置"
4
+ v-model="visible"
5
+ width="700"
6
+ @close="_cancel"
7
+ :cancelText="false"
8
+ :is-show-fullscreen="false"
9
+ :disabled="!cancelEdit"
10
+ :show-footer="false"
11
+ @change-fullscreen="val => (isFullscreen = val)"
12
+ >
13
+ <DeployToAccountLevelSetting
14
+ v-model="deployVisible"
15
+ :mode="deployMode"
16
+ :grid-params="gridParams"
17
+ :page-size="setPageSize"
18
+ :config-value="dragListColumn"
19
+ :template-info="formData"
20
+ @success="onQueryTemplate"
21
+ />
22
+ <div class="table-box" v-loading="loading || templateLoading">
23
+ <div class="tips-box warning-bg flx-left-center">
24
+ <el-icon color="#FFA00C" class="mr4">
25
+ <WarningFilled />
26
+ </el-icon>
27
+ 拖拽表格行来调整顺序,或双击标题/列宽直接进行编辑。
28
+ </div>
29
+ <el-form v-if="isAdmin && gridTemplateList.length > 0" :model="formData" ref="formRef" label-width="auto">
30
+ <el-form-item label="当前列配置模版名称" prop="templateId">
31
+ <el-select-v2
32
+ v-model="formData.templateId"
33
+ placeholder="请选择当前列配置模版名称"
34
+ filterable
35
+ style="width: 50%"
36
+ :options="gridTemplateList"
37
+ :props="{
38
+ value: 'id',
39
+ label: 'configName'
40
+ }"
41
+ @change="onChangeTemplate"
42
+ />
43
+ </el-form-item>
44
+ </el-form>
45
+ <el-table
46
+ row-key="prop"
47
+ :data="dragListColumn"
48
+ ref="dragTableRef"
49
+ id="table_uuid_setting_drag"
50
+ style="width: 100%"
51
+ :max-height="isFullscreen ? 'calc(100vh - 220px)' : 'calc(60vh - 100px)'"
52
+ >
53
+ <el-table-column label="排序" width="80" align="left" fixed="left">
54
+ <template #default="{ $index }">
55
+ <div class="move_allowDrag" style="cursor: move">
56
+ <i class="iconfont icon-paixu"></i>
57
+ </div>
58
+ </template>
59
+ </el-table-column>
60
+ <el-table-column prop="prop" label="ID" minWidth="130" />
61
+ <el-table-column prop="text" label="标题" minWidth="130">
62
+ <template #default="{ row, $index }">
63
+ <el-input
64
+ v-if="editIndex == $index"
65
+ v-model="row.label"
66
+ :maxlength="20"
67
+ @blur="saveEdit(row, 'label')"
68
+ class="label-edit-input"
69
+ ></el-input>
70
+ <div v-else @dblclick="startEdit(row, $index, 'label')" style="width: 100%; height: 30px">
71
+ {{ row.label }}
72
+ </div>
73
+ </template>
74
+ </el-table-column>
75
+ <el-table-column prop="minWidth" label="列宽" width="110">
76
+ <template #default="{ row, $index }">
77
+ <el-input-number
78
+ v-if="editIndex == $index"
79
+ :controls="false"
80
+ v-model="row.minWidth"
81
+ :maxlength="20"
82
+ :min="60"
83
+ :max="800"
84
+ @blur="saveEdit(row, 'minWidth')"
85
+ style="width: 90px"
86
+ class="width-edit-input"
87
+ ></el-input-number>
88
+ <div v-else @dblclick="startEdit(row, $index, 'minWidth')" style="width: 100%; height: 30px">
89
+ {{ row.minWidth }}
90
+ </div>
91
+ </template>
92
+ </el-table-column>
93
+ <el-table-column prop="isSetShow" label="显示" width="100" align="center" fixed="right">
94
+ <template #default="{ row }">
95
+ <el-switch v-if="row.isSetting" v-model="row.isSetShow" @change="changeSwitch(row)" />
96
+ <div v-else>-</div>
97
+ </template>
98
+ </el-table-column>
99
+ </el-table>
100
+ <div class="page-size flx-left-center">
101
+ 默认每页记录数:
102
+ <el-select v-model="setPageSize" placeholder="请选择" style="width: 100px">
103
+ <el-option v-for="item in pageSizes" :key="item" :label="item" :value="item" />
104
+ </el-select>
105
+ </div>
106
+ </div>
107
+ <template v-if="isAdmin && gridTemplateList.length > 0" #footer>
108
+ <el-button v-if="formData.templateId === '0'" type="primary" plain @click="removeSetting">重置默认配置</el-button>
109
+ <el-button v-if="formData.templateId === '0'" type="primary" plain @click="onOpenDeployDialog('add')">
110
+ 下发至用户
111
+ </el-button>
112
+ <template v-if="formData.templateId !== '0'">
113
+ <el-button type="primary" plain @click="onRemoveTemplate">删除模版</el-button>
114
+ <el-button type="primary" plain @click="onOpenDeployDialog('edit')">编辑模版</el-button>
115
+ <el-button type="primary" plain @click="onOpenDeployDialog('view')">查看生效账号</el-button>
116
+ <el-button type="primary" @click="onSaveTemplate">保存并下发</el-button>
117
+ </template>
118
+ <el-button v-if="formData.templateId === '0'" type="primary" @click="() => _saveColumn()">保存当前配置</el-button>
119
+ </template>
120
+ <template v-else #footer>
121
+ <el-button type="danger" @click="removeSetting">重置</el-button>
122
+ <el-button type="primary" @click="() => _saveColumn()">确定</el-button>
123
+ </template>
124
+ </JztDialog>
125
+ </template>
126
+
127
+ <script lang="tsx" setup>
128
+ import { ElMessage, ElMessageBox, ElTable } from 'element-plus'
129
+ import * as _ from 'lodash-es'
130
+ import Sortable from 'sortablejs'
131
+ import { nextTick, onBeforeUnmount, readonly, ref, unref } from 'vue'
132
+ import JztDialog from '../../JztDialog/index.vue'
133
+ import { pageSizes } from '../const'
134
+ import { useSettingTable } from '../hooks/useTableSetting'
135
+ import { useTemplate } from '../hooks/useTemplate'
136
+ import { ColumnProps, GridParams } from '../interface/index'
137
+ import DeployToAccountLevelSetting from './DeployToAccountLevelSetting.vue'
138
+ const $emit = defineEmits(['update:columns', 'refreshSetting', 'update:loading', 'changeColumns', 'refreshColumnTable'])
139
+ const { getTableSetting, setTableSetting, removeGridConfig, currentTableColumns } = useSettingTable()
140
+ const props = withDefaults(
141
+ defineProps<{
142
+ columns?: ColumnProps[]
143
+ loading: boolean
144
+ // gridParams?: GridParams
145
+ }>(),
146
+ {
147
+ columns: () => [],
148
+ loading: false
149
+ }
150
+ )
151
+
152
+ const backupColumnsList = ref<ColumnProps[]>([])
153
+ const gridParams = ref<GridParams>({ gridId: '', url: '' })
154
+ const isFullscreen = ref(false)
155
+ const visible = ref(false)
156
+ const dragListColumn = ref<any[]>([])
157
+ const originalColumn = ref<any[]>([])
158
+
159
+ const {
160
+ loading: templateLoading,
161
+ deployVisible,
162
+ deployMode,
163
+ isAdmin,
164
+ formData,
165
+ gridTemplateList,
166
+ onOpenDeployDialog,
167
+ onRemoveTemplate,
168
+ onSaveTemplate,
169
+ onQueryTemplate,
170
+ onChangeTemplate
171
+ } = useTemplate(
172
+ () => gridParams.value,
173
+ () => setPageSize.value,
174
+ dragListColumn,
175
+ originalColumn,
176
+ async (columns: any) => processColumns(columns),
177
+ () => onValidIsAllHidden()
178
+ )
179
+
180
+ const changeDialog = async (gridParams1: GridParams) => {
181
+ visible.value = true
182
+ nextTick(() => {
183
+ gridParams.value = gridParams1
184
+ dragSort()
185
+ onQueryTemplate()
186
+ })
187
+ }
188
+ const changeSwitch = row => {
189
+ row.hidden = !row.isSetShow
190
+ }
191
+
192
+ const editIndex = ref(-1)
193
+ const editProp = ref('')
194
+ const cancelEdit = ref(true)
195
+ const setPageSize = ref(10)
196
+ const defaultPageSize = ref(10) // 用于恢复数据
197
+
198
+ const startEdit = (row, index, prop) => {
199
+ if (!row.isSetting) return
200
+ editIndex.value = index
201
+ editProp.value = prop
202
+ nextTick(() => {
203
+ if (prop === 'label') {
204
+ ;(document?.querySelector('.label-edit-input .el-input__inner') as HTMLElement)?.focus()
205
+ } else {
206
+ ;(document?.querySelector('.width-edit-input .el-input__inner') as HTMLElement)?.focus()
207
+ }
208
+ })
209
+ }
210
+
211
+ const saveEdit = (row, prop) => {
212
+ editIndex.value = -1
213
+ editProp.value = ''
214
+ if (row[prop] === '') {
215
+ ElMessage.error('请输入列名')
216
+ cancelEdit.value = false
217
+ } else {
218
+ row.editing = false
219
+ cancelEdit.value = true
220
+ }
221
+ }
222
+
223
+ const dragTableRef = ref<InstanceType<typeof ElTable> | null>(null)
224
+
225
+ let sortableInstance: Sortable | null = null
226
+ function dragSort() {
227
+ const tbody = dragTableRef.value?.$el.querySelector('.el-table__body-wrapper tbody')
228
+ if (!tbody) return
229
+ sortableInstance = Sortable.create(tbody, {
230
+ handle: '.move_allowDrag',
231
+ animation: 150,
232
+ draggable: '.el-table__row',
233
+ onEnd(evt: any) {
234
+ if (evt.oldDraggableIndex !== evt.newDraggableIndex) {
235
+ let currRow = dragListColumn.value.splice(evt.oldDraggableIndex, 1)[0]
236
+ dragListColumn.value.splice(evt.newDraggableIndex, 0, currRow)
237
+ }
238
+ }
239
+ })
240
+ }
241
+
242
+ // 组件卸载时清理 Sortable 实例
243
+ onBeforeUnmount(() => {
244
+ if (sortableInstance) {
245
+ sortableInstance.destroy()
246
+ sortableInstance = null
247
+ }
248
+ })
249
+
250
+ // 取消
251
+ const _cancel = () => {
252
+ visible.value = false
253
+ editIndex.value = -1
254
+ editProp.value = ''
255
+ cancelEdit.value = true
256
+ setPageSize.value = defaultPageSize.value
257
+ const list = initEndColumns(originalColumn.value)
258
+ dragListColumn.value = _.cloneDeep(list)
259
+ }
260
+
261
+ const onValidIsAllHidden = () => {
262
+ const isAllHidden = dragListColumn.value.every(item => item.hidden)
263
+ if (isAllHidden) {
264
+ ElMessage.error('请至少显示一列')
265
+ return false
266
+ } else {
267
+ return true
268
+ }
269
+ }
270
+
271
+ // 保存
272
+ const _saveColumn = async (toast?: boolean) => {
273
+ return new Promise<any>(async (resolve, reject) => {
274
+ $emit('refreshColumnTable', 'confirm')
275
+ if (!onValidIsAllHidden()) return
276
+ const { id, columns } = (await setTableSetting({
277
+ gridParams: gridParams.value,
278
+ tableColumns: dragListColumn.value,
279
+ pageSize: setPageSize.value,
280
+ toast: toast || false
281
+ })) as { id: string; columns: ColumnProps[] }
282
+ visible.value = false
283
+ getTableSettingFn()
284
+
285
+ resolve({
286
+ columns,
287
+ gridId: id
288
+ })
289
+ })
290
+ }
291
+ const gridId = ref('')
292
+ const getTableSettingFn = async () => {
293
+ try {
294
+ dragListColumn.value = []
295
+ originalColumn.value = []
296
+ const cloneDeepBackupColumns = _.cloneDeep(backupColumnsList.value)
297
+ const { columns, pageSize, id } = await getTableSetting(
298
+ gridParams.value,
299
+ props.columns,
300
+ handleLoading,
301
+ cloneDeepBackupColumns
302
+ )
303
+ gridId.value = id
304
+ defaultPageSize.value = pageSize
305
+ setPageSize.value = pageSize
306
+ const list = initEndColumns(columns)
307
+ dragListColumn.value = _.cloneDeep(list)
308
+ originalColumn.value = readonly(_.cloneDeep(columns))
309
+ $emit('changeColumns', dragListColumn.value, pageSize, id)
310
+ } catch (error) {
311
+ // 获取表格配置失败
312
+ console.log(1233123, error)
313
+ }
314
+ }
315
+ const initEndColumns = columns => {
316
+ if (!columns || !columns.length) return []
317
+ const list = _.cloneDeep(columns)
318
+ dragListColumn.value = list.filter(item => item.isShow)
319
+ return list || []
320
+ }
321
+ const handleLoading = flag => {
322
+ $emit('update:loading', flag)
323
+ }
324
+ // 初始化列配置
325
+ const removeSetting = () => {
326
+ ElMessageBox.confirm(`确认重置列配置吗?`, '提示', {
327
+ confirmButtonText: '确定',
328
+ cancelButtonText: '取消',
329
+ type: 'warning'
330
+ })
331
+ .then(() => {
332
+ if (!gridParams.value) return
333
+ $emit('refreshColumnTable', 'remove')
334
+ removeGridConfig(gridParams.value, () => {
335
+ _cancel()
336
+ getTableSettingFn()
337
+ })
338
+ })
339
+ .catch(() => {
340
+ // 用户取消重置
341
+ })
342
+ }
343
+ // watch(
344
+ // () => props?.gridParams?.gridId,
345
+ // gridId => {
346
+ // if (gridId) {
347
+ // getTableSettingFn()
348
+ // }
349
+ // },
350
+ // {
351
+ // immediate: true
352
+ // }
353
+ // )
354
+
355
+ // 获取当时接口的内容
356
+ const getCurrentTableColumns = () => {
357
+ return currentTableColumns.value
358
+ }
359
+ const changeTableColumns = async (columns: ColumnProps[], gridParams1: GridParams) => {
360
+ const tableColumns = await processColumns(columns)
361
+ handleLoading(true)
362
+ gridParams.value = gridParams1
363
+ backupColumnsList.value = tableColumns
364
+ onQueryTemplate()
365
+ getTableSettingFn()
366
+ }
367
+
368
+ // 初始化 处理数据
369
+ const processColumns = async (columns: ColumnProps[]): Promise<ColumnProps[]> => {
370
+ const result: ColumnProps[] = []
371
+ for (const col of columns) {
372
+ if (col.prop && !col.type && col.isShow !== false && col.prop !== 'operation') {
373
+ const newCol: ColumnProps = {
374
+ ...col,
375
+ isShow: col.isShow ?? true,
376
+ isSetting: unref(col.isSetting) ?? true,
377
+ isFilterEnum: col.isFilterEnum ?? true
378
+ }
379
+ if (col._children?.length) {
380
+ newCol._children = await processColumns(col._children)
381
+ }
382
+ result.push(newCol)
383
+ }
384
+ }
385
+ return result
386
+ }
387
+ defineExpose({
388
+ changeDialog,
389
+ getCurrentTableColumns,
390
+ _saveColumn,
391
+ changeTableColumns
392
+ })
393
+ </script>
394
+ <style lang="scss" scoped>
395
+ .icon-paixu {
396
+ font-size: 20px;
397
+ margin-left: 2px;
398
+ }
399
+
400
+ .page-size {
401
+ border-top: 1px solid #f5f7fa;
402
+ padding: 10px 0 0 4px;
403
+ }
404
+ </style>
@@ -0,0 +1,220 @@
1
+ <template>
2
+ <el-popover
3
+ placement="bottom"
4
+ popper-class="interBarControl-setPopover"
5
+ :width="210"
6
+ :visible="visible"
7
+ trigger="click"
8
+ @click.stop=""
9
+ >
10
+ <template #reference>
11
+ <span @click.stop="visible = !visible">
12
+ <slot name="reference">
13
+ <el-button title="列设置" :icon="Setting" class="tool_btn" />
14
+ </slot>
15
+ </span>
16
+ </template>
17
+ <div class="popover-list" @click.stop>
18
+ <div class="search-box">
19
+ <el-input placeholder="搜索" size="small" v-model="inputValue" @input="querySearch" clearable>
20
+ <i class="el-icon-search el-input__icon" slot="prefix"></i>
21
+ </el-input>
22
+ </div>
23
+ <div class="switch-box">
24
+ <el-tree
25
+ :allow-drop="allowDrop"
26
+ :allow-drag="allowDrag"
27
+ :data="dragListColumn"
28
+ draggable
29
+ :props="{
30
+ children: '_children'
31
+ }"
32
+ default-expand-all
33
+ node-key="id"
34
+ >
35
+ <template #default="{ node, data }">
36
+ <div class="custom-tree-node">
37
+ <div class="operation-icon">
38
+ <el-icon><Operation /></el-icon>
39
+ </div>
40
+ <div class="text sle">{{ node.label }}</div>
41
+ <div class="show-icon">
42
+ <el-switch size="small" v-model="data.isShow" :key="data.prop"></el-switch>
43
+ </div>
44
+ </div>
45
+ </template>
46
+ </el-tree>
47
+ </div>
48
+ <div class="btn-group flx-between-center justify-content-between">
49
+ <el-button size="small" @click="_resetColumn">重置</el-button>
50
+ <div>
51
+ <el-button size="small" @click="_cancel">取消</el-button>
52
+ <el-button size="small" type="success" @click="_saveColumn">保存</el-button>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </el-popover>
57
+ </template>
58
+
59
+ <script lang="ts" setup>
60
+ import * as _ from 'lodash-es'
61
+ import { ref, watch, onMounted, onUnmounted, readonly } from 'vue'
62
+ import { Setting } from '@element-plus/icons-vue'
63
+ import type Node from 'element-plus/es/components/tree/src/model/node'
64
+ import type { AllowDropType } from 'element-plus/es/components/tree/src/tree.type'
65
+ import { setTableSetting, getTableSetting } from '../hooks/useTableSetting'
66
+ import { ColumnProps } from '../interface/index'
67
+ const $emit = defineEmits(['update:columns', 'refreshSetting', 'update:loading'])
68
+ const props = withDefaults(
69
+ defineProps<{
70
+ columns?: ColumnProps[]
71
+ columnTypes?: Array<any>
72
+ loading: boolean
73
+ }>(),
74
+ {
75
+ columns: () => [],
76
+ columnTypes: () => [],
77
+ loading: false
78
+ }
79
+ )
80
+
81
+ const visible = ref(false)
82
+ const inputValue = ref('')
83
+ const dragListColumn = ref([])
84
+ const originalColumn = ref([])
85
+
86
+ // 列表操作输入
87
+ const querySearch = queryString => {
88
+ let tableColumn = props.columns
89
+ let results = queryString ? tableColumn.filter(createFilter(queryString)) : tableColumn
90
+ dragListColumn.value = _.cloneDeep([...results])
91
+ }
92
+
93
+ const createFilter = queryString => {
94
+ return tableColumn => {
95
+ return tableColumn.label.indexOf(queryString) === 0
96
+ }
97
+ }
98
+
99
+ const allowDrop = (draggingNode: Node, dropNode: Node, type: AllowDropType): boolean => {
100
+ if (type === 'inner') return false
101
+ if (draggingNode.parent?.id && draggingNode.parent?.id !== dropNode.parent?.id) return false
102
+ if (dropNode.data?.prop === 'operation' && type === 'next') return false
103
+ return true
104
+ }
105
+ const allowDrag = (node: Node) => {
106
+ if (props.columnTypes.includes(node.data?.type) || node.data?.prop === 'operation') return false
107
+ return node.data?.isSetting
108
+ }
109
+
110
+ // 重置
111
+ const _resetColumn = () => {
112
+ dragListColumn.value = _.cloneDeep(originalColumn.value)
113
+ _saveColumn()
114
+ }
115
+
116
+ // 取消
117
+ const _cancel = () => {
118
+ closePopover()
119
+ }
120
+
121
+ // 保存
122
+ const _saveColumn = () => {
123
+ closePopover()
124
+ // TODO 暂时不走配置
125
+ // setTableSetting(dragListColumn.value)
126
+ // $emit('refreshSetting')
127
+ const newList = _.cloneDeep(dragListColumn.value)
128
+ $emit('update:columns', newList)
129
+ }
130
+ const loading = ref(true)
131
+ const getTableSettingFn = () => {
132
+ getTableSetting(props.columns, handleLoading)
133
+ }
134
+ const handleLoading = flag => {
135
+ $emit('update:loading', flag)
136
+ }
137
+ watch(
138
+ () => props.columns,
139
+ value => {
140
+ if (value) {
141
+ // console.log("watch", value);
142
+ dragListColumn.value = _.cloneDeep(props.columns)
143
+ }
144
+ }
145
+ )
146
+
147
+ const closePopover = () => {
148
+ visible.value = false
149
+ }
150
+
151
+ onMounted(() => {
152
+ getTableSettingFn()
153
+ originalColumn.value = readonly(_.cloneDeep(props.columns)) // 不可修改
154
+ dragListColumn.value = _.cloneDeep(props.columns)
155
+ window.addEventListener('click', closePopover)
156
+ })
157
+
158
+ onUnmounted(() => {
159
+ window.removeEventListener('click', closePopover)
160
+ })
161
+ </script>
162
+
163
+ <style lang="scss" scoped>
164
+ .popover-list {
165
+ margin: -12px;
166
+ padding: 8px 0 0;
167
+ .search-box {
168
+ padding: 0 8px;
169
+ }
170
+ .switch-box {
171
+ max-height: 300px;
172
+ overflow-y: auto;
173
+ margin-top: 4px;
174
+ // max-height: 246px;
175
+ // overflow-y: auto;
176
+ }
177
+ }
178
+
179
+ .custom-tree-node {
180
+ flex: 1;
181
+ display: flex;
182
+ align-items: center;
183
+ justify-content: space-between;
184
+ font-size: 14px;
185
+ padding-right: var(--el-popover-padding);
186
+ overflow: hidden;
187
+ height: 32px;
188
+ line-height: 32px;
189
+ margin-right: 4px;
190
+ .operation-icon {
191
+ width: 20px;
192
+ :deep(.el-icon) {
193
+ vertical-align: middle;
194
+ }
195
+ }
196
+ .text {
197
+ flex: 1;
198
+ text-align: left;
199
+ margin: 0 5px;
200
+ }
201
+ .show-icon {
202
+ width: 30px;
203
+ text-align: center;
204
+ }
205
+
206
+ &:hover {
207
+ color: var(--el-color-primary);
208
+ background-color: var(--theme-select-dropdown-item-hover);
209
+ border-radius: 10px;
210
+ }
211
+ }
212
+
213
+ .btn-group {
214
+ padding: 12px;
215
+ border-top: 1px solid #e4e7ed;
216
+ .el-button + .el-button {
217
+ margin-left: 8px;
218
+ }
219
+ }
220
+ </style>