feat: integrate request data into PropertiesExpansion for enhanced form handling

This commit is contained in:
puriphatt 2025-01-08 11:50:07 +07:00
parent 321a0a6048
commit a19e75e17d
2 changed files with 17 additions and 2 deletions

View file

@ -11,11 +11,14 @@ import {
PropString,
} from 'src/stores/product-service/types';
import { Attributes } from 'src/stores/request-list/types';
import { Attributes, RequestData } from 'src/stores/request-list/types';
import { getCustomerName } from 'src/stores/utils';
import useOptionStore from 'src/stores/options';
import { useRequestList } from 'src/stores/request-list';
import { useI18n } from 'vue-i18n';
const { locale } = useI18n();
const optionStore = useOptionStore();
const requestListStore = useRequestList();
@ -24,6 +27,7 @@ const props = withDefaults(
id: string;
readonly?: boolean;
propertiesToShow: (PropString | PropNumber | PropDate | PropOptions)[];
requestListData: RequestData;
}>(),
{
id: '',
@ -31,6 +35,8 @@ const props = withDefaults(
},
);
const readonlyField = ['quotationNo', 'contactPerson', 'telephone', 'employer'];
const formRemark = ref<string>('');
const formData = ref<{
[field: string]: string | number | null | undefined;
@ -77,10 +83,18 @@ function triggerEdit() {
}
function assignToForm() {
const requestData = props.requestListData;
formRemark.value = attributes.value?.remark || '';
formData.value = JSON.parse(
JSON.stringify(attributes.value?.properties || {}),
);
formData.value['quotationNo'] = requestData.quotation.code;
formData.value['contactPerson'] = requestData.quotation.contactName;
formData.value['telephone'] = requestData.quotation.contactTel;
formData.value['employer'] = getCustomerName(
requestData.quotation.customerBranch,
{ locale: locale.value },
);
}
defineEmits<{
@ -143,7 +157,7 @@ defineEmits<{
{{ i + 1 }} {{ optionStore.mapOption(prop.fieldName) }}
</article>
<PropertiesToInput
:readonly="!state.isEdit"
:readonly="!state.isEdit || readonlyField.includes(prop.fieldName)"
:prop="prop"
:placeholder="optionStore.mapOption(prop.fieldName)"
v-model="formData[prop.fieldName]"

View file

@ -816,6 +816,7 @@ function goToQuotation(
"
/>
<PropertiesExpansion
:request-list-data="data"
:id="value.id"
:readonly="
data.requestDataStatus === RequestDataStatus.Canceled