fix: 数据源分页 文本列表深色主题 数据集详情不规范

This commit is contained in:
dataeaseShu 2022-11-18 15:50:10 +08:00
parent 119644c2b9
commit 65169d8879
12 changed files with 193 additions and 204 deletions

View File

@ -136,7 +136,7 @@ export default {
unbind: 'Unbind', unbind: 'Unbind',
unlock: 'Unlock', unlock: 'Unlock',
unlock_success: 'Unlock success', unlock_success: 'Unlock success',
parameter_effect: 'Parameter values only take effect when editing a dataset',
uninstall: 'Uninstall', uninstall: 'Uninstall',
no_result: 'No Result', no_result: 'No Result',

View File

@ -136,7 +136,7 @@ export default {
unbind: '解綁', unbind: '解綁',
unlock: '解鎖', unlock: '解鎖',
unlock_success: '解鎖成功', unlock_success: '解鎖成功',
parameter_effect: '參數值僅在數据集編輯時生效',
uninstall: '卸載', uninstall: '卸載',
no_result: '沒有找到相關內容', no_result: '沒有找到相關內容',

View File

@ -137,7 +137,7 @@ export default {
unlock: '解锁', unlock: '解锁',
unlock_success: '解锁成功', unlock_success: '解锁成功',
uninstall: '卸载', uninstall: '卸载',
parameter_effect: '参数值仅在数据集编辑时生效',
no_result: '没有找到相关内容', no_result: '没有找到相关内容',
manage_member: '管理成员', manage_member: '管理成员',
confirm_remove_cancel: '确定删除该角色吗?', confirm_remove_cancel: '确定删除该角色吗?',

View File

@ -823,10 +823,17 @@ div:focus {
display: none !important; display: none !important;
} }
.el-checkbox__input.is-checked:not(.is-disabled)+.el-checkbox__label { .el-checkbox__input.is-checked:not(.is-disabled)+.el-checkbox__label {
color: #1F2329 !important; color: #1F2329 !important;
} }
.de-select-grid-class {
.el-checkbox__input.is-checked:not(.is-disabled)+.el-checkbox__label {
color: #3370ff !important;
}
}
.el-dialog__title { .el-dialog__title {
font-weight: 500; font-weight: 500;
} }
@ -1317,11 +1324,11 @@ div:focus {
} }
.user-popper { .user-popper {
padding: 0; padding: 0 !important;
background: #fff; background: #fff !important;
.popper__arrow { .popper__arrow {
display: none; display: none !important;
} }
} }

View File

@ -436,6 +436,17 @@
prop="defaultValue" prop="defaultValue"
:label="$t('commons.params_value')" :label="$t('commons.params_value')"
> >
<template #header>
{{ $t('commons.params_value') }}
<el-tooltip
class="item"
effect="dark"
:content="$t('commons.parameter_effect')"
placement="top"
>
<i class="el-icon-warning" />
</el-tooltip>
</template>
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-if="scope.row.type[0] === 'TEXT'" v-if="scope.row.type[0] === 'TEXT'"

View File

@ -141,7 +141,7 @@
</div> </div>
<div class="info-item"> <div class="info-item">
<p class="info-title">{{ $t('commons.description') }}</p> <p class="info-title">{{ $t('commons.description') }}</p>
<p class="info-content">{{ detail.datasource.desc || 'N/A' }}</p> <p class="info-content">{{ detail.datasource.desc || '-' }}</p>
</div> </div>
<div class="info-item"> <div class="info-item">
<p class="info-title">{{ $t('datasource.type') }}</p> <p class="info-title">{{ $t('datasource.type') }}</p>

View File

@ -22,10 +22,12 @@
</el-col> </el-col>
</el-row> </el-row>
<div class="table-container"> <div class="table-container">
<el-table <grid-table
v-loading="loading" v-loading="loading"
:data="filterTable" :table-data="pagingTable"
:style="{ width: '100%' }" :pagination="paginationConfig"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
> >
<el-table-column <el-table-column
key="name" key="name"
@ -33,6 +35,8 @@
:label="$t('datasource.table_name')" :label="$t('datasource.table_name')"
/> />
<el-table-column <el-table-column
slot="__operation"
key="__operation"
:label="$t('commons.operating')" :label="$t('commons.operating')"
fixed="right" fixed="right"
width="108" width="108"
@ -46,7 +50,7 @@
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </grid-table>
</div> </div>
<el-dialog <el-dialog
:title="$t('dataset.detail')" :title="$t('dataset.detail')"
@ -115,8 +119,10 @@
<script> <script>
import keyEnter from '@/components/msgCfm/keyEnter.js' import keyEnter from '@/components/msgCfm/keyEnter.js'
import { post } from '@/api/dataset/dataset' import { post } from '@/api/dataset/dataset'
import GridTable from '@/components/gridTable/index.vue'
export default { export default {
components: { GridTable },
mixins: [keyEnter], mixins: [keyEnter],
props: { props: {
params: { params: {
@ -128,6 +134,11 @@ export default {
data() { data() {
return { return {
userDrawer: false, userDrawer: false,
paginationConfig: {
currentPage: 1,
pageSize: 10,
total: 0
},
dsTableDetail: {}, dsTableDetail: {},
nickName: '', nickName: '',
loading: false, loading: false,
@ -136,12 +147,27 @@ export default {
filterTable: [] filterTable: []
} }
}, },
computed: {
pagingTable() {
const { currentPage, pageSize } = this.paginationConfig
return this.filterTable.slice((currentPage - 1) * pageSize, currentPage * pageSize)
}
},
created() { created() {
this.search() this.search()
}, },
methods: { methods: {
handleSizeChange(pageSize) {
this.paginationConfig.currentPage = 1
this.paginationConfig.pageSize = pageSize
},
handleCurrentChange(currentPage) {
this.paginationConfig.currentPage = currentPage
},
initSearch() { initSearch() {
this.handleCurrentChange(1)
this.filterTable = this.tableData.filter(ele => ele.name.includes(this.nickName)) this.filterTable = this.tableData.filter(ele => ele.name.includes(this.nickName))
this.paginationConfig.total = this.filterTable.length
}, },
selectDataset(row) { selectDataset(row) {
this.dsTableDetail = row this.dsTableDetail = row

View File

@ -26,8 +26,7 @@
<span <span
v-for="ele in usersValueCopy" v-for="ele in usersValueCopy"
:key="ele.id" :key="ele.id"
class="item" class="item active"
:class="[activeUser.includes(ele.id) ? 'active' : '']"
@click="activeUserChange(ele.id)" @click="activeUserChange(ele.id)"
>{{ ele.username }}</span> >{{ ele.username }}</span>
<el-popover <el-popover
@ -37,14 +36,13 @@
trigger="click" trigger="click"
> >
<el-select <el-select
ref="userSelect" ref="select"
v-model="usersValue" v-model="usersValue"
multiple
filterable filterable
multiple
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
value-key="id" value-key="id"
@change="changeUser" @change="changeUser"
@remove-tag="changeUser"
> >
<el-option <el-option
v-for="item in usersComputed" v-for="item in usersComputed"
@ -102,7 +100,6 @@ export default {
usersValue: [], usersValue: [],
activeUser: [], activeUser: [],
users: [], users: [],
userCache: [],
activeType: [], activeType: [],
userDrawer: false userDrawer: false
} }
@ -112,7 +109,7 @@ export default {
return this.users.filter((ele) => !this.activeUser.includes(ele.id)) return this.users.filter((ele) => !this.activeUser.includes(ele.id))
}, },
usersValueCopy() { usersValueCopy() {
return this.userCache.filter((ele) => this.activeUser.includes(ele.id)) return this.users.filter((ele) => this.activeUser.includes(ele.id))
} }
}, },
mounted() { mounted() {
@ -132,48 +129,24 @@ export default {
this.users = res.data this.users = res.data
}) })
}, },
changeUser() { changeUser(list) {
if ( const [val] = list
this.userCache.length > this.activeUser.push(val.id)
this.usersValue.length + this.activeUser.length this.usersValue = []
) { const { query } = this.$refs.select
this.userCache = this.userCache.filter((ele) => this.$nextTick(() => {
this.usersValue this.$refs.select.query = query
.map((ele) => ele.id) this.$refs.select.handleQueryChange(query)
.concat(this.activeUser) })
.includes(ele.id)
)
return
}
const userIdx = this.usersValue.findIndex(
(ele) =>
!this.userCache
.map((ele) => ele.id)
.concat(this.activeUser)
.includes(ele.id)
)
if (userIdx === -1) return
this.activeUser.push(this.usersValue[userIdx].id)
this.userCache.push(this.usersValue[userIdx])
this.usersValue.splice(userIdx, 1)
}, },
activeUserChange(id) { activeUserChange(id) {
const userIndex = this.activeUser.findIndex((ele) => ele === id) this.activeUser = this.activeUser.filter((ele) => ele !== id)
if (userIndex === -1) {
this.activeUser.push(id)
this.usersValue = this.usersValue.filter((ele) => ele.id !== id)
} else {
this.activeUser.splice(userIndex, 1)
const user = this.userCache.find((ele) => ele.id === id)
this.usersValue.push(user)
}
}, },
clearFilter() { clearFilter() {
this.dataRange = [] this.dataRange = []
this.usersValue = [] this.usersValue = []
this.activeUser = [] this.activeUser = []
this.activeType = [] this.activeType = []
this.userCache = []
this.$emit('search', [], []) this.$emit('search', [], [])
}, },
clearOneFilter(index) { clearOneFilter(index) {
@ -217,8 +190,7 @@ export default {
params.push(str.slice(0, str.length - 1)) params.push(str.slice(0, str.length - 1))
this.filterTextMap.push([ this.filterTextMap.push([
'usersValue', 'usersValue',
'activeUser', 'activeUser'
'userCache'
]) ])
} }

View File

@ -515,8 +515,8 @@ export default {
datasetTaskList(currentPage, pageSize, param, showLoading).then( datasetTaskList(currentPage, pageSize, param, showLoading).then(
(response) => { (response) => {
const multipleSelection = this.multipleSelection.map(ele => ele.id) const multipleSelection = this.multipleSelection.map(ele => ele.id)
this.data = response.data.listObject this.data = response.data?.listObject
this.paginationConfig.total = response.data.itemCount this.paginationConfig.total = response.data?.itemCount
if (multipleSelection.length) { if (multipleSelection.length) {
this.$nextTick(() => { this.$nextTick(() => {
this.data.forEach(row => { this.data.forEach(row => {

View File

@ -14,8 +14,7 @@
<span <span
v-for="ele in selectDatasetsCache" v-for="ele in selectDatasetsCache"
:key="ele.id" :key="ele.id"
class="item" class="item active"
:class="[activeDataset.includes(ele.id) ? 'active' : '']"
@click="activeDatasetChange(ele.id)" @click="activeDatasetChange(ele.id)"
>{{ ele.name }}</span> >{{ ele.name }}</span>
<el-popover <el-popover
@ -34,7 +33,7 @@
<el-tree <el-tree
ref="datasetTreeRef" ref="datasetTreeRef"
current-node-key="id" current-node-key="id"
:data="treeData" :data="deptsComputed"
node-key="id" node-key="id"
highlight-current highlight-current
:filter-node-method="filterNode" :filter-node-method="filterNode"
@ -77,22 +76,12 @@
</span> </span>
</el-tree> </el-tree>
<el-select <el-input
ref="datasetSelect"
slot="reference" slot="reference"
v-model="selectDatasets" v-model="selectDatasets"
popper-class="tree-select"
multiple
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
value-key="id" clearable
>
<el-option
v-for="item in selectDatasets"
:key="item.name"
:label="item.name"
:value="item"
/> />
</el-select>
</el-popover> </el-popover>
<span <span
slot="reference" slot="reference"
@ -155,8 +144,7 @@ export default {
return { return {
treeLoading: false, treeLoading: false,
dataRange: [], dataRange: [],
selectDatasets: [], selectDatasets: '',
datasetCache: [],
activeDataset: [], activeDataset: [],
selectDatasetsCache: [], selectDatasetsCache: [],
treeData: [], treeData: [],
@ -169,10 +157,31 @@ export default {
userDrawer: false userDrawer: false
} }
}, },
computed: {
deptsComputed() {
return this.dfs(this.treeData)
}
},
watch: {
selectDatasets(val) {
this.$refs.datasetTreeRef.filter(val)
}
},
mounted() { mounted() {
this.treeNode() this.treeNode()
}, },
methods: { methods: {
dfs(arr) {
return arr.reduce((pre, ele) => {
if (!this.activeDataset.includes(ele.id)) {
if (ele.children?.length) {
ele.children = this.dfs(ele.children)
}
pre.push(ele)
}
return pre
}, [])
},
treeNode() { treeNode() {
this.treeLoading = true this.treeLoading = true
queryAuthModel( queryAuthModel(
@ -200,7 +209,7 @@ export default {
}, },
filterNode(value, data) { filterNode(value, data) {
if (!value) return true if (!value) return true
return !this.activeDataset.includes(data.id) return data.label.indexOf(value) !== -1
}, },
clearFilter() { clearFilter() {
this.active = { this.active = {
@ -210,7 +219,7 @@ export default {
} }
this.dataRange = [] this.dataRange = []
this.activeDataset = [] this.activeDataset = []
this.selectDatasets = [] this.selectDatasets = ''
this.datasetCache = [] this.datasetCache = []
this.selectDatasetsCache = [] this.selectDatasetsCache = []
this.$refs.datasetTreeRef.filter() this.$refs.datasetTreeRef.filter()
@ -239,22 +248,14 @@ export default {
} }
}, },
handleNodeClick(id, name) { handleNodeClick(id, name) {
const datasetIdx = this.selectDatasets.findIndex((ele) => ele.id === id)
if (datasetIdx !== -1) {
this.selectDatasets.splice(datasetIdx, 1)
}
this.activeDataset.push(id) this.activeDataset.push(id)
this.selectDatasetsCache.push({ id, name }) this.selectDatasetsCache.push({ id, name })
this.datasetCache.push({ id, name }) this.$nextTick(() => {
this.$refs.datasetTreeRef.filter(id) this.$refs.datasetTreeRef.filter(this.selectDatasets)
})
}, },
activeDatasetChange(id) { activeDatasetChange(id) {
const dataset = this.datasetCache.find((ele) => ele.id === id)
this.selectDatasets.push(dataset)
this.activeDataset = this.activeDataset.filter((ele) => ele !== id) this.activeDataset = this.activeDataset.filter((ele) => ele !== id)
this.datasetCache = this.datasetCache.filter(
(ele) => ele.id !== id
)
this.selectDatasetsCache = this.selectDatasetsCache.filter( this.selectDatasetsCache = this.selectDatasetsCache.filter(
(ele) => ele.id !== id (ele) => ele.id !== id
) )
@ -266,6 +267,7 @@ export default {
}, },
formatText() { formatText() {
this.filterTextMap = [] this.filterTextMap = []
this.selectDatasets = ''
const params = [] const params = []
if (this.activeDataset.length) { if (this.activeDataset.length) {
const str = `${this.$t('dataset.datalist')}:${this.activeDataset.reduce( const str = `${this.$t('dataset.datalist')}:${this.activeDataset.reduce(
@ -278,9 +280,7 @@ export default {
params.push(str.slice(0, str.length - 1)) params.push(str.slice(0, str.length - 1))
this.filterTextMap.push([ this.filterTextMap.push([
'activeDataset', 'activeDataset',
'selectDatasets', 'selectDatasetsCache'
'selectDatasetsCache',
'datasetCache'
]) ])
} }
[ [

View File

@ -34,7 +34,7 @@
<el-tree <el-tree
ref="datasetTreeRef" ref="datasetTreeRef"
current-node-key="id" current-node-key="id"
:data="treeData" :data="datasetComputed"
node-key="id" node-key="id"
highlight-current highlight-current
:filter-node-method="filterNode" :filter-node-method="filterNode"
@ -77,22 +77,12 @@
</span> </span>
</el-tree> </el-tree>
<el-select <el-input
ref="datasetSelect"
slot="reference" slot="reference"
v-model="selectDatasets" v-model="selectDatasets"
popper-class="tree-select"
multiple
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
value-key="id" clearable
>
<el-option
v-for="item in selectDatasets"
:key="item.name"
:label="item.name"
:value="item"
/> />
</el-select>
</el-popover> </el-popover>
<span <span
slot="reference" slot="reference"
@ -159,8 +149,7 @@ export default {
treeLoading: false, treeLoading: false,
filterTextMap: [], filterTextMap: [],
dataRange: [], dataRange: [],
selectDatasets: [], selectDatasets: '',
datasetCache: [],
activeDataset: [], activeDataset: [],
selectDatasetsCache: [], selectDatasetsCache: [],
treeData: [], treeData: [],
@ -171,6 +160,16 @@ export default {
userDrawer: false userDrawer: false
} }
}, },
computed: {
datasetComputed() {
return this.dfs(this.treeData)
}
},
watch: {
selectDatasets(val) {
this.$refs.selectDatasets.filter(val)
}
},
mounted() { mounted() {
this.treeNode() this.treeNode()
}, },
@ -195,6 +194,18 @@ export default {
this.treeLoading = false this.treeLoading = false
}) })
}, },
dfs(arr) {
return arr.reduce((pre, ele) => {
if (!this.activeDataset.includes(ele.id)) {
if (ele.children?.length) {
pre.push(this.dfs(ele.children))
} else {
pre.push(ele)
}
}
return pre
}, [])
},
nodeClick(data) { nodeClick(data) {
const { id, name, modelInnerType: type } = data const { id, name, modelInnerType: type } = data
if (type === 'group') return if (type === 'group') return
@ -202,7 +213,7 @@ export default {
}, },
filterNode(value, data) { filterNode(value, data) {
if (!value) return true if (!value) return true
return !this.activeDataset.includes(data.id) return data.label.indexOf(value) !== -1
}, },
clearFilter() { clearFilter() {
this.active = { this.active = {
@ -210,7 +221,7 @@ export default {
} }
this.dataRange = [] this.dataRange = []
this.activeDataset = [] this.activeDataset = []
this.selectDatasets = [] this.selectDatasets = ''
this.datasetCache = [] this.datasetCache = []
this.selectDatasetsCache = [] this.selectDatasetsCache = []
this.$refs.datasetTreeRef.filter() this.$refs.datasetTreeRef.filter()
@ -239,32 +250,22 @@ export default {
} }
}, },
handleNodeClick(id, name) { handleNodeClick(id, name) {
const datasetIdx = this.selectDatasets.findIndex((ele) => ele.id === id)
if (datasetIdx !== -1) {
this.selectDatasets.splice(datasetIdx, 1)
}
this.activeDataset.push(id) this.activeDataset.push(id)
this.selectDatasetsCache.push({ id, name }) this.selectDatasetsCache.push({ id, name })
this.datasetCache.push({ id, name }) this.selectDatasets = ''
this.$refs.datasetTreeRef.filter(id)
}, },
activeDatasetChange(id) { activeDatasetChange(id) {
const dataset = this.datasetCache.find((ele) => ele.id === id)
this.selectDatasets.push(dataset)
this.activeDataset = this.activeDataset.filter((ele) => ele !== id) this.activeDataset = this.activeDataset.filter((ele) => ele !== id)
this.datasetCache = this.datasetCache.filter(
(ele) => ele.id !== id
)
this.selectDatasetsCache = this.selectDatasetsCache.filter( this.selectDatasetsCache = this.selectDatasetsCache.filter(
(ele) => ele.id !== id (ele) => ele.id !== id
) )
this.$refs.datasetTreeRef.filter(true)
}, },
search() { search() {
this.userDrawer = false this.userDrawer = false
this.$emit('search', this.formatCondition(), this.formatText()) this.$emit('search', this.formatCondition(), this.formatText())
}, },
formatText() { formatText() {
this.selectDatasets = ''
this.filterTextMap = [] this.filterTextMap = []
const params = [] const params = []
if (this.activeDataset.length) { if (this.activeDataset.length) {
@ -278,9 +279,7 @@ export default {
params.push(str.slice(0, str.length - 1)) params.push(str.slice(0, str.length - 1))
this.filterTextMap.push([ this.filterTextMap.push([
'activeDataset', 'activeDataset',
'selectDatasets', 'selectDatasetsCache'
'selectDatasetsCache',
'datasetCache'
]) ])
} }
['dataset.task.last_exec_status'].forEach((ele, index) => { ['dataset.task.last_exec_status'].forEach((ele, index) => {

View File

@ -43,30 +43,22 @@
trigger="click" trigger="click"
> >
<el-tree <el-tree
ref="tree"
:load="loadNode" :load="loadNode"
:lazy="true" :lazy="true"
:expand-on-click-node="false" :expand-on-click-node="false"
:data="deptsComputed" :data="deptsComputed"
:props="defaultProps" :props="defaultProps"
:filter-node-method="filterNode"
@node-click="handleNodeClick" @node-click="handleNodeClick"
/> />
<el-select <el-input
ref="roleSelect"
slot="reference" slot="reference"
v-model="selectDepts" v-model="selectDepts"
popper-class="tree-select"
multiple
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
value-key="id" clearable
>
<el-option
v-for="item in selectDepts"
:key="item.label"
:label="item.label"
:value="item"
/> />
</el-select>
</el-popover> </el-popover>
<span <span
slot="reference" slot="reference"
@ -81,8 +73,7 @@
<span <span
v-for="ele in rolesValueCopy" v-for="ele in rolesValueCopy"
:key="ele.id" :key="ele.id"
class="item" class="item active"
:class="[activeRole.includes(ele.id) ? 'active' : '']"
@click="activeRoleChange(ele.id)" @click="activeRoleChange(ele.id)"
>{{ ele.name }}</span> >{{ ele.name }}</span>
<el-popover <el-popover
@ -92,13 +83,13 @@
trigger="click" trigger="click"
> >
<el-select <el-select
ref="roleSelect" ref="select"
v-model="rolesValue" v-model="rolesValue"
multiple
:placeholder="$t('commons.please_select')" :placeholder="$t('commons.please_select')"
value-key="id" value-key="id"
filterable
multiple
@change="changeRole" @change="changeRole"
@remove-tag="changeRole"
> >
<el-option <el-option
v-for="item in rolesComputed" v-for="item in rolesComputed"
@ -139,10 +130,6 @@ import { getDeptTree, treeByDeptId } from '@/api/system/dept'
export default { export default {
data() { data() {
return { return {
roleCache: [],
deptCache: [],
roles: [],
filterTextMap: [],
status: [ status: [
{ {
id: 1, id: 1,
@ -153,11 +140,13 @@ export default {
label: 'commons.disable' label: 'commons.disable'
} }
], ],
roles: [],
filterTextMap: [],
activeStatus: [], activeStatus: [],
rolesValue: [], rolesValue: [],
activeRole: [], activeRole: [],
depts: [], depts: [],
selectDepts: [], selectDepts: '',
selectDeptsCache: [], selectDeptsCache: [],
activeDept: [], activeDept: [],
defaultProps: { defaultProps: {
@ -173,27 +162,40 @@ export default {
return this.roles.filter((ele) => !this.activeRole.includes(ele.id)) return this.roles.filter((ele) => !this.activeRole.includes(ele.id))
}, },
rolesValueCopy() { rolesValueCopy() {
return this.roleCache.filter((ele) => this.activeRole.includes(ele.id)) return this.roles.filter((ele) => this.activeRole.includes(ele.id))
}, },
deptsComputed() { deptsComputed() {
return this.depts.filter((ele) => !this.activeDept.includes(ele.id)) return this.dfs(this.depts)
}
},
watch: {
selectDepts(val) {
this.$refs.tree.filter(val)
} }
}, },
mounted() { mounted() {
this.initRoles() this.initRoles()
}, },
methods: { methods: {
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
clearFilter() { clearFilter() {
Array(3) Array(3)
.fill(1) .fill(1)
.forEach((_, index) => { .forEach((_, index) => {
this.clearOneFilter(index) this.clearOneFilter(index)
}) })
this.$refs.tree.filter()
this.$emit('search', [], []) this.$emit('search', [], [])
}, },
clearOneFilter(index) { clearOneFilter(index) {
(this.filterTextMap[index] || []).forEach((ele) => { (this.filterTextMap[index] || []).forEach((ele) => {
this[ele] = [] this[ele] = []
if (ele === 'activeDept') {
this.$refs.tree.filter()
}
}) })
}, },
// //
@ -207,63 +209,40 @@ export default {
}) })
}) })
}, },
changeRole() { dfs(arr) {
if ( return arr.reduce((pre, ele) => {
this.roleCache.length > if (!this.activeDept.includes(ele.id)) {
this.rolesValue.length + this.activeRole.length if (ele.children?.length) {
) { ele.children = this.dfs(ele.children)
this.roleCache = this.roleCache.filter((ele) =>
this.rolesValue
.map((ele) => ele.id)
.concat(this.activeRole)
.includes(ele.id)
)
return
} }
const roleIdx = this.rolesValue.findIndex( pre.push(ele)
(ele) => }
!this.roleCache return pre
.map((ele) => ele.id) }, [])
.concat(this.activeRole) },
.includes(ele.id) changeRole(list) {
) const [val] = list
if (roleIdx === -1) return this.activeRole.push(val.id)
this.activeRole.push(this.rolesValue[roleIdx].id) this.rolesValue = []
this.roleCache.push(this.rolesValue[roleIdx]) const { query } = this.$refs.select
this.rolesValue.splice(roleIdx, 1) this.$nextTick(() => {
this.$refs.select.query = query
this.$refs.select.handleQueryChange(query)
})
}, },
activeRoleChange(id) { activeRoleChange(id) {
const roleIndex = this.activeRole.findIndex((ele) => ele === id) this.activeRole = this.activeRole.filter((ele) => ele !== id)
if (roleIndex === -1) {
this.activeRole.push(id)
this.rolesValue = this.rolesValue.filter((ele) => ele.id !== id)
} else {
this.activeRole.splice(roleIndex, 1)
const role = this.roleCache.find((ele) => ele.id === id)
this.rolesValue.push(role)
}
}, },
handleNodeClick({ id, label }) { handleNodeClick({ id, label }) {
const deptIdx = this.selectDepts.findIndex((ele) => ele.id === id)
if (deptIdx !== -1) {
this.selectDepts.splice(deptIdx, 1)
this.selectDeptsCache = this.selectDeptsCache.filter(
(ele) => ele.id !== id
)
this.deptCache = this.deptCache.filter((ele) => ele.id !== id)
return
}
this.activeDept.push(id) this.activeDept.push(id)
this.selectDeptsCache.push({ id, label }) this.selectDeptsCache.push({ id, label })
this.deptCache.push({ id, label }) this.$nextTick(() => {
this.$refs.tree.filter(this.selectDatasets)
})
}, },
activeDeptChange(id) { activeDeptChange(id) {
const dept = this.deptCache.find((ele) => ele.id === id)
this.selectDepts.push(dept)
this.activeDept = this.activeDept.filter((ele) => ele !== id) this.activeDept = this.activeDept.filter((ele) => ele !== id)
this.selectDeptsCache = this.selectDeptsCache.filter( this.selectDeptsCache = this.selectDeptsCache.filter((ele) => ele.id !== id)
(ele) => ele.id !== id
)
}, },
statusChange(id) { statusChange(id) {
const statusIndex = this.activeStatus.findIndex((ele) => ele === id) const statusIndex = this.activeStatus.findIndex((ele) => ele === id)
@ -273,10 +252,6 @@ export default {
this.activeStatus.splice(statusIndex, 1) this.activeStatus.splice(statusIndex, 1)
} }
}, },
changeDepts() {
const depts = this.selectDepts.map((item) => item.id)
this.activeDept = this.activeDept.filter((ele) => depts.includes(ele))
},
loadNode(node, resolve) { loadNode(node, resolve) {
if (!this.depts.length) { if (!this.depts.length) {
this.treeByDeptId() this.treeByDeptId()
@ -310,6 +285,7 @@ export default {
this.$emit('search', this.formatCondition(), this.formatText()) this.$emit('search', this.formatCondition(), this.formatText())
}, },
formatText() { formatText() {
this.selectDepts = ''
this.filterTextMap = [] this.filterTextMap = []
const params = [] const params = []
if (this.activeStatus.length) { if (this.activeStatus.length) {
@ -331,9 +307,7 @@ export default {
) )
this.filterTextMap.push([ this.filterTextMap.push([
'activeDept', 'activeDept',
'selectDepts', 'selectDeptsCache'
'selectDeptsCache',
'deptCache'
]) ])
} }
if (this.activeRole.length) { if (this.activeRole.length) {
@ -342,7 +316,7 @@ export default {
.map((ele) => ele.name) .map((ele) => ele.name)
.join('、')}` .join('、')}`
) )
this.filterTextMap.push(['rolesValue', 'activeRole', 'roleCache']) this.filterTextMap.push(['activeRole', 'rolesValue'])
} }
return params return params
}, },