style:table组件的完善自适应头部高度。进度查询的修改
Showing
7 changed files
with
95 additions
and
34 deletions
| ... | @@ -10,13 +10,13 @@ | ... | @@ -10,13 +10,13 @@ |
| 10 | 10 | ||
| 11 | <template> | 11 | <template> |
| 12 | <div :class="['lb-table', customClass]"> | 12 | <div :class="['lb-table', customClass]"> |
| 13 | <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable" | 13 | <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable" :border='border' |
| 14 | :border='border' :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection" | 14 | :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection" v-bind="$attrs" |
| 15 | :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners" | 15 | :height="tableHeight" v-on="$listeners" :data="data" style="width: 100%" |
| 16 | :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod"> | 16 | :span-method="this.merge ? this.mergeMethod : this.spanMethod"> |
| 17 | <el-table-column width="45" align="center" v-if="isRadio"> | 17 | <el-table-column width="45" align="center" v-if="isRadio"> |
| 18 | <template slot-scope="scope"> | 18 | <template slot-scope="scope"> |
| 19 | <el-radio v-model="selected" :label="scope.$index" class="table-radio"></el-radio> | 19 | <el-radio v-model="selected" :label="scope.$index"></el-radio> |
| 20 | </template> | 20 | </template> |
| 21 | </el-table-column> | 21 | </el-table-column> |
| 22 | 22 | ||
| ... | @@ -24,14 +24,14 @@ | ... | @@ -24,14 +24,14 @@ |
| 24 | </lb-column> | 24 | </lb-column> |
| 25 | </el-table> | 25 | </el-table> |
| 26 | 26 | ||
| 27 | <el-table v-else ref="elTable" class="table-fixed" :row-style="{ height: '50px' }" :border='border' | 27 | <el-table v-else ref="elTable" id="heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" |
| 28 | :row-class-name="tableRowClassName" :show-header='showHeader' | 28 | :border='border' :row-class-name="tableRowClassName" :show-header='showHeader' v-bind="$attrs" |
| 29 | :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight" | 29 | :max-height="maxHeight" :height="tableHeight" v-on="$listeners" :data="data" style="width: 100%" |
| 30 | v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod"> | 30 | :span-method="this.merge ? this.mergeMethod : this.spanMethod"> |
| 31 | 31 | ||
| 32 | <el-table-column width="45" align="center" v-if="isRadio"> | 32 | <el-table-column width="45" align="center" v-if="isRadio"> |
| 33 | <template slot-scope="scope"> | 33 | <template slot-scope="scope"> |
| 34 | <el-radio v-model="selected" :label="scope.$index" class="table-radio"></el-radio> | 34 | <el-radio v-model="selected" :label="scope.$index"></el-radio> |
| 35 | </template> | 35 | </template> |
| 36 | </el-table-column> | 36 | </el-table-column> |
| 37 | <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item"> | 37 | <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item"> |
| ... | @@ -40,7 +40,7 @@ | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | ||
| 41 | <br> | 41 | <br> |
| 42 | <el-pagination class="lb-table-pagination" v-if="pagination" v-bind="$attrs" v-on="$listeners" background | 42 | <el-pagination class="lb-table-pagination" v-if="pagination" v-bind="$attrs" v-on="$listeners" background |
| 43 | :page-sizes="[10, 20, 50, 100]" layout="total, sizes, prev, pager, next" @current-change="paginationCurrentChange" | 43 | layout="total, prev, pager, next" @current-change="paginationCurrentChange" |
| 44 | :style="{ 'margin-top': paginationTop, 'text-align': paginationAlign }"> | 44 | :style="{ 'margin-top': paginationTop, 'text-align': paginationAlign }"> |
| 45 | </el-pagination> | 45 | </el-pagination> |
| 46 | </div> | 46 | </div> |
| ... | @@ -63,7 +63,7 @@ export default { | ... | @@ -63,7 +63,7 @@ export default { |
| 63 | }, | 63 | }, |
| 64 | border: { | 64 | border: { |
| 65 | type: Boolean, | 65 | type: Boolean, |
| 66 | default: true, | 66 | default: false, |
| 67 | }, | 67 | }, |
| 68 | showHeader: { | 68 | showHeader: { |
| 69 | type: Boolean, | 69 | type: Boolean, |
| ... | @@ -75,12 +75,16 @@ export default { | ... | @@ -75,12 +75,16 @@ export default { |
| 75 | }, | 75 | }, |
| 76 | heightNum: { | 76 | heightNum: { |
| 77 | type: Number, | 77 | type: Number, |
| 78 | default: 265, | 78 | default: 355, |
| 79 | }, | 79 | }, |
| 80 | maxHeight: { | 80 | maxHeight: { |
| 81 | type: Number, | 81 | type: Number, |
| 82 | default: 500 | 82 | default: 500 |
| 83 | }, | 83 | }, |
| 84 | minHeight: { | ||
| 85 | type: Number, | ||
| 86 | default: undefined | ||
| 87 | }, | ||
| 84 | heightNumSetting: { | 88 | heightNumSetting: { |
| 85 | type: Boolean, | 89 | type: Boolean, |
| 86 | default: false, | 90 | default: false, |
| ... | @@ -93,6 +97,10 @@ export default { | ... | @@ -93,6 +97,10 @@ export default { |
| 93 | type: String, | 97 | type: String, |
| 94 | default: 'left', | 98 | default: 'left', |
| 95 | }, | 99 | }, |
| 100 | calcHeight: { | ||
| 101 | type: Number, | ||
| 102 | default: 170 | ||
| 103 | }, | ||
| 96 | merge: Array, | 104 | merge: Array, |
| 97 | }, | 105 | }, |
| 98 | components: { | 106 | components: { |
| ... | @@ -100,7 +108,7 @@ export default { | ... | @@ -100,7 +108,7 @@ export default { |
| 100 | }, | 108 | }, |
| 101 | data () { | 109 | data () { |
| 102 | return { | 110 | return { |
| 103 | tableHeight: '', | 111 | tableHeight: 'auto', |
| 104 | mergeLine: {}, | 112 | mergeLine: {}, |
| 105 | mergeIndex: {}, | 113 | mergeIndex: {}, |
| 106 | selected: '' | 114 | selected: '' |
| ... | @@ -128,8 +136,63 @@ export default { | ... | @@ -128,8 +136,63 @@ export default { |
| 128 | }, | 136 | }, |
| 129 | getHeight () { | 137 | getHeight () { |
| 130 | if (!this.heightNumSetting) { | 138 | if (!this.heightNumSetting) { |
| 131 | this.tableHeight = window.innerHeight - this.heightNum | 139 | let _this = this |
| 140 | if (this.heightNum) { | ||
| 141 | _this.$nextTick(() => { | ||
| 142 | if (document.querySelector(".tags-view-container")) { | ||
| 143 | window.addEventListener('resize', () => { | ||
| 144 | if (_this.calcHeight == 230) { | ||
| 145 | _this.tableHeight = _this.calcHeightx(192) | ||
| 146 | } else { | ||
| 147 | _this.tableHeight = _this.calcHeightx(_this.calcHeight) | ||
| 132 | } | 148 | } |
| 149 | }); | ||
| 150 | if (_this.calcHeight == 230) { | ||
| 151 | _this.tableHeight = _this.calcHeightx(192) | ||
| 152 | } else { | ||
| 153 | _this.tableHeight = _this.calcHeightx(_this.calcHeight) | ||
| 154 | } | ||
| 155 | } else { | ||
| 156 | window.addEventListener('resize', () => { | ||
| 157 | _this.tableHeight = _this.calcHeightx(_this.calcHeight) | ||
| 158 | }); | ||
| 159 | _this.tableHeight = _this.calcHeightx(_this.calcHeight) | ||
| 160 | } | ||
| 161 | }) | ||
| 162 | } else { | ||
| 163 | _this.tableHeight = window.innerHeight - _this.heightNum | ||
| 164 | } | ||
| 165 | } else { | ||
| 166 | this.tableHeight = this.heightNum | ||
| 167 | this.$nextTick(() => { | ||
| 168 | this.minHeight && (document.getElementById('heightNumSetting').style.minHeight = this.minHeight + 'px') | ||
| 169 | }) | ||
| 170 | } | ||
| 171 | }, | ||
| 172 | calcHeightx (value, wappered = true) { | ||
| 173 | //项目自定义的公共header部分的高度,可忽略 | ||
| 174 | let header = document.querySelector(".from-clues-header").offsetHeight; | ||
| 175 | |||
| 176 | //value为动态计算table界面高度时,减去的其他空白部分,需自行在调试找到临界值,剩下的就是table表格的高度(包含header+body部分) | ||
| 177 | value = value == undefined ? 100 : value; | ||
| 178 | if (document.querySelector(".tags-view-container")) { | ||
| 179 | let tagsView = document.querySelector(".tags-view-container").offsetHeight; | ||
| 180 | var res = window.innerHeight - parseInt(header) - value - parseInt(tagsView); | ||
| 181 | } else { | ||
| 182 | var res = window.innerHeight - parseInt(header) - value; | ||
| 183 | } | ||
| 184 | if (wappered) { | ||
| 185 | //通过原生方法,获取dom节点的高度------获取element-ui table表格body的元素 | ||
| 186 | let wapper = window.document.getElementsByClassName('el-table__body-wrapper'); | ||
| 187 | //通过原生方法,获取dom节点的高度------获取element-ui table表格header的元素 | ||
| 188 | let header = window.document.getElementsByClassName('el-table__header-wrapper'); | ||
| 189 | //必须加延时,要不然赋不上去值 | ||
| 190 | setTimeout(() => { | ||
| 191 | //通过上边计算得到的table高度的value值,减去table表格的header高度,剩下的通过dom节点直接强行赋给table表格的body | ||
| 192 | wapper[0].style.height = (value - header[0].clientHeight) | ||
| 193 | }, 100) | ||
| 194 | } | ||
| 195 | return res; | ||
| 133 | }, | 196 | }, |
| 134 | clearSelection () { | 197 | clearSelection () { |
| 135 | this.$refs.elTable.clearSelection() | 198 | this.$refs.elTable.clearSelection() |
| ... | @@ -220,13 +283,7 @@ export default { | ... | @@ -220,13 +283,7 @@ export default { |
| 220 | padding-right: 3px; | 283 | padding-right: 3px; |
| 221 | } | 284 | } |
| 222 | 285 | ||
| 223 | .table-radio { | 286 | /deep/.el-radio__label { |
| 224 | /deep/.el-radio__label { | ||
| 225 | display: none; | 287 | display: none; |
| 226 | } | ||
| 227 | } | ||
| 228 | |||
| 229 | /deep/.el-radio { | ||
| 230 | margin-right: 5px !important; | ||
| 231 | } | 288 | } |
| 232 | </style> | 289 | </style> | ... | ... |
| 1 | <!-- | ||
| 2 | * @Description: | ||
| 3 | * @Autor: renchao | ||
| 4 | * @LastEditTime: 2023-04-26 16:05:28 | ||
| 5 | --> | ||
| 1 | <template> | 6 | <template> |
| 2 | <div class='batchDel'> | 7 | <div class='batchDel'> |
| 3 | <lb-table :column="columns" :data="formData.dataList" :maxHeight="460" :heightNumSetting="true" :pagination="false" | 8 | <lb-table :column="columns" :data="formData.dataList" :maxHeight="460" :heightNumSetting="true" :pagination="false" | ... | ... |
| ... | @@ -53,10 +53,10 @@ | ... | @@ -53,10 +53,10 @@ |
| 53 | </el-select> | 53 | </el-select> |
| 54 | <el-table :data="taskCommentList" size="mini" border header-cell-class-name="table-header-gray"> | 54 | <el-table :data="taskCommentList" size="mini" border header-cell-class-name="table-header-gray"> |
| 55 | <el-table-column label="序号" header-align="center" align="center" type="index" width="55px" /> | 55 | <el-table-column label="序号" header-align="center" align="center" type="index" width="55px" /> |
| 56 | <el-table-column label="环节名称" prop="taskName" minWidth="150px" align="center" /> | 56 | <el-table-column label="环节名称" prop="taskName" minWidth="150" align="center" /> |
| 57 | <el-table-column label="办理人" prop="assigneeName" minWidth="100px" align="center" /> | 57 | <el-table-column label="办理人" prop="assigneeName" minWidth="100" align="center" /> |
| 58 | <el-table-column label="处理时间" prop="createTime" width="140px" align="center" /> | 58 | <el-table-column label="处理时间" prop="createTime" width="160" align="center" /> |
| 59 | <el-table-column label="办结时间" prop="finishTime" width="140px" align="center" /> | 59 | <el-table-column label="办结时间" prop="finishTime" width="160" align="center" /> |
| 60 | <el-table-column label="操作方式" align="center"> | 60 | <el-table-column label="操作方式" align="center"> |
| 61 | </el-table-column> | 61 | </el-table-column> |
| 62 | </el-table> | 62 | </el-table> | ... | ... |
| ... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
| 16 | <span class="iconName">{{ item.name }}</span> | 16 | <span class="iconName">{{ item.name }}</span> |
| 17 | </li> | 17 | </li> |
| 18 | </ul> | 18 | </ul> |
| 19 | <NoticeBar class="NoticeBar" :noticeList="noticeList" /> | 19 | <NoticeBar class="NoticeBar" :noticeList="noticeList" v-if="noticeList.length > 0" /> |
| 20 | </div> | 20 | </div> |
| 21 | <!-- 内容框架 --> | 21 | <!-- 内容框架 --> |
| 22 | <div class="containerFrame"> | 22 | <div class="containerFrame"> | ... | ... |
| ... | @@ -13,10 +13,10 @@ | ... | @@ -13,10 +13,10 @@ |
| 13 | <ul> | 13 | <ul> |
| 14 | <li @click="operation(item)" v-for="(item, index) in rightButtonList" :key="index"> | 14 | <li @click="operation(item)" v-for="(item, index) in rightButtonList" :key="index"> |
| 15 | <svg-icon class="icon" :icon-class="item.icon" /> | 15 | <svg-icon class="icon" :icon-class="item.icon" /> |
| 16 | <span class="iconName">{{ item.name }} {{item.value }}</span> | 16 | <span class="iconName">{{ item.name }} {{ item.value }}</span> |
| 17 | </li> | 17 | </li> |
| 18 | </ul> | 18 | </ul> |
| 19 | <NoticeBar class="NoticeBar" :noticeList="noticeList" /> | 19 | <NoticeBar class="NoticeBar" :noticeList="noticeList" v-if="noticeList.length > 0" /> |
| 20 | </div> | 20 | </div> |
| 21 | <!-- 内容框架 --> | 21 | <!-- 内容框架 --> |
| 22 | <div class="containerFrame"> | 22 | <div class="containerFrame"> | ... | ... |
| ... | @@ -86,9 +86,8 @@ | ... | @@ -86,9 +86,8 @@ |
| 86 | </div> | 86 | </div> |
| 87 | <div class="from-clues-content"> | 87 | <div class="from-clues-content"> |
| 88 | <lb-table :page-size="pageData.size" class="loadingtext" @sort-change="handleSort" | 88 | <lb-table :page-size="pageData.size" class="loadingtext" @sort-change="handleSort" |
| 89 | :current-page.sync="pageData.currentPage" :heightNum="335" :total="tableData.total" | 89 | :current-page.sync="pageData.currentPage" :total="tableData.total" @size-change="handleSizeChange" |
| 90 | @size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns" | 90 | @p-current-change="handleCurrentChange" :column="tableData.columns" :data="tableData.data"> |
| 91 | :data="tableData.data"> | ||
| 92 | </lb-table> | 91 | </lb-table> |
| 93 | </div> | 92 | </div> |
| 94 | <searchBox v-model="isSearch" @getSearch="getSearch" :advancedForm="otherForm" /> | 93 | <searchBox v-model="isSearch" @getSearch="getSearch" :advancedForm="otherForm" /> | ... | ... |
| ... | @@ -2,10 +2,10 @@ | ... | @@ -2,10 +2,10 @@ |
| 2 | <div class="from-clues"> | 2 | <div class="from-clues"> |
| 3 | <!-- 表单部分 --> | 3 | <!-- 表单部分 --> |
| 4 | <div class="from-clues-header"> | 4 | <div class="from-clues-header"> |
| 5 | <el-form :model="queryForm" ref="queryForm" @submit.native.prevent label-width="80px"> | 5 | <el-form :model="queryForm" ref="queryForm" @submit.native.prevent label-width="100px"> |
| 6 | <el-row> | 6 | <el-row> |
| 7 | <el-col :span="5"> | 7 | <el-col :span="5"> |
| 8 | <el-form-item label="业务来源" label-width="70px"> | 8 | <el-form-item label="业务来源"> |
| 9 | <el-select v-model="queryForm.ywly" class="width100" filterable clearable placeholder="请选择业务来源"> | 9 | <el-select v-model="queryForm.ywly" class="width100" filterable clearable placeholder="请选择业务来源"> |
| 10 | <el-option v-for="item in dictData['ywly']" :key="item.dcode" :label="item.dname" :value="item.dcode"> | 10 | <el-option v-for="item in dictData['ywly']" :key="item.dcode" :label="item.dname" :value="item.dcode"> |
| 11 | </el-option> | 11 | </el-option> | ... | ... |
-
Please register or sign in to post a comment