表格增加宽高配置

lexmarn 3 years ago
parent d07f8f9e00
commit 95ac1cf6c2

@ -6,11 +6,12 @@
icon="el-icon-plus" icon="el-icon-plus"
plain plain
@click="handleAddClick" @click="handleAddClick"
>新增</el-button >新增</el-button
> >
<el-table :data="formData" style="width: 100%"> <el-table :data="formData" style="width: 100%">
<el-table-column prop="name" label="名称" width="80" /> <el-table-column prop="name" label="名称" width="60" />
<el-table-column prop="key" label="key值" width="80" /> <el-table-column prop="key" label="key值" width="70" />
<el-table-column prop="width" label="宽度" width="50" />
<el-table-column label="操作" width="100"> <el-table-column label="操作" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<div class="button-group"> <div class="button-group">
@ -18,13 +19,13 @@
@click="handleEditorClick(scope.$index, scope.row)" @click="handleEditorClick(scope.$index, scope.row)"
type="text" type="text"
size="small" size="small"
>编辑</el-button >编辑</el-button
> >
<el-button <el-button
type="text" type="text"
size="small" size="small"
@click="handleDeleteClick(scope.$index, scope.row)" @click="handleDeleteClick(scope.$index, scope.row)"
>删除</el-button >删除</el-button
> >
</div> </div>
</template> </template>
@ -54,11 +55,19 @@
> >
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="宽度:">
<el-input
v-model.trim="rowFormData['width']"
placeholder="请输入宽度"
size="mini"
>
</el-input>
</el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="mini" @click="dialogVisible = false"> </el-button> <el-button size="mini" @click="dialogVisible = false"> </el-button>
<el-button size="mini" type="primary" @click="handleSaveClick" <el-button size="mini" type="primary" @click="handleSaveClick"
> </el-button > </el-button
> >
</span> </span>
</el-dialog> </el-dialog>

@ -50,6 +50,14 @@ export const widgetTable = {
placeholder: '', placeholder: '',
value: '5' value: '5'
}, },
{
type: 'el-input-number',
label: '行高',
name: 'rowHeight',
required: false,
placeholder: '',
value: '50'
},
{ {
type: 'el-switch', type: 'el-switch',
label: '开启滚动', label: '开启滚动',
@ -172,10 +180,10 @@ export const widgetTable = {
name: 'dynamicAddTable', name: 'dynamicAddTable',
required: false, required: false,
placeholder: '', placeholder: '',
value: [{name: '日期', key: 'date', width: 200}, {name: '姓名', key: 'name', width: 200}, { value: [
name: '地址', {name: '日期', key: 'date', width: '50%'},
key: 'address', {name: '姓名', key: 'name', width: '50%'},
width: '200' {name: '地址', key: 'address', width: '200%',
}] }]
} }
], ],

@ -5,7 +5,7 @@
<div class="title"> <div class="title">
<div <div
v-for="(item, index) in header" v-for="(item, index) in header"
:style="headerTableStlye" :style="[headerTableStlye,tableFiledWidth(index),tableRowHeight()]"
:key="index" :key="index"
> >
{{ item.name }} {{ item.name }}
@ -14,11 +14,11 @@
<!--数据--> <!--数据-->
<div class="bd"> <div class="bd">
<ul class="infoList"> <ul class="infoList">
<li v-for="(item, index) in list" :key="index"> <li v-for="(item, index) in list" :key="index" :style="tableRowHeight()" >
<div <div
v-for="(itemChild, idx) in header" v-for="(itemChild, idx) in header"
:key="idx" :key="idx"
:style="[bodyTableStyle, bodyTable(index)]" :style="[bodyTableStyle, bodyTable(index),tableFiledWidth(idx),tableRowHeight()]"
> >
{{ item[itemChild.key] }} {{ item[itemChild.key] }}
</div> </div>
@ -48,7 +48,8 @@ export default {
autoPage: true, autoPage: true,
//effect: "top", //effect: "top",
autoPlay: true, autoPlay: true,
vis: 5 vis: 5,
rowHeight:'50px'
}, },
header: [], header: [],
list: [], list: [],
@ -172,15 +173,32 @@ export default {
}, },
// //
bodyTable(index) { bodyTable(index) {
var styleJson = {};
if (index % 2) { if (index % 2) {
return { styleJson["background-color"] = this.optionsSetUp.eventColor
"background-color": this.optionsSetUp.eventColor
};
} else { } else {
return { styleJson["background-color"] = this.optionsSetUp.oldColor
"background-color": this.optionsSetUp.oldColor
};
} }
return styleJson;
},
tableRowHeight(){
var styleJson = {};
if(this.optionsSetUp.rowHeight){
styleJson['height'] = this.optionsSetUp.rowHeight+'px';
styleJson['line-height'] = this.optionsSetUp.rowHeight+'px';
}else{
styleJson['height'] =this.options.rowHeight
styleJson['line-height'] = this.optionsSetUp.rowHeight+'px';
}
return styleJson;
},
tableFiledWidth(index){
var styleJson = {};
debugger
if(this.optionsSetUp.dynamicAddTable[index].width ){
styleJson["width"] = this.optionsSetUp.dynamicAddTable[index].width
}
return styleJson
} }
} }
}; };

Loading…
Cancel
Save