feat: default properties type

This commit is contained in:
puriphatt 2024-06-25 10:17:25 +00:00
parent ee5717c609
commit 8a49fcf76a
3 changed files with 107 additions and 49 deletions

View file

@ -1179,178 +1179,221 @@
"servicePropertiesField": [
{
"label": "บันทึกบริการ_Name",
"value": "serviceRecordName"
"value": "serviceRecordName",
"type": "string"
},
{
"label": "RN_บันทึกบริการ",
"value": "serviceRecordRN"
"value": "serviceRecordRN",
"type": "string"
},
{
"label": "สถานะคนงาน",
"value": "workerStatus"
"value": "workerStatus",
"type": "array"
},
{
"label": "ช่องทางการการติดต่อ",
"value": "contactChannel"
"value": "contactChannel",
"type": "string"
},
{
"label": "Quotation No.",
"value": "quotationNo"
"value": "quotationNo",
"type": "string"
},
{
"label": "วันที่รับงาน",
"value": "startDate"
"value": "startDate",
"type": "date"
},
{
"label": "โปรเจ็ค",
"value": "project"
"value": "project",
"type": "string"
},
{
"label": "ลูกจ้าง",
"value": "employee"
"value": "employee",
"type": "string"
},
{
"label": "นายจ้าง",
"value": "employer"
"value": "employer",
"type": "string"
},
{
"label": "เขตพื้นที่จัดหางาน",
"value": "area"
"value": "area",
"type": "string"
},
{
"label": "ลงชื่อผู้ขาย",
"value": "sellerSignature"
"value": "sellerSignature",
"type": "string"
},
{
"label": "นายหน้า",
"value": "agent"
"value": "agent",
"type": "string"
},
{
"label": "ผู้ติดต่อ",
"value": "contactPerson"
"value": "contactPerson",
"type": "string"
},
{
"label": "อีเมล์ผู้ติดต่อ",
"value": "email"
"value": "email",
"type": "string"
},
{
"label": "เบอร์โทรผู้ติดต่อ",
"value": "telephone"
"value": "telephone",
"type": "string"
},
{
"label": "เอเจนซี่",
"value": "agency"
"value": "agency",
"type": "string"
},
{
"label": "หมายเหตุ",
"value": "remark"
"value": "remark",
"type": "string"
},
{
"label": "ลงชื่อผู้บันทึกข้อมูล",
"value": "recordBy"
"value": "recordBy",
"type": "string"
}
],
"workPropertiesField": [
{
"label": "Ref No:",
"value": "refNo"
"value": "refNo",
"type": "string"
},
{
"label": "ใบสั่งงานเลขที่ (TO)",
"value": "workOrderNo"
"value": "workOrderNo",
"type": "string"
},
{
"label": "วันที่สั่งซื้อ (TO)",
"value": "orderDate"
"value": "orderDate",
"type": "date"
},
{
"label": "ใบรับสินค้าเลขที่ (TR)",
"value": "productReceiptNo"
"value": "productReceiptNo",
"type": "string"
},
{
"label": "วันที่รับสินค้า (TR)",
"value": "productReceiptDate"
"value": "productReceiptDate",
"type": "date"
},
{
"label": "สถานะงาน",
"value": "workStatus"
"value": "workStatus",
"type": "string"
},
{
"label": "หมายเหตุ",
"value": "remark"
"value": "remark",
"type": "string"
},
{
"label": "เลขที่ รง.",
"value": "factoryNo"
"value": "factoryNo",
"type": "string"
},
{
"label": "ลงวันที่",
"value": "dateIssued"
"value": "dateIssued",
"type": "date"
},
{
"label": "ประเภท (การดำเนินการของประเทศต้นทาง)",
"value": "typeOriginCountryOperation"
"value": "typeOriginCountryOperation",
"type": "array"
},
{
"label": "ช่องทางการจัดส่ง",
"value": "deliveryChannel"
"value": "deliveryChannel",
"type": "array"
},
{
"label": "Name list No.",
"value": "nameListNo"
"value": "nameListNo",
"type": "string"
},
{
"label": "สถานที่ประกันสุขภาพ",
"value": "insuranceLocation"
"value": "insuranceLocation",
"type": "array"
},
{
"label": "ประเภท (ยื่นขอประกันสุขภาพคนต่างด้าว)",
"value": "typeForeignInsurance"
"value": "typeForeignInsurance",
"type": "string"
},
{
"label": "ประเภท (ยื่นขอใบอนุญาตทำงานแทนคนต่างด้าว)",
"value": "typePermitWorkBehalf"
"value": "typePermitWorkBehalf",
"type": "string"
},
{
"label": "วันที่นัดรับเอกสาร",
"value": "docPickupDate"
"value": "docPickupDate",
"type": "date"
},
{
"label": "Calling Visa No.",
"value": "callVisaNo"
"value": "callVisaNo",
"type": "string"
},
{
"label": "ด่านที่คนงานเดินทาง",
"value": "checkpoint"
"value": "checkpoint",
"type": "array"
},
{
"label": "วันที่เดินทาง",
"value": "travelDate"
"value": "travelDate",
"type": "date"
},
{
"label": "สถานที่ตรวจสุขภาพ",
"value": "healthCheckupLocation"
"value": "healthCheckupLocation",
"type": "array"
},
{
"label": "สถานที่แจ้งที่พักอาศัย",
"value": "residenceLocation"
"value": "residenceLocation",
"type": "string"
},
{
"label": "รายงานตัว 90 วัน ครั้งต่อไป",
"value": "next90Days"
"value": "next90Days",
"type": "date"
},
{
"label": "ช่องทางในการจัดส่งเอกสาร",
"value": "docDeliveryChannel"
"value": "docDeliveryChannel",
"type": "string"
},
{
"label": "สถานะส่งมอบ",
"value": "deliveryStatus"
"value": "deliveryStatus",
"type": "array"
},
{
"label": "ประเภท 90 วัน",
"value": "type90Days"
"value": "type90Days",
"type": "string"
}
]
}

View file

@ -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

View file

@ -1 +1 @@
export type Option = { label: string; value: string };
export type Option = { label: string; value: string; type?: string };