hy-dispatch-ui-v3 0.2.34 → 0.2.35

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.
@@ -23,11 +23,10 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
23
23
  type: String,
24
24
  default: "default"
25
25
  },
26
- zIndex: {
27
- type: Number,
28
- default: null
29
- // default-默认类型 right-右侧弹窗 fullscreen-全屏
30
- },
26
+ // zIndex: {
27
+ // type: Number,
28
+ // default: null, // default-默认类型 right-右侧弹窗 fullscreen-全屏
29
+ // },
31
30
  top: String,
32
31
  // 支持缩小化
33
32
  showShrink: { type: Boolean, default: false },
@@ -147,7 +146,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
147
146
  }
148
147
  const dialogTestRef = ref();
149
148
  function dialogMousedown(e) {
150
- if (props.zIndex != null) return;
151
149
  emits("onDialogMousedown", e);
152
150
  }
153
151
  __expose({
@@ -1,10 +1,6 @@
1
1
  .hy-form-container {
2
2
  display: grid;
3
3
  column-gap: 24px;
4
- .el-form-item__label::before {
5
- content: '' !important;
6
- display: none;
7
- }
8
4
 
9
5
  .label-required {
10
6
  &::after {
@@ -2,7 +2,7 @@ import { useTemplateRef, ref, computed, unref, watch, openBlock, createBlock, wi
2
2
  import Sortable from 'sortablejs';
3
3
  import { ElPopover, ElIcon, ElCheckboxGroup, ElMessage } from 'element-plus';
4
4
  import { CircleClose, Warning, Edit } from '@element-plus/icons-vue';
5
- import { tableColumnHandler } from '../js/index.mjs';
5
+ import { tableColumnShowHandler, tableColumnHandler } from '../js/index.mjs';
6
6
  import _sfc_main$1 from './columnSelectItem.vue.mjs';
7
7
  import { useLocale } from '../../../hooks/useLocale.mjs';
8
8
  import { HyTooltip } from '../../hyTooltip/index.mjs';
@@ -36,11 +36,11 @@ const _sfc_main = {
36
36
  const tableEditableColumns = ref([]);
37
37
  const showColumnsLength = computed(() => {
38
38
  return (tableColumns.value || []).reduce((total, column) => {
39
- return total + (isFilterColumn(column) ? 0 : 1);
39
+ return total + (isShowColumn(column) ? 1 : 0);
40
40
  }, 0);
41
41
  });
42
- function isFilterColumn(column) {
43
- return !column.editable.edit || column.prop === "operator";
42
+ function isShowColumn(column) {
43
+ return tableColumnShowHandler(column) && column.editable.edit;
44
44
  }
45
45
  function showPopover() {
46
46
  initColumnsInfo(props.columns, props.columnsEditable);
@@ -53,26 +53,20 @@ const _sfc_main = {
53
53
  popoverRef.value?.hide?.();
54
54
  }
55
55
  function initColumnsInfo(columns, columnsEditable) {
56
+ const columnArr = [];
56
57
  const checkedArr = [];
57
- tableEditableColumns.value = columns.reduce((list, column, index) => {
58
- if (!isFilterColumn(column) && !column.editable.lock) {
59
- list.push({
58
+ for (const column of columns) {
59
+ if (isShowColumn(column) && !column.editable.lock) {
60
+ columnArr.push({
60
61
  ...column,
61
- sortIndex: index
62
+ sortIndex: columnsEditable[column.prop].sortIndex
62
63
  });
63
- }
64
- return list;
65
- }, []);
66
- for (const key in columnsEditable || {}) {
67
- const target = columnsEditable[key];
68
- const { column } = target;
69
- if (isFilterColumn(column) || column.editable.lock) {
70
- continue;
71
- }
72
- if (target.checked) {
73
- checkedArr.push(column.prop);
64
+ if (columnsEditable[column.prop].checked) {
65
+ checkedArr.push(column.prop);
66
+ }
74
67
  }
75
68
  }
69
+ tableEditableColumns.value = columnArr;
76
70
  checkedList.value = checkedArr;
77
71
  }
78
72
  const showClear = ref(true);
@@ -105,7 +99,7 @@ const _sfc_main = {
105
99
  }
106
100
  const editableObj = tableEditableColumns.value.reduce(
107
101
  (editableObj2, column) => {
108
- editableObj2[column.prop].index = column.sortIndex;
102
+ editableObj2[column.prop].sortIndex = column.sortIndex;
109
103
  editableObj2[column.prop].checked = checkMap.value.has(column.prop);
110
104
  return editableObj2;
111
105
  },
@@ -133,29 +127,19 @@ const _sfc_main = {
133
127
  const { oldIndex, newIndex } = event;
134
128
  if (isEmpty(oldIndex) || isEmpty(newIndex) || oldIndex === newIndex)
135
129
  return;
136
- const newSortIndex = tableEditableColumns.value[newIndex].sortIndex;
137
- tableEditableColumns.value[newIndex].sortIndex = tableEditableColumns.value[oldIndex].sortIndex;
138
- tableEditableColumns.value[oldIndex].sortIndex = newSortIndex;
139
- if (oldIndex < newIndex) {
140
- tableEditableColumns.value.splice(
141
- oldIndex,
142
- 1,
143
- tableEditableColumns.value.splice(
144
- newIndex,
145
- 1,
146
- tableEditableColumns.value[oldIndex]
147
- )[0]
148
- );
149
- } else {
150
- tableEditableColumns.value.splice(
151
- newIndex,
152
- 1,
153
- tableEditableColumns.value.splice(
154
- oldIndex,
155
- 1,
156
- tableEditableColumns.value[newIndex]
157
- )[0]
158
- );
130
+ const minIndex = Math.min(oldIndex, newIndex);
131
+ const maxIndex = Math.max(oldIndex, newIndex);
132
+ const sortList = [];
133
+ for (let i = minIndex; i <= maxIndex; i++) {
134
+ sortList[i] = tableEditableColumns.value[i].sortIndex;
135
+ }
136
+ tableEditableColumns.value.splice(
137
+ newIndex,
138
+ 0,
139
+ tableEditableColumns.value.splice(oldIndex, 1)[0]
140
+ );
141
+ for (let i = minIndex; i <= maxIndex; i++) {
142
+ tableEditableColumns.value[i].sortIndex = sortList[i];
159
143
  }
160
144
  showClear.value = true;
161
145
  }
@@ -250,7 +234,7 @@ const _sfc_main = {
250
234
  Fragment,
251
235
  { key: index },
252
236
  [
253
- !isFilterColumn(item) && item.editable.lock ? (openBlock(), createBlock(_sfc_main$1, {
237
+ isShowColumn(item) && item.editable.lock ? (openBlock(), createBlock(_sfc_main$1, {
254
238
  key: 0,
255
239
  column: item,
256
240
  checkMap: checkMap.value
@@ -308,8 +308,8 @@ const _sfc_main = {
308
308
  width: __props.width,
309
309
  height: __props.height,
310
310
  "header-height": __props.showHeader ? 44 : 0,
311
- "row-height": 50,
312
- "estimated-row-height": 50,
311
+ "row-height": 64,
312
+ "estimated-row-height": 64,
313
313
  "expand-column-key": expandColumn.value?.key,
314
314
  fixed: "",
315
315
  "row-class": rowClass,
@@ -435,7 +435,7 @@ const _sfc_main = {
435
435
  /* STABLE_FRAGMENT */
436
436
  )) : column.type === "operator" ? (openBlock(), createElementBlock("div", {
437
437
  key: 4,
438
- class: "w-full flex items-center justify-end gap-2 text-main",
438
+ class: "w-full flex items-center justify-end gap-3 text-main",
439
439
  onClick: withModifiers(() => {
440
440
  }, ["stop"]),
441
441
  onContextmenu: withModifiers(() => {
@@ -1,6 +1,6 @@
1
1
  import { ref, computed, watchEffect, unref, nextTick } from 'vue';
2
2
  import { ElLoading } from 'element-plus';
3
- import { isString, isBoolean, isFunction, isPermission, isArray, isNumber } from '../../../utils/is.mjs';
3
+ import { isString, isBoolean, isFunction, isPermission, isNumber, isArray } from '../../../utils/is.mjs';
4
4
  import { useLocale } from '../../../hooks/useLocale.mjs';
5
5
  import { usePermissionMap } from '../../../hooks/usePermissionMap.mjs';
6
6
 
@@ -13,67 +13,67 @@ function tableColumnShowHandler(column) {
13
13
  if (isFunction(show)) return show(column);
14
14
  return true;
15
15
  }
16
- function tableColumnsEditableleHandler(columns, columnsEditablele, searchArr) {
17
- const searchLabelSet = /* @__PURE__ */ new Set();
16
+ function tableColumnsEditableleHandler(columns, columnsEditablele) {
18
17
  const columnsEditableleObj = {};
18
+ const sortSet = /* @__PURE__ */ new Set();
19
19
  for (const column of columns) {
20
- const { editable } = column;
21
- const columnsEditableleItem = columnsEditablele[column.prop] || editable;
22
- const { index } = columnsEditableleItem;
23
- if (!columnsEditableleObj[index]) {
24
- columnsEditableleObj[index] = [];
20
+ const columnsEditableleItem = columnsEditablele[column.prop];
21
+ const { sortIndex } = columnsEditableleItem;
22
+ sortSet.add(sortIndex);
23
+ if (!columnsEditableleObj[sortIndex]) {
24
+ columnsEditableleObj[sortIndex] = [];
25
25
  }
26
- columnsEditableleObj[index].push({
27
- ...columnsEditableleItem,
26
+ columnsEditableleObj[sortIndex].push({
27
+ editable: columnsEditableleItem,
28
28
  column
29
29
  });
30
- if (column.isSearch) {
31
- searchLabelSet.add(column.label);
32
- }
33
- }
34
- if (searchArr?.length > 0) {
35
- searchArr.forEach((item) => {
36
- searchLabelSet.add(item.label);
37
- });
38
30
  }
39
- return Object.keys(columnsEditableleObj).reduce(
40
- ({ columnsEditablele: columnsEditablele2, columnsList, searchText }, key) => {
31
+ Array.from(sortSet.values()).reduce((a, b) => a - b);
32
+ const columnsList = Object.keys(columnsEditableleObj).reduce(
33
+ (columnsList2, key) => {
41
34
  const list = columnsEditableleObj[key];
42
35
  for (let i = 0; i < list.length; i++) {
43
36
  const target = list[i];
44
- columnsEditablele2[target.column.prop] = {
45
- ...target,
46
- index: columnsList.length + i
47
- };
48
- columnsList.push(target.column);
37
+ columnsList2.push(target.column);
49
38
  }
50
- return { columnsEditablele: columnsEditablele2, columnsList, searchText };
39
+ return columnsList2;
51
40
  },
52
- {
53
- columnsEditablele: {},
54
- columnsList: [],
55
- searchText: Array.from(searchLabelSet.values()).join("\u3001")
56
- }
41
+ []
57
42
  );
43
+ return {
44
+ columnsList,
45
+ columnsEditablele
46
+ };
58
47
  }
59
- function tableColumnHandler(columns, cacheKey, searchArr) {
60
- const cacheColumnsValue = cacheKey ? JSON.parse(sessionStorage.getItem(cacheKey) || "{}") : {};
48
+ function tableColumnHandler(columns, cacheKey) {
49
+ const cacheColumnsValue = cacheKey && sessionStorage.getItem(cacheKey) ? JSON.parse(sessionStorage.getItem(cacheKey) || "{}") : null;
50
+ const otherColumns = [];
51
+ let maxIndex = 0;
61
52
  const cacheColumnsEditablele = columns.reduce((obj, column) => {
62
- obj[column.prop] = {
63
- ...column.editable,
64
- ...cacheColumnsValue[column.prop],
65
- lock: column.editable.lock,
66
- edit: column.editable.edit,
67
- desc: column.editable.desc,
68
- examples: column.editable.examples
69
- };
53
+ const { editable, prop, type, permission } = column;
54
+ if (cacheColumnsValue && (!cacheColumnsValue[prop] || type === "operator") || permission && !isPermission(permission)) {
55
+ otherColumns.push(column);
56
+ } else {
57
+ let { sortIndex, checked } = cacheColumnsValue?.[prop] || {};
58
+ obj[prop] = {
59
+ prop,
60
+ sortIndex: isNumber(sortIndex) ? sortIndex : editable.index,
61
+ checked: isBoolean(checked) ? checked : editable.checked
62
+ };
63
+ maxIndex = Math.max(maxIndex, obj[prop].sortIndex);
64
+ }
70
65
  return obj;
71
66
  }, {});
72
- return tableColumnsEditableleHandler(
73
- columns,
74
- cacheColumnsEditablele,
75
- searchArr
76
- );
67
+ otherColumns.forEach((item, index) => {
68
+ const { prop, type } = item;
69
+ maxIndex = maxIndex < item.editable.index ? item.editable.index : maxIndex + index + 1;
70
+ cacheColumnsEditablele[prop] = {
71
+ prop,
72
+ sortIndex: maxIndex,
73
+ checked: type !== "checked"
74
+ };
75
+ });
76
+ return tableColumnsEditableleHandler(columns, cacheColumnsEditablele);
77
77
  }
78
78
  function operatorShowHandler(operator, scope) {
79
79
  if (operator.permission && !isPermission(operator.permission)) {
@@ -159,17 +159,35 @@ const useAppTableWrapper = (hy) => {
159
159
  const tableColumnsList = computed(() => {
160
160
  return tableColumns.value.filter((column) => tableColumnShowHandler(column));
161
161
  });
162
- const searchPlaceholder = ref("");
162
+ const searchPlaceholder = computed(() => {
163
+ const searchLabelSet = tableColumnsList.value.reduce(
164
+ (searchLabelSet2, column) => {
165
+ if (column.isSearch) {
166
+ searchLabelSet2.add(column.label);
167
+ }
168
+ return searchLabelSet2;
169
+ },
170
+ /* @__PURE__ */ new Set()
171
+ );
172
+ if (props.searchArr?.length > 0) {
173
+ props.searchArr.forEach((item) => {
174
+ searchLabelSet.add(item.label);
175
+ });
176
+ }
177
+ return Array.from(searchLabelSet.values());
178
+ });
163
179
  function getRowKey(row = {}) {
164
180
  if (isString(props.rowKey)) return row[props.rowKey];
165
181
  if (isFunction(props.rowKey)) return props.rowKey(row);
166
182
  return row.id;
167
183
  }
168
184
  function onTableColumnsSelectHandler(value) {
169
- const { columnsEditablele, columnsList, searchText } = tableColumnsEditableleHandler(props.tableColumns, value, props.searchArr);
185
+ const { columnsList, searchText } = tableColumnsEditableleHandler(
186
+ props.tableColumns,
187
+ value
188
+ );
170
189
  tableColumns.value = columnsList;
171
- tableColumnsEditablele.value = columnsEditablele;
172
- searchPlaceholder.value = searchText;
190
+ tableColumnsEditablele.value = value;
173
191
  sessionStorage.setItem(CACHE_COLUMNS_KEY, JSON.stringify(value));
174
192
  }
175
193
  function doLayout() {
@@ -335,12 +353,10 @@ const useAppTableWrapper = (hy) => {
335
353
  watchEffect(() => {
336
354
  const { columnsList, columnsEditablele, searchText } = tableColumnHandler(
337
355
  props.tableColumns,
338
- CACHE_COLUMNS_KEY,
339
- props.searchArr
356
+ CACHE_COLUMNS_KEY
340
357
  );
341
358
  tableColumns.value = columnsList;
342
359
  tableColumnsEditablele.value = columnsEditablele;
343
- searchPlaceholder.value = searchText;
344
360
  });
345
361
  return {
346
362
  // 表格配置项
@@ -1,5 +1,5 @@
1
1
  import { toRef } from 'vue';
2
- import { isEmpty, isBoolean, isString, isObject } from '../../../utils/is.mjs';
2
+ import { isEmpty, isBoolean, isString, isObject, isPermission } from '../../../utils/is.mjs';
3
3
  import { useAppSearch } from '../../hySearch/js/useAppSearch.mjs';
4
4
  import { useLocale } from '../../../hooks/useLocale.mjs';
5
5
 
@@ -13,7 +13,7 @@ function getColumnDefaultConfig(column) {
13
13
  };
14
14
  case "index":
15
15
  return {
16
- props: `${column.type}_prop`,
16
+ prop: `${column.type}_prop`,
17
17
  label: t("table.index")
18
18
  };
19
19
  case "expand":
@@ -34,7 +34,21 @@ function getColumnDefaultWidth(column) {
34
34
  if (column.type === "expand" && column.expandType === "expand") return 40;
35
35
  if (column.type === "selection") return 40;
36
36
  if (column.type === "index") return 80;
37
- if (column.type === "operator") return 172;
37
+ if (column.type === "operator") {
38
+ const length = (column.operator || []).reduce((total, item) => {
39
+ if (!item.permission && isPermission(item.permission)) {
40
+ total++;
41
+ }
42
+ return total;
43
+ }, 0);
44
+ if (length >= 3) {
45
+ return 168;
46
+ } else if (length === 2) {
47
+ return 168 - 52;
48
+ } else {
49
+ return 168 - 52 * 2;
50
+ }
51
+ }
38
52
  return;
39
53
  }
40
54
  function generateColumnItem(column) {
@@ -58,13 +72,13 @@ function getColumnEditable(column, index) {
58
72
  };
59
73
  }
60
74
  return {
61
- index: type === "operator" ? 1e3 : index,
62
75
  lock: false,
63
76
  edit: !type || type === "default",
64
77
  checked: !type || type !== "default" || type === "operator",
65
78
  desc: void 0,
66
79
  examples: [],
67
- ...editable || {}
80
+ ...editable || {},
81
+ index: type === "operator" ? 1e3 : index
68
82
  };
69
83
  }
70
84
  function getColumnSort(column) {
@@ -88,7 +102,7 @@ function getColumnSort(column) {
88
102
  return sort;
89
103
  }
90
104
  const useAppTable = (config = {}) => {
91
- const { columns, filterModel, filterColumns } = config || {};
105
+ const { columns, filterModel = {}, filterColumns } = config || {};
92
106
  const tableColumns = [];
93
107
  let defaultSortInfo = null;
94
108
  try {
@@ -6,21 +6,26 @@
6
6
  color: rgb(var(--hy-main));
7
7
  font-size: 14px;
8
8
  background-color: rgb(var(--hy-background));
9
- .el-table {
9
+ .hy-el-table {
10
10
  &.hideSelect {
11
11
  /* 禁用全选 */
12
- .el-table__header-wrapper .el-checkbox {
12
+ .hy-el-table__header-wrapper .hy-el-checkbox {
13
13
  display: none !important;
14
14
  }
15
15
  }
16
- .el-table__cell .cell {
16
+ .hy-el-table__cell .cell {
17
17
  display: flex;
18
18
  align-items: center;
19
- .el-table__expand-icon {
19
+ .hy-el-table__expand-icon {
20
20
  flex-shrink: 0;
21
21
  }
22
22
  }
23
23
  }
24
+ .hy-el-table-v2 {
25
+ .hy-el-table-v2__row-cell {
26
+ padding: 8px 12px;
27
+ }
28
+ }
24
29
  .hy-table-search {
25
30
  width: 160px;
26
31
  .hy-el-input__inner::placeholder {
@@ -482,7 +482,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
482
482
  default: withCtx((scope) => [
483
483
  column?.slot ? renderSlot(_ctx.$slots, column?.slot, mergeProps({ ref_for: true }, scope), void 0, void 0, 0) : column.type === "operator" ? (openBlock(), createElementBlock("div", {
484
484
  key: 1,
485
- class: "flex items-center justify-end gap-2 text-main"
485
+ class: "w-full flex items-center justify-end gap-3 text-main"
486
486
  }, [
487
487
  (openBlock(true), createElementBlock(
488
488
  Fragment,
package/es/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
- const version = "0.2.33";
1
+ const version = "0.2.34";
2
2
 
3
3
  export { version };
@@ -27,11 +27,10 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
27
27
  type: String,
28
28
  default: "default"
29
29
  },
30
- zIndex: {
31
- type: Number,
32
- default: null
33
- // default-默认类型 right-右侧弹窗 fullscreen-全屏
34
- },
30
+ // zIndex: {
31
+ // type: Number,
32
+ // default: null, // default-默认类型 right-右侧弹窗 fullscreen-全屏
33
+ // },
35
34
  top: String,
36
35
  // 支持缩小化
37
36
  showShrink: { type: Boolean, default: false },
@@ -151,7 +150,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
151
150
  }
152
151
  const dialogTestRef = vue.ref();
153
152
  function dialogMousedown(e) {
154
- if (props.zIndex != null) return;
155
153
  emits("onDialogMousedown", e);
156
154
  }
157
155
  __expose({
@@ -1,10 +1,6 @@
1
1
  .hy-form-container {
2
2
  display: grid;
3
3
  column-gap: 24px;
4
- .el-form-item__label::before {
5
- content: '' !important;
6
- display: none;
7
- }
8
4
 
9
5
  .label-required {
10
6
  &::after {
@@ -6,11 +6,11 @@ var vue = require('vue');
6
6
  var Sortable = require('sortablejs');
7
7
  var elementPlus = require('element-plus');
8
8
  var iconsVue = require('@element-plus/icons-vue');
9
- var index$2 = require('../js/index.js');
9
+ var index = require('../js/index.js');
10
10
  var columnSelectItem = require('./columnSelectItem.vue.js');
11
11
  var useLocale = require('../../../hooks/useLocale.js');
12
- var index = require('../../hyTooltip/index.js');
13
- var index$1 = require('../../hyButton/index.js');
12
+ var index$1 = require('../../hyTooltip/index.js');
13
+ var index$2 = require('../../hyButton/index.js');
14
14
  var is = require('../../../utils/is.js');
15
15
 
16
16
  const _sfc_main = {
@@ -40,11 +40,11 @@ const _sfc_main = {
40
40
  const tableEditableColumns = vue.ref([]);
41
41
  const showColumnsLength = vue.computed(() => {
42
42
  return (tableColumns.value || []).reduce((total, column) => {
43
- return total + (isFilterColumn(column) ? 0 : 1);
43
+ return total + (isShowColumn(column) ? 1 : 0);
44
44
  }, 0);
45
45
  });
46
- function isFilterColumn(column) {
47
- return !column.editable.edit || column.prop === "operator";
46
+ function isShowColumn(column) {
47
+ return index.tableColumnShowHandler(column) && column.editable.edit;
48
48
  }
49
49
  function showPopover() {
50
50
  initColumnsInfo(props.columns, props.columnsEditable);
@@ -57,26 +57,20 @@ const _sfc_main = {
57
57
  popoverRef.value?.hide?.();
58
58
  }
59
59
  function initColumnsInfo(columns, columnsEditable) {
60
+ const columnArr = [];
60
61
  const checkedArr = [];
61
- tableEditableColumns.value = columns.reduce((list, column, index) => {
62
- if (!isFilterColumn(column) && !column.editable.lock) {
63
- list.push({
62
+ for (const column of columns) {
63
+ if (isShowColumn(column) && !column.editable.lock) {
64
+ columnArr.push({
64
65
  ...column,
65
- sortIndex: index
66
+ sortIndex: columnsEditable[column.prop].sortIndex
66
67
  });
67
- }
68
- return list;
69
- }, []);
70
- for (const key in columnsEditable || {}) {
71
- const target = columnsEditable[key];
72
- const { column } = target;
73
- if (isFilterColumn(column) || column.editable.lock) {
74
- continue;
75
- }
76
- if (target.checked) {
77
- checkedArr.push(column.prop);
68
+ if (columnsEditable[column.prop].checked) {
69
+ checkedArr.push(column.prop);
70
+ }
78
71
  }
79
72
  }
73
+ tableEditableColumns.value = columnArr;
80
74
  checkedList.value = checkedArr;
81
75
  }
82
76
  const showClear = vue.ref(true);
@@ -109,7 +103,7 @@ const _sfc_main = {
109
103
  }
110
104
  const editableObj = tableEditableColumns.value.reduce(
111
105
  (editableObj2, column) => {
112
- editableObj2[column.prop].index = column.sortIndex;
106
+ editableObj2[column.prop].sortIndex = column.sortIndex;
113
107
  editableObj2[column.prop].checked = checkMap.value.has(column.prop);
114
108
  return editableObj2;
115
109
  },
@@ -119,7 +113,7 @@ const _sfc_main = {
119
113
  closePopover();
120
114
  }
121
115
  function onClearHandler() {
122
- const { columnsList, columnsEditablele } = index$2.tableColumnHandler(
116
+ const { columnsList, columnsEditablele } = index.tableColumnHandler(
123
117
  props.originColumns
124
118
  );
125
119
  initColumnsInfo(columnsList, columnsEditablele);
@@ -137,29 +131,19 @@ const _sfc_main = {
137
131
  const { oldIndex, newIndex } = event;
138
132
  if (is.isEmpty(oldIndex) || is.isEmpty(newIndex) || oldIndex === newIndex)
139
133
  return;
140
- const newSortIndex = tableEditableColumns.value[newIndex].sortIndex;
141
- tableEditableColumns.value[newIndex].sortIndex = tableEditableColumns.value[oldIndex].sortIndex;
142
- tableEditableColumns.value[oldIndex].sortIndex = newSortIndex;
143
- if (oldIndex < newIndex) {
144
- tableEditableColumns.value.splice(
145
- oldIndex,
146
- 1,
147
- tableEditableColumns.value.splice(
148
- newIndex,
149
- 1,
150
- tableEditableColumns.value[oldIndex]
151
- )[0]
152
- );
153
- } else {
154
- tableEditableColumns.value.splice(
155
- newIndex,
156
- 1,
157
- tableEditableColumns.value.splice(
158
- oldIndex,
159
- 1,
160
- tableEditableColumns.value[newIndex]
161
- )[0]
162
- );
134
+ const minIndex = Math.min(oldIndex, newIndex);
135
+ const maxIndex = Math.max(oldIndex, newIndex);
136
+ const sortList = [];
137
+ for (let i = minIndex; i <= maxIndex; i++) {
138
+ sortList[i] = tableEditableColumns.value[i].sortIndex;
139
+ }
140
+ tableEditableColumns.value.splice(
141
+ newIndex,
142
+ 0,
143
+ tableEditableColumns.value.splice(oldIndex, 1)[0]
144
+ );
145
+ for (let i = minIndex; i <= maxIndex; i++) {
146
+ tableEditableColumns.value[i].sortIndex = sortList[i];
163
147
  }
164
148
  showClear.value = true;
165
149
  }
@@ -254,7 +238,7 @@ const _sfc_main = {
254
238
  vue.Fragment,
255
239
  { key: index },
256
240
  [
257
- !isFilterColumn(item) && item.editable.lock ? (vue.openBlock(), vue.createBlock(columnSelectItem.default, {
241
+ isShowColumn(item) && item.editable.lock ? (vue.openBlock(), vue.createBlock(columnSelectItem.default, {
258
242
  key: 0,
259
243
  column: item,
260
244
  checkMap: checkMap.value
@@ -336,13 +320,13 @@ const _sfc_main = {
336
320
  _: 1
337
321
  /* STABLE */
338
322
  }),
339
- checkedList.value?.length >= 8 ? (vue.openBlock(), vue.createBlock(vue.unref(index.HyTooltip), {
323
+ checkedList.value?.length >= 8 ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.HyTooltip), {
340
324
  key: 0,
341
325
  "is-always": false,
342
326
  content: vue.unref(t)("table.tooManyFieldsWillAffectReadability"),
343
327
  class: "mr-2 text-auxiliary"
344
328
  }, null, 8, ["content"])) : vue.createCommentVNode("v-if", true),
345
- vue.createVNode(vue.unref(index$1.HyButton), {
329
+ vue.createVNode(vue.unref(index$2.HyButton), {
346
330
  type: "primary",
347
331
  size: "small",
348
332
  onClick: onConfirmHandler
@@ -312,8 +312,8 @@ const _sfc_main = {
312
312
  width: __props.width,
313
313
  height: __props.height,
314
314
  "header-height": __props.showHeader ? 44 : 0,
315
- "row-height": 50,
316
- "estimated-row-height": 50,
315
+ "row-height": 64,
316
+ "estimated-row-height": 64,
317
317
  "expand-column-key": expandColumn.value?.key,
318
318
  fixed: "",
319
319
  "row-class": rowClass,
@@ -439,7 +439,7 @@ const _sfc_main = {
439
439
  /* STABLE_FRAGMENT */
440
440
  )) : column.type === "operator" ? (vue.openBlock(), vue.createElementBlock("div", {
441
441
  key: 4,
442
- class: "w-full flex items-center justify-end gap-2 text-main",
442
+ class: "w-full flex items-center justify-end gap-3 text-main",
443
443
  onClick: vue.withModifiers(() => {
444
444
  }, ["stop"]),
445
445
  onContextmenu: vue.withModifiers(() => {
@@ -15,67 +15,67 @@ function tableColumnShowHandler(column) {
15
15
  if (is.isFunction(show)) return show(column);
16
16
  return true;
17
17
  }
18
- function tableColumnsEditableleHandler(columns, columnsEditablele, searchArr) {
19
- const searchLabelSet = /* @__PURE__ */ new Set();
18
+ function tableColumnsEditableleHandler(columns, columnsEditablele) {
20
19
  const columnsEditableleObj = {};
20
+ const sortSet = /* @__PURE__ */ new Set();
21
21
  for (const column of columns) {
22
- const { editable } = column;
23
- const columnsEditableleItem = columnsEditablele[column.prop] || editable;
24
- const { index } = columnsEditableleItem;
25
- if (!columnsEditableleObj[index]) {
26
- columnsEditableleObj[index] = [];
22
+ const columnsEditableleItem = columnsEditablele[column.prop];
23
+ const { sortIndex } = columnsEditableleItem;
24
+ sortSet.add(sortIndex);
25
+ if (!columnsEditableleObj[sortIndex]) {
26
+ columnsEditableleObj[sortIndex] = [];
27
27
  }
28
- columnsEditableleObj[index].push({
29
- ...columnsEditableleItem,
28
+ columnsEditableleObj[sortIndex].push({
29
+ editable: columnsEditableleItem,
30
30
  column
31
31
  });
32
- if (column.isSearch) {
33
- searchLabelSet.add(column.label);
34
- }
35
- }
36
- if (searchArr?.length > 0) {
37
- searchArr.forEach((item) => {
38
- searchLabelSet.add(item.label);
39
- });
40
32
  }
41
- return Object.keys(columnsEditableleObj).reduce(
42
- ({ columnsEditablele: columnsEditablele2, columnsList, searchText }, key) => {
33
+ Array.from(sortSet.values()).reduce((a, b) => a - b);
34
+ const columnsList = Object.keys(columnsEditableleObj).reduce(
35
+ (columnsList2, key) => {
43
36
  const list = columnsEditableleObj[key];
44
37
  for (let i = 0; i < list.length; i++) {
45
38
  const target = list[i];
46
- columnsEditablele2[target.column.prop] = {
47
- ...target,
48
- index: columnsList.length + i
49
- };
50
- columnsList.push(target.column);
39
+ columnsList2.push(target.column);
51
40
  }
52
- return { columnsEditablele: columnsEditablele2, columnsList, searchText };
41
+ return columnsList2;
53
42
  },
54
- {
55
- columnsEditablele: {},
56
- columnsList: [],
57
- searchText: Array.from(searchLabelSet.values()).join("\u3001")
58
- }
43
+ []
59
44
  );
45
+ return {
46
+ columnsList,
47
+ columnsEditablele
48
+ };
60
49
  }
61
- function tableColumnHandler(columns, cacheKey, searchArr) {
62
- const cacheColumnsValue = cacheKey ? JSON.parse(sessionStorage.getItem(cacheKey) || "{}") : {};
50
+ function tableColumnHandler(columns, cacheKey) {
51
+ const cacheColumnsValue = cacheKey && sessionStorage.getItem(cacheKey) ? JSON.parse(sessionStorage.getItem(cacheKey) || "{}") : null;
52
+ const otherColumns = [];
53
+ let maxIndex = 0;
63
54
  const cacheColumnsEditablele = columns.reduce((obj, column) => {
64
- obj[column.prop] = {
65
- ...column.editable,
66
- ...cacheColumnsValue[column.prop],
67
- lock: column.editable.lock,
68
- edit: column.editable.edit,
69
- desc: column.editable.desc,
70
- examples: column.editable.examples
71
- };
55
+ const { editable, prop, type, permission } = column;
56
+ if (cacheColumnsValue && (!cacheColumnsValue[prop] || type === "operator") || permission && !is.isPermission(permission)) {
57
+ otherColumns.push(column);
58
+ } else {
59
+ let { sortIndex, checked } = cacheColumnsValue?.[prop] || {};
60
+ obj[prop] = {
61
+ prop,
62
+ sortIndex: is.isNumber(sortIndex) ? sortIndex : editable.index,
63
+ checked: is.isBoolean(checked) ? checked : editable.checked
64
+ };
65
+ maxIndex = Math.max(maxIndex, obj[prop].sortIndex);
66
+ }
72
67
  return obj;
73
68
  }, {});
74
- return tableColumnsEditableleHandler(
75
- columns,
76
- cacheColumnsEditablele,
77
- searchArr
78
- );
69
+ otherColumns.forEach((item, index) => {
70
+ const { prop, type } = item;
71
+ maxIndex = maxIndex < item.editable.index ? item.editable.index : maxIndex + index + 1;
72
+ cacheColumnsEditablele[prop] = {
73
+ prop,
74
+ sortIndex: maxIndex,
75
+ checked: type !== "checked"
76
+ };
77
+ });
78
+ return tableColumnsEditableleHandler(columns, cacheColumnsEditablele);
79
79
  }
80
80
  function operatorShowHandler(operator, scope) {
81
81
  if (operator.permission && !is.isPermission(operator.permission)) {
@@ -161,17 +161,35 @@ const useAppTableWrapper = (hy) => {
161
161
  const tableColumnsList = vue.computed(() => {
162
162
  return tableColumns.value.filter((column) => tableColumnShowHandler(column));
163
163
  });
164
- const searchPlaceholder = vue.ref("");
164
+ const searchPlaceholder = vue.computed(() => {
165
+ const searchLabelSet = tableColumnsList.value.reduce(
166
+ (searchLabelSet2, column) => {
167
+ if (column.isSearch) {
168
+ searchLabelSet2.add(column.label);
169
+ }
170
+ return searchLabelSet2;
171
+ },
172
+ /* @__PURE__ */ new Set()
173
+ );
174
+ if (props.searchArr?.length > 0) {
175
+ props.searchArr.forEach((item) => {
176
+ searchLabelSet.add(item.label);
177
+ });
178
+ }
179
+ return Array.from(searchLabelSet.values());
180
+ });
165
181
  function getRowKey(row = {}) {
166
182
  if (is.isString(props.rowKey)) return row[props.rowKey];
167
183
  if (is.isFunction(props.rowKey)) return props.rowKey(row);
168
184
  return row.id;
169
185
  }
170
186
  function onTableColumnsSelectHandler(value) {
171
- const { columnsEditablele, columnsList, searchText } = tableColumnsEditableleHandler(props.tableColumns, value, props.searchArr);
187
+ const { columnsList, searchText } = tableColumnsEditableleHandler(
188
+ props.tableColumns,
189
+ value
190
+ );
172
191
  tableColumns.value = columnsList;
173
- tableColumnsEditablele.value = columnsEditablele;
174
- searchPlaceholder.value = searchText;
192
+ tableColumnsEditablele.value = value;
175
193
  sessionStorage.setItem(CACHE_COLUMNS_KEY, JSON.stringify(value));
176
194
  }
177
195
  function doLayout() {
@@ -337,12 +355,10 @@ const useAppTableWrapper = (hy) => {
337
355
  vue.watchEffect(() => {
338
356
  const { columnsList, columnsEditablele, searchText } = tableColumnHandler(
339
357
  props.tableColumns,
340
- CACHE_COLUMNS_KEY,
341
- props.searchArr
358
+ CACHE_COLUMNS_KEY
342
359
  );
343
360
  tableColumns.value = columnsList;
344
361
  tableColumnsEditablele.value = columnsEditablele;
345
- searchPlaceholder.value = searchText;
346
362
  });
347
363
  return {
348
364
  // 表格配置项
@@ -15,7 +15,7 @@ function getColumnDefaultConfig(column) {
15
15
  };
16
16
  case "index":
17
17
  return {
18
- props: `${column.type}_prop`,
18
+ prop: `${column.type}_prop`,
19
19
  label: t("table.index")
20
20
  };
21
21
  case "expand":
@@ -36,7 +36,21 @@ function getColumnDefaultWidth(column) {
36
36
  if (column.type === "expand" && column.expandType === "expand") return 40;
37
37
  if (column.type === "selection") return 40;
38
38
  if (column.type === "index") return 80;
39
- if (column.type === "operator") return 172;
39
+ if (column.type === "operator") {
40
+ const length = (column.operator || []).reduce((total, item) => {
41
+ if (!item.permission && is.isPermission(item.permission)) {
42
+ total++;
43
+ }
44
+ return total;
45
+ }, 0);
46
+ if (length >= 3) {
47
+ return 168;
48
+ } else if (length === 2) {
49
+ return 168 - 52;
50
+ } else {
51
+ return 168 - 52 * 2;
52
+ }
53
+ }
40
54
  return;
41
55
  }
42
56
  function generateColumnItem(column) {
@@ -60,13 +74,13 @@ function getColumnEditable(column, index) {
60
74
  };
61
75
  }
62
76
  return {
63
- index: type === "operator" ? 1e3 : index,
64
77
  lock: false,
65
78
  edit: !type || type === "default",
66
79
  checked: !type || type !== "default" || type === "operator",
67
80
  desc: void 0,
68
81
  examples: [],
69
- ...editable || {}
82
+ ...editable || {},
83
+ index: type === "operator" ? 1e3 : index
70
84
  };
71
85
  }
72
86
  function getColumnSort(column) {
@@ -90,7 +104,7 @@ function getColumnSort(column) {
90
104
  return sort;
91
105
  }
92
106
  const useAppTable = (config = {}) => {
93
- const { columns, filterModel, filterColumns } = config || {};
107
+ const { columns, filterModel = {}, filterColumns } = config || {};
94
108
  const tableColumns = [];
95
109
  let defaultSortInfo = null;
96
110
  try {
@@ -6,21 +6,26 @@
6
6
  color: rgb(var(--hy-main));
7
7
  font-size: 14px;
8
8
  background-color: rgb(var(--hy-background));
9
- .el-table {
9
+ .hy-el-table {
10
10
  &.hideSelect {
11
11
  /* 禁用全选 */
12
- .el-table__header-wrapper .el-checkbox {
12
+ .hy-el-table__header-wrapper .hy-el-checkbox {
13
13
  display: none !important;
14
14
  }
15
15
  }
16
- .el-table__cell .cell {
16
+ .hy-el-table__cell .cell {
17
17
  display: flex;
18
18
  align-items: center;
19
- .el-table__expand-icon {
19
+ .hy-el-table__expand-icon {
20
20
  flex-shrink: 0;
21
21
  }
22
22
  }
23
23
  }
24
+ .hy-el-table-v2 {
25
+ .hy-el-table-v2__row-cell {
26
+ padding: 8px 12px;
27
+ }
28
+ }
24
29
  .hy-table-search {
25
30
  width: 160px;
26
31
  .hy-el-input__inner::placeholder {
@@ -486,7 +486,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
486
486
  default: vue.withCtx((scope) => [
487
487
  column?.slot ? vue.renderSlot(_ctx.$slots, column?.slot, vue.mergeProps({ ref_for: true }, scope), void 0, void 0, 0) : column.type === "operator" ? (vue.openBlock(), vue.createElementBlock("div", {
488
488
  key: 1,
489
- class: "flex items-center justify-end gap-2 text-main"
489
+ class: "w-full flex items-center justify-end gap-3 text-main"
490
490
  }, [
491
491
  (vue.openBlock(true), vue.createElementBlock(
492
492
  vue.Fragment,
package/lib/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const version = "0.2.33";
3
+ const version = "0.2.34";
4
4
 
5
5
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-dispatch-ui-v3",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "scripts": {