@neatui/vue 2.7.2 → 2.7.4
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 +4 -5
- package/src/components/basic/IDraggable.vue +11 -11
- package/src/components/loader/FormLoader/FormLoader@v2.vue +14 -14
- package/src/components/loader/TableLoader/TableColView.vue +14 -18
- package/src/components/loader/TableLoader/TableLoader.vue +149 -112
- package/src/components/loader/TableLoader/index.ts +1 -1
- package/src/components/loader/TableLoader@v3/TableColView@v3.vue +0 -155
- package/src/components/loader/TableLoader@v3/TableLoader@v3.vue +0 -636
- package/src/components/loader/TableLoader@v3/index@v3.ts +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neatui/vue",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.4",
|
|
4
4
|
"description": "basic component ui",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,15 +20,14 @@
|
|
|
20
20
|
"typescript": "^5.1.6"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@fekit/floor": "^
|
|
24
|
-
"@fekit/follow": "^1.
|
|
23
|
+
"@fekit/floor": "^3.0.1",
|
|
24
|
+
"@fekit/follow": "^1.7.0",
|
|
25
25
|
"@fekit/itable": "^1.1.6",
|
|
26
26
|
"@fekit/pullload": "^1.3.5",
|
|
27
27
|
"@fekit/scale": "^2.0.1",
|
|
28
28
|
"@fekit/scrollto": "^3.0.3",
|
|
29
29
|
"@fekit/toast": "^2.7.2",
|
|
30
|
-
"@fekit/
|
|
31
|
-
"@fekit/utils": "^2.16.1",
|
|
30
|
+
"@fekit/utils": "^3.1.0",
|
|
32
31
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
33
32
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
34
33
|
"@vue/compiler-sfc": "^3.4.30",
|
|
@@ -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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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="
|
|
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"
|
|
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.
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.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 :square" :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-
|
|
51
|
+
<Icon name="tableloader-setting" class="co-auto"></Icon>
|
|
46
52
|
</button>
|
|
47
53
|
<template #tips>
|
|
48
|
-
<div class="w-mm h-
|
|
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.
|
|
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,
|
|
81
|
+
<template v-for="(col, cid) in state.table" :key="cid">
|
|
76
82
|
<td
|
|
77
|
-
v-if="!col.
|
|
78
|
-
:class="`${!slots.operate &&
|
|
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
|
|
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
|
-
<
|
|
96
|
-
<
|
|
97
|
-
<
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
</
|
|
116
|
-
</
|
|
117
|
-
</
|
|
118
|
-
</
|
|
119
|
-
</
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
<
|
|
123
|
-
<
|
|
124
|
-
<
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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">
|
|
@@ -153,18 +152,22 @@
|
|
|
153
152
|
import { IFollowView, Icon } from '../../basic';
|
|
154
153
|
import { itable } from '@fekit/itable';
|
|
155
154
|
import TableColView from './TableColView.vue';
|
|
156
|
-
import { isFunction, isObject, deepcopy } from '@fekit/utils';
|
|
155
|
+
import { isFunction, isObject, hasOwnProp, deepcopy } from '@fekit/utils';
|
|
157
156
|
const route = useRoute();
|
|
158
157
|
const router = useRouter();
|
|
159
158
|
// 外部插槽
|
|
160
159
|
const slots: any = useSlots();
|
|
161
160
|
// 外部方法
|
|
162
|
-
const emits = defineEmits(['update:table', '
|
|
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
|
-
|
|
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] &&
|
|
210
|
-
item.
|
|
214
|
+
if (_cache[item.field] && hasOwnProp(_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.
|
|
218
|
+
item.__close = 1;
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
return item;
|
|
@@ -239,32 +244,52 @@
|
|
|
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((
|
|
258
|
+
?.map((col: any, idx: number) => {
|
|
259
|
+
// 表头属性处理
|
|
260
|
+
col.thead ??= {};
|
|
261
|
+
col.thead.class = (col.thead.class || '').split(/\s+/);
|
|
262
|
+
if (!col.thead.class.some((c: any) => c === 'wrap' || c === 'nowrap')) {
|
|
263
|
+
col.thead.class.push('nowrap');
|
|
264
|
+
}
|
|
265
|
+
// 如果没有以 fs- 开头的类,就加 fs-xs
|
|
266
|
+
if (!col.thead.class.some((c: string) => /^fs-/.test(c))) {
|
|
267
|
+
col.thead.class.push('fs-xs');
|
|
268
|
+
}
|
|
269
|
+
|
|
252
270
|
// 缓存的显示信息
|
|
253
|
-
if (_cache[
|
|
254
|
-
|
|
271
|
+
if (_cache[col.field] && hasOwnProp(_cache[col.field], '__close')) {
|
|
272
|
+
col.__close = _cache[col.field]?.__close;
|
|
255
273
|
} else {
|
|
256
|
-
if (
|
|
257
|
-
|
|
274
|
+
if (col.close === true || col.close === 1 || col.close === 'always') {
|
|
275
|
+
col.__close = 1;
|
|
258
276
|
}
|
|
259
277
|
}
|
|
260
|
-
//
|
|
261
|
-
if (_cache[
|
|
262
|
-
|
|
278
|
+
// 获取缓存的表格列顺序(注意不是数据记录的排序)
|
|
279
|
+
if (_cache[col.field] && hasOwnProp(_cache[col.field], '_sort')) {
|
|
280
|
+
col._sort = _cache[col.field]?._sort;
|
|
263
281
|
}
|
|
264
|
-
|
|
282
|
+
|
|
283
|
+
// 获取本地存储的字段升降序(注意不是表格列的顺序)
|
|
284
|
+
if (col.order === 0 || col.order === 1 || col.order === 2 || (_cache[col.field] && hasOwnProp(_cache[col.field], '__order'))) {
|
|
285
|
+
col.__order = _cache[col.field]?.__order || col.order;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 最后一列可见列
|
|
289
|
+
if (!col.__close) {
|
|
265
290
|
state._last = idx;
|
|
266
291
|
}
|
|
267
|
-
return
|
|
292
|
+
return col;
|
|
268
293
|
})
|
|
269
294
|
.sort((a: any, b: any) => a._sort - b._sort)
|
|
270
295
|
.sort((a: any, b: any) => {
|
|
@@ -276,33 +301,37 @@
|
|
|
276
301
|
},
|
|
277
302
|
{
|
|
278
303
|
deep: true,
|
|
279
|
-
immediate: true
|
|
280
|
-
}
|
|
304
|
+
immediate: true,
|
|
305
|
+
},
|
|
281
306
|
);
|
|
307
|
+
|
|
308
|
+
// 缓存配置
|
|
282
309
|
watch(
|
|
283
310
|
[() => state.table],
|
|
284
311
|
() => {
|
|
285
312
|
const _table: any = {};
|
|
286
313
|
state._last = 0;
|
|
287
|
-
state.table.forEach((
|
|
288
|
-
_table[
|
|
289
|
-
if (
|
|
290
|
-
_table[
|
|
314
|
+
state.table.forEach((col: any, idx: number) => {
|
|
315
|
+
_table[col.field] = { _sort: idx };
|
|
316
|
+
if (hasOwnProp(col, '__close')) {
|
|
317
|
+
_table[col.field].__close = col.__close ? 1 : 0;
|
|
291
318
|
}
|
|
292
|
-
if (
|
|
319
|
+
if (hasOwnProp(col, '__order')) {
|
|
320
|
+
_table[col.field].__order = col.__order;
|
|
321
|
+
}
|
|
322
|
+
if (!col.__close) {
|
|
293
323
|
state._last = idx;
|
|
294
324
|
}
|
|
295
325
|
});
|
|
296
|
-
console.log(338);
|
|
297
326
|
localStorage.setItem(`${state.name}_table`, JSON.stringify(_table));
|
|
298
327
|
},
|
|
299
|
-
{ deep: true }
|
|
328
|
+
{ deep: true },
|
|
300
329
|
);
|
|
301
330
|
|
|
302
331
|
// 全选
|
|
303
332
|
const fSelectAll = ({ target = {} }: any = {}) => {
|
|
304
|
-
props.lists.map((
|
|
305
|
-
|
|
333
|
+
props.lists.map((col: any = {}) => {
|
|
334
|
+
col.__selected = target.checked;
|
|
306
335
|
});
|
|
307
336
|
};
|
|
308
337
|
const tableRef: any = ref(null);
|
|
@@ -321,13 +350,21 @@
|
|
|
321
350
|
});
|
|
322
351
|
},
|
|
323
352
|
{
|
|
324
|
-
deep: true
|
|
325
|
-
}
|
|
353
|
+
deep: true,
|
|
354
|
+
},
|
|
326
355
|
);
|
|
327
356
|
onUnmounted(() => {
|
|
328
357
|
itable.remove();
|
|
329
358
|
});
|
|
330
359
|
|
|
360
|
+
// 设置字段升降序
|
|
361
|
+
const fSetOrder = (col: any) => {
|
|
362
|
+
const all = state.table.filter((i: any) => i.__order && i.field !== col.field).map((i: any) => ({ field: i.field, order: i.__order }));
|
|
363
|
+
col.__order = col.__order = (col.__order + 1) % 3;
|
|
364
|
+
all.unshift({ field: col.field, order: col.__order });
|
|
365
|
+
emits('order', { field: col.field, order: col.__order }, all);
|
|
366
|
+
};
|
|
367
|
+
|
|
331
368
|
// 事件处理
|
|
332
369
|
const event: any = (event: any, data: any): object => {
|
|
333
370
|
const _event: any = {};
|