lcw
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<!-- input表单 input-->
|
||||
<MOSTY.Other v-if="item.type == 'input'" width="100%" clearable v-model="listQuery[item.prop]" :placeholder="`请输入${item.label}`" :disabled="item.disabled" :readonly="item.readonly" />
|
||||
|
||||
<el-input v-model="listQuery[item.prop]" v-else-if="item.type == 'textarea'" type="textarea" :rows="3" :placeholder="`请输入${item.label}`" :disabled="item.disabled" />
|
||||
<el-input v-model="listQuery[item.prop]" v-else-if="item.type == 'textarea'" type="textarea" :rows="item.rows || 3" :placeholder="`请输入${item.label}`" :disabled="item.disabled" />
|
||||
<!-- 数值 inputNumber-->
|
||||
<el-input type="number" v-model="listQuery[item.prop]" v-else-if="item.type == 'inputNumber'" :placeholder="`请输入${item.label}`" :disabled="item.disabled" />
|
||||
<!-- 数值 number-->
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
<template>
|
||||
<div style="width: 100%" :class="getConfiger.showSelectType === 'radio' ? 'tabBoxRadio' : ''">
|
||||
|
||||
|
||||
<!-- hasChildren要在tableData中定义表示当前行有没有下一级 children要在tableData中定义表示下一级的数据-->
|
||||
<el-table ref="multipleTableRef" :data="tableData" @selection-change="handleSelectionChange"
|
||||
:row-key="getConfiger.rowKey" :border="getConfiger.border" :default-expand-all="getConfiger.defaultExpandAll"
|
||||
:stripe="getConfiger.stripe" :height="tableHeight" v-loading="tableConfiger.loading" :lazy="getConfiger.lazy"
|
||||
:load="load" :tree-props="treePros" style="width: 100%" :header-cell-class-name="() => 'HeadBgColor'"
|
||||
:highlight-current-row="getConfiger.showSelectType === 'radio'"
|
||||
:row-style="{ height: getConfiger.rowHeight === 'auto' ? getConfiger.rowHeight : getConfiger.rowHeight + 'px' }">
|
||||
:row-style="(row, index) => getRowStyle(row, index)"
|
||||
:row-class-name="(row, index) => getRowClassName(row, index)">
|
||||
|
||||
|
||||
<!-- 修改v-if条件,让showSelectType为null时也能显示选择列,默认为复选框 -->
|
||||
<el-table-column style="width: 55px" type="selection" width="55" v-if="getConfiger.showSelectType !='null'" :class="getConfiger.showSelectType === 'radio' ? 'tabBoxRadio' : ''" />
|
||||
|
||||
<el-table-column style="width: 55px" type="selection" width="55" v-if="getConfiger.showSelectType != 'null'"
|
||||
:class="getConfiger.showSelectType === 'radio' ? 'tabBoxRadio' : ''" />
|
||||
<el-table-column type="expand" v-if="expand">
|
||||
<template #default="props">
|
||||
<slot name="expand" :props="props.row"></slot>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="index" label="序号" v-if="getConfiger.showIndex" width="60" :align="getConfiger?.align" />
|
||||
|
||||
<el-table-column v-for="(item, index) in tableColumn" :align="getConfiger?.align" :prop="item.prop" :key="index"
|
||||
@ -18,7 +27,6 @@
|
||||
:show-overflow-tooltip="item.showOverflowTooltip || false" :sortable="item.sortable || false">
|
||||
<!-- 使用自定义 -->
|
||||
<template v-if="item.showSolt" #default="scope">
|
||||
|
||||
<slot :name="item.prop" v-bind="scope"></slot>
|
||||
</template>
|
||||
<!-- 默认 -->
|
||||
@ -72,6 +80,18 @@ const props = defineProps({
|
||||
fixed: {
|
||||
type: String,
|
||||
default: "right"
|
||||
},
|
||||
expand: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
rowStyle: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
rowClassName: {
|
||||
type: Function,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
// 可选的时候选择的数据
|
||||
@ -133,6 +153,30 @@ const load = (date, treeNode, resolve) => {
|
||||
]);
|
||||
}, 1000);
|
||||
};
|
||||
// 获取行样式
|
||||
const getRowStyle = (row, index) => {
|
||||
// 基础行高样式
|
||||
const baseStyle = { height: getConfiger.rowHeight === 'auto' ? getConfiger.rowHeight : getConfiger.rowHeight + 'px' };
|
||||
|
||||
// 如果有自定义行样式函数,合并样式
|
||||
if (props.rowStyle) {
|
||||
const customStyle = props.rowStyle(row, index);
|
||||
return { ...baseStyle, ...customStyle };
|
||||
}
|
||||
|
||||
return baseStyle;
|
||||
};
|
||||
|
||||
// 获取行类名
|
||||
const getRowClassName = (row, index) => {
|
||||
// 如果有自定义行类名函数,使用它
|
||||
if (props.rowClassName) {
|
||||
return props.rowClassName(row, index);
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
// 设置默认选中(在调用的父页面要确保 tableData传出来了如果延迟传过来默认选中不会生效)
|
||||
function setDefaultChoose() {
|
||||
nextTick(() => {
|
||||
@ -160,5 +204,4 @@ function setDefaultChoose() {
|
||||
.tabBoxRadio .el-table__header-wrapper .el-checkbox {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user