br-dionysus 1.6.5 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +90 -52
  2. package/attributes.json +1 -1
  3. package/dist/br-dionysus.es.js +4659 -4595
  4. package/dist/br-dionysus.umd.js +8 -8
  5. package/dist/index.css +1 -1
  6. package/dist/packages/MTable/src/MTable.vue.d.ts +21 -0
  7. package/dist/packages/MTable/src/token.d.ts +10 -1
  8. package/docs/assets/README-BIIm2ID5.css +1 -0
  9. package/docs/assets/README-BVC502ud.js +1 -0
  10. package/docs/assets/README-BaVHXTcr.js +1 -0
  11. package/docs/assets/README-BkoXPzeT.js +1 -0
  12. package/docs/assets/README-BpY9wwJ5.js +1 -0
  13. package/docs/assets/README-BxVIiLkB.css +1 -0
  14. package/docs/assets/README-C8q4oePg.css +1 -0
  15. package/docs/assets/README-C9E9QEak.js +1 -0
  16. package/docs/assets/README-CJnIKztR.css +1 -0
  17. package/docs/assets/README-CPi9K5cm.css +1 -0
  18. package/docs/assets/README-CVikrcuu.js +1 -0
  19. package/docs/assets/README-CwxKEz5n.js +1 -0
  20. package/docs/assets/README-D-sCcuuV.js +1 -0
  21. package/docs/assets/README-D1NyMPDh.css +1 -0
  22. package/docs/assets/README-D8dRnWkj.css +1 -0
  23. package/docs/assets/README-DC5fWcO7.css +1 -0
  24. package/docs/assets/README-DFookNbq.js +1 -0
  25. package/docs/assets/README-DJM0QNOa.css +1 -0
  26. package/docs/assets/README-DJsWJjpr.js +2 -0
  27. package/docs/assets/README-DZH0ZBFE.js +1 -0
  28. package/docs/assets/README-DuLXE9ma.css +1 -0
  29. package/docs/assets/README-DxdjMTiZ.js +1 -0
  30. package/docs/assets/README-DxzXrur_.js +1 -0
  31. package/docs/assets/README-ZSEyYWl3.css +1 -0
  32. package/docs/assets/empty-BHv0FmNK.png +0 -0
  33. package/docs/assets/index-B3d27dSP.js +66 -0
  34. package/docs/assets/index-BeGJML3j.css +1 -0
  35. package/docs/index.html +14 -0
  36. package/docs/packages/Hook/usePackageConfig/README.md +35 -0
  37. package/docs/packages/Hook/usePackageConfig/demo.vue +28 -0
  38. package/docs/packages/Hook/usePackageConfig/usePackageConfig.ts +39 -0
  39. package/docs/packages/Hook/useRemainingSpace/README.md +26 -0
  40. package/docs/packages/Hook/useRemainingSpace/useRemainingSpace.ts +148 -0
  41. package/docs/packages/Hook/useTableConfig/README.md +50 -0
  42. package/docs/packages/Hook/useTableConfig/demo.vue +134 -0
  43. package/docs/packages/Hook/useTableConfig/useTableConfig.ts +173 -0
  44. package/docs/packages/Hook/useZIndex/README.md +6 -0
  45. package/docs/packages/Hook/useZIndex/useGlobalZIndex.ts +34 -0
  46. package/docs/packages/MDialog/docs/README.md +26 -0
  47. package/docs/packages/MDialog/docs/demo.vue +72 -0
  48. package/docs/packages/MDialog/index.ts +10 -0
  49. package/docs/packages/MDialog/src/MDialog.vue +150 -0
  50. package/docs/packages/MInline/docs/README.md +26 -0
  51. package/docs/packages/MInline/docs/demo.vue +138 -0
  52. package/docs/packages/MInline/index.ts +10 -0
  53. package/docs/packages/MInline/src/MInline.vue +284 -0
  54. package/docs/packages/MInputNumber/docs/README.md +35 -0
  55. package/docs/packages/MInputNumber/docs/demo.vue +17 -0
  56. package/docs/packages/MInputNumber/index.ts +10 -0
  57. package/docs/packages/MInputNumber/src/MInputNumber.vue +268 -0
  58. package/docs/packages/MSelect/docs/README.md +20 -0
  59. package/docs/packages/MSelect/docs/demo.vue +36 -0
  60. package/docs/packages/MSelect/index.ts +17 -0
  61. package/docs/packages/MSelect/src/MOption.vue +43 -0
  62. package/docs/packages/MSelect/src/MSelect.vue +57 -0
  63. package/docs/packages/MSelect/src/token.ts +8 -0
  64. package/docs/packages/MSelectTable/docs/README.md +88 -0
  65. package/docs/packages/MSelectTable/docs/demo.vue +196 -0
  66. package/docs/packages/MSelectTable/index.ts +10 -0
  67. package/docs/packages/MSelectTable/src/MSelectTable.vue +493 -0
  68. package/docs/packages/MSelectTableV1/docs/README.md +49 -0
  69. package/docs/packages/MSelectTableV1/docs/demo.vue +77 -0
  70. package/docs/packages/MSelectTableV1/index.ts +10 -0
  71. package/docs/packages/MSelectTableV1/src/MSelectTableV1.vue +460 -0
  72. package/docs/packages/MSelectV2/docs/README.md +31 -0
  73. package/docs/packages/MSelectV2/docs/demo.vue +36 -0
  74. package/docs/packages/MSelectV2/index.ts +10 -0
  75. package/docs/packages/MSelectV2/src/MSelectV2.vue +116 -0
  76. package/docs/packages/MTable/docs/README.md +40 -0
  77. package/docs/packages/MTable/docs/demo.vue +93 -0
  78. package/docs/packages/MTable/index.ts +10 -0
  79. package/docs/packages/MTable/src/MTable.vue +228 -0
  80. package/docs/packages/MTable/src/token.ts +9 -0
  81. package/docs/packages/MTableColumn/docs/README.md +22 -0
  82. package/docs/packages/MTableColumn/docs/demo.vue +110 -0
  83. package/docs/packages/MTableColumn/index.ts +10 -0
  84. package/docs/packages/MTableColumn/src/MTableColumn.vue +345 -0
  85. package/docs/packages/MTableColumnSet/docs/README.md +31 -0
  86. package/docs/packages/MTableColumnSet/docs/demo.vue +36 -0
  87. package/docs/packages/MTableColumnSet/index.ts +10 -0
  88. package/docs/packages/MTableColumnSet/src/MTableColumnSet.vue +310 -0
  89. package/docs/packages/README.md +10 -0
  90. package/docs/packages/SkinConfig/docs/README.md +42 -0
  91. package/docs/packages/SkinConfig/docs/demo.vue +680 -0
  92. package/docs/packages/SkinConfig/index.ts +10 -0
  93. package/docs/packages/SkinConfig/src/SkinConfig.vue +478 -0
  94. package/docs/packages/SkinConfig/src/useSkin.ts +230 -0
  95. package/docs/packages/TabPage/docs/README.md +10 -0
  96. package/docs/packages/TabPage/docs/demo.vue +96 -0
  97. package/docs/packages/TabPage/index.ts +10 -0
  98. package/docs/packages/TabPage/src/TabPage.vue +566 -0
  99. package/docs/packages/Tool/moneyFormat/README.md +15 -0
  100. package/docs/packages/Tool/moneyFormat/moneyFormat.ts +69 -0
  101. package/docs/packages/index.ts +61 -0
  102. package/docs/packages/list.json +80 -0
  103. package/docs/packages/typings/class.ts +22 -0
  104. package/docs/packages/typings/enum.ts +9 -0
  105. package/docs/packages/typings/global.d.ts +69 -0
  106. package/docs/packages/typings/interface.ts +6 -0
  107. package/package.json +1 -1
  108. package/packages/MTable/docs/README.md +22 -17
  109. package/packages/MTable/docs/demo.vue +15 -1
  110. package/packages/MTable/src/MTable.vue +54 -6
  111. package/packages/MTable/src/token.ts +11 -2
  112. package/packages/MTableColumn/docs/README.md +8 -8
  113. package/packages/MTableColumn/src/MTableColumn.vue +73 -6
  114. package/tags.json +1 -1
  115. package/web-types.json +1 -1
