1.0.9 • Published 6 months ago

sdevcore-element-v2 v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

SDevCore-element-v2

安装教程

npm  i  sdevcore-element-v2

使用说明

引入

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";

//入口js文件
import SC from 'sdevcore-element-v2'

//引入组件库样式
import 'sdevcore-element-v2/index.css'


//依赖element组件库
Vue.use(ElementUI, {
  size: "mini",
});

//使用开发工具
Vue.use(SC);

/**
 * 支持传入主题色配置, 必须为 16进制 颜色值
 */
// Vue.use(SC, '#f39800');

组件

SBody

<SBody>
    <template #logo>
      左侧头部
    </template>
    <template #menu>
      左侧菜单
    </template>
    <template #copyright>
      左侧底部
    </template>
    <template #header>
      右侧头部
    </template>
    <template #main>
      主体部分
    </template>
</SBody>

SPanel

<SPanel title="用户列表" hide-title @full-change="onFullChange">
    <template #body>
      面板主体
    </template>
    <template #footerLeft>
      底部左侧
    </template>
    <template #footerRight>
      底部右侧
    </template>
</SPanel>

SPanel配置项/事件

配置项/事件说明类型描述
title标题string
hideTitle隐藏头部标题boolean默认值:false
@fullChange全屏状态变化事件参数:isFullscreen

STable

<STable :data="data" :columns="columns">
    <template #cloumnKey="{ data }">
        {{  data[columnKey] }}
    </template>
</STable>

STable组件配置项

配置项说明类型示例
columns表格列配置项Array{key: 'name', label: '姓名'}
data表格数据Array{name: '张三'}
loading加载状态Boolean默认值: false
hideIndex隐藏序号列Boolean默认值: false
hideSelect隐藏选择列Boolean默认值: false
hideDelete隐藏删除按钮Boolean默认值: false
showDetail显示详情按钮Boolean默认值: false
hideEdit隐藏编辑按钮Boolean默认值: false
hideCtrl隐藏操作列Boolean默认值: false
ctrlWidth操作列宽度Number默认值: 140
editStr编辑按钮文字String默认值: '编辑'
detailStr详情按钮文字String默认值: '详情'
deleteStr删除按钮文字String默认值: '删除'
autoHeight表格自适应高度Boolean默认值: false
selectList选中列表Array默认值: []

STable事件

事件名称说明参数
@edit编辑事件row
@detail详情事件row
@delete删除事件row
@select选择事件selectList
@onSelect(同select)selectList

STable插槽

插槽名称说明示例
tableHeader表格头部插槽--
actionBefore默认操作按钮左侧插槽--
actionEnd默认操作按钮右侧插槽--
tableFooter表格底部插槽--
columnKey表格内部列插槽<template #columnKey="{ data }">{{ data }}

STableBar

<STableBar 
    :search-field-list="searchFieldList" 
    search-immediate
    @search="onSearch"
    @reset="onReset"
/>

STableBar配置项

配置项说明类型示例
hideAdd隐藏新增按钮boolean默认值:false
addStr新增按钮文字string默认值:添加
searchFieldList搜索对象列表searchField详见searchField配置
searchImmediate搜索立即执行boolean默认值:false
hideSearch隐藏右侧搜索区域boolean默认值:false

searchField 对象配置

配置项类型描述示例
keystring搜索字段的key值
labelstring搜索字段的名称
typestring搜索字段组件类型可选值:input,select,cascader,date,daterange
placeholderstringplaceholder占位文字若不传入,默认使用label
enumRecordarray当type为select,cascader时传入{key:'xxx', label: 'xxx'}
valueKeystring指定enumRecord列表的value的key默认值:‘key'
labelKeystring指定enumRecord列表的label的key默认值:‘label'
childrenKeystring指定enumRecord列表的 children的key默认值:‘children'

SPage

<SPage :page-data="response" @change="onPageChange" />

SPage配置项/事件

配置项/事件说明类型描述
pageData隐藏新增按钮boolean必传 ,示例{pageNum: 1, pageSize: 20, total: 999 }
pageSizes新增按钮文字array默认值:20, 50, 100
@change分页器change事件参数:pageData

SDialog

<SDialog title="弹窗" @cancel="onCancel()" @confirm="onConfirm()">
    <!---弹窗内容区域-->
</SDialog>

SDialog配置项

配置项说明类型描述
title弹窗标题string
width宽度string默认值:50%
height高度string默认值:50%
minWidth最小宽度string默认值:500px
minHeight最小高度string默认值:500px
fullable是否支持全屏boolean默认值:true
closeByMask点击遮罩是否关闭弹窗boolean默认值:true

SDialog事件

事件名描述
cancel点击取消触发
onCancel同cancel
confirm点击确定触发
onConfirm同confirm
fullChange切换全屏是触发

SDialog使用说明

SDialog是自定义的DIalog组件,需配合全局工具类 DialogHelper 一起使用

示例

index.vue 主页面

<template>
    <STable data="userList" :columns="columns" @edit="onEditUser"/>
</template>
<script>
export default{
    data() {
        return{
            userList: [],
            columns:[
                {key: 'name', label: '姓名'},
                {key: 'age', label: '年龄'},
                {key: 'sex', label: '性别'}
            ]
        }
    },
    methods: {
        async getUserList() {
            this.userList = await $http.userList.post()
        },
         async onEditUser() {
              await this.$DialogHelper.show(SDialog, param)
              // 刷新列表
              this.getUserList()
        }
    }
}
</script>

editView.vue 弹窗页面

<template>
  <SDialog title="编辑弹窗" @cancel="onCancel()" @confirm="onSubmit()">
      <el-form v-model="formData">
          ......
      <el-form>
  </SDialog>
</template>
<script>
export default{
    props:{
        // props里面这三项是固定的,只要使用了DialogHelper都会传入这三项
        onConfirm: Function,
        onCancel: Function,
        param: Object
    },
    data() {
        return{
            formData: {}
        }
    },
    methods: {
        async onSubmit() {
            await $http.updateUser.post(this.formData)
            // 调用onConfirm事件,关闭弹窗,完成Promise
            // onConfirm 也可传递参数 this.confirm(param),外部在promise完成之后拿到param
            this.onConfirm()
        }
    }
}

</script>

SBoard

<SBoard :background-img="require('@/assets/bg1.png')">

   <!--看板内容区域,内部使用绝对定位控制元素块位置即可-->

</SBoard>

工具类

1.  class DialogHelper

// 打开弹窗
this.$DialogHelper.show(element, param)

// 打开单选弹窗
this.$DialogHelper.select(element, param)

// 打开多选弹窗
this.$DialogHelper.selectList(element, param)

2.  class FormHelper

this.$FormHelper.validate(formRef)

3.  class EnumHelper

this.$EnumHelper.getLabel(enumList, key)
this.$EnumHelper.getColor(enumList, key)
this.$EnumHelper.getByKey(enumList, key)

4.  class FileHelper

this.$FileHelper.blob2Excel(blob, name)

5.  class ThemeHelper

/**
 * 获取主题色 
 */
this.$ThemeHelper.getThemeColor()
/**
 * 设置主题色 仅支持16进制
 */
this.$ThemeHelper.setThemeColor(color)
1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago