feat(X-Pack): 新增数据源查看权限

This commit is contained in:
fit2cloud-chenyw 2024-12-18 22:04:26 +08:00 committed by dataeaseShu
parent 38d1ce5932
commit 010a55b3b4
3 changed files with 55 additions and 30 deletions

View File

@ -141,8 +141,12 @@ export const perDelete = async (id): Promise<boolean> => {
}) })
} }
export const getDatasourceList = async (): Promise<IResponse> => { export const getDatasourceList = async (weight?: number): Promise<IResponse> => {
return request.post({ url: '/datasource/tree', data: { busiFlag: 'datasource' } }).then(res => { const data = { busiFlag: 'datasource' }
if (weight) {
data['weight'] = weight
}
return request.post({ url: '/datasource/tree', data }).then(res => {
return res?.data return res?.data
}) })
} }

View File

@ -662,7 +662,8 @@ const getTableName = async (datasourceId, tableName) => {
searchTable.value = tableName searchTable.value = tableName
} }
} }
const isEdit = ref(false)
const datasetCheckRef = ref()
const initEdite = async () => { const initEdite = async () => {
let { id, datasourceId, tableName } = route.query let { id, datasourceId, tableName } = route.query
let { id: copyId } = route.params let { id: copyId } = route.params
@ -672,11 +673,13 @@ const initEdite = async () => {
tableName = embeddedStore.tableName tableName = embeddedStore.tableName
copyId = embeddedStore.datasetCopyId || copyId copyId = embeddedStore.datasetCopyId || copyId
} }
isEdit.value = false
if (copyId || id) { if (copyId || id) {
const barRes = await barInfoApi(copyId || id) const barRes = await barInfoApi(copyId || id)
if (!barRes || !barRes['id']) { if (!barRes || !barRes['id']) {
return return
} }
isEdit.value = true
} }
if (datasourceId) { if (datasourceId) {
dataSource.value = datasourceId as string dataSource.value = datasourceId as string
@ -685,12 +688,13 @@ const initEdite = async () => {
if (!id && !copyId) return if (!id && !copyId) return
loading.value = true loading.value = true
getDatasetDetails(copyId || id) try {
.then(res => { const res = await getDatasetDetails(copyId || id)
loading.value = false
let arr = [] let arr = []
const { id, pid, name } = res || {} const { pid, name } = res || {}
nodeInfo = { nodeInfo = {
id, id: res?.id || null,
pid, pid,
name: copyId ? t('data_set.copy_a_dataset') : name name: copyId ? t('data_set.copy_a_dataset') : name
} }
@ -704,10 +708,10 @@ const initEdite = async () => {
dataSource.value = fir?.currentDs?.datasourceId dataSource.value = fir?.currentDs?.datasourceId
dsChange(dataSource.value) dsChange(dataSource.value)
datasetDrag.value.initState(arr) datasetDrag.value.initState(arr)
}) } catch (error) {
.finally(() => { console.error(error)
loading.value = false loading.value = false
}) }
} }
const joinEditor = (arr: []) => { const joinEditor = (arr: []) => {
@ -1045,9 +1049,10 @@ const saveAndBack = () => {
let p = null let p = null
const XpackLoaded = () => p(true) const XpackLoaded = () => p(true)
onMounted(async () => { onMounted(async () => {
isEdit.value = false
await new Promise(r => (p = r)) await new Promise(r => (p = r))
await initEdite() await initEdite()
getDatasource() getDatasource(isEdit.value ? 0 : 2)
window.addEventListener('resize', handleResize) window.addEventListener('resize', handleResize)
getSqlResultHeight() getSqlResultHeight()
quotaTableHeight.value = sqlResultHeight.value - 242 quotaTableHeight.value = sqlResultHeight.value - 242
@ -1059,14 +1064,21 @@ onBeforeUnmount(() => {
const getSqlResultHeight = () => { const getSqlResultHeight = () => {
sqlResultHeight.value = (document.querySelector('.sql-result') as HTMLElement).offsetHeight sqlResultHeight.value = (document.querySelector('.sql-result') as HTMLElement).offsetHeight
} }
const getDatasource = () => { const getDatasource = (weight?: number) => {
getDatasourceList().then(res => { getDatasourceList(weight).then(res => {
const _list = (res as unknown as DataSource[]) || [] const _list = (res as unknown as DataSource[]) || []
if (_list && _list.length > 0 && _list[0].id === '0') { if (_list && _list.length > 0 && _list[0].id === '0') {
state.dataSourceList = dfsChild(_list[0].children) state.dataSourceList = dfsChild(_list[0].children)
} else { } else {
state.dataSourceList = dfsChild(_list) state.dataSourceList = dfsChild(_list)
} }
nextTick(() => {
const param = {
methodName: 'execute',
args: null
}
datasetCheckRef.value?.invokeMethod(param)
})
}) })
} }
@ -2257,6 +2269,15 @@ const getDsIconName = data => {
jsname="L2NvbXBvbmVudC9wbHVnaW5zLWhhbmRsZXIvRHNDYXRlZ29yeUhhbmRsZXI=" jsname="L2NvbXBvbmVudC9wbHVnaW5zLWhhbmRsZXIvRHNDYXRlZ29yeUhhbmRsZXI="
@load-ds-plugin="loadDsPlugin" @load-ds-plugin="loadDsPlugin"
/> />
<XpackComponent
v-if="state.dataSourceList"
ref="datasetCheckRef"
:is-edit="isEdit"
:ds-list="state.dataSourceList"
:ds-id="dataSource"
@back="pushDataset"
jsname="L2NvbXBvbmVudC9kYXRhc2V0L2luZGV4"
/>
</template> </template>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -1,7 +1,7 @@
package io.dataease.constant; package io.dataease.constant;
public enum AuthEnum { public enum AuthEnum {
READ(1), EXPORT(4), EXPORT_VIEW(5), EXPORT_DETAIL(6), MANAGE(7), AUTH(9); READ(1), USER(2), EXPORT(4), EXPORT_VIEW(5), EXPORT_DETAIL(6), MANAGE(7), AUTH(9);
private Integer weight; private Integer weight;
public Integer getWeight() { public Integer getWeight() {