diff --git a/src/components/TableModel/index.vue b/src/components/TableModel/index.vue index d072e38..0f02183 100644 --- a/src/components/TableModel/index.vue +++ b/src/components/TableModel/index.vue @@ -96,6 +96,7 @@ border ref="tableRef" select-on-indeterminate + style="width: 100%" > - + @@ -167,7 +175,15 @@ export default { }) }, }, - + watch: { + handleShow: { + handler(newValue) { + if (!newValue) { + this.dynamicWidth = 0 + } + }, + }, + }, data() { return { // 列表接口查询参数 @@ -180,8 +196,16 @@ export default { indexNumShow: true, // 是否显示操作列 handleShow: true, + // 列表每列 label columCheckList: [], - tableList: [], + // 列表数据源 + tableList: [ + { scrapNum: '测试' }, + { scrapNum: '123' }, + { scrapNum: '测试' }, + ], + // 操作列最小宽度 + dynamicWidth: 0, } }, @@ -197,7 +221,9 @@ export default { }) this.getTableList() }, - + updated() { + this.dynamicWidth = this.getOperatorWidth() + }, methods: { /** 获取列表数据 */ async getTableList() { @@ -217,6 +243,37 @@ export default { checkboxChange(list) { this.columCheckList = list }, + + /** 动态设置操作列的列宽 */ + getOperatorWidth() { + const operatorColumn = + document.getElementsByClassName('optionDivRef') + + // 默认宽度 + let width = 100 + // 内间距 + let paddingSpacing = 0 + // 按钮数量 + let buttonCount = 0 + + if (operatorColumn.length > 0) { + Array.prototype.forEach.call(operatorColumn, function (item) { + // 最宽的宽度 + width = width > item.offsetWidth ? width : item.offsetWidth + const buttons = item.getElementsByClassName('el-button') + buttonCount = buttons.length + buttonCount = + buttonCount > buttons.length + ? buttonCount + : buttons.length + }) + // 如果按钮数量大于2,宽度要加上边距*(按钮数量-1) + // if (buttonCount > 2) { + // width += paddingSpacing * (buttonCount - 1) + // } + return width + } + }, }, } @@ -234,4 +291,13 @@ export default { padding: 6px 18px; } } + +::v-deep .optionDivRef { + white-space: nowrap; + display: inline-block; + + .el-button { + padding: 6px 12px; + } +} diff --git a/src/router/index.js b/src/router/index.js index b35dc4f..0ad2ce4 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -83,6 +83,18 @@ export const constantRoutes = [ component: () => import('@/views/BasicManage/ContactUnits'), name: 'ContactUnits', meta: { title: '往来单位', icon: 'dashboard', affix: true } + }, + { + path: 'UnitType', + component: () => import('@/views/BasicManage/UnitType'), + name: 'UnitType', + meta: { title: '单位类型', icon: 'dashboard', affix: true } + }, + { + path: 'ProtocolManage', + component: () => import('@/views/BasicManage/ProtocolManage'), + name: 'ProtocolManage', + meta: { title: '协议管理', icon: 'dashboard', affix: true } } ] }, diff --git a/src/views/BasicManage/ContactUnits/components/form-contact-units.vue b/src/views/BasicManage/ContactUnits/components/form-contact-units.vue index 62ac463..773c929 100644 --- a/src/views/BasicManage/ContactUnits/components/form-contact-units.vue +++ b/src/views/BasicManage/ContactUnits/components/form-contact-units.vue @@ -1,4 +1,5 @@