twmodule 0.0.50 → 0.0.52
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/README.md +189 -1
- package/lib/twComp.common.js +965 -155
- package/lib/twComp.css +1 -1
- package/lib/twComp.umd.js +965 -155
- package/lib/twComp.umd.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -61,6 +61,21 @@ npm run test
|
|
61
61
|
|
62
62
|
7、delRepeat(arr)数组去重
|
63
63
|
8、delRepeatObj(arr,keyWord)数组对象去重
|
64
|
+
9、guidance(list,path,_this)新手引导功能
|
65
|
+
list:引导的参数
|
66
|
+
path:是否需要跳转页面进行引导
|
67
|
+
_this:配合path一起传入
|
68
|
+
例:
|
69
|
+
this.guidance(this.yindao);
|
70
|
+
yindao:[//引导顺序依照数组顺序
|
71
|
+
{id: 'create1',//DOM组件的ID
|
72
|
+
className: 'firstStyle',//可以添加引导框的类名
|
73
|
+
title: '新功能引导',//引导框的标题
|
74
|
+
description: '现在可以查看XX拉!',//引导框的内容
|
75
|
+
position: 'bottom-center'//引导框的位置},
|
76
|
+
{id: 'create2',title: '新功能引导',description: '现在可以查看YY拉!',position: 'bottom'},
|
77
|
+
]
|
78
|
+
10、resetObj(obj)重置对象,如果遍历时,里面的对象是数组,则会重置为空数组,其他都为空字符串。
|
64
79
|
```
|
65
80
|
### 公共样式
|
66
81
|
#### 1、字体
|
@@ -460,7 +475,7 @@ stepData:{
|
|
460
475
|
formModule:{//整个对象都是非必须的,有配置需求再用
|
461
476
|
size:'small',//表单尺寸大小,非必填,默认small
|
462
477
|
labelWidth:'75px',//整体label的宽度,非必填,默认值为75px(满足4个字的宽度)最大值为100px(满足6个汉字不换行)
|
463
|
-
hideLabelWidth:'
|
478
|
+
hideLabelWidth:'75px',//隐藏表单里面,整体label的宽度,非必填,默认75px(满足4个汉字的宽度)
|
464
479
|
reset:true,//是否需要重置按钮,非必填,默认false
|
465
480
|
showSearchMore:true//是否需要启用隐藏表单,非必填,默认false
|
466
481
|
}
|
@@ -518,4 +533,177 @@ stepData:{
|
|
518
533
|
{label:'多选',itemValue:'checkBox',itemType:'checkBox',checkBoxList:[]},
|
519
534
|
{label:'金额区间',itemValue:'valueRange1',itemValueSec:'valueRange2',itemType:'valueRange',isNumber:true},
|
520
535
|
],
|
536
|
+
|
537
|
+
```
|
538
|
+
|
539
|
+
|
540
|
+
#### 6、table组件
|
541
|
+
```
|
542
|
+
<TwTable :tableInit="tableInit" :tableData="tableData" :columns="columns" @cellClick="cellClick"
|
543
|
+
@cellClickFBC="cellClickFBC" @changePage="changePage" @selectRow="selectRow"></TwTable>
|
544
|
+
|
545
|
+
//表格整体设置
|
546
|
+
tableInit = {
|
547
|
+
tableClassName:'tableClass',//表样式名
|
548
|
+
size:'small',//表格大小:middle 默认small,
|
549
|
+
select:false,//开启左侧select选项 不要与selectRow同时使用,不然勾选后,selectRow修改的行样式会消失。
|
550
|
+
height:'500',//表格高
|
551
|
+
width:'',//表格宽
|
552
|
+
selectRow:false,//开启选中行数据事件 点击后默认添加checkedRowClass行样式,可以在公共CSS里面强制覆盖改样式。
|
553
|
+
changeRow:{label:'state',value:'fail',addClass:'redFont'},
|
554
|
+
//label匹配dataindex的值,value为dataindex等于某个值时,添加addClass(需要写在公共CSS里面)
|
555
|
+
//例如:当state这一列的值为fail时,这一行的文字都变成蓝色
|
556
|
+
/*.redFont{
|
557
|
+
color: blue !important;
|
558
|
+
.el-checkbox__label,.el-radio__label,input,textarea{//非文字时,需要再定位一层
|
559
|
+
color: blue !important;
|
560
|
+
}
|
561
|
+
*/
|
562
|
+
pagination:{//是否开启分页,有值就开启
|
563
|
+
total:100,
|
564
|
+
currPage:1
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
//table列设置(数组中枚举了所有单元格可能会出现的场景,如有满足不了的需求,请联系管理人员添加场景)
|
569
|
+
columns = [
|
570
|
+
{
|
571
|
+
title: 'Name',
|
572
|
+
dataIndex: 'name',
|
573
|
+
tableSort:true,//开启当前页前端的简单排序
|
574
|
+
align:'left',//对齐方式'left' | 'right' | 'center'
|
575
|
+
fixed:'left',//开启固定列,left/right
|
576
|
+
colSpan: 2,//开启表头列合并,下一列必须设置colSpan: 0,不然表头会错乱
|
577
|
+
tableRowSpan:true,//开启数据行合并
|
578
|
+
isSpecial:{//是否开启字段样式特殊处理
|
579
|
+
textStyle:{"color":"red"}//为单元格的文体设置样式(仅针对文字)
|
580
|
+
}
|
581
|
+
},
|
582
|
+
{
|
583
|
+
title: 'Phone',
|
584
|
+
colSpan: 0,
|
585
|
+
dataIndex: 'phone',
|
586
|
+
isSpecial:{//是否开启字段样式特殊处理
|
587
|
+
isClick:true,//开启状态列点击事件
|
588
|
+
textStyle:{"color":"red","border-bottom":"1px solid red","cursor":"pointer"}
|
589
|
+
}
|
590
|
+
},
|
591
|
+
{
|
592
|
+
title: '状态',
|
593
|
+
dataIndex: 'state',
|
594
|
+
isState:{//开启状态列,根据不同的值,限制不同的状态样式
|
595
|
+
isClick:true,//开启状态列点击事件
|
596
|
+
stateList:[{name:'成功',value:'success',class:'stateColorBlue',icon:'el-icon-edit'},
|
597
|
+
{name:'失败',value:'fail',class:'stateColorRed',styles:{color:'red'}},
|
598
|
+
{name:'警告',value:'warning',class:'stateColorYellow'},
|
599
|
+
{value:'danger',styles:{color:'red'},class:'stateColorGrey'},
|
600
|
+
{value:'ing',styles:{color:'blue'},class:'stateColorGreen',img:require("../assets/logo.png")}]
|
601
|
+
//状态列数组,name表示要显示的值,没有该字段时,就显示dataindex匹配的值。
|
602
|
+
//value就是dataindex的枚举值,icon:element的图标库,img:本地图片(一定要用require的方式引入),
|
603
|
+
//styles表格中的自定义样式, class内置了五种状态样式,写上class就行了(注意:styles里面的样式会覆盖class内的样式)
|
604
|
+
}
|
605
|
+
},
|
606
|
+
{
|
607
|
+
title: 'number/text',
|
608
|
+
dataIndex: 'age',
|
609
|
+
isEdit:{type:'textBox',cellChange:true,cellFocus:true,cellBlur:true},
|
610
|
+
//isEdit:是否向单元格填充输入组件:包含以下类型(带有Box后缀的类型,是对普通类型的增强版,用于输入区域太小,或者需要输入大量文案的时候,推荐使用)
|
611
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
612
|
+
},
|
613
|
+
{
|
614
|
+
title: 'textarea',
|
615
|
+
dataIndex: 'textarea',
|
616
|
+
isEdit:{type:'textareaBox',cellChange:true,cellFocus:true,cellBlur:true,minDate:'2023-04-01',maxDate:'2023-05-01',dataList:[{value: '111',name: '黄金糕'}, {value: '222',name: '双皮奶'}]},
|
617
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
618
|
+
},
|
619
|
+
{
|
620
|
+
title: 'select',
|
621
|
+
dataIndex: 'select',
|
622
|
+
isEdit:{type:'select',cellChange:true,cellFocus:true,cellBlur:true,minDate:'2023-04-01',maxDate:'2023-05-01',dataList:[{value: '111',name: '黄金糕'}, {value: '222',name: '双皮奶'}]},
|
623
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
624
|
+
//select,radio,checkBox三种类型,需要有数据源dataList支持,name为展示的名字,value为对应的数值,
|
625
|
+
},
|
626
|
+
{
|
627
|
+
title: 'date',
|
628
|
+
dataIndex: 'date',
|
629
|
+
isEdit:{type:'date',dateType:'date',cellChange:true,cellFocus:true,cellBlur:true,minDate:'2023-04-01',maxDate:'2023-05-01',dataList:[{value: '111',name: '黄金糕'}, {value: '222',name: '双皮奶'}]},
|
630
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
631
|
+
//date为时间选择组件,dateType可为date(默认date) month year。minDate为最小可选,maxDate为最大可选。
|
632
|
+
},
|
633
|
+
{
|
634
|
+
title: 'radio',
|
635
|
+
dataIndex: 'radio',
|
636
|
+
width: 180,
|
637
|
+
isEdit:{type:'radio',cellChange:true,cellFocus:true,cellBlur:true,minDate:'2023-04-01',maxDate:'2023-05-01',dataList:[{value: '111',name: '黄金糕'}, {value: '222',name: '双皮奶'}]},
|
638
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
639
|
+
},
|
640
|
+
{
|
641
|
+
title: 'checkBox',
|
642
|
+
dataIndex: 'checkBox',
|
643
|
+
isEdit:{type:'checkBox',cellChange:true,cellFocus:true,cellBlur:true,minDate:'2023-04-01',maxDate:'2023-05-01',dataList:[{value: '111',name: '黄金糕'}, {value: '222',name: '双皮奶'}]},
|
644
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
645
|
+
},
|
646
|
+
{
|
647
|
+
title: 'switch',
|
648
|
+
dataIndex: 'switch',
|
649
|
+
width: 80,
|
650
|
+
isEdit:{type:'switch',cellChange:true,cellFocus:true,cellBlur:true,minDate:'2023-04-01',maxDate:'2023-05-01',dataList:[{value: '111',name: '黄金糕'}, {value: '222',name: '双皮奶'}]},
|
651
|
+
//text,number,textarea,textBox,numberBox,textareaBox,select,radio,checkBox,switch,date
|
652
|
+
//switch时,如果dataindex匹配的值不为布尔型或者为''空值时,会直接按ture显示
|
653
|
+
},
|
654
|
+
{
|
655
|
+
title: 'Address',
|
656
|
+
dataIndex: 'address',
|
657
|
+
twEllipsis:1,//超出多少行出现省略号,目前支持1和2,twEllipsis会覆盖ellipsis的效果,并且会让表头搜索功能失效
|
658
|
+
width:150,
|
659
|
+
colSearch:true,//表头搜索功能,与twEllipsis冲突,不能共用,如果非要用,就使用ellipsis: true。但是没有twEllipsis悬浮框的效果
|
660
|
+
ellipsis: true,//超出1行出现省略号,twEllipsis会覆盖ellipsis的效果。
|
661
|
+
},
|
662
|
+
{
|
663
|
+
title: 'html',
|
664
|
+
dataIndex: 'html',
|
665
|
+
isHtml:[{value:'red',html:'<div style="width: 100%;height: 10px;background-color: red"></div>'}
|
666
|
+
,{value:'blue',html:'<div style="width: 100%;height: 10px;background-color: blue"></div>'}],
|
667
|
+
//html类型时,根据数组对象中,不同的value显示不同的自定义html单元格样式
|
668
|
+
//value用来匹配dataindex在tableData中的值
|
669
|
+
},
|
670
|
+
{
|
671
|
+
title: '操作',
|
672
|
+
isBtn:{btnList:[{name:'查看',color:'#3399ff'},{name:'编辑',icon:'el-icon-edit'},{name:'删除',color:'red',icon:'el-icon-delete'}]}
|
673
|
+
//自定义按钮:统一按钮为文字按钮,name名称 color颜色 icon图标 自带点击事件
|
674
|
+
},
|
675
|
+
];
|
676
|
+
|
677
|
+
//接口请求回来的参数
|
678
|
+
tableData
|
679
|
+
|
680
|
+
//对应事件
|
681
|
+
cellClick(params){//单元格的点击事件
|
682
|
+
params = {
|
683
|
+
currItem:currItem,//columns中的列数据
|
684
|
+
rowItem:rowItem//tableData中的行数据
|
685
|
+
}
|
686
|
+
}
|
687
|
+
cellClickFBC(params){//单元格输入组件的focus,blur,change事件(input组件才会使用这个方法)
|
688
|
+
params = {
|
689
|
+
type:type,//事件类型,focus,blur,change三种
|
690
|
+
rowItem:rowItem,
|
691
|
+
currItem:currItem,
|
692
|
+
val:val//change事件才会有的当前输入值
|
693
|
+
}
|
694
|
+
}
|
695
|
+
changePage(params){//分页事件
|
696
|
+
params = {
|
697
|
+
currPage:currPage,//当前页
|
698
|
+
currSize:currSize//分页条数
|
699
|
+
}
|
700
|
+
}
|
701
|
+
selectRow(params){//tableInit.selectRow为true时,开启选中一行后的事件包括样式
|
702
|
+
params//tableData中的行数据
|
703
|
+
}
|
704
|
+
|
705
|
+
最简单的使用案例:
|
706
|
+
<TwTable :tableData="tableData" :columns="columns"></TwTable>
|
707
|
+
tableData = [{}];
|
708
|
+
columns = [{}];
|
521
709
|
```
|