1.1.11 • Published 5 days ago

common-list v1.1.11

Weekly downloads
-
License
ISC
Repository
-
Last release
5 days ago

多功能便捷CRUD组件

用于快速搭建CRUD的前端应用, 目前已实现网络的增删改查的请求封装,实现表格数据的筛选,查找,分页等常用功能,使用该组件可以快速开发出业务系统的常用功能界面。

在线Demo

Live Demo 在线演示

安装--Install

$ npm install common-list --save

使用--Usage

1.全局引入

main.js

import { createApp } from 'vue'
import App from './App.vue'
import MyTable from 'common-list'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css';
import zhCn from 'element-plus/es/locale/lang/zh-cn'
createApp(App).use(ElementPlus, {
    locale: zhCn,
}).use(router).use(MyTable).mount('#app')

2.使用组件

<template>
    <CommonList :datatitle="DemoUrlSet.title" key-field-name="demoID" :table-data="tableData"
      :column-list="DemoColumns" :op-column-width="300" :total-count="tableData.length" searchplaceholder="搜索" :use-select="false">

    </CommonList>
</template>

<script setup lang="ts">

import { InitComponentData} from 'common-list' //初始化组件,获取列表数据
import { DemoColumns,netUtil } from '/@/models/columndata';//字段集合和网络工具类

import { Demo } from "/@/models/index"; //数据对象
import { DemoUrlSet } from "/@/models/urlset";//读取数据的网址对象

const { tableData } = InitComponentData<Demo>(netUtil,DemoUrlSet, 'demoID', null, {});
//RoleCheck()
</script>

3.common-list中的数据类型

export enum SaveType { Add, Edit, Delete, MultiSet, Upload, Check }
export interface KeyValue {
    title: string,
    value: string | number
}

export interface DataColumn { //数据列类型
    title: string,
    fieldName: string,
    placeholder?: string,
    inputType?: string,//input的数据类型,对应input : text,number,date
    options?: KeyValue[],
    isMultiple?: boolean,
    required?: boolean,
    useSwitch?: boolean,
    dataType?: string,
    isMainField?: boolean, //是否需要占用多点显示位置,如35%
    isHideInList?: boolean, //是否不在表格里显示
    isHideInForm?: boolean, //是否不在表单里显示
    isImg?: boolean,
    isDate?: boolean,
    needShowTime?: boolean,
    isWholeRow?: boolean,//是否独占一行!!!
    isRichText?: boolean,
    isFile?: boolean,
    isAutoUpload?: boolean,
    fileLimit?: number,
    useComponent?: boolean,
    canEditInTable?: boolean,
    showInDetail?: boolean,  
}

export class CrudUrlSet {  //api网址集合
    getListApiUrl: string;
    getSingleApiUrl: string;
    addApiUrl: string;
    editApiUrl: string;
    delApiUrl: string;
    checkApiUrl: string;//用于登录
    multiSetApiUrl: string;//批量重置
    resetListApiUrl: string;  //批量重置修复
    importApiUrl: string; //批量导入
    restfulApiUrl: string; //统一api地址,根据http method去辨别!
    keyFieldName: string;
    demoFieldName: string;
    title: string;
    needResetKeysWhenUpdated: string[];
}


export interface FilterData {
    datalist: any[],//这个是数据数组
    selectedlist: any[] | any,//这个选中数据数组
    isMultiple: boolean,//是否可以多选
    onlyLocal?: boolean,//是否只是本地筛选
    placeholder: string,//占位符文本
    filterFieldName: string //列表筛选字段名,这个是必选的
    valueFieldName: string //选项值的字段名
    textFieldName?: string //选项文本的字段名
}