@@ -0,0 +1,460 @@
1
+ <template>
2
+ <div
3
+ class="g-box g-select-table-box"
4
+ :class="elClassName"
5
+ >
6
+ <div class="u-input-gp">
7
+ <el-input
8
+ v-model="_this.vValue"
9
+ :class="_this.inputClass"
10
+ :size="props.size"
11
+ :placeholder="props.placeholder"
12
+ @input="props.remoteMethod($event, page);_this.showPanel = true"
13
+ @focus="focus"
14
+ @keyup.enter="addRowData"
15
+ :disabled="props.disabled"
16
+ />
17
+ <div
18
+ class="el-icon el-icon-circle-close"
19
+ v-if="props.clearable && _this.vValue"
20
+ @click="empty"
21
+ >
22
+ <el-icon><CircleClose /></el-icon>
23
+ </div>
24
+ </div>
25
+
26
+ <Teleport to="body">
27
+ <div
28
+ class="m-table-box"
29
+ v-show="_this.showPanel"
30
+ :style="{...mTableBoxStyle, ..._this.boxStyle}"
31
+ >
32
+ <div
33
+ v-if="isSelect"
34
+ class="btn-box"
35
+ >
36
+ <el-button
37
+ @click="selectMultiple"
38
+ size="small"
39
+ >
40
+ 确认
41
+ </el-button>
42
+ </div>
43
+ <el-table
44
+ ref="mTableRef"
45
+ class="m-table s-table"
46
+ :data="optionsMap"
47
+ :size="props.size"
48
+ :scrollbarAlwaysOn="props.scrollbarAlwaysOn"
49
+ @currentChange="handleCurrentChange"
50
+ :rowClassName="tableRowClassName"
51
+ :rowStyle="tableRowStyle"
52
+ :cellStyle="tableCellStyle"
53
+ @selectionChange="handleSelectionChange"
54
+ >
55
+ <el-table-column
56
+ v-if="props.isSelect"
57
+ type="selection"
58
+ width="55"
59
+ />
60
+ <el-table-column
61
+ showOverflowTooltip
62
+ v-for="item in tableTitle"
63
+ :key="item.prop"
64
+ :prop="item.prop"
65
+ :label="item.label"
66
+ :width="item.width"
67
+ :minWidth="item.minWidth"
68
+ :filters="item.filters"
69
+ :headerAlign="item.headerAlign"
70
+ >
71
+ <template #default="scope">
72
+ {{ optionsMap[scope.$index][item.prop] || '-' }}
73
+ </template>
74
+ </el-table-column>
75
+ </el-table>
76
+
77
+ <!--分页-->
78
+ <div
79
+ class="m-page"
80
+ v-if="props.total"
81
+ >
82
+ <el-pagination
83
+ v-model:currentPage="page.currentPage"
84
+ v-model:pageSize="page.pageSize"
85
+ hideOnSinglePage
86
+ :small="props.size === 'small'"
87
+ :pageSizes="page.pageSizesOptions"
88
+ layout="total, prev, pager, next, sizes"
89
+ :total="page.total"
90
+ @currentChange="toPage"
91
+ @sizeChange="toPage(page.currentPage, $event)"
92
+ />
93
+ </div>
94
+ </div>
95
+
96
+ <div
97
+ v-show="_this.showPanel"
98
+ :style="mMarkStyle as any"
99
+ @click="clickOutside"
100
+ />
101
+ </Teleport>
102
+ </div>
103
+ </template>
104
+
105
+ <script setup lang="ts">
106
+ import { reactive, computed, watch, nextTick, ref } from 'vue'
107
+ import { ElMessage } from 'element-plus'
108
+ import { Page } from './../../typings/class'
109
+
110
+ const createHash = (hashLength: number = 24) => {
111
+ return Array.from(Array(Number(hashLength) || 24), () => Math.floor(Math.random() * 36).toString(36)).join('')
112
+ }
113
+
114
+ const props = withDefaults(defineProps<{
115
+ modelValue?: string | number,
116
+ placeholder?: string,
117
+ disabled?: boolean,
118
+ options: Option[],
119
+ tableTitle: any[],
120
+ remoteMethod?: Function,
121
+ allowCreate?: boolean, // 是否创建条目
122
+ focusShow?: boolean, // 聚焦显示
123
+ isSelect?: boolean, // 是否多选
124
+ clearable?: boolean,
125
+ size?: 'small' | 'large' | '',
126
+ labelKey?: string, // 显示字段
127
+ scrollbarAlwaysOn?: boolean, // 总是显示滚动条
128
+ total?: number | null // 总数据量,当有值时,出现分页器
129
+ }>(), {
130
+ modelValue: '',
131
+ placeholder: '请输入',
132
+ disabled: false,
133
+ options: () => [],
134
+ tableTitle: () => [],
135
+ remoteMethod: () => {},
136
+ allowCreate: false,
137
+ focusShow: false,
138
+ isSelect: false,
139
+ clearable: false,
140
+ size: '',
141
+ labelKey: 'label',
142
+ scrollbarAlwaysOn: false,
143
+ total: null
144
+ })
145
+
146
+ const _this = reactive<{
147
+ vValue: string | number,
148
+ vLabel: string | number,
149
+ oValue: string | number,
150
+ inputClass: string,
151
+ masterPieceLoading: boolean,
152
+ showPanel: boolean, // 显示面板
153
+ selectedRow: Option | {},
154
+ boxStyle: any,
155
+ selectKeys: string[]
156
+ }>({
157
+ vValue: '',
158
+ vLabel: '',
159
+ oValue: '',
160
+ inputClass: 'j-' + createHash(),
161
+ masterPieceLoading: false,
162
+ showPanel: false, // 显示面板
163
+ selectedRow: {},
164
+ boxStyle: {
165
+ },
166
+ selectKeys: []
167
+ })
168
+
169
+ const emit = defineEmits(['update:modelValue', 'selectMultiple', 'change', 'selected', 'clear'])
170
+ const optionsMap = computed(() => {
171
+ const options = props.options.map(item => ({
172
+ ...item,
173
+ className: item.disabled ? 's-disabled' : ''
174
+ }))
175
+ if (!props.allowCreate || !_this.vValue) return options
176
+ const checkSame = options.some(item => item.label === _this.vValue)
177
+ if (checkSame) return options
178
+ const nodeObj: any = {}
179
+ props.tableTitle.forEach(key => {
180
+ nodeObj[key] = null
181
+ })
182
+ return [...options, {
183
+ ...nodeObj,
184
+ label: _this.vValue,
185
+ value: '#' + createHash(),
186
+ className: 's-add'
187
+ // [props.labelKey]: _this.vValue
188
+ }
189
+ ]
190
+ })
191
+
192
+ const elClassName = 'j-' + createHash(6)
193
+
194
+ // 分页
195
+ const page = reactive<Page>(new Page({
196
+ total: props.total as number,
197
+ pageSize: 5,
198
+ currentPage: 1,
199
+ pageSizesOptions: [5, 10, 20]
200
+ }))
201
+ const toPage = (currentPage: number = 1, pageSize: number = page.pageSize) => {
202
+ page.currentPage = currentPage
203
+ page.pageSize = pageSize
204
+ props.remoteMethod(_this.vValue || '', page)
205
+ }
206
+
207
+ watch(
208
+ () => _this.showPanel,
209
+ () => {
210
+ const style = {}
211
+ if (_this.showPanel) {
212
+ const element = document.querySelector('.' + _this.inputClass)
213
+ if (!element) return
214
+ const rect = element.getBoundingClientRect()
215
+ if (!rect) return
216
+ const bottom = window.innerHeight - rect.top - rect.height
217
+ const right = window.innerWidth - rect.left - rect.width
218
+ if (bottom < 250) {
219
+ Object.assign(style, { bottom: (bottom + rect.height) + 'px' })
220
+ Object.assign(style, { transform: 'translateY(-10px)' })
221
+ } else {
222
+ Object.assign(style, { top: (rect.top + rect.height) + 'px' })
223
+ Object.assign(style, { transform: 'translateY(10px)' })
224
+ }
225
+ if ((window.innerWidth - rect.left) < 550) {
226
+ Object.assign(style, { right: right + 'px' })
227
+ } else {
228
+ Object.assign(style, { left: rect.left + 'px' })
229
+ }
230
+
231
+ Object.assign(style, { opacity: 1 })
232
+ }
233
+ if (!_this.showPanel) {
234
+ Object.assign(style, { opacity: 0 })
235
+ }
236
+
237
+ nextTick(() => {
238
+ _this.boxStyle = style
239
+ })
240
+ }
241
+ )
242
+
243
+ watch(
244
+ () => props.modelValue,
245
+ () => {
246
+ _this.vValue = props.options.find(item => item.value === props.modelValue)?.label || props.modelValue as string
247
+ }
248
+ )
249
+
250
+ watch(() => props.total, () => {
251
+ page.total = props.total as number
252
+ })
253
+
254
+ _this.vValue = props.options.find(item => item.value === props.modelValue)?.label || props.modelValue as string
255
+
256
+ const empty = () => {
257
+ _this.selectedRow = {}
258
+ selected()
259
+ emit('clear')
260
+ }
261
+
262
+ const handleSelectionChange = (val: string[]) => {
263
+ _this.selectKeys = val
264
+ }
265
+
266
+ const mTableRef = ref<any>(null)
267
+
268
+ const selectMultiple = () => {
269
+ if (!_this.selectKeys.length) return ElMessage.warning('请勾选数据')
270
+ const arr = JSON.parse(JSON.stringify(_this.selectKeys))
271
+ _this.selectKeys = []
272
+ mTableRef.value.clearSelection()
273
+ _this.showPanel = false
274
+ emit('selectMultiple', arr)
275
+ }
276
+
277
+ const handleCurrentChange = (currentRow: Option) => {
278
+ if (!currentRow) return false
279
+ _this.showPanel = false
280
+ if (currentRow[props.labelKey] !== undefined) {
281
+ _this.vValue = currentRow[props.labelKey] as string
282
+ }
283
+ _this.selectedRow = currentRow
284
+ selected()
285
+ }
286
+
287
+ const addRowData = () => {
288
+ handleCurrentChange(optionsMap.value[optionsMap.value.length - 1])
289
+ }
290
+
291
+ const selected = () => {
292
+ emit('update:modelValue', (_this.selectedRow as Option)?.value || '')
293
+ emit('change', (_this.selectedRow as Option)?.value || '')
294
+ emit('selected', _this.selectedRow)
295
+ }
296
+
297
+ const clickOutside = () => {
298
+ if (!_this.showPanel) return false
299
+ _this.showPanel = false
300
+ _this.vValue = (_this.selectedRow as Option)?.label || _this.oValue
301
+ }
302
+
303
+ /** 关闭 */
304
+ const close = () => {
305
+ if (!_this.showPanel) return false
306
+ setTimeout(() => {
307
+ _this.showPanel = false
308
+ })
309
+ }
310
+
311
+ const focus = () => {
312
+ const elDom = document.querySelector('.' + elClassName)
313
+ if (elDom) {
314
+ const clickEvent = new MouseEvent('click', {
315
+ bubbles: true, // 允许事件冒泡
316
+ cancelable: true // 允许事件可以被取消
317
+ })
318
+ elDom.dispatchEvent(clickEvent)
319
+ }
320
+ _this.oValue = _this.vValue
321
+ if (props.focusShow) {
322
+ _this.showPanel = true
323
+ if (props.total !== null) {
324
+ props.remoteMethod(_this.vValue || '', page)
325
+ } else {
326
+ props.remoteMethod(_this.vValue || '')
327
+ }
328
+ }
329
+ }
330
+
331
+ const tableRowClassName = ({ row }: { row: any, rowIndex: number }): string => {
332
+ return row.className
333
+ }
334
+
335
+ const tableRowStyle = ({ row }: { row: any, rowIndex: number }): any => {
336
+ const style: any = {}
337
+ if (row.className.includes('s-disabled')) {
338
+ style.color = 'var(--el-disabled-text-color)'
339
+ style.cursor = 'not-allowed'
340
+ }
341
+ if (row.className.includes('s-add')) {
342
+ style.backgroundColor = 'rgba(135, 208, 104, 0.1)'
343
+ }
344
+ return style
345
+ }
346
+
347
+ const tableCellStyle = ({ row }: { row: any, column: any, rowIndex: number, columnIndex: number }): any => {
348
+ const style: any = {}
349
+ if (row.className.includes('s-disabled')) {
350
+ style.pointerEvents = 'none'
351
+ }
352
+ return style
353
+ }
354
+
355
+ const mTableBoxStyle = {
356
+ position: 'fixed',
357
+ opacity: 0,
358
+ zIndex: 9000,
359
+ padding: '8px',
360
+ width: '500px',
361
+ border: '1px solid var(--el-border-color-lighter, #ebeef5)',
362
+ boxShadow: '0 2px 12px 0 rgba(0,0,0,.1)',
363
+ background: 'var(--el-bg-color, #fff)',
364
+ borderRadius: '4px'
365
+ }
366
+
367
+ const mMarkStyle = {
368
+ position: 'fixed',
369
+ top: 0,
370
+ left: 0,
371
+ zIndex: 8,
372
+ width: '100%',
373
+ height: '100%'
374
+ }
375
+
376
+ defineExpose({
377
+ close
378
+ })
379
+ </script>
380
+
381
+ <style scoped lang="scss">
382
+ .g-select-table-box {
383
+ position: relative;
384
+ line-height: normal;
385
+
386
+ .u-input-gp {
387
+ position: relative;
388
+ //height: 24px;
389
+
390
+ &:hover .el-icon-circle-close {
391
+ display: block;
392
+ }
393
+ }
394
+
395
+ .el-icon-circle-close {
396
+ display: none;
397
+ position: absolute;
398
+ top: 50%;
399
+ right: 10px;
400
+ font-size: 14px;
401
+ color: #c0c4cc;
402
+ transform: translateY(-50%);
403
+ cursor: pointer;
404
+
405
+ &:hover {
406
+ color: #a4a7ad;
407
+ }
408
+ }
409
+
410
+ .s-table {
411
+ width: 100%;
412
+ }
413
+ }
414
+
415
+ .btn-box{
416
+ text-align: right;
417
+ padding-bottom: 6px;
418
+ }
419
+
420
+ .m-page {
421
+ padding-top: 4px;
422
+ }
423
+ </style>
424
+
425
+ <style lang="scss">
426
+ .g-select-table-box {
427
+ .u-input-gp .el-input {
428
+ display: flex;
429
+ }
430
+
431
+ .el-table {
432
+ --el-table-header-bg-color: var(--m-list-el-table-header-bg-color, #f5f5f5);
433
+ }
434
+ }
435
+
436
+ /*标记*/
437
+ //.m-table-box {
438
+ // position: fixed;
439
+ // //top: 100%;
440
+ // //left: 0;
441
+ // opacity: 0;
442
+ // z-index: 9;
443
+ // padding: 8px;
444
+ // width: 500px;
445
+ // border: 1px solid var(--el-border-color-lighter, #ebeef5);
446
+ // -webkit-box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
447
+ // box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
448
+ // background: var(--el-bg-color, #fff);
449
+ // border-radius: 4px;
450
+ //}
451
+
452
+ //.m-mask {
453
+ // position: fixed;
454
+ // top: 0;
455
+ // left: 0;
456
+ // z-index: 8;
457
+ // width: 100%;
458
+ // height: 100%;
459
+ //}
460
+ </style>
@@ -0,0 +1,31 @@
1
+ <script setup>
2
+ import demo from './demo.vue'
3
+ </script>
4
+
5
+ 下拉选择器V2组件
6
+ =================
7
+
8
+ ### 1) 基础用法
9
+
10
+ <Preview comp-name="MSelectV2" demo-name="demo">
11
+ <demo />
12
+ </Preview>
13
+
14
+ ### 2) Attributes
15
+
16
+ | 参数 | 说明 | 类型 | 可选值 | 默认值 |
17
+ |-------------------------------|:---------------------------------------------------------:|:--------:|:---:|:-----:|
18
+ | value / v-model | 绑定值 | number | - | '' |
19
+ | checkbox-mode | 是否为复选框模式(只影响样式) | boolean | - | false |
20
+ | multiple | 是否多选 | boolean | - | false |
21
+ | show-all | 是否显示全选选项(只在multiple为true时生效) | boolean | - | false |
22
+ | options | 选项值 | Option[] | - | [] |
23
+ | 其他属性同element-plus的el-select组件 | https://element-plus.gitee.io/zh-CN/component/select.html | - | - | - |
24
+
25
+ #### Option(选项对象)
26
+
27
+ | 参数 | 说明 | 类型 | 必填 | 可选值 | 默认值 |
28
+ |----------|:---------------------:|:-------:|:--:|:---:|:-----:|
29
+ | label | 选项的标签,若不设置则默认与value相同 | string | 否 | - | - |
30
+ | value | 选项的值 | number | 是 | - | - |
31
+ | disabled | 是否禁用该选项 | boolean | 否 | - | false |
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div class="g-demo-m-select-box">
3
+ <m-select-v2
4
+ v-model="test"
5
+ checkboxMode
6
+ multiple
7
+ :options="options"
8
+ showAll
9
+ >
10
+ </m-select-v2>
11
+ </div>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { ref } from 'vue'
16
+
17
+ const test = ref<string>('')
18
+
19
+ const options: Option[] = [{
20
+ label: '这是选项一',
21
+ value: 'a'
22
+ }, {
23
+ label: '这是选项二',
24
+ value: 'b'
25
+ }, {
26
+ label: '这是选项三',
27
+ value: 'c',
28
+ disabled: true
29
+ }]
30
+ </script>
31
+
32
+ <style scoped>
33
+ .g-demo-m-select-box {
34
+ max-width: 1000px;
35
+ }
36
+ </style>
@@ -0,0 +1,10 @@
1
+ import { App, Plugin } from 'vue'
2
+ import MSelectV2 from './src/MSelectV2.vue'
3
+
4
+ export const MSelectV2Plugin: Plugin = {
5
+ install (app: App) {
6
+ app.component('MSelectV2', MSelectV2)
7
+ }
8
+ }
9
+
10
+ export { MSelectV2 }
@@ -0,0 +1,116 @@
1
+ <template>
2
+ <el-select
3
+ v-bind="attrs"
4
+ :multiple="props.multiple"
5
+ v-model="modelValue"
6
+ >
7
+ <template
8
+ v-if="showAll && props.multiple"
9
+ #header
10
+ >
11
+ <el-checkbox
12
+ class="u-checkbox"
13
+ v-model="checkAll"
14
+ :indeterminate="indeterminate"
15
+ @change="handleCheckAll"
16
+ >
17
+ 全选
18
+ </el-checkbox>
19
+ </template>
20
+ <el-option
21
+ v-for="item in props.options"
22
+ :key="item.value"
23
+ :label="item.label"
24
+ :value="item.value"
25
+ :disabled="item.disabled"
26
+ ></el-option>
27
+ </el-select>
28
+ </template>
29
+
30
+ <script setup lang="ts">
31
+ import { provide, useAttrs, ref, watch } from 'vue'
32
+ import { selectKey } from 'packages/MSelect/src/token'
33
+
34
+ const props = withDefaults(defineProps<{
35
+ /** @description 是否为checkbox模式 */
36
+ checkboxMode?: boolean,
37
+ /** @description 多选 */
38
+ multiple?: boolean,
39
+ /** @description 是否显示全选 */
40
+ showAll?: boolean,
41
+ /** @description 选项 */
42
+ options?: Option[]
43
+ }>(), {
44
+ /** @description 是否为checkbox模式 */
45
+ checkboxMode: false,
46
+ /** @description 多选 */
47
+ multiple: false,
48
+ /** @description 是否显示全选 */
49
+ showAll: false,
50
+ /** @description 选项 */
51
+ options: () => []
52
+ })
53
+
54
+ const attrs = useAttrs()
55
+
56
+ type ValueType = string | number | Array<string | number>
57
+ const modelValue = ref<ValueType>(attrs.modelValue as ValueType)
58
+ watch(
59
+ () => attrs.modelValue,
60
+ () => {
61
+ modelValue.value = attrs.modelValue as ValueType
62
+ }
63
+ )
64
+
65
+ const emit = defineEmits<{
66
+ 'update:modelValue': [data: any]
67
+ }>()
68
+
69
+ const checkAll = ref(false)
70
+ const indeterminate = ref(false)
71
+ const handleCheckAll = (val: boolean) => {
72
+ indeterminate.value = false
73
+ if (val) {
74
+ modelValue.value = props.options.filter(item => !item.disabled).map(item => item.value)
75
+ } else {
76
+ modelValue.value = []
77
+ }
78
+ }
79
+ watch(
80
+ () => modelValue.value,
81
+ (val) => {
82
+ if (!Array.isArray(val)) return
83
+ if (val.length === 0) {
84
+ checkAll.value = false
85
+ indeterminate.value = false
86
+ } else if (val.length === props.options.filter(item => !item.disabled).length) {
87
+ checkAll.value = true
88
+ indeterminate.value = false
89
+ } else {
90
+ indeterminate.value = true
91
+ }
92
+ }
93
+ )
94
+
95
+ watch(
96
+ () => modelValue.value,
97
+ () => {
98
+ emit('update:modelValue', modelValue.value)
99
+ }
100
+ )
101
+
102
+ provide(selectKey, {
103
+ checkboxMode: props.checkboxMode,
104
+ modelValue,
105
+ multiple: props.multiple as boolean
106
+ })
107
+ </script>
108
+
109
+ <style lang="scss" scoped>
110
+ .u-checkbox {
111
+ height: var(--el-checkbox-height, 20px)
112
+ }
113
+ </style>
114
+
115
+ <style lang="scss">
116
+ </style>
@@ -0,0 +1,40 @@
1
+ <script setup>
2
+ import demo from './demo.vue'
3
+ </script>
4
+
5
+ 表格组件
6
+ =================
7
+
8
+ ### 1) 基础用法
9
+
10
+ <Preview comp-name="MTable" demo-name="demo">
11
+ <demo />
12
+ </Preview>
13
+
14
+
15
+ ### 2) Attributes
16
+ | 参数 | 说明 | 类型 | 可选值 | 默认值 |
17
+ | ----------- | ------- | ---------------------------- |-----|--------|
18
+ |data |表格的数据 | Array | - | [ ] |
19
+ |sole |行的唯一值 |String , number | - | key |
20
+ |filtersValue |表格内容筛选 |Function | - | () => void |
21
+ |其余参数 |参考el官网的table |any | - |https://element-plus.org/zh-CN/component/table.html|
22
+ ## 要求
23
+ ```
24
+ sole 必须传递在表格数据内为唯一的值 如id key 等不会发生重复的关键字
25
+ ```
26
+
27
+ ### 3) Events
28
+ | 方法名 | 说明 | 回调参数 |
29
+ | ----------- | ------- | ---------------------------- |
30
+ | pasteData | 表格粘贴方法 | 共有2个参数,依次为粘贴动作的数据PasteAction ,表格原始数据tableData |
31
+ |其余方法 |参考el官网的table |https://element-plus.org/zh-CN/component/table.html|
32
+
33
+ ### 4) PasteAction
34
+ |参数 | 说明 | 类型 |
35
+ |-----|-------|-------|
36
+ |editRow|返回粘贴的对应行的原始数据|Object|
37
+ |editColumn|返回粘贴时鼠标所在列的 表格prop值|String|
38
+ |arr|返回粘贴时候处理之后的 数组信息|Array|
39
+ |rowIndex|根据sole的值 去data内查找 当前操作的 粘贴行在data内的序号|number|
40
+