sone-ui-component-3.2.4 2.1.28 → 2.1.30

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.
@@ -0,0 +1,496 @@
1
+ <!--
2
+ * @Description: 直接copy的table 优化代码 硬是让我删掉了800行。。。
3
+ * @Author:xjl
4
+ * @Date:2021-09-10 11:03
5
+ -->
6
+ <template>
7
+ <div class="sone_table_box" >
8
+ <div class="table-menu-left" v-if="showMenuLeft">
9
+ <slot name="menuLeft"></slot>
10
+ </div>
11
+ <div class="table-menu-right" v-if="showMenuRight">
12
+ <slot name="menuRight"></slot>
13
+ <el-dropdown trigger="click" :hide-on-click="false" v-if="showColumnHandleBtn">
14
+ <IconButton
15
+ :iconfont="false"
16
+ :tooltipDisabled="tooltipDisabled"
17
+ class="sort-btn"
18
+ content="列展示"
19
+ icon="el-icon-s-operation" />
20
+ <ColumnTransfer
21
+ ref="column-transfer"
22
+ :columns.sync="internalColumns"
23
+ @save="save"
24
+ @resetColumnTransfer="$emit('resetColumnTransfer')" />
25
+ </el-dropdown>
26
+ <slot name="transferRight"></slot>
27
+ </div>
28
+ <el-table
29
+ v-if="isTable"
30
+ v-loading="loading"
31
+ style="width: 100%"
32
+ :ref="tabelRef"
33
+ :class="'sone-table ' + className"
34
+ :cell-class-name="option.cellClassName"
35
+ :cell-style="option.cellStyle"
36
+ :data="tableData"
37
+ :header-cell-class-name="option.headerCellClassName"
38
+ :header-cell-style="option.headerCellStyle"
39
+ :header-row-class-name="option.headerRowClassName"
40
+ :header-row-style="option.headerRowStyle"
41
+ :height="option.height"
42
+ :highlight-current-row="option.highlightRow"
43
+ :max-height="option.maxHeight"
44
+ :row-class-name="tableRowClassName"
45
+ :row-key="option.rowKey"
46
+ :row-style="option.rowStyle"
47
+ :show-summary="option.showSummary"
48
+ :render-header="option.renderHeader"
49
+ :span-method="spanMethod"
50
+ :show-header="showHeader"
51
+ :stripe="stripe"
52
+ :border="border"
53
+ :sum-text="option.sumText"
54
+ :summary-method="summaryMethod"
55
+ @filter-change="filterChange"
56
+ @row-click="rowClick"
57
+ @header-dragend="onHeaderDragend"
58
+ @select="selectChange"
59
+ @select-all="selectAll">
60
+ <el-table-column
61
+ v-if="operation"
62
+ fixed
63
+ type="index"
64
+ :width="operation.width"
65
+ :label="operation.label ? operation.label : '操作'"
66
+ :resizable="operation.hasOwnProperty('resizable') ? operation.resizable : true">
67
+ <template slot-scope="scope">
68
+ <template v-if="!hideButtonMode">
69
+ <div class="sone-table-buttonList" v-if="scope.row.buttonShow&&scope.row.buttonShow.filter(d=>d.isShow).length<=3">
70
+ <template v-for="(item,index) in operation.buttonList">
71
+ <el-tooltip :content="item.label" :key="index" effect="light" placement="top" v-show="scope.row.buttonShow.find(i=>i.id===item.id).isShow">
72
+ <el-button
73
+ :icon="item.icon"
74
+ :style="{color:item.color}"
75
+ :disabled="scope.row.buttonShow.find(i=>i.id===item.id).isDisabled || false"
76
+ @click.native.stop="handButton(item.function, scope, item.id)"
77
+ circle
78
+ type="text"
79
+ ></el-button>
80
+ </el-tooltip>
81
+ </template>
82
+ </div>
83
+
84
+ <div class="sone-table-buttonList" v-if="!scope.row.buttonShow&&operation.buttonList.length<=3">
85
+ <template v-for="(item,index) in operation.buttonList">
86
+ <el-tooltip :content="item.label" :key="index" effect="light" placement="top">
87
+ <el-button
88
+ :icon="item.icon"
89
+ :style="{color:item.color}"
90
+ @click.native.stop="handButton(item.function,scope, item.id)"
91
+ circle
92
+ type="text"
93
+ ></el-button>
94
+ </el-tooltip>
95
+ </template>
96
+ </div>
97
+ </template>
98
+ <template v-else>
99
+ <el-dropdown v-if="scope.row.buttonShow" class="dropdown_box_button sone-table-buttonList">
100
+ <span class="el-dropdown-link color-span menu-more" v-show="scope.row.buttonShow.filter(d=>d.isShow).length > 0">
101
+ <el-button type="text">
102
+ <i :style="{color:operation.moreIconColor}" class="el-icon-more more-handel"></i>
103
+ </el-button>
104
+ </span>
105
+ <el-dropdown-menu slot="dropdown">
106
+ <el-dropdown-item class="sone-table-dropdown" command="copy" v-for="(item, i) in scope.row.buttonShow.filter(d=>d.isShow)" :key="i">
107
+ <el-button
108
+ :icon="operation.buttonList.find(d=>d.id===item.id).icon"
109
+ :disabled="item.hasOwnProperty('isDisabled') ? item.isDisabled : false"
110
+ :style="{color:operation.buttonList.find(d=>d.id===item.id).color}"
111
+ type="text"
112
+ :title="operation.buttonList.find(d=>d.id === item.id).label"
113
+ @click.native.stop="handButton(operation.buttonList.find(d=>d.id===item.id).function, scope, item.id)"
114
+ >{{operation.buttonList.find(d=>d.id===item.id).label}}</el-button>
115
+ </el-dropdown-item>
116
+ </el-dropdown-menu>
117
+ </el-dropdown>
118
+ <el-dropdown v-else @command.stop="(command)=>{handleCommand(command,row)}" class="dropdown_box_button sone-table-buttonList">
119
+ <span class="el-dropdown-link color-span menu-more" v-show="operation.buttonList.length > 0">
120
+ <el-button type="text">
121
+ <i :style="{color:operation.moreIconColor}" class="el-icon-more more-handel"></i>
122
+ </el-button>
123
+ </span>
124
+ <el-dropdown-menu slot="dropdown">
125
+ <el-dropdown-item
126
+ class="sone-table-dropdown"
127
+ command="copy"
128
+ v-for="(item, i) in operation.buttonList"
129
+ :key="i">
130
+ <el-button
131
+ :icon="item.icon"
132
+ :style="{color:item.color}"
133
+ :title="item.label"
134
+ type="text"
135
+ @click.native.stop="handButton(item.function, scope, item.id)"
136
+ >{{item.label}}</el-button>
137
+ </el-dropdown-item>
138
+ </el-dropdown-menu>
139
+ </el-dropdown>
140
+ </template>
141
+ </template>
142
+ </el-table-column>
143
+ <el-table-column
144
+ v-if="option.index"
145
+ fixed
146
+ type="index"
147
+ :width="option.indexWidth||50"
148
+ :label="option.indexLabel ? option.indexLabel : '序号'"
149
+ :index="indexMethod"
150
+ ></el-table-column>
151
+ <el-table-column
152
+ v-if="option.selection"
153
+ fixed
154
+ type="selection"
155
+ :show-overflow-tooltip="false"
156
+ :width="option.selectionWidth || 45">
157
+ </el-table-column>
158
+ <template v-for="(column, index) in internalColumns">
159
+ <!-- 自定义列 -->
160
+ <slot v-if="column.slot && column.istrue" :name="column.slot"></slot>
161
+ <el-table-column
162
+ v-else-if="column.hasOwnProperty('istrue')?column.istrue:true"
163
+ :filter-method="column.filters ? filterHandler : null"
164
+ :filters="column.filters"
165
+ :fixed="column.fixed"
166
+ :key="`col_${column.prop}_${column.label}`"
167
+ :label="column.label"
168
+ :min-width="column.minWidth"
169
+ :prop="column.prop"
170
+ :width="column.width"
171
+ :align="column.hasOwnProperty('align') ? column.align : 'left'"
172
+ :show-overflow-tooltip="column.hasOwnProperty('showOverflowTooltip') ? column.showOverflowTooltip : false"
173
+ filter-placement="bottom-end"
174
+ :header-align="column.hasOwnProperty('headerAlign') ? column.headerAlign : 'left'"
175
+ :column-key="column.hasOwnProperty('elementId')? column.elementId:column.prop"
176
+ :resizable="column.hasOwnProperty('resizable') ? column.resizable : true">
177
+ <!-- 表头 -->
178
+ <template slot="header" slot-scope="scope">
179
+ <slot
180
+ v-if="column.slotColumnHeader && isShow"
181
+ :header="{column: scope.column, $index:scope.$index }"
182
+ :name="column.slotColumnHeader"
183
+ ></slot>
184
+ <template v-if="!column.slotColumnHeader && isShow">
185
+ <div class="slot_header_class">
186
+ <span class="table-header-isRequire" v-if="column.isRequire">*</span>
187
+ <span>{{ column.label }}</span>
188
+ <span class="hide">
189
+ <i
190
+ class="iconfont icon-help icon_describe"
191
+ :title="column.headerDescribe"
192
+ v-if="column.headerDescribe"
193
+ ></i>
194
+ <span
195
+ :class="{ 'ascending': sortVal === column.prop + 'ascending', 'descending': sortVal === column.prop + 'descending' }"
196
+ class="caret-wrapper"
197
+ v-if="column.headerFilterSort">
198
+ <i
199
+ @click="handleCommand(column.prop, index, { command: 'ascending' })"
200
+ class="sort-caret ascending"
201
+ title="升序"
202
+ ></i>
203
+ <i
204
+ @click="handleCommand(column.prop, index, { command: 'descending' })"
205
+ class="sort-caret descending"
206
+ title="降序"
207
+ ></i>
208
+ </span>
209
+ </span>
210
+ </div>
211
+ </template>
212
+ </template>
213
+ <!--表体-->
214
+ <template slot-scope="scope">
215
+ <slot :index="scope.$index" :name="column.slotCell" :row="scope.row" v-if="column.slotCell"></slot>
216
+ <template v-else>{{ scope.row[column.prop] }}</template>
217
+ </template>
218
+ </el-table-column>
219
+ </template>
220
+ </el-table>
221
+ <div class="pagination-box" v-if="page && page.total > 0">
222
+ <el-pagination
223
+ :current-page="page.current"
224
+ :layout="page.layout ? page.layout : 'total, sizes, prev, pager, next, jumper'"
225
+ :page-size="page.size"
226
+ :page-sizes="page.pageSizes"
227
+ :total="page.total"
228
+ :page-count="page.pageCount"
229
+ :pager-count="page.pagerCount"
230
+ @current-change="currentChange"
231
+ @size-change="sizeChange"
232
+ background
233
+ ></el-pagination>
234
+ </div>
235
+ </div>
236
+ </template>
237
+
238
+ <script>
239
+ import { deepClone } from 'sone-ui-component/src/utils/util'
240
+ import ColumnTransfer from './columnTransfer.vue'
241
+ import IconButton from "sone-ui-component/packages/IconButton/index.vue";
242
+ export default {
243
+ name: "SoneNormalTable",
244
+ components: { ColumnTransfer, IconButton },
245
+ props: {
246
+ showMenuLeft: {
247
+ type: Boolean,
248
+ default: false
249
+ },
250
+ showMenuRight: {
251
+ type: Boolean,
252
+ default: true
253
+ },
254
+ showColumnHandleBtn: {
255
+ type: Boolean,
256
+ default: true
257
+ },
258
+ hideButtonMode: {
259
+ type: Boolean,
260
+ default: false
261
+ },
262
+ tabelRef: {
263
+ type: String,
264
+ default: 'tableDataRef'
265
+ },
266
+ loading: {
267
+ type: Boolean,
268
+ default: false,
269
+ },
270
+ showHeader: {
271
+ type: Boolean,
272
+ default: true,
273
+ },
274
+ stripe: {
275
+ type: Boolean,
276
+ default: true,
277
+ },
278
+ border: {
279
+ type: Boolean,
280
+ default: true,
281
+ },
282
+ option: {
283
+ type: Object,
284
+ default: () => {
285
+ return {
286
+ index: true,
287
+ indexWidth: 70,
288
+ height: 'auto',
289
+ maxHeight: 'auto',
290
+ showSummary: false,
291
+ }
292
+ }
293
+ },
294
+ operation: {
295
+ type: [Object, Boolean],
296
+ default: () => {
297
+ return {
298
+ width: 82,
299
+ label: '操作',
300
+ buttonList: [
301
+ {
302
+ label: '删除',
303
+ icon: 'el-icon-remove-outline',
304
+ function: 'handDetele',
305
+ tooltipContent: '删除',
306
+ color: 'red'
307
+ }, {
308
+ label: '添加',
309
+ icon: 'el-icon-circle-plus-outline',
310
+ function: 'hand',
311
+ tooltipContent: '删除',
312
+ color: 'red'
313
+ }
314
+ ]
315
+ }
316
+ }
317
+ },
318
+ page: {
319
+ type: Object,
320
+ },
321
+ columns: {
322
+ type: Array,
323
+ default: () => []
324
+ },
325
+ tableData: {
326
+ type: Array,
327
+ default: () => []
328
+ },
329
+ // 表格className
330
+ className:{
331
+ type:String,
332
+ default:''
333
+ },
334
+ // 合计小数位数
335
+ summaryToFixed:{
336
+ type:[Number, String],
337
+ default:''
338
+ },
339
+ spanMethod: Function,
340
+ indexMethod: Function,
341
+ // 默认显示按钮图标加提示,
342
+ tooltipDisabled: {
343
+ type: Boolean,
344
+ default: false,
345
+ },
346
+ },
347
+ data() {
348
+ return {
349
+ internalColumns: deepClone(this.columns).filter(d => d && !d.isHidden),
350
+ sortVal: '', // 排序
351
+ isShow: true,
352
+ isTable: true
353
+ }
354
+ },
355
+ watch: {
356
+ columns: {
357
+ deep: true,
358
+ handler() {
359
+ this.internalColumns = deepClone(this.columns).filter(d => d && !d.isHidden);
360
+ }
361
+ },
362
+ },
363
+ methods: {
364
+ // 下拉button
365
+ handleCommand(columnName, columnIndex, data) {
366
+ let tableData = deepClone(this.tableData)
367
+ if (data.command === "ascending" || data.command === "descending") {
368
+ if (this.sortVal && this.sortVal.indexOf(data.command) > -1) {
369
+ this.sortVal = ''
370
+ } else {
371
+ this.sortVal = columnName + data.command
372
+ }
373
+ if (this.option.defineSort) {
374
+ this.$emit('handleColumnFilter', columnName, columnIndex, data, !!!this.sortVal)
375
+ } else {
376
+ let isIncludeNaN = tableData.some(item => isNaN(Number(item[columnName])))
377
+ if ( isIncludeNaN ) { // 数据非纯数字使用原生ele方法
378
+ if(this.sortVal){
379
+ this.$refs[this.tabelRef].sort(columnName, data.command);
380
+ } else {
381
+ this.$refs[this.tabelRef].clearSort();
382
+ }
383
+ } else { // 纯数字使用sort排序
384
+ tableData.sort((a, b) => {
385
+ return data.command === 'ascending' ? a[columnName] - b[columnName] : b[columnName] - a[columnName]
386
+ })
387
+ this.$emit('update:tableData', tableData)
388
+ }
389
+ }
390
+ } else {
391
+ this.$emit('handleColumnFilter', columnName, columnIndex, data)
392
+ }
393
+ },
394
+ selectChange(selection, row){
395
+ this.$emit('handleChecked', selection, row);
396
+ },
397
+ selectAll(selection){
398
+ this.$emit('selectAll', selection);
399
+ },
400
+ toggleSelection(rows, selected = true) {
401
+ if (rows) {
402
+ rows.forEach(row => {
403
+ this.$refs[this.tabelRef].toggleRowSelection(row, selected);
404
+ });
405
+ } else {
406
+ this.$refs[this.tabelRef].clearSelection();
407
+ }
408
+ },
409
+ // 翻页
410
+ sizeChange(val) {
411
+ this.$emit('sizeChange', val)
412
+ },
413
+ currentChange(val) {
414
+ this.$emit('currentChange', val)
415
+ },
416
+ // 合计
417
+ summaryMethod({ columns, data }) {
418
+ if (this.option.summaryMethod) {
419
+ return this.option.summaryMethod({ columns, data })
420
+ }
421
+ let _columns = deepClone(this.internalColumns);
422
+ const sums = [];
423
+ // 固定列会导致窜行 待改
424
+ if (!!this.operation ) sums.push(this.option.sumText || '合计')
425
+ if (this.option.selection) {
426
+ !!this.operation ? sums.push('') : sums.push('合计')
427
+ }
428
+ _columns.forEach((column, index) => {
429
+ if ( column.istrue ) {
430
+ let num = 0
431
+ data.forEach(item => num += Number(item[column.prop]))
432
+ if ( isNaN(num) || !column.summary ) {
433
+ sums.push('')
434
+ } else if ( String(num).indexOf('.') != -1 && this.summaryToFixed ) {
435
+ sums.push(num.toFixed(this.summaryToFixed))
436
+ } else {
437
+ sums.push(num)
438
+ }
439
+ }
440
+ });
441
+ return sums;
442
+ },
443
+ // 行点击
444
+ rowClick(row, column, event) {
445
+ this.$emit('rowClick', row, column, event)
446
+ },
447
+ filterChange(filters) {
448
+ let data = deepClone(this.tableData)
449
+ // 判断是哪一列筛选
450
+ if (filters.name) {
451
+ data.name = filters.name[0]
452
+ }
453
+ this.$emit('update:tableData', data)
454
+ },
455
+ //过滤
456
+ filterHandler(value, row, column) {
457
+ const property = column['property'];
458
+ return row[property] === value;
459
+ },
460
+ // class
461
+ tableRowClassName({ row, rowIndex }) {
462
+ if (this.option.rowClassName) {
463
+ return this.option.rowClassName({ row, rowIndex })
464
+ }else return ''
465
+ },
466
+ handButton(functionName, scope, id) {
467
+ this.$emit(functionName, scope, id)
468
+ },
469
+ doLayout() {
470
+ this.$refs[this.tabelRef].doLayout();
471
+ },
472
+ /* 当拖动表头改变了列的宽度的时候会触发该事件 */
473
+ onHeaderDragend(newWidth, oldWidth, column, event){
474
+ let arr = [
475
+ ...this.$refs['column-transfer'].leftColumns,
476
+ ...this.$refs['column-transfer'].noColumns,
477
+ ...this.$refs['column-transfer'].rightColumns
478
+ ]
479
+ this.$emit('headerDragend', newWidth, oldWidth, column, arr, event);
480
+ },
481
+ save(arr){
482
+ this.internalColumns = deepClone(arr);
483
+ this.isTable = false
484
+ this.$nextTick(() => {
485
+ this.isTable = true
486
+ })
487
+ this.$emit('save', arr);
488
+ },
489
+ /* 用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。 */
490
+ setCurrentRow(row){
491
+ this.$refs[this.tabelRef] && this.$refs[this.tabelRef].setCurrentRow(row);
492
+ this.$emit('setCurrentRow', row);
493
+ },
494
+ },
495
+ }
496
+ </script>
package/src/index.js CHANGED
@@ -57,7 +57,7 @@ if (typeof window !== 'undefined' && window.Vue) {
57
57
  }