export interface TableListOption<T> {
    tableID?: string,//表格ID,用于导出
    maxHeight?: number,//最大高度
    opColumnWidth?: number, //操作栏宽度,默认200  
    opColumnTitle?: string, //操作栏标题   
    highlightCurrentRow?: boolean,//高亮显示当前行
    noOpColumn?: boolean,//不显示操作栏
    useSelect?: boolean,  //使用选择,默认为true			
    singleSelect?: boolean,//单选,在useSelect为true是时才有意义
    resizable?: boolean, //允许调宽
    canEdit?: boolean,//表格中直接显示编辑,一般是配合editChange方法
    paging?: boolean,//是否分页,数据总数量与tableData的数量不一致时为true,
    searchText?: string,//来自ListHead的搜索文字
    showDelOpBtns?: boolean,//显示删除按钮,默认为true	
    showDetailOpBtns?: boolean,	//显示详情按钮,默认为true	
    showEditOpBtns?: boolean,//显示编辑按钮,默认为true	
    columnList: DataColumn[], //字段属性数组,表格数据根据这个来显示
    tableData: T[], //表格数据源
    totalCount?: number, //数据总数量,如果与tableData的数量不一致时,则显示分页
    downloadFile?: (url: string) => {}, //参数传过来是方法!!
    pageSizes?: number[],//页码设置,默认为[20, 30, 50, 100]
}

export interface ListHeadOption<T> {
    searchplaceholder?: string, //搜索框占位符文字
    sampleFileUrl?: string,//导入的样例文件
    addBtnText?: string, //新增按钮的文本,默认为添加
    tableID?: string,//表格ID,用于导出
    enableBatchSet?: boolean, //支持批量设置
    hasResizeBtn?: boolean, //  显示调整表格宽度的按钮
    enableMultiAdd?: boolean, //支持批量添加
    isCustomRefresh?: boolean, //自定义重新刷新列表,自定义读取数据api
    hasSearchInput?:boolean,//显示搜索框
    showImportBtn?: boolean,//显示导入按钮
    enableExport?: boolean,//显示导出
    enableColumnBtn?: boolean,//管理显示列
    searchFromServer?: boolean,//从服务器上搜索
    filterFromServer?: boolean, //通过在服务器里筛选!!
    showDefaultOpBtns?: boolean,//显示默认按钮,默认为true	
    columnList: DataColumn[], //字段属性数组,表格数据根据这个来显示
    tableData: T[], //表格数据源
    totalCount?: number, //数据总数量,如果与tableData的数量不一致时,则显示分页
    filterObjList?: FilterData[],//筛选数据列表,可以有多个,可选单选或多选	
}

export interface CommonListOption<T> extends TableListOption<T>, ListHeadOption<T> {
    dialogWidth?: number, //对话框宽度,默认1000	
    datatitle?: string, //对话框的标题       
    keyFieldName?: string, //主键字段名
    maxImgSize?: number, // 图片大小最大字节, 默认2 * 1024 * 1024		
    maxVideoSize?: number, // 视频大小最大字节, 默认50 * 1024 * 1024		
    hasListHead?: boolean,//是否包含列表头
    newDialogData?: boolean,  //使用新的对话框数据,默认为true
    showDialogSizeSet?: boolean,//显示对话框大小设置按钮
    showEditInTable?: boolean,//表格中直接显示编辑,一般是配合editChange方法
    containDialog?: boolean,//是否包含对话框,如果只显示数据,可以设置这个为true,已节省组件开销
    showKeepData?: boolean,		//保存之前的表单数据
    isDemo?: boolean, //是否用于demo显示
    addNewObj?: T,  //新建对象
    autoOpenObj?: T,//自动打开的对象,一般为接受其他系统传过来的参数
    listStyle: string,//列表显示方式,分别为table(表格),pic(图片列表),free(自由列表)
    getRowData?: (n: number) => {}, //参数传过来是方法!用于获取单条记录,一般从服务器重新获取!
    settingColumnList?: DataColumn[],//设置后,ListHead的enableBatchSet将为true

}

4.对应的Demo模型类

export class Demo {
    demoID: number;
    name: string;
    demoDesc: string;
    constructor(name: string) {

        this.demoID = 0;
        this.demoDesc = ''
        this.name = name
    }
}
export const DemoColumns = ref<DataColumn[]>([
    {
        title: '标题',
        fieldName: 'name',

    },
    {
        title: '内容',
        fieldName: 'demoDesc',
        isHideInList: true
    }
])

export const DemoUrlRestfulSet: CrudUrlSet = {
    restfulApiUrl:'/api/demo/rest',
    importApiUrl: '/api/demo/importdemos',
    keyFieldName: 'demoID',
    title: '演示'
}

