mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +08:00
feat: Load basic data with tab (#951)
* feat: Load basic data into tab * change with click
This commit is contained in:
parent
fb3ae87a3d
commit
1a51f6bce9
@ -244,8 +244,9 @@ export default {
|
|||||||
// TODO: Evaluate record uuid without route.action
|
// TODO: Evaluate record uuid without route.action
|
||||||
// edit mode is diferent to create new
|
// edit mode is diferent to create new
|
||||||
let isWithRecord = this.field.recordUuid !== 'create-new'
|
let isWithRecord = this.field.recordUuid !== 'create-new'
|
||||||
|
// TODO: Remove false condition to production
|
||||||
// evaluate context
|
// evaluate context
|
||||||
if ((this.preferenceClientId !== this.metadataField.clientId) && isWithRecord) {
|
if ((this.preferenceClientId !== this.metadataField.clientId && 1 === 2) && isWithRecord) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actionKeyPerformed(value) {
|
actionKeyPerformed(value) {
|
||||||
|
// TODO: Delete for production
|
||||||
|
console.info('actionKeyPerformed ', value)
|
||||||
if (this.metadata.handleActionKeyPerformed) {
|
if (this.metadata.handleActionKeyPerformed) {
|
||||||
this.$store.dispatch('notifyActionKeyPerformed', {
|
this.$store.dispatch('notifyActionKeyPerformed', {
|
||||||
containerUuid: this.metadata.containerUuid,
|
containerUuid: this.metadata.containerUuid,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
:windowuuid="windowUuid"
|
:windowuuid="windowUuid"
|
||||||
:tabuuid="tabAttributes.uuid"
|
:tabuuid="tabAttributes.uuid"
|
||||||
:name="String(key)"
|
:name="String(key)"
|
||||||
|
:tabindex="String(key)"
|
||||||
lazy
|
lazy
|
||||||
:disabled="isDisabledTab(key)"
|
:disabled="isDisabledTab(key)"
|
||||||
:style="tabStyle"
|
:style="tabStyle"
|
||||||
@ -53,7 +54,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { defineComponent, computed, ref, watch } from '@vue/composition-api'
|
import { defineComponent, computed, ref } from '@vue/composition-api'
|
||||||
|
|
||||||
import PanelDefinition from '@/components/ADempiere/PanelDefinition'
|
import PanelDefinition from '@/components/ADempiere/PanelDefinition'
|
||||||
import LockRecord from '@/components/ADempiere/ContainerOptions/LockRecord'
|
import LockRecord from '@/components/ADempiere/ContainerOptions/LockRecord'
|
||||||
@ -82,7 +83,10 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { root }) {
|
setup(props, { root }) {
|
||||||
const currentTab = ref(root.$route.query.tab)
|
// if tabParent is present in path set this
|
||||||
|
const tabNo = root.$route.query.tab || '0'
|
||||||
|
const currentTab = ref(tabNo)
|
||||||
|
|
||||||
const tabUuid = ref(props.tabsList[0].uuid)
|
const tabUuid = ref(props.tabsList[0].uuid)
|
||||||
|
|
||||||
const tabStyle = computed(() => {
|
const tabStyle = computed(() => {
|
||||||
@ -112,22 +116,23 @@ export default defineComponent({
|
|||||||
* @param {object} tabHTML DOM HTML the tab clicked
|
* @param {object} tabHTML DOM HTML the tab clicked
|
||||||
*/
|
*/
|
||||||
const handleClick = (tabHTML) => {
|
const handleClick = (tabHTML) => {
|
||||||
tabUuid.value = tabHTML.$attrs.tabuuid
|
const { tabuuid, tabindex } = tabHTML.$attrs
|
||||||
setCurrentTab()
|
if (tabUuid.value !== tabuuid) {
|
||||||
setTabNumber(tabHTML.index)
|
tabUuid.value = tabuuid
|
||||||
|
setCurrentTab()
|
||||||
|
}
|
||||||
|
if (currentTab.value !== tabindex) {
|
||||||
|
setTabNumber(tabindex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// watch router query tab parent value
|
const setTabNumber = (tabNumber = '0') => {
|
||||||
watch(() => root.$route.query.tab, (newValue) => {
|
if (root.isEmptyValue(tabNumber)) {
|
||||||
if (root.isEmptyValue(newValue)) {
|
tabNumber = '0'
|
||||||
setTabNumber('0')
|
}
|
||||||
return
|
if (tabNumber !== currentTab.value) {
|
||||||
|
currentTab.value = tabNumber
|
||||||
}
|
}
|
||||||
setTabNumber(newValue)
|
|
||||||
})
|
|
||||||
|
|
||||||
const setTabNumber = (tabNumber) => {
|
|
||||||
currentTab.value = tabNumber
|
|
||||||
|
|
||||||
root.$router.push({
|
root.$router.push({
|
||||||
query: {
|
query: {
|
||||||
@ -141,8 +146,23 @@ export default defineComponent({
|
|||||||
|
|
||||||
// TODO: Delete this to production
|
// TODO: Delete this to production
|
||||||
console.log('Click tab number ', tabNumber)
|
console.log('Click tab number ', tabNumber)
|
||||||
|
return tabNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getData = () => {
|
||||||
|
root.$store.dispatch('getDataListTab', {
|
||||||
|
parentUuid: props.windowUuid,
|
||||||
|
containerUuid: tabUuid.value
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getData()
|
||||||
|
|
||||||
|
setTabNumber(currentTab.value)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentTab,
|
currentTab,
|
||||||
tabUuid,
|
tabUuid,
|
||||||
|
@ -317,7 +317,7 @@ const window = {
|
|||||||
let isTabsChildren = false
|
let isTabsChildren = false
|
||||||
if (!isAdvancedQuery) {
|
if (!isAdvancedQuery) {
|
||||||
const window = getters.getWindow(parentUuid)
|
const window = getters.getWindow(parentUuid)
|
||||||
if (window) {
|
if (window && window.tabsListChildren) {
|
||||||
isTabsChildren = Boolean(window.tabsListChildren.length)
|
isTabsChildren = Boolean(window.tabsListChildren.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { root }) {
|
setup(props, { root }) {
|
||||||
const panelType = 'window'
|
|
||||||
const isLoaded = ref(false)
|
const isLoaded = ref(false)
|
||||||
const windowMetadata = ref({})
|
const windowMetadata = ref({})
|
||||||
|
|
||||||
@ -77,27 +76,28 @@ export default defineComponent({
|
|||||||
isLoaded.value = true
|
isLoaded.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const getterWindow = computed(() => {
|
const storedWindow = computed(() => {
|
||||||
return root.$store.getters.getWindow(windowUuid)
|
return root.$store.getters.getWindow(windowUuid)
|
||||||
})
|
})
|
||||||
|
|
||||||
// get window from vuex store or request from server
|
// get window from vuex store or request from server
|
||||||
const getWindow = () => {
|
const getWindow = () => {
|
||||||
|
const window = storedWindow.value
|
||||||
|
if (!root.isEmptyValue(window)) {
|
||||||
|
generateWindow(window)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// metadata props use for test
|
// metadata props use for test
|
||||||
if (!root.isEmptyValue(props.metadata)) {
|
if (!root.isEmptyValue(props.metadata)) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const windowResponse = generateWindowRespose(props.metadata)
|
const windowResponse = generateWindowRespose(props.metadata)
|
||||||
|
root.$store.commit('addWindow', windowResponse)
|
||||||
generateWindow(windowResponse)
|
generateWindow(windowResponse)
|
||||||
resolve(windowResponse)
|
resolve(windowResponse)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const window = getterWindow.value
|
|
||||||
if (!root.isEmptyValue(window)) {
|
|
||||||
generateWindow(window)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
root.$store.dispatch('getWindowFromServer', {
|
root.$store.dispatch('getWindowFromServer', {
|
||||||
windowUuid,
|
windowUuid,
|
||||||
routeToDelete: root.$route
|
routeToDelete: root.$route
|
||||||
@ -131,11 +131,9 @@ export default defineComponent({
|
|||||||
getWindow()
|
getWindow()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
panelType,
|
|
||||||
windowUuid,
|
windowUuid,
|
||||||
windowMetadata,
|
windowMetadata,
|
||||||
// computed
|
// computed
|
||||||
getterWindow,
|
|
||||||
renderWindowComponent,
|
renderWindowComponent,
|
||||||
isLoaded
|
isLoaded
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user