58
58
 
59
59
  export default {
60
- version: '2.1.28',
60
+ version: '2.1.30',
61
61
  locale: locale.use,
62
62
  i18n: locale.i18n,
63
63
  install,
@@ -299,8 +299,9 @@
299
299
  color: $--color-primary;
300
300
  cursor: pointer;
301
301
  font-size: 12px;
302
+ margin: 0;
303
+ padding: 0 0 0 10px;
302
304
  }
303
-
304
305
  }
305
306
  .table-drag-ghost {
306
307
  border-bottom: 1px dashed $--color-primary;
package/Notice.md DELETED
@@ -1,106 +0,0 @@
1
- # sone-ui-component
2
-
3
- ## Sone UI 组件开发文档
4
-
5
- ## 基本介绍
6
-
7
- ### 开发说明
8
-
9
- 1. 安装依赖
10
-
11
- ``` bash
12
- npm i
13
- ```
14
-
15
- ### 脚手架
16
- - [Vue-cli3.x](https://cli.vuejs.org/zh/)
17
-
18
- ### 主要框架和库
19
- - 核心:[Vue2.x](https://cn.vuejs.org/v2/guide/)
20
- - 打包:[webpack4.x](https://webpack.js.org/concepts/)
21
- - UI库:[element-ui](https://element.eleme.cn/#/zh-CN/guide/design)
22
-
23
- ### 主要目录结构
24
-
25
- ``` bash
26
- ├─build 构建配置文件
27
- ├─docs 组件的文档项目
28
- ├─demo 组件的本地测试
29
- ├─lib 组件UMD打包的目录
30
- ├─packages 组件定义目录
31
- ├─public 公共目录
32
- └─src 组件引用的目录
33
- ```
34
-
35
- ## 运行指令说明
36
-
37
- ### 在定义好组件后,运行以下命令生成组件被使用的入口文件,用于组件注册和单独引入
38
-
39
- ``` bash
40
- npm run build:file
41
- ```
42
-
43
- ### 组件打包成UMD
44
-
45
- ``` bash
46
- npm run lib
47
- ```
48
-
49
- ### 组件库在发布之前,最好运行,以保证最新的组件入口文件和UMD生成
50
-
51
- ``` bash
52
- npm run publish:pre
53
- ```
54
-
55
- ### 在定义好组件后维护组件文档,想要在组件的文档(markdown)中使用组件做示例时,使用以下命令,自动在vuepress 生成定义好的组件文件[慎用!!!]
56
-
57
- ``` bash
58
- npm run build:docs
59
- ```
60
-
61
- [慎用!!!]:此操作会覆盖原有的组件文件,可能会出现对象未定义(nodejs)
62
-
63
- ### 本地启动组件的文档项目
64
-
65
- ``` bash
66
- npm run docs:dev
67
- ```
68
-
69
- ### 组件的文档项目打包
70
-
71
- ``` bash
72
- npm run docs:build
73
- ```
74
-
75
- ### 本地组件测试:在demo文件夹的App.vue,使用你想要查看效果的组件
76
-
77
- ``` bash
78
- npm run dev:demo
79
- ```
80
-
81
- ## 主要流程
82
-
83
- ### 定义组件
84
-
85
- 1. 在`src`文件夹下,定义组件;
86
- 2. 在`components.json`文件中,维护好组件的地址;
87
- 3. 运行`npm run build:file`, 生成组件的入口文件;
88
-
89
- ### 测试组件效果
90
-
91
- 定义组件后,测试组件
92
-
93
- 1. 在`demo`文件夹下的`*.vue`,书写相关组件的测试代码;
94
- 2. 运行`npm run dev:demo`,查看效果;
95
-
96
- ### 组件文档维护
97
-
98
- 1. 当有新的组件定义,就需要运行`npm run build:docs`, 将组件复制到docs项目内部;
99
- 2. 在`docs`文件夹的`components`文件夹内,维护组件markdown文件;
100
- 3. 在`docs`文件夹的`.vuepress`的`config.js`内,定义组件的导航路径;
101
- 4. 运行`npm run docs:dev`,查看效果;
102
-
103
- ## 参考
104
-
105
- [element](https://github.com/ElemeFE/element)
106
- [vuepress](https://www.vuepress.cn/guide/directory-structure.html)