From 26480bc2132d95023331d7bb8d04b48471b8b6ce Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Thu, 8 Aug 2024 10:44:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E5=AE=8C=E5=96=84=EF=BC=8C=E5=8D=8F=E8=AE=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E7=B1=BB=E5=9E=8B=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TableModel/index.vue | 76 ++++++++- src/router/index.js | 12 ++ .../components/form-contact-units.vue | 2 + src/views/BasicManage/ContactUnits/index.vue | 1 + .../ProjectManage/components/form-project.vue | 2 + src/views/BasicManage/ProjectManage/config.js | 3 - src/views/BasicManage/ProjectManage/index.vue | 5 + .../components/form-protocol.vue | 160 ++++++++++++++++++ .../BasicManage/ProtocolManage/config.js | 26 +++ .../BasicManage/ProtocolManage/index.vue | 59 ++++++- .../UnitType/components/form-units-type.vue | 80 +++++++++ src/views/BasicManage/UnitType/config.js | 14 ++ src/views/BasicManage/UnitType/index.vue | 58 ++++++- 13 files changed, 482 insertions(+), 16 deletions(-) create mode 100644 src/views/BasicManage/ProtocolManage/components/form-protocol.vue create mode 100644 src/views/BasicManage/ProtocolManage/config.js create mode 100644 src/views/BasicManage/UnitType/components/form-units-type.vue create mode 100644 src/views/BasicManage/UnitType/config.js 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 @@