1.1.1 • Published 10 months ago

common-components-csy v1.1.1

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

common-components

安装

yarn add common-components-csy
//or
npm istall common-components-csy

使用

引入

//main.js
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import commonComponentsCsy from 'common-components-csy'

Vue.use(ElementUI);
Vue.use(commonComponentsCsy)

SvgIcon组件

用法

  • 在src目录下创建icons目录,将下载的svg图标放在此目录下
  • 使用
<SvgIcon icon-name="add" class="add-svg"></SvgIcon>

Options

参数说明类型可选值默认值
icon-namesvg的名称string----
color图标的颜色string----
size图标的尺寸stringmedium(图标大小为1.5em)/small(图标大小为1em)--

MultistageTable组件

使用

<template>
  <div class="hello">
    <MultistageTable ref="MultistageTable" class="M-table" :colsHead="colsHead" :tableDatas="tableData"
                     :need-select="false" :show-summary="true" :other-cols-head="otherColsHead"
                     :need-page="false" table-height="calc(100vh - 520px)">
      <template #table-column>
        <el-table-column header-align="center" label="插入的输入框" width="167" align="right">
          <template slot-scope="scope">
            <el-input style="font-weight: bold" :ref="`rowInput${scope.$index}`" v-model="scope.row['bcdkje']" placeholder="请输入数据"
                      size="small" class="column-input"></el-input>
          </template>
        </el-table-column>
      </template>
    </MultistageTable>
  </div>
</template>

<script>

export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      colsHead: [{prop: 'htwjbh', label: '表头1'}, {prop: 'cqhtqdsj', label: '表头2'}
        , {prop: 'jdxzmc', label: '表头3'}, {prop: 'bcqrhbbcje', label: '表头4', align: 'right', amount: true}
        , {amount: true, prop: 'dksyje', label: '表头5', align: 'right'}],
      otherColsHead: [{prop: 'bcdkje', label: '表头6', amount: true}],
      tableData:[{htwjbh:'xxx'}],
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">

</style>

样式

为了保持项目中,其他未使用此组建的表格样式与该组件一致,可以在vuex里面统一设置表头和表格基础样式

  state: {
    cellStyle: {
      'font-size': '14px',
      'padding': '10px 0',
      'color': 'rgba(0, 0, 0, 0.65)',
      border:'1px solid #D4E1E7',
      'borderLeft':'none',
      'borderTop':'none'
    },
    tableHeaderStyle: {
      // 'background': '#fafafa',
      'font-size': '14px',
      'padding': '10px 0',
      'color': 'rgba(0, 0, 0, 0.85)',
      'background':'#C2D8F2',
      border:'1px solid #D4E1E7',
      'borderLeft':'none',
    },
  },

Options

参数说明类型可选值默认值举例
cols-head表头列表,prop:该列只对应的字段名;label:表头名称;amount:是否是金额(金额列需要千分制,所以合计计算的时候需要转换),align:设置表头的水平位置。不传则默认是left type:如需要编辑单元格,则传input;editable:编辑的单元格初始状态,默认是不可编辑,如需要默认可编辑则传trueArray----{prop: 'price', label: '成交价格', amount: true,align:'right',type:'input',editable:true}
table-datas表格数据。有两种格式,需要分页传Object,无分页传ArrayObject/Array----Object:{count:200,data:{name:'张三',age:'18'},{name:'李四',age:'20'}},Array:{name:'张三',age:'18'}
otherColsHead表格列求和时,如果有一些列不是通过colsHead传过来的,需要通过该参数传过来。数据格式和colsHead一致Array----{prop: 'price', label: '成交价格', amount: true,align:'right'}
page当前页数,数字类型Number------
pageSize每页的行数,数字类型Number------
needButton是否需要表头上面的按钮Boolean--true--
needSelect是否需要左侧选择框Boolean--true--
needPage是否需要分页Boolean--true--
needIndex是否需要左侧第一行的index自动排序Boolean--false--
menuList右键单击后出现的菜单选项Array--[]{name:'菜单1',callback:()=>{console.log('菜单1')},id:1},{name:'菜单2',callback:()=>{console.log('菜单2')},id:2}
showSummary是否在表格下方显示合计行Boolean--false--
allowSelect在有第一列选择框的时候,是否允许手动选择他的子集Boolean--true--
buttonList表格上方的按钮列表,name:按钮名字;buttonId:按钮点击之后触发的事件名,isPrimary:是否主要按钮Array--[]{name: '添加', buttonId: 'openAddDialog', isPrimary: '1'},
tableHeight自定义表格的高度String--calc(100vh - 220px)--
hasSelectedRows表格默认选中行,数据格式与table-datas单行一致Array------
customLongCell自定义列的宽度,name为该列的表头名,width为该列需要的宽度类型为数字Array----{name: '动态调整计划名称', width: 275}
needSetWidth是否需要按照表头文字的长度,设置默认的表头宽度Boolean--true--
selectType单选/多选Stringradio/checkbox----
customStyleCell自定义单元格或行列的样式,如果要设置整行或整列的样式,只需要将列或行设为null即可Arrayradio/checkbox--[rowIndex,columnIndex,{单元格样式对象},rowIndex,columnIndex,{单元格样式对象},]
totals传过来的总的数量数据Number------
needTitle表格是否需要标题Boolean--false--
listTitle传过来的列表的标题String------
ShowHeader表格是否需要表头Boolean--true--
listAlign标题位置String--center--

Events

事件名说明参数
dblclick双击行时触发的事件row
RowClick单击行时触发的事件row
update:completeInput表格输入完成时触发的事件--
cancelSelect取消选中行时触发的事件row,如果是全选的取消勾选,则参数为字符串all
currentChange翻页时触发的事件page,row(当前页的选中行)
SelectChange选中/取消选中行时触发的事件row
1.1.1

10 months ago

1.1.0

10 months ago

1.0.0

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago