Merge branch 'dev' into pr@dev_memory_component

This commit is contained in:
dataeaseShu 2023-02-08 15:38:47 +08:00
commit cb489518c7
3 changed files with 44 additions and 46 deletions

View File

@ -365,7 +365,7 @@ export default {
if (result !== 'success' && result !== 'fail') { if (result !== 'success' && result !== 'fail') {
window.location.href = result window.location.href = result
} else { } else {
this.$router.push('/login') this.$router.push(`/login?redirect=${this.$route.fullPath}`)
} }
}, },
loadUiInfo() { loadUiInfo() {

View File

@ -118,8 +118,7 @@ router.beforeEach(async(to, from, next) => routeBefore(() => {
next() next()
} else { } else {
// other pages that do not have permission to access are redirected to the login page. // other pages that do not have permission to access are redirected to the login page.
// next(`/login?redirect=${to.path}`) next(`/login?redirect=${to.path}`)
next('/login')
NProgress.done() NProgress.done()
} }
} }

View File

@ -7,7 +7,6 @@
<div class="container-wrapper"> <div class="container-wrapper">
<el-form <el-form
ref="form" ref="form"
:rules="rules"
:inline="true" :inline="true"
:model="formInline" :model="formInline"
class="de-form-inline" class="de-form-inline"
@ -15,6 +14,7 @@
<el-form-item <el-form-item
prop="queryType" prop="queryType"
:label="$t('commons.adv_search.search') + $t('table.type')" :label="$t('commons.adv_search.search') + $t('table.type')"
:required="true"
> >
<el-select <el-select
v-model="formInline.queryType" v-model="formInline.queryType"
@ -31,8 +31,8 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
prop="dataSourceName"
:label="queryTypeTitle" :label="queryTypeTitle"
:error="errorMsg"
> >
<el-popover <el-popover
v-model="showTree" v-model="showTree"
@ -72,24 +72,15 @@
</span> </span>
</span> </span>
</el-tree> </el-tree>
<el-select <el-input
ref="treeSelect" ref="treeSelect"
slot="reference" slot="reference"
v-model="formInline.dataSourceName" v-model="querySelected"
filterable :placeholder="queryPlaceholder"
remote @click.native.stop="showTree = true"
:filter-method="filterMethod" @input="onQueryInput"
:title="nodeData.name" @focus="onQueryFocus"
popper-class="tree-select"
@focus="showTree = true"
>
<el-option
v-for="item in ignoredOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/> />
</el-select>
</el-popover> </el-popover>
</el-form-item> </el-form-item>
<el-form-item style="float: right"> <el-form-item style="float: right">
@ -186,10 +177,6 @@ export default {
queryType: 'datasource', queryType: 'datasource',
dataSourceName: '' dataSourceName: ''
}, },
rules: {
queryType: [{ required: true, trigger: 'blur' }],
dataSourceName: [{ required: true, trigger: 'blur', message: this.$t('chart.name_can_not_empty') }]
},
queryTypeNameList: [ queryTypeNameList: [
{ {
label: 'commons.datasource', label: 'commons.datasource',
@ -218,11 +205,13 @@ export default {
total: 0 total: 0
}, },
resourceTreeData: [], resourceTreeData: [],
ignoredOptions: [],
showTree: false, showTree: false,
nodeData: {}, nodeData: {},
popoverSize: 400, popoverSize: 400,
currentNode: {} currentNode: {},
querySelected: '',
queryPlaceholder: '',
errorMsg: ''
} }
}, },
computed: { computed: {
@ -271,7 +260,9 @@ export default {
data, data,
activeQueryType(activeIcon) { activeQueryType(activeIcon) {
this.activeIcon = activeIcon this.activeIcon = activeIcon
if (this.formInline.dataSourceName) {
this.onSubmit() this.onSubmit()
}
}, },
async searchDetail(id, queryType, name) { async searchDetail(id, queryType, name) {
switch (queryType) { switch (queryType) {
@ -289,7 +280,7 @@ export default {
} }
this.formInline = { queryType, dataSourceName: id } this.formInline = { queryType, dataSourceName: id }
this.nodeData = { id, name } this.nodeData = { id, name }
this.ignoredOptions = [this.nodeData] this.querySelected = this.queryPlaceholder = name
this.$refs.resourceTree.setCurrentKey(id) this.$refs.resourceTree.setCurrentKey(id)
const currentParents = this.$refs.resourceTree.getNodePath(this.nodeData) const currentParents = this.$refs.resourceTree.getNodePath(this.nodeData)
currentParents.forEach((node) => { currentParents.forEach((node) => {
@ -438,6 +429,7 @@ export default {
this.resourceTreeData = [] this.resourceTreeData = []
this.nodeData = {} this.nodeData = {}
this.currentNode = {} this.currentNode = {}
this.querySelected = this.queryPlaceholder = ''
switch (val) { switch (val) {
case 'datasource': { case 'datasource': {
this.listDatasource() this.listDatasource()
@ -456,15 +448,16 @@ export default {
} }
}, },
onSubmit() { onSubmit() {
this.$refs.form.validate((valid) => { if (!this.formInline.dataSourceName) {
if (valid) { this.errorMsg = this.$t('chart.name_can_not_empty')
return
}
this.errorMsg = ''
if (this.activeIcon === 'date') { if (this.activeIcon === 'date') {
this.getChartData() this.getChartData()
} else { } else {
this.$refs.consanguinity.getChartData(this.current) this.$refs.consanguinity.getChartData(this.current)
} }
}
})
}, },
handleSizeChange(pageSize) { handleSizeChange(pageSize) {
this.paginationConfig.currentPage = 1 this.paginationConfig.currentPage = 1
@ -528,29 +521,36 @@ export default {
} }
return data.name.toLowerCase().indexOf(value.toLowerCase()) !== -1 return data.name.toLowerCase().indexOf(value.toLowerCase()) !== -1
}, },
filterMethod(filterText) { onQueryInput(filterText) {
this.$refs.resourceTree.filter(filterText) this.$refs.resourceTree.filter(filterText)
}, },
onQueryFocus() {
this.querySelected = ''
},
nodeClick(data, node) { nodeClick(data, node) {
if (node.isLeaf) { if (node.isLeaf) {
this.ignoredOptions = [{ id: data.id, name: data.name }]
this.formInline.dataSourceName = data.id this.formInline.dataSourceName = data.id
this.showTree = false this.showTree = false
this.nodeData = data this.nodeData = data
this.currentNode = node this.currentNode = node
this.querySelected = this.queryPlaceholder = data.name
this.errorMsg = ''
} }
}, },
resetFilter() { resetFilter() {
if (this.showTree) { if (this.showTree) {
this.showTree = false this.showTree = false
this.querySelected = this.queryPlaceholder = this.nodeData.name
this.$refs.resourceTree.filter() this.$refs.resourceTree.filter()
this.$refs.resourceTree.setCurrentKey(this.formInline.dataSourceName) this.$refs.resourceTree.setCurrentKey(this.formInline.dataSourceName)
if (this.formInline.dataSourceName === '') { if (this.formInline.dataSourceName === '') {
this.$refs.resourceTree.setCurrentKey(null) this.$refs.resourceTree.setCurrentKey(null)
} }
if (this.formInline.dataSourceName) {
const currentParents = this.$refs.resourceTree.getNodePath(this.nodeData).map((item) => item.id)
const nodesMap = this.$refs.resourceTree.store.nodesMap || {} const nodesMap = this.$refs.resourceTree.store.nodesMap || {}
let currentParents = []
if (this.formInline.dataSourceName) {
currentParents = this.$refs.resourceTree.getNodePath(this.nodeData).map((item) => item.id)
}
for (const key in nodesMap) { for (const key in nodesMap) {
nodesMap[key].expanded = currentParents.includes(key) nodesMap[key].expanded = currentParents.includes(key)
} }
@ -558,7 +558,6 @@ export default {
} }
} }
} }
}
</script> </script>
<style lang="less"> <style lang="less">