格式化

This commit is contained in:
Theluyuan 2023-05-29 13:24:59 +08:00
parent 49d7a25529
commit c2027a8665
5 changed files with 226 additions and 91 deletions

View File

@ -44,7 +44,7 @@ export interface SelectProps {
showSearch?: boolean;
contentClass?: string | Array<string | object> | object;
contentStyle?: StyleValue;
position?:string;
position?: string;
}
export interface SelectEmits {
@ -62,7 +62,7 @@ const props = withDefaults(defineProps<SelectProps>(), {
disabled: false,
multiple: false,
size: "md",
position:"top"
position: "top",
});
const slots = useSlots();

View File

@ -17,7 +17,7 @@ export interface StandardProps {
min?: number;
max?: number;
showDots?: boolean;
backgroundColor:string;
backgroundColor: string;
}
const props = withDefaults(defineProps<StandardProps>(), {
@ -27,7 +27,7 @@ const props = withDefaults(defineProps<StandardProps>(), {
min: 0,
max: 100,
showDots: false,
backgroundColor:"#ccc"
backgroundColor: "#ccc",
});
const moveAction = throttle(standardMove);
@ -119,9 +119,12 @@ const focusDot = (val: number) => {
class="layui-slider-rate-v"
:class="[disabled ? 'layui-slider-disabled disable-line' : '']"
></div>
<div class="layui-slider-line-v" :style="{
backgroundColor:props.backgroundColor
}"></div>
<div
class="layui-slider-line-v"
:style="{
backgroundColor: props.backgroundColor,
}"
></div>
<div
v-show="showDots"
@click="focusDot(item)"

View File

@ -22,7 +22,7 @@ export interface SliderProps {
range?: boolean;
rangeValue?: number[];
showDots?: boolean;
backgroundColor:string;
backgroundColor: string;
}
const emit = defineEmits(["update:modelValue"]);
@ -35,7 +35,7 @@ const props = withDefaults(defineProps<SliderProps>(), {
min: 0,
max: 100,
showDots: false,
backgroundColor:"#ccc"
backgroundColor: "#ccc",
});
let rangeValues: Ref<number[]> | any = toRef(props, "rangeValue");

View File

@ -73,13 +73,13 @@ const props = withDefaults(defineProps<TableProps>(), {
rowStyle: "",
cellStyle: "",
defaultExpandAll: false,
spanMethod: () => { },
spanMethod: () => {},
expandKeys: () => [],
loading: false,
getCheckboxProps: () => { },
getRadioProps: () => { },
getCheckboxProps: () => {},
getRadioProps: () => {},
download: "",
serverpage: false
serverpage: false,
});
const emit = defineEmits([
@ -367,7 +367,6 @@ const change = function (page: any) {
page.limit * page.current
);
}
};
const rowClick = function (data: any, evt: MouseEvent) {
@ -836,27 +835,50 @@ window.addEventListener("click", heddin);
</div>
<div v-if="defaultToolbar" class="layui-table-tool-self">
<!-- 筛选 -->
<lay-dropdown v-if="showToolbar('filter')" updateAtScroll :style="toolbarStyle('filter')">
<lay-dropdown
v-if="showToolbar('filter')"
updateAtScroll
:style="toolbarStyle('filter')"
>
<div class="layui-inline" title="筛选" lay-event>
<i class="layui-icon layui-icon-slider"></i>
</div>
<template #content>
<div class="layui-table-tool-checkbox">
<lay-checkbox v-for="column in tableHeadColumns[0]" v-model="tableColumnKeys" skin="primary"
:disabled="column.children" :key="column.key" :value="column.key">{{ column.title }}</lay-checkbox>
<lay-checkbox
v-for="column in tableHeadColumns[0]"
v-model="tableColumnKeys"
skin="primary"
:disabled="column.children"
:key="column.key"
:value="column.key"
>{{ column.title }}</lay-checkbox
>
</div>
</template>
</lay-dropdown>
<!-- 导出 -->
<div v-if="showToolbar('export')" class="layui-inline" title="导出" lay-event :style="toolbarStyle('export')"
@click="exportData()">
<div
v-if="showToolbar('export')"
class="layui-inline"
title="导出"
lay-event
:style="toolbarStyle('export')"
@click="exportData()"
>
<i class="layui-icon layui-icon-export"></i>
</div>
<!-- 打印 -->
<div v-if="showToolbar('print')" :style="toolbarStyle('print')" class="layui-inline" title="打印" lay-event
@click="print()">
<div
v-if="showToolbar('print')"
:style="toolbarStyle('print')"
class="layui-inline"
title="打印"
lay-event
@click="print()"
>
<i class="layui-icon layui-icon-print"></i>
</div>
</div>
@ -868,26 +890,47 @@ window.addEventListener("click", heddin);
<div class="layui-table-box">
<!-- 表头 -->
<div class="layui-table-header" :style="[{ 'padding-right': `${scrollWidthCell}px` }]">
<div
class="layui-table-header"
:style="[{ 'padding-right': `${scrollWidthCell}px` }]"
>
<div class="layui-table-header-wrapper" ref="tableHeader">
<table class="layui-table" :lay-size="size" :lay-skin="skin" ref="tableHeaderTable">
<table
class="layui-table"
:lay-size="size"
:lay-skin="skin"
ref="tableHeaderTable"
>
<colgroup>
<template v-for="column in tableBodyColumns" :key="column">
<template v-if="tableColumnKeys.includes(column.key)">
<col :width="column.width" :style="{
minWidth: column.minWidth ? column.minWidth : '50px',
}" />
<col
:width="column.width"
:style="{
minWidth: column.minWidth ? column.minWidth : '50px',
}"
/>
</template>
</template>
</colgroup>
<thead>
<template v-for="(
<template
v-for="(
tableHeadColumn, tableHeadColumnIndex
) in tableHeadColumns" :key="tableHeadColumnIndex">
) in tableHeadColumns"
:key="tableHeadColumnIndex"
>
<tr>
<template v-for="(column, columnIndex) in tableHeadColumn" :key="column">
<th v-if="tableColumnKeys.includes(column.key)" :colspan="column.colspan" :rowspan="column.rowspan"
class="layui-table-cell" :class="[
<template
v-for="(column, columnIndex) in tableHeadColumn"
:key="column"
>
<th
v-if="tableColumnKeys.includes(column.key)"
:colspan="column.colspan"
:rowspan="column.rowspan"
class="layui-table-cell"
:class="[
renderFixedClassName(column, columnIndex),
column.fixed
? `layui-table-fixed-${column.fixed}`
@ -901,19 +944,26 @@ window.addEventListener("click", heddin);
column.type == 'number'
? 'layui-table-cell-number'
: '',
]" :style="[
{
textAlign: column.align,
},
renderHeadFixedStyle(
column,
columnIndex,
tableHeadColumn
),
]">
]"
:style="[
{
textAlign: column.align,
},
renderHeadFixedStyle(
column,
columnIndex,
tableHeadColumn
),
]"
>
<template v-if="column.type == 'checkbox'">
<lay-checkbox v-model="hasChecked" :is-indeterminate="!allChecked" skin="primary" value="all"
@change="changeAll" />
<lay-checkbox
v-model="hasChecked"
:is-indeterminate="!allChecked"
skin="primary"
value="all"
@change="changeAll"
/>
</template>
<template v-else>
<span>
@ -925,16 +975,33 @@ window.addEventListener("click", heddin);
</template>
</span>
<!-- 插槽 -->
<span v-if="column.sort" class="layui-table-sort layui-inline" lay-sort>
<i @click.stop="sortTable($event, column.key, 'asc')" class="layui-edge layui-table-sort-asc"
title="升序"></i>
<i @click.stop="
sortTable($event, column.key, 'desc')
" class="layui-edge layui-table-sort-desc" title="降序"></i>
<span
v-if="column.sort"
class="layui-table-sort layui-inline"
lay-sort
>
<i
@click.stop="sortTable($event, column.key, 'asc')"
class="layui-edge layui-table-sort-asc"
title="升序"
></i>
<i
@click.stop="
sortTable($event, column.key, 'desc')
"
class="layui-edge layui-table-sort-desc"
title="降序"
></i>
</span>
<span v-if="column.soul" class="layui-table-sort layui-inline soul-icon">
<i class="soul-icon soul-box" :class="column.soulclass || 'soul-icon-filter'"
@click.stop="showsoul($event, column, column.key)">
<span
v-if="column.soul"
class="layui-table-sort layui-inline soul-icon"
>
<i
class="soul-icon soul-box"
:class="column.soulclass || 'soul-icon-filter'"
@click.stop="showsoul($event, column, column.key)"
>
<!-- <div v-show="column.soulshow" @click.stop="" class="soulbox">
11111
</div> -->
@ -950,29 +1017,61 @@ window.addEventListener("click", heddin);
</div>
</div>
<!-- 表身 -->
<div class="layui-table-body layui-table-main" :style="{ height: height, maxHeight: maxHeight }" ref="tableBody">
<table class="layui-table" v-if="datalist.length > 0 && loading == false"
:class="{ 'layui-table-even': props.even }" :lay-size="size" :lay-skin="skin">
<div
class="layui-table-body layui-table-main"
:style="{ height: height, maxHeight: maxHeight }"
ref="tableBody"
>
<table
class="layui-table"
v-if="datalist.length > 0 && loading == false"
:class="{ 'layui-table-even': props.even }"
:lay-size="size"
:lay-skin="skin"
>
<colgroup>
<template v-for="(column, columnIndex) in tableBodyColumns" :key="columnIndex">
<template
v-for="(column, columnIndex) in tableBodyColumns"
:key="columnIndex"
>
<template v-if="tableColumnKeys.includes(column.key)">
<col :width="column.width" :style="{
minWidth: column.minWidth ? column.minWidth : '50px',
}" />
<col
:width="column.width"
:style="{
minWidth: column.minWidth ? column.minWidth : '50px',
}"
/>
</template>
</template>
</colgroup>
<tbody>
<!-- 渲染 -->
<template v-for="(children, index) in datalist" :key="index">
<table-row :id="id" :index="index" :data="children" :columns="tableBodyColumns" :indent-size="indentSize"
:currentIndentSize="currentIndentSize" :tableColumnKeys="tableColumnKeys"
:expandSpace="childrenExpandSpace" :expandIndex="expandIndex" :cellStyle="cellStyle"
:cellClassName="cellClassName" :rowStyle="rowStyle" :rowClassName="rowClassName"
:spanMethod="spanMethod" :defaultExpandAll="defaultExpandAll" :getCheckboxProps="getCheckboxProps"
:getRadioProps="getRadioProps" v-model:expandKeys="tableExpandKeys"
v-model:selectedKeys="tableSelectedKeys" v-model:selectedKey="tableSelectedKey" @row="rowClick"
@row-double="rowDoubleClick" @row-contextmenu="rowContextmenu">
<table-row
:id="id"
:index="index"
:data="children"
:columns="tableBodyColumns"
:indent-size="indentSize"
:currentIndentSize="currentIndentSize"
:tableColumnKeys="tableColumnKeys"
:expandSpace="childrenExpandSpace"
:expandIndex="expandIndex"
:cellStyle="cellStyle"
:cellClassName="cellClassName"
:rowStyle="rowStyle"
:rowClassName="rowClassName"
:spanMethod="spanMethod"
:defaultExpandAll="defaultExpandAll"
:getCheckboxProps="getCheckboxProps"
:getRadioProps="getRadioProps"
v-model:expandKeys="tableExpandKeys"
v-model:selectedKeys="tableSelectedKeys"
v-model:selectedKey="tableSelectedKey"
@row="rowClick"
@row-double="rowDoubleClick"
@row-contextmenu="rowContextmenu"
>
<template v-for="name in slotsData" #[name]="{ data }">
<slot :name="name" :data="data"></slot>
</template>
@ -982,21 +1081,28 @@ window.addEventListener("click", heddin);
</table-row>
</template>
<tr v-if="hasTotalRow" class="layui-table-total">
<template v-for="(column, columnIndex) in columns" :key="columnIndex">
<template
v-for="(column, columnIndex) in columns"
:key="columnIndex"
>
<template v-if="tableColumnKeys.includes(column.key)">
<td :style="[
{
textAlign: column.align,
whiteSpace: column.ellipsisTooltip
? 'nowrap'
: 'normal',
},
renderFixedStyle(column, columnIndex),
]" :class="[
'layui-table-cell',
renderFixedClassName(column, columnIndex),
column.fixed ? `layui-table-fixed-${column.fixed}` : '',
]" v-html="renderTotalRowCell(column)"></td>
<td
:style="[
{
textAlign: column.align,
whiteSpace: column.ellipsisTooltip
? 'nowrap'
: 'normal',
},
renderFixedStyle(column, columnIndex),
]"
:class="[
'layui-table-cell',
renderFixedClassName(column, columnIndex),
column.fixed ? `layui-table-fixed-${column.fixed}` : '',
]"
v-html="renderTotalRowCell(column)"
></td>
</template>
</template>
</tr>
@ -1008,7 +1114,9 @@ window.addEventListener("click", heddin);
</template>
<template v-if="loading == true">
<div class="layui-table-loading">
<i class="layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>
<i
class="layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"
></i>
</div>
</template>
</div>
@ -1017,17 +1125,41 @@ window.addEventListener("click", heddin);
</div>
</div>
<div v-if="page && page.total > 0" class="layui-table-page">
<table-page :total="page.total" :pages="page.pages" :theme="page.theme" :limits="page.limits"
:showSkip="page.showSkip" :show-page="page.showPage" :showRefresh="page.showRefresh" :showLimit="page.showLimit"
:showCount="page.showCount" :count="page.count" v-model:current="page.current" v-model:limit="page.limit"
@change="change">
<table-page
:total="page.total"
:pages="page.pages"
:theme="page.theme"
:limits="page.limits"
:showSkip="page.showSkip"
:show-page="page.showPage"
:showRefresh="page.showRefresh"
:showLimit="page.showLimit"
:showCount="page.showCount"
:count="page.count"
v-model:current="page.current"
v-model:limit="page.limit"
@change="change"
>
</table-page>
</div>
</div>
<div v-for="(tableHeadColumn, tableHeadColumnIndex) in tableHeadColumns" :key="tableHeadColumnIndex">
<div
v-for="(tableHeadColumn, tableHeadColumnIndex) in tableHeadColumns"
:key="tableHeadColumnIndex"
>
<div v-for="(column, columnIndex) in tableHeadColumn" :key="column">
<soultable :top="soultop" :left="soulleft" v-show="soulkey == column.key" :show="soulkey == column.key" @asc="asc"
@desc="desc" @daochu="exportData" :list="datalist" :soulkey="column.key" @sx="sx"></soultable>
<soultable
:top="soultop"
:left="soulleft"
v-show="soulkey == column.key"
:show="soulkey == column.key"
@asc="asc"
@desc="desc"
@daochu="exportData"
:list="datalist"
:soulkey="column.key"
@sx="sx"
></soultable>
</div>
</div>
</div>

View File

@ -40,14 +40,14 @@ export interface TagInputProps {
size?: TagInputSize;
tagProps?: TagProps;
disabledInput?: boolean;
position?:string;
position?: string;
}
const props = withDefaults(defineProps<TagInputProps>(), {
placeholder: undefined,
minCollapsedNum: 0,
size: "md",
position:"top"
position: "top",
});
const emit = defineEmits([