@neatui/vue 2.7.2 → 2.7.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/vue",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "basic component ui",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -13,8 +13,8 @@
13
13
  const props = defineProps({
14
14
  lists: {
15
15
  type: Array as PropType<any[]>,
16
- default: () => []
17
- }
16
+ default: () => [],
17
+ },
18
18
  });
19
19
  const emit = defineEmits(['update:lists']);
20
20
 
@@ -25,14 +25,14 @@
25
25
  watch(
26
26
  () => props.lists,
27
27
  (newVal, oldVal) => {
28
- console.log('IDraggable props.lists changed:', {
29
- newLength: newVal?.length,
30
- oldLength: oldVal?.length,
31
- newVal: newVal?.map((item) => item.label || item.field),
32
- oldVal: oldVal?.map((item) => item.label || item.field)
33
- });
28
+ // console.log('IDraggable props.lists changed:', {
29
+ // newLength: newVal?.length,
30
+ // oldLength: oldVal?.length,
31
+ // newVal: newVal?.map((item) => item.label || item.field),
32
+ // oldVal: oldVal?.map((item) => item.label || item.field)
33
+ // });
34
34
  },
35
- { deep: true }
35
+ { deep: true },
36
36
  );
37
37
 
38
38
  onMounted(() => {
@@ -54,13 +54,13 @@
54
54
 
55
55
  console.log(
56
56
  'Emitting new list:',
57
- newList.map((item) => item.label || item.field)
57
+ newList.map((item) => item.label || item.field),
58
58
  );
59
59
 
60
60
  // 通知父组件更新数据
61
61
  emit('update:lists', newList);
62
62
  }
63
- }
63
+ },
64
64
  });
65
65
  }
66
66
  });
@@ -204,7 +204,7 @@
204
204
  SearchMoreSelect,
205
205
  ImgUpload,
206
206
  Upload,
207
- Cascader
207
+ Cascader,
208
208
  } from '../../form';
209
209
  import { Tree } from '../../display';
210
210
 
@@ -238,39 +238,39 @@
238
238
  // 用户是否交互
239
239
  interacted: {
240
240
  type: Boolean,
241
- default: false
241
+ default: false,
242
242
  },
243
243
  // JSON规则
244
244
  form: {
245
245
  type: Object,
246
- default: () => ({})
246
+ default: () => ({}),
247
247
  },
248
248
  // 表单数据
249
249
  data: {
250
250
  type: Object as any,
251
- default: () => ({})
251
+ default: () => ({}),
252
252
  },
253
253
  // 栅格系统
254
254
  rows: {
255
255
  type: String,
256
- default: 'mob-24 pad-12 dpc-8'
256
+ default: 'mob-24 pad-12 dpc-8',
257
257
  },
258
258
  // 如果表单是数组的话这里传入下标
259
259
  idx: {
260
260
  type: [String, Number],
261
- default: ''
261
+ default: '',
262
262
  },
263
263
  // 是否垂直排列
264
264
  vertical: {
265
265
  type: Boolean,
266
- default: false
267
- }
266
+ default: false,
267
+ },
268
268
  });
269
269
 
270
270
  // 数据
271
271
  const state: any = reactive({
272
272
  form: [],
273
- _lw: 6
273
+ _lw: 6,
274
274
  });
275
275
 
276
276
  // 监听结构
@@ -382,13 +382,13 @@
382
382
  },
383
383
  {
384
384
  deep: true,
385
- immediate: true
386
- }
387
- )
385
+ immediate: true,
386
+ },
387
+ ),
388
388
  );
389
389
  }
390
390
  },
391
- { deep: true, immediate: true }
391
+ { deep: true, immediate: true },
392
392
  );
393
393
 
394
394
  // 处理
@@ -409,7 +409,7 @@
409
409
  }
410
410
  });
411
411
  },
412
- { deep: true }
412
+ { deep: true },
413
413
  );
414
414
 
415
415
  onBeforeUnmount(() => {
@@ -16,21 +16,7 @@
16
16
  <div v-if="json.model === 'Image'" :class="json?.attrs?.class?.includes('wrap') ? 'wrap' : 'nowrap'" ui-img="@a read :round" v-bind="json.attrs" v-on="event(json, data)">
17
17
  <img :src="json.value || data[json.field] || DefaultImage" alt="" />
18
18
  </div>
19
- <div
20
- v-else
21
- :class="json?.attrs?.class?.includes('wrap') ? 'wrap' : 'nowrap'"
22
- v-bind="json.attrs"
23
- v-on="event(json, data)"
24
- v-html="
25
- json.value !== null && json.value !== undefined
26
- ? isFunction(json.value)
27
- ? json.value(json)
28
- : json.value
29
- : findEnumName(json.enums, data[json.field]) !== null && findEnumName(json.enums, data[json.field]) !== undefined
30
- ? findEnumName(json.enums, data[json.field])
31
- : '‐‐'
32
- "
33
- ></div>
19
+ <div v-else :class="json?.attrs?.class?.includes('wrap') ? 'wrap' : 'nowrap'" v-bind="json.attrs" v-on="event(json, data)" v-html="value(json, data)"></div>
34
20
  </template>
35
21
  </template>
36
22
  <script lang="ts" setup>
@@ -71,12 +57,12 @@
71
57
  const props: any = defineProps({
72
58
  col: {
73
59
  type: Object,
74
- default: () => ({})
60
+ default: () => ({}),
75
61
  },
76
62
  data: {
77
63
  type: [Object],
78
- default: () => ({})
79
- }
64
+ default: () => ({}),
65
+ },
80
66
  });
81
67
 
82
68
  // 运行函数计算
@@ -97,6 +83,16 @@
97
83
 
98
84
  const json = computed(() => runfun(deepcopy(props.col)));
99
85
 
86
+ const value = (json: any, data: any) => {
87
+ return json.value !== null && json.value !== undefined
88
+ ? isFunction(json.value)
89
+ ? json.value(json)
90
+ : json.value
91
+ : findEnumName(json.enums, data[json.field]) !== null && findEnumName(json.enums, data[json.field]) !== undefined
92
+ ? findEnumName(json.enums, data[json.field])
93
+ : '‐‐';
94
+ };
95
+
100
96
  // 事件处理
101
97
  const event: any = (col: any, data: any): object => {
102
98
  const _event: any = {};
@@ -1,40 +1,46 @@
1
1
  <template>
2
2
  <div class="full" ui-scroll=":x :y">
3
3
  <!-- 桌面端 -->
4
- <table ui-hide="<pad" ui-table="@b sz:l" ref="tableRef">
4
+ <table ui-hide="<pad" :ui-table="theme" ref="tableRef">
5
5
  <thead class="table-head-fixed">
6
6
  <tr>
7
- <th v-if="selected" col-fixed="1" min-width>
7
+ <th v-if="selected" min-width col-fixed="1">
8
8
  <label class="mb-ss" ui-form="@a type:checkbox"><input type="checkbox" :checked="state.isAllSelect" @change="fSelectAll" /><span></span></label>
9
9
  </th>
10
10
  <template v-for="(col, idx) in state.table" :key="idx">
11
- <th v-if="!col._close" class="fs-xs nowrap" :min-width="col.fixed" :col-fixed="col.fixed" :col-fixed-side="col.fixed || 'l'" :data-field="col.field">
12
- <div :ui-flex="`row ${!slots.operate && idx === state._last ? 'rm' : 'lm'}`">
13
- <span class="nl-xs" v-if="col.sort" :ui-sort="0" @click="emits('onsort', col)">{{ col.label }}</span>
14
- <span class="nl-xs" v-else>{{ col.label }}</span>
15
- <IFollowView v-if="!slots.operate && idx === state._last" tipBoxClass="n-no">
16
- <button :ui-btn="`@a none s :square`">
17
- <Icon name="tableloader-setting" class="co-read"></Icon>
18
- </button>
19
- <template #tips>
20
- <div class="w-mm h-ls n-sl" ui-scroll="x:hidden :y">
21
- <IDraggable v-model:lists="state.table">
22
- <template #default="{ item: element, idx: index }">
23
- <div :class="`item ux-hover nowrap r-ss ${element.fixed ? 'forbid' : 'element'}`" :key="index">
24
- <label ui-form="@a type:checkbox" class="ny-xs nx-sl">
25
- <input type="checkbox" :checked="!element._close" @change="element._close = element._close ? 0 : 1" />
26
- <span>
27
- {{ element.label }}
28
- <i v-if="element.fixed" class="icon icon-fixed fs-xs"></i>
29
- </span>
30
- </label>
31
- </div>
32
- </template>
33
- </IDraggable>
34
- </div>
35
- </template>
36
- </IFollowView>
37
- </div>
11
+ <th v-if="!col.__close" :min-width="col.fixed" :col-fixed="col.fixed" :col-fixed-side="col.fixed || 'l'" :data-field="col.field">
12
+ <slot :name="`thead-${col.field}`" :col="col" :idx="idx">
13
+ <div v-bind="{ ...col.attrs, ...col.thead }">
14
+ <span class="nl-xs ux-none" v-if="col.order === 0 || col.order === 1 || col.order === 2" @click="fSetOrder(col)">
15
+ <span>{{ col.label }}</span>
16
+ <span ui-btn="@a none s" :ui-order="col.__order"></span>
17
+ </span>
18
+ <span class="nl-xs" v-else>{{ col.label }}</span>
19
+ <!-- 设置 -->
20
+ <IFollowView v-if="!slots.operate && idx === state._last" tipBoxClass="n-no">
21
+ <button :ui-btn="`@a none s :square`">
22
+ <Icon name="tableloader-setting" class="co-read"></Icon>
23
+ </button>
24
+ <template #tips>
25
+ <div class="w-mm h-ml+ n-sl" ui-scroll="x:hidden :y">
26
+ <IDraggable v-model:lists="state.table">
27
+ <template #default="{ item: element, idx: index }">
28
+ <div :class="`item ux-hover nowrap r-ss ${element.fixed ? 'forbid' : 'element'}`" :key="index">
29
+ <label ui-form="@a type:checkbox" class="ny-xs nx-sl">
30
+ <input type="checkbox" :checked="!element.__close" @change="element.__close = element.__close ? 0 : 1" />
31
+ <span>
32
+ {{ element.label }}
33
+ <i v-if="element.fixed" class="icon icon-fixed fs-xs"></i>
34
+ </span>
35
+ </label>
36
+ </div>
37
+ </template>
38
+ </IDraggable>
39
+ </div>
40
+ </template>
41
+ </IFollowView>
42
+ </div>
43
+ </slot>
38
44
  </th>
39
45
  </template>
40
46
  <th v-if="slots.operate" col-fixed="r" class="fs-xs nowrap ar">
@@ -42,15 +48,15 @@
42
48
  <span class="mr-sm">{{ words['operate'] || '操作' }}</span>
43
49
  <IFollowView v-if="tools" tipBoxClass="n-no">
44
50
  <button :ui-btn="`@a none s :square`">
45
- <Icon name="tableloader-setting" class="co-read"></Icon>
51
+ <Icon name="tableloader-setting" class="co-auto"></Icon>
46
52
  </button>
47
53
  <template #tips>
48
- <div class="w-mm h-ls n-sl" ui-scroll="x:hidden :y">
54
+ <div class="w-mm h-ml+ n-sl" ui-scroll="x:hidden :y">
49
55
  <IDraggable v-model:lists="state.table">
50
56
  <template #default="{ item: element, idx: index }">
51
57
  <div :class="`item ux-hover nowrap r-ss ${element.fixed ? 'forbid' : 'element'}`" :key="index">
52
58
  <label ui-form="@a type:checkbox" class="ny-xs nx-sl">
53
- <input type="checkbox" :checked="!element._close" @change="element._close = element._close ? 0 : 1" />
59
+ <input type="checkbox" :checked="!element.__close" @change="element.__close = element.__close ? 0 : 1" />
54
60
  <span>
55
61
  {{ element.label }}
56
62
  <i v-if="element.fixed" class="icon icon-fixed fs-xs"></i>
@@ -72,17 +78,16 @@
72
78
  <td v-if="selected" col-fixed="1" min-width>
73
79
  <label class="mb-ss" ui-form="@a type:checkbox"><input type="checkbox" v-model="item.__selected" /><span></span></label>
74
80
  </td>
75
- <template v-for="(col, idx) in state.table" :key="idx">
81
+ <template v-for="(col, cid) in state.table" :key="cid">
76
82
  <td
77
- v-if="!col._close"
78
- :class="`${!slots.operate && idx === state._last ? 'ar' : ''}`"
83
+ v-if="!col.__close"
84
+ :class="`${!slots.operate && cid === state._last ? 'ar' : ''}`"
79
85
  :min-width="col.fixed"
80
86
  :col-fixed="col.fixed"
81
87
  :col-fixed-side="col.fixed || 'l'"
82
88
  :data-field="col.field"
83
89
  >
84
- <slot v-if="slots[col.field]" :name="col.field"></slot>
85
- <TableColView v-else :col="col" :data="item" />
90
+ <slot :name="col.field" :col="col" :item="item" :idx="idx"><TableColView :col="col" :data="item" /></slot>
86
91
  </td>
87
92
  </template>
88
93
  <td v-if="slots.operate" col-fixed="r" class="ar"><slot name="operate" :item="item" :idx="idx"></slot></td>
@@ -92,51 +97,45 @@
92
97
  </table>
93
98
  <!-- 移动端 -->
94
99
  <div ui-hide=">mob">
95
- <table class="n-sl" ui-table="@a">
96
- <thead class="table-head-fixed">
97
- <tr>
98
- <th class="fs-xs ar ps nr-no">
99
- <div ui-flex="row xm">
100
- <span class="fs-xs bold">信息</span>
101
- <IFollowView>
102
- <button :ui-btn="`@a none s :square`"><Icon name="tableloader-setting" class="co-read"></Icon></button>
103
- <template #tips>
104
- <IDraggable v-model:lists="state.table">
105
- <template #default="{ item: element, idx: index }">
106
- <div class="item ux-hover nowrap r-ss" :key="index">
107
- <label ui-form="@a type:checkbox" class="ny-xs nx-sl">
108
- <input type="checkbox" :checked="!element._close" @change="element._close = element._close ? 0 : 1" />
109
- <span>{{ element.label }}</span>
110
- </label>
111
- </div>
112
- </template>
113
- </IDraggable>
100
+ <ul>
101
+ <li class="bg-fore r-sm my-sl nx-ms ny-sl" ui-flex="row xm">
102
+ <div>
103
+ <label class="mb-ss" ui-form="@a type:checkbox"><input type="checkbox" :checked="state.isAllSelect" @change="fSelectAll" /><span>全选</span></label>
104
+ </div>
105
+ <div>
106
+ <IFollowView>
107
+ <button :ui-btn="`@a none s :square`"><Icon name="tableloader-setting" class="co-read"></Icon></button>
108
+ <template #tips>
109
+ <IDraggable v-model:lists="state.table">
110
+ <template #default="{ item: element, idx: index }">
111
+ <div class="item ux-hover nowrap r-ss" :key="index">
112
+ <label ui-form="@a type:checkbox" class="ny-xs nx-sl">
113
+ <input type="checkbox" :checked="!element.__close" @change="element.__close = element.__close ? 0 : 1" />
114
+ <span>{{ element.label }}</span>
115
+ </label>
116
+ </div>
114
117
  </template>
115
- </IFollowView>
116
- </div>
117
- </th>
118
- </tr>
119
- </thead>
120
- <tbody :ui-tbody-load="state.load">
121
- <template v-if="lists.length">
122
- <tr v-for="(item, idx) in lists" :key="idx" v-bind="rows.attrs" v-on="event(rows.event, item)">
123
- <td ui-card="@a bk:line" class="mb-sl">
124
- <div ui-card-body="" class="n-ss">
125
- <ul>
126
- <template v-for="(col, idx) in state.table" :key="idx">
127
- <li v-if="!col._close" :class="`${col.fixed ? 'ps z-sm' : ''}`" ui-flex="row lm">
128
- <div class="w-sl">{{ col.label }}:</div>
129
- <TableColView :col="col" :data="item" />
130
- </li>
131
- </template>
132
- <li v-if="slots.operate"><slot name="operate" :item="item" :idx="idx"></slot></li>
133
- </ul>
134
- </div>
135
- </td>
136
- </tr>
137
- </template>
138
- </tbody>
139
- </table>
118
+ </IDraggable>
119
+ </template>
120
+ </IFollowView>
121
+ </div>
122
+ </li>
123
+ <li v-for="(item, idx) in lists" :key="idx" class="bg-fore r-sm my-sl n-ms">
124
+ <table>
125
+ <tbody>
126
+ <template v-for="(col, idx) in state.table" :key="idx">
127
+ <tr v-if="!col.__close">
128
+ <td class="nowrap vt n-ss">{{ col.label }}:</td>
129
+ <td class="n-ss">
130
+ <TableColView :col="col" :data="item" />
131
+ </td>
132
+ </tr>
133
+ </template>
134
+ </tbody>
135
+ </table>
136
+ <div v-if="slots.operate"><slot name="operate" :item="item" :idx="idx"></slot></div>
137
+ </li>
138
+ </ul>
140
139
  </div>
141
140
  <div v-if="!lists.length" class="ny-ls o-mm" ui-flex="col cm">
142
141
  <div class="ac">
@@ -159,12 +158,16 @@
159
158
  // 外部插槽
160
159
  const slots: any = useSlots();
161
160
  // 外部方法
162
- const emits = defineEmits(['update:table', 'onsort', 'refresh']);
161
+ const emits = defineEmits(['update:table', 'order', 'refresh']);
163
162
 
164
163
  // 类型定义
165
164
  interface JSONRules {
166
165
  label: string | (() => string);
167
166
  field: string | (() => string);
167
+ width?: string | (() => string);
168
+ fixed?: string | (() => string);
169
+ thead?: object | (() => object);
170
+ tbody?: object | (() => object);
168
171
  paths?: string | (() => string);
169
172
  model?: string | Array<any> | (() => string | Array<any>);
170
173
  enums?: Array<any> | (() => string | Array<any>);
@@ -173,7 +176,7 @@
173
176
  attrs?: string | Record<string, any> | Record<string, any>[] | (() => string | Record<string, any> | Record<string, any>[]);
174
177
  value?: any | (() => any);
175
178
  clear?: boolean | (() => boolean);
176
- sort?: boolean | (() => boolean);
179
+ order?: 0 | 1 | 2 | number | (() => 0 | 1 | 2 | number);
177
180
  }
178
181
  interface Props {
179
182
  words?: { [key: string]: any };
@@ -181,6 +184,7 @@
181
184
  lists: Array<any>;
182
185
  selected?: boolean;
183
186
  tools?: boolean;
187
+ theme?: string;
184
188
  rows?: {
185
189
  attrs?: { [key: string]: any };
186
190
  event?: { [key: string]: any };
@@ -193,7 +197,8 @@
193
197
  lists: () => [],
194
198
  selected: true,
195
199
  tools: true,
196
- rows: () => ({ attrs: {}, event: {} })
200
+ rows: () => ({ attrs: {}, event: {} }),
201
+ theme: '@b sz:l',
197
202
  });
198
203
 
199
204
  // 内部数据
@@ -206,11 +211,11 @@
206
211
  limit: computed(() => {
207
212
  const _cache = JSON.parse(localStorage.getItem(`${state.name}_limit`) || '{}');
208
213
  return (props.limit || [])?.map((item: any) => {
209
- if (_cache[item.field] && Object.prototype.hasOwnProperty.call(_cache[item.field], '_close')) {
210
- item._close = _cache[item.field]?._close;
214
+ if (_cache[item.field] && Object.prototype.hasOwnProperty.call(_cache[item.field], '__close')) {
215
+ item.__close = _cache[item.field]?.__close;
211
216
  } else {
212
217
  if (item.close === true || item.close === 1 || item.close === 'always') {
213
- item._close = 1;
218
+ item.__close = 1;
214
219
  }
215
220
  }
216
221
  return item;
@@ -239,32 +244,55 @@
239
244
  });
240
245
  }),
241
246
  // 最后一列可见列
242
- last: 0
247
+ last: 0,
248
+ lw: 0,
243
249
  });
244
250
 
251
+ // 前置处理
245
252
  watch(
246
253
  () => props.table,
247
254
  () => {
248
255
  const _cache = JSON.parse(localStorage.getItem(`${state.name}_table`) || '{}');
249
256
  state._last = 0;
250
257
  state.table = deepcopy(props.table || [])
251
- ?.map((item: any, idx: number) => {
258
+ ?.map((col: any, idx: number) => {
259
+ // 表头属性处理
260
+ if (!col.thead) {
261
+ col.thead = {};
262
+ }
263
+ // 表头默认样式
264
+ const _thc = (col.thead.class || '').split(/\s+/);
265
+ if (!_thc.includes('wrap') && !_thc.includes('nowrap')) {
266
+ _thc.push('nowrap');
267
+ }
268
+ if (!_thc.some((c: any) => c.startsWith('fs-'))) {
269
+ _thc.unshift('fs-xs');
270
+ }
271
+ col.thead.class = _thc.join(' ').trim();
272
+
252
273
  // 缓存的显示信息
253
- if (_cache[item.field] && Object.prototype.hasOwnProperty.call(_cache[item.field], '_close')) {
254
- item._close = _cache[item.field]?._close;
274
+ if (_cache[col.field] && Object.prototype.hasOwnProperty.call(_cache[col.field], '__close')) {
275
+ col.__close = _cache[col.field]?.__close;
255
276
  } else {
256
- if (item.close === true || item.close === 1 || item.close === 'always') {
257
- item._close = 1;
277
+ if (col.close === true || col.close === 1 || col.close === 'always') {
278
+ col.__close = 1;
258
279
  }
259
280
  }
260
- // 缓存的排序信息
261
- if (_cache[item.field] && Object.prototype.hasOwnProperty.call(_cache[item.field], '_sort')) {
262
- item._sort = _cache[item.field]?._sort;
281
+ // 获取缓存的表格列顺序(注意不是数据记录的排序)
282
+ if (_cache[col.field] && Object.prototype.hasOwnProperty.call(_cache[col.field], '_sort')) {
283
+ col._sort = _cache[col.field]?._sort;
263
284
  }
264
- if (!item._close) {
285
+
286
+ // 获取本地存储的字段升降序(注意不是表格列的顺序)
287
+ if (col.order === 0 || col.order === 1 || col.order === 2 || (_cache[col.field] && Object.prototype.hasOwnProperty.call(_cache[col.field], '__order'))) {
288
+ col.__order = _cache[col.field]?.__order || col.order;
289
+ }
290
+
291
+ // 最后一列可见列
292
+ if (!col.__close) {
265
293
  state._last = idx;
266
294
  }
267
- return item;
295
+ return col;
268
296
  })
269
297
  .sort((a: any, b: any) => a._sort - b._sort)
270
298
  .sort((a: any, b: any) => {
@@ -276,33 +304,37 @@
276
304
  },
277
305
  {
278
306
  deep: true,
279
- immediate: true
280
- }
307
+ immediate: true,
308
+ },
281
309
  );
310
+
311
+ // 缓存配置
282
312
  watch(
283
313
  [() => state.table],
284
314
  () => {
285
315
  const _table: any = {};
286
316
  state._last = 0;
287
- state.table.forEach((item: any, idx: number) => {
288
- _table[item.field] = { _sort: idx };
289
- if (Object.prototype.hasOwnProperty.call(item, '_close')) {
290
- _table[item.field]._close = item._close ? 1 : 0;
317
+ state.table.forEach((col: any, idx: number) => {
318
+ _table[col.field] = { _sort: idx };
319
+ if (Object.prototype.hasOwnProperty.call(col, '__close')) {
320
+ _table[col.field].__close = col.__close ? 1 : 0;
291
321
  }
292
- if (!item._close) {
322
+ if (Object.prototype.hasOwnProperty.call(col, '__order')) {
323
+ _table[col.field].__order = col.__order;
324
+ }
325
+ if (!col.__close) {
293
326
  state._last = idx;
294
327
  }
295
328
  });
296
- console.log(338);
297
329
  localStorage.setItem(`${state.name}_table`, JSON.stringify(_table));
298
330
  },
299
- { deep: true }
331
+ { deep: true },
300
332
  );
301
333
 
302
334
  // 全选
303
335
  const fSelectAll = ({ target = {} }: any = {}) => {
304
- props.lists.map((item: any = {}) => {
305
- item.__selected = target.checked;
336
+ props.lists.map((col: any = {}) => {
337
+ col.__selected = target.checked;
306
338
  });
307
339
  };
308
340
  const tableRef: any = ref(null);
@@ -321,13 +353,21 @@
321
353
  });
322
354
  },
323
355
  {
324
- deep: true
325
- }
356
+ deep: true,
357
+ },
326
358
  );
327
359
  onUnmounted(() => {
328
360
  itable.remove();
329
361
  });
330
362
 
363
+ // 设置字段升降序
364
+ const fSetOrder = (col: any) => {
365
+ const all = state.table.filter((i: any) => i.__order && i.field !== col.field).map((i: any) => ({ field: i.field, order: i.__order }));
366
+ col.__order = col.__order = (col.__order + 1) % 3;
367
+ all.unshift({ field: col.field, order: col.__order });
368
+ emits('order', { field: col.field, order: col.__order }, all);
369
+ };
370
+
331
371
  // 事件处理
332
372
  const event: any = (event: any, data: any): object => {
333
373
  const _event: any = {};
@@ -44,6 +44,6 @@ export function allSelected(lists: ListItem[] = []) {
44
44
  lists.forEach((item) => {
45
45
  item.__selected = value;
46
46
  });
47
- }
47
+ },
48
48
  };
49
49
  }