mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 23:20:12 +08:00
feat: Add field locator warehouse (#490)
* Add locator wharehouse (#7) * proposal for location component * change props * remove children if is empty * redefine call data Co-authored-by: leonel1524 <matosleonel0@gmail.com> * feat: Add Locator Warehouse Field. * remove unused code. Co-authored-by: leonel1524 <matosleonel0@gmail.com>
This commit is contained in:
parent
9f59dee9cb
commit
6f7b567195
10
src/api/ADempiere/field/locator.js
Normal file
10
src/api/ADempiere/field/locator.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { getEntitiesList } from '@/api/ADempiere/persistence'
|
||||||
|
|
||||||
|
export function getLocatorList({
|
||||||
|
warehouseId
|
||||||
|
}) {
|
||||||
|
return getEntitiesList({
|
||||||
|
tableName: 'M_Locator',
|
||||||
|
whereClause: `M_Warehouse_ID = ${warehouseId}`
|
||||||
|
})
|
||||||
|
}
|
88
src/components/ADempiere/Field/FieldLocator.vue
Normal file
88
src/components/ADempiere/Field/FieldLocator.vue
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<template>
|
||||||
|
<el-cascader
|
||||||
|
:ref="metadata.columnName"
|
||||||
|
v-model="value"
|
||||||
|
:placeholder="metadata.help"
|
||||||
|
:options="options"
|
||||||
|
:readonly="Boolean(metadata.readonly)"
|
||||||
|
:disabled="isDisabled"
|
||||||
|
:clearable="true"
|
||||||
|
filterable
|
||||||
|
lazy
|
||||||
|
:show-all-levels="false"
|
||||||
|
:lazy-load="searchLocatorByWarehouse"
|
||||||
|
:props="props"
|
||||||
|
@change="preHandleChange"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { fieldMixin } from '@/components/ADempiere/Field/FieldMixin'
|
||||||
|
import { getLocatorList } from '@/api/ADempiere/field/locator'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'FieldLocation',
|
||||||
|
mixins: [fieldMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
value: [],
|
||||||
|
options: [],
|
||||||
|
props: {
|
||||||
|
// checkStrictly: true,
|
||||||
|
// emitPath: false,
|
||||||
|
lazy: true,
|
||||||
|
lazyLoad: this.searchLocatorByWarehouse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
warehouse() {
|
||||||
|
return this.$store.getters['user/getWarehouse']
|
||||||
|
},
|
||||||
|
warehousesList() {
|
||||||
|
return this.$store.getters['user/getWarehouses']
|
||||||
|
.map(itemWarehouse => {
|
||||||
|
return {
|
||||||
|
label: itemWarehouse.name,
|
||||||
|
value: itemWarehouse.id,
|
||||||
|
children: []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.options = this.warehousesList
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
preHandleChange(value) {
|
||||||
|
let selected = value
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
selected = value[value.length - 1]
|
||||||
|
}
|
||||||
|
this.handleChange(selected)
|
||||||
|
this.value = value
|
||||||
|
},
|
||||||
|
searchLocatorByWarehouse(node, resolve) {
|
||||||
|
getLocatorList({
|
||||||
|
warehouseId: node.value
|
||||||
|
})
|
||||||
|
.then(responseData => {
|
||||||
|
const locatorList = responseData.recordsList.map(item => {
|
||||||
|
const { values } = item
|
||||||
|
return {
|
||||||
|
label: values.Value,
|
||||||
|
value: values.M_Locator_ID,
|
||||||
|
warehouse: values.M_Warehouse_ID, // node.value
|
||||||
|
leaf: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
resolve(locatorList)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Error getting Locator List By Warehouse from server. Code: ${error.code}. Message: ${error.message}.`)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -121,7 +121,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
// load the component that is indicated in the attributes of received property
|
// load the component that is indicated in the attributes of received property
|
||||||
componentRender() {
|
componentRender() {
|
||||||
if (this.isEmptyValue(this.field.componentPath)) {
|
if (this.isEmptyValue(this.field.componentPath || !this.field.isSupported)) {
|
||||||
return () => import('@/components/ADempiere/Field/FieldText')
|
return () => import('@/components/ADempiere/Field/FieldText')
|
||||||
}
|
}
|
||||||
if (this.isSelectCreated) {
|
if (this.isSelectCreated) {
|
||||||
@ -145,6 +145,9 @@ export default {
|
|||||||
case 'FieldImage':
|
case 'FieldImage':
|
||||||
field = () => import('@/components/ADempiere/Field/FieldImage')
|
field = () => import('@/components/ADempiere/Field/FieldImage')
|
||||||
break
|
break
|
||||||
|
case 'FieldLocator':
|
||||||
|
field = () => import('@/components/ADempiere/Field/FieldLocator')
|
||||||
|
break
|
||||||
case 'FieldNumber':
|
case 'FieldNumber':
|
||||||
field = () => import('@/components/ADempiere/Field/FieldNumber')
|
field = () => import('@/components/ADempiere/Field/FieldNumber')
|
||||||
break
|
break
|
||||||
|
@ -484,7 +484,8 @@ const data = {
|
|||||||
const {
|
const {
|
||||||
parentUuid, containerUuid,
|
parentUuid, containerUuid,
|
||||||
tableName, query, whereClause, orderByClause, conditionsList = [],
|
tableName, query, whereClause, orderByClause, conditionsList = [],
|
||||||
isShowNotification = true, isParentTab = true, isAddRecord = false
|
isShowNotification = true, isParentTab = true, isAddRecord = false,
|
||||||
|
isAddDefaultValues = true
|
||||||
} = parameters
|
} = parameters
|
||||||
if (isShowNotification) {
|
if (isShowNotification) {
|
||||||
showMessage({
|
showMessage({
|
||||||
@ -515,11 +516,14 @@ const data = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// gets the default value of the fields (including whether it is empty or undefined)
|
// gets the default value of the fields (including whether it is empty or undefined)
|
||||||
const defaultValues = rootGetters.getParsedDefaultValues({
|
let defaultValues = {}
|
||||||
parentUuid: parentUuid,
|
if (isAddDefaultValues) {
|
||||||
containerUuid: containerUuid,
|
defaultValues = rootGetters.getParsedDefaultValues({
|
||||||
isGetServer: false
|
parentUuid,
|
||||||
})
|
containerUuid,
|
||||||
|
isGetServer: false
|
||||||
|
})
|
||||||
|
}
|
||||||
return getEntitiesList({
|
return getEntitiesList({
|
||||||
tableName,
|
tableName,
|
||||||
query,
|
query,
|
||||||
@ -537,9 +541,10 @@ const data = {
|
|||||||
values.isEdit = false
|
values.isEdit = false
|
||||||
values.isSelected = false
|
values.isSelected = false
|
||||||
values.isReadOnlyFromRow = false
|
values.isReadOnlyFromRow = false
|
||||||
|
if (isAddDefaultValues) {
|
||||||
if (inEdited.find(itemEdit => itemEdit.UUID === values.UUID)) {
|
if (inEdited.find(itemEdit => itemEdit.UUID === values.UUID)) {
|
||||||
values.isEdit = true
|
values.isEdit = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// overwrite default values and sets the values obtained from the
|
// overwrite default values and sets the values obtained from the
|
||||||
|
@ -284,7 +284,7 @@ export const LOCATOR_WAREHOUSE = {
|
|||||||
id: 31,
|
id: 31,
|
||||||
isSupported: true,
|
isSupported: true,
|
||||||
valueType: 'INTEGER',
|
valueType: 'INTEGER',
|
||||||
componentPath: 'FieldSelect',
|
componentPath: 'FieldLocator',
|
||||||
size: {
|
size: {
|
||||||
xs: 24,
|
xs: 24,
|
||||||
sm: 12,
|
sm: 12,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user