feat: default properties type
This commit is contained in:
parent
ee5717c609
commit
8a49fcf76a
3 changed files with 107 additions and 49 deletions
|
|
@ -2,7 +2,7 @@
|
|||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Option } from 'src/stores/options/types';
|
||||
import { Attributes } from 'src/stores/product-service/types';
|
||||
import { AdditionalType, Attributes } from 'src/stores/product-service/types';
|
||||
import { moveItemUp, moveItemDown, deleteItem, dialog } from 'src/stores/utils';
|
||||
|
||||
import NoData from '../NoData.vue';
|
||||
|
|
@ -47,7 +47,7 @@ const typeOption = ref([
|
|||
},
|
||||
]);
|
||||
|
||||
function manageProperties(properties?: string) {
|
||||
function manageProperties(properties?: string, type?: string | AdditionalType) {
|
||||
if (properties === 'all' && propertiesOption.value) {
|
||||
if (
|
||||
formServiceProperties.value?.additional.length ===
|
||||
|
|
@ -63,7 +63,7 @@ function manageProperties(properties?: string) {
|
|||
if (!exists) {
|
||||
formServiceProperties.value?.additional.push({
|
||||
fieldName: ops.value,
|
||||
type: null,
|
||||
type: ops.type as AdditionalType,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -80,7 +80,7 @@ function manageProperties(properties?: string) {
|
|||
} else {
|
||||
formServiceProperties.value.additional.push({
|
||||
fieldName: properties ?? null,
|
||||
type: null,
|
||||
type: type as AdditionalType,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -95,6 +95,20 @@ function shouldShowItem(opt: Option) {
|
|||
}
|
||||
}
|
||||
|
||||
function changeType(val: string) {
|
||||
if (!propertiesOption.value) return;
|
||||
|
||||
const newType = propertiesOption.value.find((op) => op.value === val)?.type;
|
||||
if (!newType) return;
|
||||
|
||||
const additionalField = formServiceProperties.value?.additional.find(
|
||||
(l) => l.fieldName === val,
|
||||
);
|
||||
if (!additionalField) return;
|
||||
|
||||
additionalField.type = newType as AdditionalType;
|
||||
}
|
||||
|
||||
function confirmDelete(items: unknown[], index: number) {
|
||||
dialog({
|
||||
color: 'negative',
|
||||
|
|
@ -149,7 +163,7 @@ function confirmDelete(items: unknown[], index: number) {
|
|||
v-for="(ops, index) in propertiesOption"
|
||||
clickable
|
||||
:key="index"
|
||||
@click="manageProperties(ops.value)"
|
||||
@click="manageProperties(ops.value, ops.type)"
|
||||
>
|
||||
<div class="full-width flex items-center">
|
||||
<q-icon
|
||||
|
|
@ -243,6 +257,7 @@ function confirmDelete(items: unknown[], index: number) {
|
|||
option-value="value"
|
||||
:options="propertiesOption"
|
||||
v-model="p.fieldName"
|
||||
@update:model-value="changeType"
|
||||
>
|
||||
<template v-slot:option="scope">
|
||||
<q-item
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue