Skip to content

Commit

Permalink
feat: Product info field filter by groups. (PanJiaChen#2037)
Browse files Browse the repository at this point in the history
* feat: `Product` info field filter by groups.

* improve search and set a record.
  • Loading branch information
EdwinBetanc0urt authored Mar 26, 2024
1 parent 329bab2 commit aebedb2
Show file tree
Hide file tree
Showing 15 changed files with 718 additions and 13 deletions.
88 changes: 88 additions & 0 deletions src/api/ADempiere/field/search/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,94 @@ import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
// Constants
import { ROWS_OF_RECORDS_BY_PAGE } from '@/utils/ADempiere/tableUtils'

export function requestListProductCategories({
filters,
searchValue,
//
pageToken,
pageSize = ROWS_OF_RECORDS_BY_PAGE
}) {
return request({
url: `/field/products/categories`,
method: 'get',
params: {
is_only_active_records: true,
//
filters,
search_value: searchValue,
// Page Data
page_token: pageToken,
page_size: pageSize
}
})
}

export function requestListProductGroups({
filters,
searchValue,
//
pageToken,
pageSize = ROWS_OF_RECORDS_BY_PAGE
}) {
return request({
url: `/field/products/groups`,
method: 'get',
params: {
is_only_active_records: true,
//
filters,
search_value: searchValue,
// Page Data
page_token: pageToken,
page_size: pageSize
}
})
}

export function requestListProductClasess({
filters,
searchValue,
//
pageToken,
pageSize = ROWS_OF_RECORDS_BY_PAGE
}) {
return request({
url: `/field/products/clasess`,
method: 'get',
params: {
is_only_active_records: true,
//
filters,
search_value: searchValue,
// Page Data
page_token: pageToken,
page_size: pageSize
}
})
}

export function requestListProductClassifications({
filters,
searchValue,
//
pageToken,
pageSize = ROWS_OF_RECORDS_BY_PAGE
}) {
return request({
url: `/field/products/classifications`,
method: 'get',
params: {
is_only_active_records: true,
//
filters,
search_value: searchValue,
// Page Data
page_token: pageToken,
page_size: pageSize
}
})
}

export function requestListWarehouses({
contextAttributesList,
filters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,40 @@
</el-col>
-->
</el-row>

<el-row :gutter="10">
<el-col :span="6">
<product-category-field
:uuid-form="uuidForm"
:parent-uuid="metadata.parentUuid"
:container-uuid="metadata.containerUuid"
/>
</el-col>

<el-col :span="6">
<product-group-field
:uuid-form="uuidForm"
:parent-uuid="metadata.parentUuid"
:container-uuid="metadata.containerUuid"
/>
</el-col>

<el-col :span="6">
<product-class-field
:uuid-form="uuidForm"
:parent-uuid="metadata.parentUuid"
:container-uuid="metadata.containerUuid"
/>
</el-col>

<el-col :span="6">
<product-classification-field
:uuid-form="uuidForm"
:parent-uuid="metadata.parentUuid"
:container-uuid="metadata.containerUuid"
/>
</el-col>
</el-row>
</el-form>
</el-collapse-item>
</el-collapse>
Expand All @@ -135,6 +169,10 @@ import AttributeSetField from './attributeSet.vue'
import AttributeSetInstanceField from './attributeSetInstance.vue'
import IsStockedField from './isStockedField.vue'
import PriceListVersionField from './priceListVersionField.vue'
import ProductCategoryField from './productCategoryField.vue'
import ProductClassField from './productClassField.vue'
import ProductClassificationField from './productClassificationField.vue'
import ProductGroupField from './productGroupField.vue'
import TextField from './textField.vue'
import VendorField from './vendorField.vue'
import WarehouseField from './warehouseField.vue'
Expand All @@ -150,6 +188,10 @@ export default defineComponent({
AttributeSetInstanceField,
IsStockedField,
PriceListVersionField,
ProductCategoryField,
ProductClassField,
ProductClassificationField,
ProductGroupField,
TextField,
VendorField,
WarehouseField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
>
<el-select
v-model="currentValue"
filterable
remote
:remote-method="remoteSearch"
@visible-change="loadPriceListVersions"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!--
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https:www.gnu.org/licenses/>.
-->

<template>
<el-form-item
:label="$t('field.product.productCategory')"
>
<el-select
v-model="currentValue"
filterable
remote
:remote-method="remoteSearch"
@visible-change="loadProductCategories"
>
<empty-option-select
:current-value="currentValue"
:is-allows-zero="false"
/>
<el-option
v-for="(option, key) in optionsList"
:key="key"
:value="option.values.KeyColumn"
:label="option.values.DisplayColumn"
/>
</el-select>
</el-form-item>
</template>

<script>
import { computed, defineComponent, ref } from '@vue/composition-api'

import store from '@/store'

// API Request Methods
import { requestListProductCategories } from '@/api/ADempiere/field/search/product.ts'

// Components and Mixins
import EmptyOptionSelect from '@/components/ADempiere/FieldDefinition/FieldSelect/emptyOptionSelect.vue'

export default defineComponent({
name: 'ProductCategoryField',

components: {
EmptyOptionSelect
},

props: {
uuidForm: {
required: true,
type: String
},
parentUuid: {
type: String,
default: undefined
},
containerUuid: {
required: true,
type: String
}
},

setup(props) {
const ATTRIBUTE_KEY = 'product_category_id'

const optionsList = ref([])

const currentValue = computed({
set(newValue) {
store.commit('setProductSearchFieldQueryFilterByAttribute', {
containerUuid: props.uuidForm,
attributeKey: ATTRIBUTE_KEY,
value: newValue
})
},
get() {
return store.getters.getProductSearchFieldQueryFilterByAttribute({
containerUuid: props.uuidForm,
attributeKey: ATTRIBUTE_KEY
})
}
})

function loadProductCategories(isShowList) {
if (!isShowList) {
return
}
requestListProductCategories({
pageSize: 100
})
.then(response => {
optionsList.value = response.records
})
}

function remoteSearch(searchValue) {
requestListProductCategories({
searchValue,
pageSize: 100
})
.then(response => {
optionsList.value = response.records
})
}

return {
optionsList,
//
currentValue,
//
loadProductCategories,
remoteSearch
}
}
})
</script>
Loading

0 comments on commit aebedb2

Please sign in to comment.