From 7d8d70497d1215fb7c317f2b3fce115645f3882a Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 16 Aug 2022 14:29:57 +0800 Subject: [PATCH] =?UTF-8?q?style(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E6=96=87=E6=A1=A3=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=EF=BC=8C=E6=B2=A1=E6=9C=89=E9=AB=98=E7=BA=A7=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E7=9A=84=E8=A1=8C=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 接口测试文档表格,没有高级选项的行不显示展开按钮 --- .../document/components/ApiInfoCollapse.vue | 40 ++++++++++++++++++- .../document/components/ApiRequestInfo.vue | 39 +++++++++++++++++- .../plugin/TableAdvancedSetting.vue | 6 +-- 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue b/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue index 1969746ce4..7db961eed5 100644 --- a/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue +++ b/frontend/src/business/components/api/definition/components/document/components/ApiInfoCollapse.vue @@ -36,7 +36,7 @@
- { this.tableData.forEach(i => { - this.$refs.expandTable.toggleRowExpansion(i, expand) + if (i.hasAdvancedSetting) { + this.$refs.expandTable.toggleRowExpansion(i, expand) + } }); this.$refs.expandTable.doLayout(); }) @@ -146,6 +148,30 @@ export default { } }, methods: { + getRowClassName({row, rowIndex}) { + let classname = 'autofix-table-row '; + // 通过判断给不需要展开行功能的数据设置样式,通过样式去隐藏展开行图标 + if (!row.hasAdvancedSetting) { + classname += ' hide-expand' + } + return classname; + }, + isNotEmptyValue(value) { + return value && value !== ''; + }, + rowHasAdvancedSetting(tableData) { + let hasAdvancedSetting = false; + if (this.isNotEmptyValue(tableData['min'])) { + hasAdvancedSetting = true; + } else if (this.isNotEmptyValue(tableData['max'])) { + hasAdvancedSetting = true; + } else if (tableData['urlEncode']) { + hasAdvancedSetting = true; + } else if (this.isNotEmptyValue(tableData['description'])) { + hasAdvancedSetting = true; + } + return hasAdvancedSetting; + }, getTableClass() { if (this.language === "zh_TW") { return "test-content document-table tw-table"; @@ -182,6 +208,11 @@ export default { item.isRequired = "false"; } item.id = getUUID(); + if (this.rowHasAdvancedSetting(item)) { + item.hasAdvancedSetting = true; + } else { + item.hasAdvancedSetting = false; + } returnJsonArr.push(item); } } @@ -256,6 +287,11 @@ export default { border-right: 0px solid #EBEEF5 } +/*通过样式隐藏图标*/ +.document-table /deep/ .hide-expand .el-table__expand-column .cell { + visibility: hidden; +} + /*展开按钮未点击的样式是加号带边框*/ .cn-table /deep/ .el-table__expand-icon .el-icon-arrow-right:before { position: unset; diff --git a/frontend/src/business/components/api/definition/components/document/components/ApiRequestInfo.vue b/frontend/src/business/components/api/definition/components/document/components/ApiRequestInfo.vue index f6bba4d54d..697e1c99aa 100644 --- a/frontend/src/business/components/api/definition/components/document/components/ApiRequestInfo.vue +++ b/frontend/src/business/components/api/definition/components/document/components/ApiRequestInfo.vue @@ -3,6 +3,7 @@
{ this.tableData.forEach(i => { - this.$refs.expandTable.toggleRowExpansion(i, expand) + if (i.hasAdvancedSetting) { + this.$refs.expandTable.toggleRowExpansion(i, expand) + } }); this.$refs.expandTable.doLayout(); }) @@ -127,6 +130,30 @@ export default { } }, methods: { + getRowClassName({row, rowIndex}) { + let classname = 'autofix-table-row '; + // 通过判断给不需要展开行功能的数据设置样式,通过样式去隐藏展开行图标 + if (!row.hasAdvancedSetting) { + classname += ' hide-expand'; + } + return classname; + }, + isNotEmptyValue(value) { + return value && value !== ''; + }, + rowHasAdvancedSetting(tableData) { + let hasAdvancedSetting = false; + if (this.isNotEmptyValue(tableData['min'])) { + hasAdvancedSetting = true; + } else if (this.isNotEmptyValue(tableData['max'])) { + hasAdvancedSetting = true; + } else if (tableData['urlEncode']) { + hasAdvancedSetting = true; + } else if (this.isNotEmptyValue(tableData['description'])) { + hasAdvancedSetting = true; + } + return hasAdvancedSetting; + }, getTableClass() { if (this.language === "zh_TW") { return "test-content document-table tw-table"; @@ -174,6 +201,11 @@ export default { var item = jsonArr[index]; if (item.name !== "" && item.name !== null) { item.id = getUUID(); + if (this.rowHasAdvancedSetting(item)) { + item.hasAdvancedSetting = true; + } else { + item.hasAdvancedSetting = false; + } returnJsonArr.push(item); } } @@ -245,6 +277,11 @@ export default { border-right: 0px solid #EBEEF5 } +/*通过样式隐藏图标*/ +.document-table /deep/ .hide-expand .el-table__expand-column .cell { + visibility: hidden; +} + /*修改展开按钮时不旋转*/ .document-table /deep/ .el-table__expand-icon { -webkit-transform: rotate(0deg); diff --git a/frontend/src/business/components/api/definition/components/document/components/plugin/TableAdvancedSetting.vue b/frontend/src/business/components/api/definition/components/document/components/plugin/TableAdvancedSetting.vue index aea3051412..1c816eeaa4 100644 --- a/frontend/src/business/components/api/definition/components/document/components/plugin/TableAdvancedSetting.vue +++ b/frontend/src/business/components/api/definition/components/document/components/plugin/TableAdvancedSetting.vue @@ -34,16 +34,16 @@ export default { initAdvancedValue() { if (this.tableData) { this.advancedValue = {}; - if (this.tableData["min"] && this.isNotEmptyValue(this.tableData["min"])) { + if (this.isNotEmptyValue(this.tableData["min"])) { this.advancedValue["schema.minLength"] = this.tableData["min"]; } - if (this.tableData["max"] && this.isNotEmptyValue(this.tableData["max"])) { + if (this.isNotEmptyValue(this.tableData["max"])) { this.advancedValue["schema.maxLength"] = this.tableData["max"]; } if (this.tableData["urlEncode"]) { this.advancedValue["commons.encode"] = this.$t("commons.yes"); } - if (this.tableData["description"] && this.isNotEmptyValue(this.tableData["description"])) { + if (this.isNotEmptyValue(this.tableData["description"])) { this.advancedValue["commons.description"] = this.tableData["description"]; } if (JSON.stringify(this.advancedValue) === "{}") {