improve: tag优化; 接口地址处理;

This commit is contained in:
From-wh 2023-04-26 16:41:08 +08:00
parent da71e16f8d
commit 2434239cbd
5 changed files with 60 additions and 23 deletions

View File

@ -204,6 +204,15 @@ new Vue({
}
});
}
if (to.name == 'product_productAdd') {
let route = to.matched[1].path.split(':')[0];
this.$store.state.menus.oneLvRoutes.map((e) => {
if (route.indexOf(e.path) != -1) {
to.meta.title = `${e.title} ${to.params.id ? 'ID:' + to.params.id : ''}`;
}
});
}
},
},
});

View File

@ -1832,6 +1832,10 @@ export default {
return this.isMobile ? undefined : 15;
},
},
beforeRouteUpdate(to, from, next) {
this.bus.$emit('onTagsViewRefreshRouterView', this.$route.path);
next();
},
created() {
this.columns = this.columns2.slice(0, 8);
this.getToken();

View File

@ -39,7 +39,7 @@
<Cascader :data="menuList" change-on-select v-model="formValidate.path" filterable></Cascader>
</FormItem>
</Col>
<Col v-bind="grid" v-if="!authType">
<!-- <Col v-bind="grid" v-if="!authType">
<FormItem label="请求方式:" prop="methods">
<Select v-model="formValidate.methods">
<Option value="">请求</Option>
@ -49,15 +49,15 @@
<Option value="DELETE">DELETE</Option>
</Select>
</FormItem>
</Col>
<Col v-bind="grid" v-if="!authType">
</Col> -->
<!-- <Col v-bind="grid" v-if="!authType">
<FormItem label="接口地址:">
<Input v-model="formValidate.api_url" placeholder="请输入接口地址" prop="api_url"></Input>
</FormItem>
</Col>
</Col> -->
<Col v-bind="grid" v-show="authType">
<FormItem label="路由地址:" prop="menu_path">
<Input v-model="formValidate.menu_path" placeholder="请输入路由地址">
<Input v-model="formValidate.menu_path" placeholder="请输入路由地址" @on-change="changeUnique">
<template #prepend>
<span>{{ $routeProStr }}</span>
</template>
@ -80,7 +80,7 @@
</FormItem>
</Col>
<Col v-bind="grid">
<Col v-bind="grid" v-if="authType">
<FormItem label="排序:">
<Input type="number" v-model="formValidate.sort" placeholder="请输入排序" number></Input>
</FormItem>
@ -306,6 +306,12 @@ export default {
this.ruleModal = false;
}
},
changeUnique(val) {
console.log(val.target.value);
let value = this.$routeProStr + val.target.value;
if (value.slice(0, 1) === '/') value = value.replace('/', '');
this.formValidate.unique_auth = value.replaceAll('/', '-');
},
visible(type) {
if (!type) {
this.authType = true;

View File

@ -57,8 +57,8 @@
@on-change="onchangeIsShow(row)"
size="large"
>
<span slot="open">显示</span>
<span slot="close">隐藏</span>
<span slot="open">开启</span>
<span slot="close">关闭</span>
</i-switch>
</template>
</vxe-table-column>
@ -554,6 +554,9 @@ export default {
width: 200px;
overflow-y: scroll;
max-height: 600px;
/deep/ .el-tree-node__children .el-tree-node .el-tree-node__content {
padding-left: 14px !important;
}
}
}
</style>

View File

@ -31,10 +31,10 @@
<div></div>
<div
class="tree-node"
:class="{ node: slotProps.model.method, open: formValidate.id == slotProps.model.id }"
:class="{ node: slotProps.model.method, open: formValidate.path == slotProps.model.path }"
@click.stop="onClick(slotProps.model)"
>
<span class="" :class="{ open: formValidate.id == slotProps.model.id }">{{
<span class="" :class="{ open: formValidate.path == slotProps.model.path }">{{
slotProps.model.name
}}</span>
<Dropdown
@ -76,9 +76,9 @@
class="req-method"
:style="{
color: methodsColor(slotProps.model.method),
'font-weight': slotProps.model.id == formValidate.id ? '500' : '500',
'font-weight': slotProps.model.pid == formValidate.pid ? '500' : '500',
}"
>{{ slotProps.model.method == 'delete' ? 'DEL' : slotProps.model.method || '' }}</span
>{{ slotProps.model.method }}</span
>
<!-- <span v-if="slotProps.model.method"></span> -->
@ -241,7 +241,7 @@
<template #default="{ row }">
<vxe-button
type="text"
v-if="row.type === 'array'"
v-if="row.type === 'array' || row.type === 'object'"
status="primary"
@click="insertRow(row, 'xTable')"
>插入</vxe-button
@ -302,7 +302,7 @@
<template #default="{ row }">
<vxe-button
type="text"
v-if="row.type === 'array'"
v-if="row.type === 'array' || row.type === 'object'"
status="primary"
@click="insertRow(row, 'resTable')"
>插入</vxe-button
@ -347,10 +347,11 @@
keep-source
ref="codeTable"
row-id="id"
is-tree-view
:print-config="{}"
:export-config="{}"
:loading="loading"
:tree-config="{ transform: true, rowField: 'id', parentField: 'parentId' }"
:tree-config="{ rowField: 'id', parentField: 'parentId' }"
:data="formValidate.error_code"
>
<!-- <vxe-column type="checkbox" width="60"></vxe-column> -->
@ -625,10 +626,17 @@ export default {
res.data[0].expand = false;
this.treeData = new Tree(res.data);
this.$nextTick((e) => {
if (disk_type) document.querySelectorAll('.vtl-icon-caret-right')[0].click();
if (disk_type) {
if (res.data[0].children[0].children.length) {
document.querySelectorAll('.vtl-icon-caret-right')[0].click();
document.querySelectorAll('.vtl-icon-caret-right')[1].click();
} else {
document.querySelectorAll('.vtl-icon-caret-right')[0].click();
}
}
});
if (res.data[0].children && res.data[0].children.length) {
this.onClick(res.data[0].children[0]);
this.onClick(res.data[0]?.children[0]?.children[0]);
}
}
})
@ -668,6 +676,7 @@ export default {
} else if (!this.formValidate.path) {
return this.$Message.warning('请输入路由地址');
}
console.log(await this.$refs.xTable.getTableData());
this.formValidate.request = await this.$refs.xTable.getTableData().tableData;
this.formValidate.response = await this.$refs.resTable.getTableData().tableData;
this.formValidate.error_code = await this.$refs.codeTable.getTableData().tableData;
@ -1015,7 +1024,8 @@ export default {
.req-method {
display:block;
padding: 0px 2px;
font-size: 12px;
font-size: 13px;
line-height: 13px;
margin-right: 5px;
border-radius: 4px;
@ -1031,7 +1041,7 @@ export default {
padding: 3px 7px 3px 0;
}
.node{
padding:7px 2px 7px 0px;
padding:4px 2px 4px 0px;
}
.open {
// background-color: #fff1ef;
@ -1064,8 +1074,8 @@ export default {
justify-content: center;
align-items: center;
border-radius: 50%;
width: 20px;
height: 20px;
width: 18px;
height: 18px;
}
>>> .vtl-node-content:hover .add:hover {
@ -1134,12 +1144,17 @@ export default {
width: 100% !important;
}
>>> .vtl-tree-margin{
margin-left: 5px;
margin-left: 15px;
}
>>> .ivu-btn-icon-only.ivu-btn-small {
width: 28px;
}
>>> .tree-node > span{
font-size: 14px
}
>>> .tree-node.node > span{
font-size: 13px
}
.nothing {
display: flex;
align-items: center;