CommonList常用属性说明

参数说明类型可选值默认值
tableData表格数据列表,数组Array数组[]
column-list列集合Array0
key-field-name主键字段名Stringtrue
datatitle数据标题Booleanfalse
use-select是否开启选择数据Booleanfalse
total-count数据条数Number

##插槽

插槽名称说明
otherbtns自定义操作按钮系列
headTitle自定义表头区域
opColumn表格操作列行内的自定义操作
1.1.11

5 days ago

1.1.10

10 days ago

1.1.9

18 days ago

1.1.8

19 days ago

1.1.7

19 days ago

1.1.6

19 days ago

1.1.1

21 days ago

1.1.0

21 days ago

1.1.5

21 days ago

1.1.4

21 days ago

1.1.3

21 days ago

1.1.2

21 days ago

1.0.50

1 month ago

1.0.48

1 month ago

1.0.49

1 month ago

1.0.47

2 months ago

1.0.46

2 months ago

1.0.45

2 months ago

1.0.44

2 months ago

1.0.43

2 months ago

1.0.42

2 months ago

1.0.39

2 months ago

1.0.38

2 months ago

1.0.40

2 months ago

1.0.41

2 months ago

1.0.37

2 months ago

1.0.36

2 months ago

1.0.33

2 months ago

1.0.32

2 months ago

1.0.31

2 months ago

1.0.35

2 months ago

1.0.34

2 months ago

1.0.26

2 months ago

1.0.29

2 months ago

1.0.28

2 months ago

1.0.27

2 months ago

1.0.30

2 months ago

1.0.25

3 months ago

1.0.24

3 months ago

1.0.23

3 months ago

1.0.22

3 months ago

1.0.21

3 months ago

1.0.19

3 months ago

1.0.18

3 months ago

1.0.20

3 months ago

1.0.17

3 months ago

1.0.16

3 months ago

1.0.15

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago

1.0.9

3 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.11

3 months ago

1.0.10

3 months ago

1.0.14

3 months ago

1.0.13

3 months ago

1.0.12

3 months ago

0.1.9

11 months ago

0.1.8

1 year ago

0.1.7

1 year ago

0.0.119

1 year ago

0.0.128

1 year ago

0.0.127

1 year ago

0.0.126

1 year ago

0.0.125

1 year ago

0.0.120

1 year ago

0.0.124

1 year ago

0.0.123

1 year ago

0.0.122

1 year ago

0.0.121

1 year ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.0.106

2 years ago

0.0.105

2 years ago

0.0.104

2 years ago

0.0.103

2 years ago

0.0.109

1 year ago

0.0.108

1 year ago

0.0.107

2 years ago

0.0.102

2 years ago

0.0.101

2 years ago

0.0.100

2 years ago

0.0.117

1 year ago

0.0.116

1 year ago

0.0.115

1 year ago

0.0.114

1 year ago

0.0.118

1 year ago

0.0.113

1 year ago

0.0.112

1 year ago

0.0.111

1 year ago

0.0.110

1 year ago

0.0.95

2 years ago

0.0.96

2 years ago

0.0.97

2 years ago

0.0.98

2 years ago

0.0.99

2 years ago

0.0.90

2 years ago

0.0.91

2 years ago

0.0.92

2 years ago

0.0.93

2 years ago

0.0.94

2 years ago

0.0.84

2 years ago

0.0.85

2 years ago

0.0.86

2 years ago

0.0.87

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.83

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.80

2 years ago

0.0.81

2 years ago

0.0.82

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.73

2 years ago

0.0.74

2 years ago

0.0.75

2 years ago

0.0.76

2 years ago

0.0.77

2 years ago

0.0.78

2 years ago

0.0.79

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.70

2 years ago

0.0.71

2 years ago

0.0.72

2 years ago

0.0.62

2 years ago

0.0.63

2 years ago

0.0.64

2 years ago

0.0.65

2 years ago

0.0.66

2 years ago

0.0.67

2 years ago

0.0.68

2 years ago

0.0.69

2 years ago

0.0.60

2 years ago

0.0.61

2 years ago

0.0.59

2 years ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.55

2 years ago

0.0.56

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago