|
|
@ -4,7 +4,7 @@ |
|
|
|
<span class="font-weight-bold"> {{ modelName }}</span> <span class="font-weight-regular ml-1">( Main View )</span> |
|
|
|
<span class="font-weight-bold"> {{ modelName }}</span> <span class="font-weight-regular ml-1">( Main View )</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<v-toolbar height="40" dense class="elevation-0 xc-toolbar xc-border-bottom" style="z-index: 7;border-radius: 4px"> |
|
|
|
<v-toolbar v-if="meta" height="40" dense class="elevation-0 xc-toolbar xc-border-bottom" style="z-index: 7;border-radius: 4px"> |
|
|
|
<div class="d-flex xc-border align-center search-box"> |
|
|
|
<div class="d-flex xc-border align-center search-box"> |
|
|
|
<v-menu bottom offset-y> |
|
|
|
<v-menu bottom offset-y> |
|
|
|
<template #activator="{on}"> |
|
|
|
<template #activator="{on}"> |
|
|
@ -107,6 +107,7 @@ |
|
|
|
</v-toolbar> |
|
|
|
</v-toolbar> |
|
|
|
|
|
|
|
|
|
|
|
<div |
|
|
|
<div |
|
|
|
|
|
|
|
v-if="meta" |
|
|
|
:class="`cell-height-${cellHeight}`" |
|
|
|
:class="`cell-height-${cellHeight}`" |
|
|
|
style="overflow:auto;transition: width 500ms " |
|
|
|
style="overflow:auto;transition: width 500ms " |
|
|
|
class="d-flex" |
|
|
|
class="d-flex" |
|
|
@ -117,13 +118,14 @@ |
|
|
|
|
|
|
|
|
|
|
|
<xc-grid-view |
|
|
|
<xc-grid-view |
|
|
|
v-else |
|
|
|
v-else |
|
|
|
|
|
|
|
is-public-view |
|
|
|
:meta="meta" |
|
|
|
:meta="meta" |
|
|
|
|
|
|
|
:metas="metas" |
|
|
|
:data="data" |
|
|
|
:data="data" |
|
|
|
:available-columns="availableColumns" |
|
|
|
:available-columns="availableColumns" |
|
|
|
:show-fields="showFields" |
|
|
|
:show-fields="showFields" |
|
|
|
:belongs-to="belongsTo" |
|
|
|
:belongs-to="belongsTo" |
|
|
|
:has-many="hasMany" |
|
|
|
:has-many="hasMany" |
|
|
|
:is-public-view="true" |
|
|
|
|
|
|
|
:nodes="{dbAlias:''}" |
|
|
|
:nodes="{dbAlias:''}" |
|
|
|
:sql-ui="sqlUi" |
|
|
|
:sql-ui="sqlUi" |
|
|
|
/> |
|
|
|
/> |
|
|
@ -170,22 +172,21 @@ |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
import ApiFactory from '@/components/project/spreadsheet/apis/apiFactory' |
|
|
|
import spreadsheet from '../mixins/spreadsheet' |
|
|
|
// import EditableCell from "@/components/project/spreadsheet/editableCell"; |
|
|
|
import ApiFactory from '../apis/apiFactory' |
|
|
|
|
|
|
|
// import EditableCell from "../editableCell"; |
|
|
|
|
|
|
|
import FieldsMenu from '../components/fieldsMenu' |
|
|
|
|
|
|
|
import SortListMenu from '../components/sortListMenu' |
|
|
|
|
|
|
|
import ColumnFilterMenu from '../components/columnFilterMenu' |
|
|
|
|
|
|
|
import XcGridView from '../views/xcGridView' |
|
|
|
import { SqlUI } from '@/helpers/sqlUi' |
|
|
|
import { SqlUI } from '@/helpers/sqlUi' |
|
|
|
import FieldsMenu from '@/components/project/spreadsheet/components/fieldsMenu' |
|
|
|
// import ExpandedForm from "../expandedForm"; |
|
|
|
import SortListMenu from '@/components/project/spreadsheet/components/sortListMenu' |
|
|
|
|
|
|
|
import ColumnFilterMenu from '@/components/project/spreadsheet/components/columnFilterMenu' |
|
|
|
|
|
|
|
import XcGridView from '@/components/project/spreadsheet/views/xcGridView' |
|
|
|
|
|
|
|
import spreadsheet from '@/components/project/spreadsheet/mixins/spreadsheet' |
|
|
|
|
|
|
|
// import ExpandedForm from "@/components/project/spreadsheet/expandedForm"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
name: 'XcTable', |
|
|
|
name: 'XcTable', |
|
|
|
components: { XcGridView, ColumnFilterMenu, SortListMenu, FieldsMenu }, |
|
|
|
components: { XcGridView, ColumnFilterMenu, SortListMenu, FieldsMenu }, |
|
|
|
mixins: [spreadsheet], |
|
|
|
mixins: [spreadsheet], |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
dbAlias: String, |
|
|
|
|
|
|
|
env: String, |
|
|
|
env: String, |
|
|
|
nodes: Object, |
|
|
|
nodes: Object, |
|
|
|
addNewRelationTab: Function, |
|
|
|
addNewRelationTab: Function, |
|
|
@ -196,6 +197,7 @@ export default { |
|
|
|
relationPrimaryValue: [String, Number] |
|
|
|
relationPrimaryValue: [String, Number] |
|
|
|
}, |
|
|
|
}, |
|
|
|
data: () => ({ |
|
|
|
data: () => ({ |
|
|
|
|
|
|
|
metas: {}, |
|
|
|
fieldsOrder: [], |
|
|
|
fieldsOrder: [], |
|
|
|
password: null, |
|
|
|
password: null, |
|
|
|
showPasswordModal: false, |
|
|
|
showPasswordModal: false, |
|
|
@ -211,7 +213,7 @@ export default { |
|
|
|
showExpandModal: false, |
|
|
|
showExpandModal: false, |
|
|
|
selectedExpandRowIndex: null, |
|
|
|
selectedExpandRowIndex: null, |
|
|
|
selectedExpandRowMeta: null, |
|
|
|
selectedExpandRowMeta: null, |
|
|
|
meta: [], |
|
|
|
meta: null, |
|
|
|
navDrawer: true, |
|
|
|
navDrawer: true, |
|
|
|
selected: { |
|
|
|
selected: { |
|
|
|
row: null, |
|
|
|
row: null, |
|
|
@ -361,7 +363,7 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
async mounted() { |
|
|
|
async mounted() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// await this.loadMeta(); |
|
|
|
await this.loadMetaData() |
|
|
|
await this.loadTableData() |
|
|
|
await this.loadTableData() |
|
|
|
// const {list, count} = await this.api.paginatedList(this.queryParams); |
|
|
|
// const {list, count} = await this.api.paginatedList(this.queryParams); |
|
|
|
// this.count = count; |
|
|
|
// this.count = count; |
|
|
@ -471,34 +473,100 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.filters = this.filters.slice() |
|
|
|
this.filters = this.filters.slice() |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
async loadMetaData() { |
|
|
|
|
|
|
|
this.loading = true |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// eslint-disable-next-line camelcase |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
meta, |
|
|
|
|
|
|
|
// model_name, |
|
|
|
|
|
|
|
client, |
|
|
|
|
|
|
|
query_params: qp, |
|
|
|
|
|
|
|
db_alias: dbAlias, |
|
|
|
|
|
|
|
relatedTableMetas |
|
|
|
|
|
|
|
} = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'sharedViewGet', { |
|
|
|
|
|
|
|
view_id: this.$route.params.id, |
|
|
|
|
|
|
|
password: this.password |
|
|
|
|
|
|
|
}]) |
|
|
|
|
|
|
|
this.client = client |
|
|
|
|
|
|
|
this.meta = meta |
|
|
|
|
|
|
|
this.query_params = JSON.parse(qp) |
|
|
|
|
|
|
|
this.dbAlias = dbAlias |
|
|
|
|
|
|
|
this.metas = relatedTableMetas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.showFields = this.query_params.showFields || {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.fieldList = Object.keys(this.showFields) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let fields = this.query_params.fieldsOrder || [] |
|
|
|
|
|
|
|
if (!fields.length) { fields = Object.keys(this.showFields) } |
|
|
|
|
|
|
|
// eslint-disable-next-line camelcase |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let columns = this.meta.columns |
|
|
|
|
|
|
|
if (this.meta && this.meta.v) { |
|
|
|
|
|
|
|
columns = [...columns, ...this.meta.v.map(v => ({ ...v, virtual: 1 }))] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const _ref = {} |
|
|
|
|
|
|
|
columns.forEach((c) => { |
|
|
|
|
|
|
|
if (c.virtual && c.bt) { |
|
|
|
|
|
|
|
c.prop = `${c.bt.rtn}Read` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (c.virtual && c.mm) { |
|
|
|
|
|
|
|
c.prop = `${c.mm.rtn}MMList` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (c.virtual && c.hm) { |
|
|
|
|
|
|
|
c.prop = `${c.hm.tn}List` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (c.virtual && c.lk) { |
|
|
|
|
|
|
|
c.alias = `${c.lk._lcn} (from ${c.lk._ltn})` |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
c.alias = c._cn |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (c.alias in _ref) { |
|
|
|
|
|
|
|
c.alias += _ref[c.alias]++ |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
_ref[c.alias] = 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
if (e.message === 'Not found') { |
|
|
|
|
|
|
|
this.notFound = true |
|
|
|
|
|
|
|
} else if (e.message === 'Invalid password') { |
|
|
|
|
|
|
|
this.showPasswordModal = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.loadingData = false |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
async loadTableData() { |
|
|
|
async loadTableData() { |
|
|
|
this.loadingData = true |
|
|
|
this.loadingData = true |
|
|
|
try { |
|
|
|
try { |
|
|
|
// eslint-disable-next-line camelcase |
|
|
|
// eslint-disable-next-line camelcase |
|
|
|
const { data: list, count, meta, model_name, client } = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ |
|
|
|
const { data: list, count, meta, model_name, client, queryParams } = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ |
|
|
|
query: this.queryParams |
|
|
|
query: this.queryParams |
|
|
|
}, 'getSharedViewData', { |
|
|
|
}, 'getSharedViewData', { |
|
|
|
view_id: this.$route.params.id, |
|
|
|
view_id: this.$route.params.id, |
|
|
|
password: this.password |
|
|
|
password: this.password |
|
|
|
}]) |
|
|
|
}]) |
|
|
|
|
|
|
|
|
|
|
|
this.client = client |
|
|
|
this.client = client |
|
|
|
this.meta = meta |
|
|
|
|
|
|
|
|
|
|
|
// this.showFields = queryParams && queryParams.showFields |
|
|
|
|
|
|
|
// this.meta = meta |
|
|
|
// eslint-disable-next-line camelcase |
|
|
|
// eslint-disable-next-line camelcase |
|
|
|
this.modelName = model_name |
|
|
|
this.modelName = model_name |
|
|
|
|
|
|
|
|
|
|
|
this.fieldList = this.meta.columns.map(c => c._cn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.count = count |
|
|
|
this.count = count |
|
|
|
this.data = list.map(row => ({ |
|
|
|
this.data = list.map(row => ({ |
|
|
|
row, |
|
|
|
row, |
|
|
|
oldRow: { ...row }, |
|
|
|
oldRow: { ...row }, |
|
|
|
rowMeta: {} |
|
|
|
rowMeta: {} |
|
|
|
})) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
this.showFields = this.fieldList.reduce((obj, k) => { |
|
|
|
|
|
|
|
obj[k] = true |
|
|
|
|
|
|
|
return obj |
|
|
|
|
|
|
|
}, {}) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
this.showPasswordModal = true |
|
|
|
this.showPasswordModal = true |
|
|
|
} |
|
|
|
} |
|
|
|