@94ai/nf-table 3.1.13

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/lib/types.d.ts ADDED
@@ -0,0 +1,270 @@
1
+ import { NfSearchFormItemOption } from '@94ai/nf-search-form/lib/types';
2
+ export type ElTableEventKey = 'select' | 'select-all' | 'selection-change ' | 'cell-mouse-enter' | 'cell-mouse-leave' | 'cell-click' | 'cell-dblclick' | 'row-click' | 'row-contextmenu' | 'row-dblclick' | 'header-click' | 'header-contextmenu' | 'sort-change' | 'filter-change' | 'current-change' | 'header-dragend' | 'expand-change';
3
+ export type ElPaginationEventKey = 'size-change' | 'current-change' | 'prev-click' | 'next-click';
4
+ export type NfSearchFormEventKey = 'open' | 'opened' | 'close' | 'closed' | 'on-change' | 'itemsChange' | 'onSearch' | 'onExport' | 'onResetFields';
5
+ export interface NfSearchFormAttributes {
6
+ upIcon?: string;
7
+ downIcon?: string;
8
+ columns?: number;
9
+ showBtn?: boolean;
10
+ isCollapse?: boolean;
11
+ labelPosition?: 'top' | 'right' | 'left';
12
+ inline?: boolean;
13
+ rules?: Record<string, any>;
14
+ labelSuffix?: string;
15
+ hideRequiredAsterisk?: boolean;
16
+ showMessage?: boolean;
17
+ inlineMessage?: boolean;
18
+ statusIcon?: boolean;
19
+ validateOnRuleChange?: boolean;
20
+ size?: 'medium' | 'small' | 'mini';
21
+ disabled?: boolean;
22
+ labelWidth?: number;
23
+ formOptions?: NfSearchFormItemOption[];
24
+ showItems?: string[];
25
+ closable?: boolean;
26
+ itemWidth?: number;
27
+ btnItems?: string[] | 'search' | 'export' | 'reset' | '';
28
+ isShowAdd?: boolean;
29
+ btnBoxLabel?: string;
30
+ btnModel?: 'inline' | 'flex';
31
+ checkBtnIcon?: string;
32
+ checkBtnType?: string;
33
+ checkBtnPlain?: boolean;
34
+ checkBtnSize?: string;
35
+ checkBtnRound?: boolean;
36
+ checkBtnCircle?: boolean;
37
+ checkBtnLoading?: boolean;
38
+ checkBtnDisabled?: boolean;
39
+ checkBtnText?: string;
40
+ checkBtnClass?: string;
41
+ exportBtnIcon?: string;
42
+ exportBtnType?: string;
43
+ exportBtnPlain?: boolean;
44
+ exportBtnSize?: string;
45
+ exportBtnRound?: boolean;
46
+ exportBtnCircle?: boolean;
47
+ exportBtnLoading?: boolean;
48
+ exportBtnDisabled?: boolean;
49
+ exportBtnText?: string;
50
+ exportBtnClass?: string;
51
+ queryBtnIcon?: string;
52
+ queryBtnType?: string;
53
+ queryBtnPlain?: boolean;
54
+ queryBtnSize?: string;
55
+ queryBtnRound?: boolean;
56
+ queryBtnCircle?: boolean;
57
+ queryBtnLoading?: boolean;
58
+ queryBtnDisabled?: boolean;
59
+ queryBtnText?: string;
60
+ queryBtnClass?: string;
61
+ resetBtnIcon?: string;
62
+ resetBtnType?: string;
63
+ resetBtnPlain?: boolean;
64
+ resetBtnSize?: string;
65
+ resetBtnRound?: boolean;
66
+ resetBtnCircle?: boolean;
67
+ resetBtnLoading?: boolean;
68
+ resetBtnDisabled?: boolean;
69
+ resetBtnText?: string;
70
+ resetBtnClass?: string;
71
+ reverseBtnSlot?: boolean;
72
+ moreDialogWidth?: string;
73
+ moreDialogTitle?: string;
74
+ modalAppendToBody?: boolean;
75
+ modal?: boolean;
76
+ fullscreen?: boolean;
77
+ top?: string;
78
+ appendToBody?: boolean;
79
+ lockScroll?: boolean;
80
+ customClass?: string;
81
+ closeOnlickModal?: boolean;
82
+ closeOnPressEscape?: boolean;
83
+ showClose?: boolean;
84
+ beforeClose?: Function;
85
+ center?: boolean;
86
+ destroyOnClose?: boolean;
87
+ }
88
+ export interface ElTableAttributes {
89
+ 'data'?: Record<string, any>[];
90
+ 'height'?: string | number;
91
+ 'max-height'?: string | number;
92
+ 'stripe'?: boolean;
93
+ 'border'?: boolean;
94
+ 'size'?: 'medium' | 'small' | 'mini';
95
+ 'fit'?: boolean;
96
+ 'show-header'?: boolean;
97
+ 'highlight-current-row'?: boolean;
98
+ 'highlight-selection-row'?: boolean;
99
+ 'current-row-key'?: string | number;
100
+ 'row-class-name'?: Function | string;
101
+ 'row-style'?: Function | Record<string, string>;
102
+ 'cell-class-name'?: Function | string;
103
+ 'cell-style'?: Function | Record<string, string>;
104
+ 'header-row-class-name'?: Function | string;
105
+ 'header-row-style'?: Function | Record<string, string>;
106
+ 'header-cell-class-name'?: Function | string;
107
+ 'header-cell-style'?: Function | Record<string, string>;
108
+ 'row-key'?: Function | string;
109
+ 'empty-text'?: string;
110
+ 'default-expand-all'?: boolean;
111
+ 'expand-row-keys'?: string[];
112
+ 'default-sort'?: {
113
+ prop?: string;
114
+ order?: 'descending' | 'ascending';
115
+ };
116
+ 'tooltip-effect'?: 'dark' | 'light';
117
+ 'show-summary'?: boolean;
118
+ 'sum-text'?: string;
119
+ 'summary-method'?: Function;
120
+ 'span-method'?: Function;
121
+ 'select-on-indeterminate'?: boolean;
122
+ 'indent'?: number;
123
+ 'lazy'?: boolean;
124
+ 'load'?: Function;
125
+ 'tree-props'?: {
126
+ hasChildren: string;
127
+ children: string;
128
+ };
129
+ }
130
+ export interface ElTableColumnAttributes {
131
+ type?: 'selection' | 'index' | 'expand';
132
+ label?: string;
133
+ prop?: string;
134
+ index?: number | ((index: number) => number);
135
+ 'column-key'?: string;
136
+ width?: string;
137
+ 'min-width'?: string;
138
+ fixed?: 'left' | 'right' | boolean;
139
+ 'render-header'?: Function;
140
+ sortable?: boolean | 'custom';
141
+ 'sort-method'?: Function;
142
+ 'sort-by'?: string | string[] | Function;
143
+ 'sort-orders'?: ['ascending' | 'descending' | null, 'ascending' | 'descending' | null, 'ascending' | 'descending' | null];
144
+ resizable?: boolean;
145
+ formatter?: Function;
146
+ 'show-overflow-tooltip'?: boolean;
147
+ align?: 'left' | 'center' | 'right';
148
+ 'class-name'?: string;
149
+ 'label-class-name'?: string;
150
+ selectable?: Function;
151
+ 'reserve-selection'?: boolean;
152
+ filters?: {
153
+ text?: string | number;
154
+ value?: string | number;
155
+ }[];
156
+ 'filter-placement'?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
157
+ 'filter-multiple'?: boolean;
158
+ 'filter-method'?: Function;
159
+ 'filtered-value'?: string[];
160
+ }
161
+ export interface ElPaginationAttributes {
162
+ small?: boolean;
163
+ background?: boolean;
164
+ 'page-size'?: number;
165
+ total?: number;
166
+ 'page-count'?: number;
167
+ 'pager-count'?: number;
168
+ 'current-page'?: number;
169
+ layout?: 'prev' | 'pager' | 'next' | 'jumper' | '->' | 'total';
170
+ 'page-sizes'?: number[];
171
+ 'popper-class'?: string;
172
+ 'prev-text'?: string;
173
+ 'next-text'?: string;
174
+ 'disabled'?: boolean;
175
+ 'hide-on-single-page'?: boolean;
176
+ }
177
+ export interface NfTableColumnAttributes {
178
+ _index?: number;
179
+ __index?: number;
180
+ initHidden?: boolean;
181
+ destory?: boolean;
182
+ type?: 'selection' | 'index' | 'expand';
183
+ label?: string;
184
+ addLabel?: string;
185
+ prop?: string;
186
+ render?: Function;
187
+ slot?: any;
188
+ headerSlot?: any;
189
+ singleHeadMutiColSlot?: any;
190
+ attr?: ElTableColumnAttributes;
191
+ }
192
+ export interface NfTableActionBtnAttributes {
193
+ value?: string | number | boolean | (string | number | boolean)[];
194
+ element?: 'el-button' | 'el-checkbox' | 'el-radio' | 'el-input' | 'el-switch' | 'el-input-number' | 'el-autocomplete' | 'el-checkbox-group' | 'el-checkbox-button' | 'el-radio-group' | 'el-radio-button' | 'text';
195
+ size?: 'medium' | 'small' | 'mini' | 'large';
196
+ type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text';
197
+ disabled?: boolean;
198
+ loading?: boolean;
199
+ class?: string;
200
+ plain?: boolean;
201
+ icon?: string;
202
+ round?: boolean;
203
+ circle?: boolean;
204
+ style?: string;
205
+ key?: number | string;
206
+ text?: string;
207
+ min?: number;
208
+ max?: number;
209
+ step?: number;
210
+ 'step-strictly'?: boolean;
211
+ precision?: number;
212
+ controls?: boolean;
213
+ 'controls-position': 'right';
214
+ name?: string;
215
+ label?: string;
216
+ placeholder?: string;
217
+ 'true-label'?: string | number;
218
+ 'false-label'?: string | number;
219
+ border?: boolean;
220
+ checked?: boolean;
221
+ indeterminate?: boolean;
222
+ width?: number;
223
+ 'active-icon-class'?: string;
224
+ 'inactive-icon-class'?: string;
225
+ 'active-text'?: string;
226
+ 'inactive-text'?: string;
227
+ 'inactive-value'?: string | boolean | number;
228
+ 'active-color'?: string;
229
+ 'inactive-color'?: string;
230
+ 'validate-event'?: boolean;
231
+ maxlength?: number;
232
+ minlength?: number;
233
+ clearable?: boolean;
234
+ 'show-word-limit'?: boolean;
235
+ 'prefix-icon'?: string;
236
+ 'suffix-icon'?: string;
237
+ 'show-password'?: boolean;
238
+ rows?: number;
239
+ autosize?: boolean | {
240
+ minRows?: number;
241
+ maxRows?: number;
242
+ };
243
+ autocomplete?: 'on' | 'off';
244
+ readonly?: boolean;
245
+ resize?: 'none' | 'both' | 'horizontal' | 'vertical';
246
+ autofocus?: boolean;
247
+ form?: string;
248
+ tabindex?: string;
249
+ debounce?: number;
250
+ placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
251
+ 'value-key'?: string;
252
+ 'fetch-suggestions'?: Function;
253
+ 'popper-class'?: string;
254
+ 'trigger-on-focus'?: boolean;
255
+ 'select-when-unmatched'?: boolean;
256
+ 'hide-loading'?: boolean;
257
+ 'popper-append-to-body'?: boolean;
258
+ 'highlight-first-item'?: boolean;
259
+ 'text-color'?: string;
260
+ 'fill'?: string;
261
+ attr?: Record<string, any>;
262
+ events?: Record<string, Function>;
263
+ slot?: {
264
+ prefix?: string;
265
+ suffix?: string;
266
+ prepend?: string;
267
+ append?: string;
268
+ };
269
+ children?: NfTableActionBtnAttributes[];
270
+ }
@@ -0,0 +1,14 @@
1
+ import NfTable from './nf-table.vue'
2
+ import { Vue2, PluginObject } from 'vue-demi'
3
+ import NfMessage from '@94ai/nf-message'
4
+
5
+ NfTable.install = (app: typeof Vue2) => {
6
+ // @ts-ignore
7
+ if (!app.$openMessage) {
8
+ // @ts-ignore
9
+ app.use(NfMessage)
10
+ }
11
+ app!.component('nf-table', NfTable)
12
+ }
13
+
14
+ export default NfTable as typeof NfTable & PluginObject<undefined>
@@ -0,0 +1,201 @@
1
+ <template>
2
+ <el-dialog
3
+ @open="$emit('open', $event)"
4
+ @opened="$emit('opened', $event)"
5
+ @close="$emit('close', $event)"
6
+ @closed="$emit('closed', $event)"
7
+ :visible.sync="visible"
8
+ :title="title"
9
+ :width="width"
10
+ :modal-append-to-body="modalAppendToBody"
11
+ :modal="modal"
12
+ :fullscreen="fullscreen"
13
+ :top="top"
14
+ :append-to-body="appendToBody"
15
+ :lock-scroll="lockScroll"
16
+ :custom-class="(customClass || '') + ' nf-table-nf-column-check-dialog'"
17
+ :close-on-click-modal="closeOnlickModal"
18
+ :close-on-press-escape="closeOnPressEscape"
19
+ :show-close="showClose"
20
+ :before-close="beforeClose"
21
+ :center="center"
22
+ :destroy-on-close="destroyOnClose"
23
+ >
24
+ <slot slot="title" name="title"></slot>
25
+ <div class="nf-table-nf-column-check-dialog-check-content">
26
+ <div v-for="(item,index) in fields" :key="index" class="nf-check-item">
27
+ <div class="nf-check-title">{{ item.name }}</div>
28
+ <el-checkbox
29
+ v-for="obj in item.list"
30
+ :key="obj.prop"
31
+ v-model="tableData[obj.prop]"
32
+ class="nf-check-box"
33
+ :label="obj.prop"
34
+ :disabled="unChangedColumn.includes(obj.prop)"
35
+ >{{ obj.addLabel || obj.label }}</el-checkbox>
36
+ </div>
37
+ </div>
38
+ <slot slot="footer" name="footer">
39
+ <div class="nf-table-nf-column-check-dialog-button-container">
40
+ <nf-button size="mini" @click="visible=false" class="nf-table-nf-column-check-dialog-button-cancel">{{ cancelText }}</nf-button>
41
+ <nf-button type="primary" size="mini" @click="submit" class="nf-table-nf-column-check-dialog-button-confirm">{{ confirmText }}</nf-button>
42
+ </div>
43
+ </slot>
44
+ </el-dialog>
45
+ </template>
46
+
47
+
48
+ <script lang="ts">
49
+ import { defineComponent } from 'vue-demi'
50
+
51
+ export default defineComponent({
52
+ name: "NfColumnCheckDialog",
53
+ })
54
+ </script>
55
+
56
+ <script lang="ts" setup>
57
+ import {
58
+ computed,
59
+ getCurrentInstance,
60
+ onMounted,
61
+ ref
62
+ } from 'vue-demi'
63
+ import { CachedManager } from '@94ai/common-utils'
64
+
65
+ const props = withDefaults(defineProps<{
66
+ /**
67
+ * 列编辑显示开关
68
+ */
69
+ columnEdit?: boolean,
70
+ operationPropKey?: string
71
+ storageKey?: string
72
+ show?: boolean,
73
+ title?: string,
74
+ width?: string,
75
+ confirmText?: string
76
+ cancelText?: string
77
+ basicFieldDesc?: string
78
+ tableColumns?: Record<string, any>[],
79
+ modalAppendToBody?: boolean,
80
+ modal?: boolean,
81
+ fullscreen?: boolean,
82
+ top?: string,
83
+ appendToBody?: boolean,
84
+ lockScroll?: boolean,
85
+ customClass?: string,
86
+ closeOnlickModal?: boolean,
87
+ closeOnPressEscape?: boolean,
88
+ showClose?: boolean,
89
+ beforeClose?: Function,
90
+ center?: boolean,
91
+ destroyOnClose?: boolean,
92
+ }>(), {
93
+ columnEdit: false,
94
+ operationPropKey: 'operation',
95
+ storageKey: 'nf-table-columns-cached-key',
96
+ show: false,
97
+ width: '600px',
98
+ title: '设置显示字段',
99
+ /**
100
+ * 默认category分类标题
101
+ */
102
+ basicFieldDesc: '基础字段',
103
+ cancelText: '取 消',
104
+ confirmText: '保 存',
105
+ tableColumns: () => [],
106
+ modalAppendToBody: true,
107
+ modal: true,
108
+ fullscreen: false,
109
+ top: '15vh',
110
+ appendToBody: false,
111
+ lockScroll: true,
112
+ customClass: '',
113
+ closeOnlickModal: true,
114
+ closeOnPressEscape: true,
115
+ showClose: true,
116
+ beforeClose: undefined,
117
+ center: false,
118
+ destroyOnClose: false,
119
+ })
120
+
121
+
122
+ const emit = defineEmits<{
123
+ (e: 'update:show', event: boolean): void
124
+ (e: 'save', event: Record<string, any>): void
125
+ }>()
126
+
127
+
128
+ const instance = getCurrentInstance()?.proxy
129
+
130
+ const tableData = ref<Record<string, any>>({})
131
+ // 不可操作列
132
+ const unChangedColumn = ref<string[]>([])
133
+
134
+ const visible = computed({
135
+ get() {
136
+ return props.show
137
+ },
138
+ set(val) {
139
+ emit('update:show', val)
140
+ }
141
+ })
142
+
143
+ const fields = computed(() => {
144
+ const obj: Record<string, any> = {}
145
+ props.tableColumns.filter(item => !item.destory).map(item => {
146
+ if (!item.type) {
147
+ const key = item.category || props.basicFieldDesc
148
+ if (!obj[key]) {
149
+ obj[key] = []
150
+ }
151
+ obj[key].push(item)
152
+ }
153
+ })
154
+ const fields: {name: string, list:Record<string, any>[] }[] = []
155
+ for (const key in obj) {
156
+ fields.push({
157
+ name: key,
158
+ list: obj[key]
159
+ })
160
+ }
161
+ return fields
162
+ })
163
+
164
+ const submit = () => {
165
+ visible.value = false
166
+ const columnState = {}
167
+ props.tableColumns.map((i, index) => {
168
+ columnState[i.prop] = {
169
+ initHidden: !tableData.value[i.prop] || false,
170
+ fixed: i.attr?.fixed || false,
171
+ prop: i.prop,
172
+ index
173
+ }
174
+ })
175
+ emit('save', tableData.value)
176
+ if (props.columnEdit) {
177
+ CachedManager.syncCachedSet(props.storageKey, columnState)
178
+ }
179
+ }
180
+
181
+ const addInitValue = () => {
182
+ const obj: Record<string, any> = {}
183
+ props.tableColumns.forEach(v => {
184
+ obj[v.prop] = !v.initHidden
185
+ })
186
+ tableData.value = obj
187
+
188
+ if (props.tableColumns.findIndex((item) => !!item.type) > -1) {
189
+ unChangedColumn.value.push('selection')
190
+ }
191
+ if (props.tableColumns.findIndex((item) => (item.prop || item.attr?.prop) === props.operationPropKey) > -1) {
192
+ unChangedColumn.value.push(props.operationPropKey)
193
+ }
194
+ }
195
+
196
+ onMounted(() => {
197
+ addInitValue()
198
+ })
199
+
200
+ </script>
201
+