Fix code format

This commit is contained in:
2025-02-06 21:50:55 +08:00
parent cc0e34a651
commit 41ba930473
5 changed files with 70 additions and 72 deletions

View File

@@ -28,28 +28,28 @@
/> />
<kuc-multi-choice <kuc-multi-choice
v-else-if="valueType === 'kuc-multichoice'" v-else-if="valueType === 'kuc-multichoice'"
:value = "muiltValue" :value="multiValue"
:items="multiChoiceItems" :items="multiChoiceItems"
:requiredIcon="true" :requiredIcon="true"
@change="updateMuiltValue" @change="updateMultiValue"
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading" :disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
></kuc-multi-choice> />
<table-condition-value-multi-input <table-condition-value-multi-input
v-else-if="valueType === 'multi-input'" v-else-if="valueType === 'multi-input'"
:value="muiltInput" :value="multiInput"
@change="updateTableValue" @change="updateTableValue"
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading" :disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
/> />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { getComponent } from '@/js/conditions'; import { getComponent } from '@/js/conditions';
import { getFieldObj, isStringArray, search } from '@/js/helper'; import { getFieldObj, isStringArray, search } from '@/js/helper';
import { isType } from '@/js/kintone-rest-api-client'; import { isType } from '@/js/kintone-rest-api-client';
import { isSelectType } from '@/js/mapping';
import type { CachedSelectedAppData, StringValue, WhereCondition } from '@/types/model'; import type { CachedSelectedAppData, StringValue, WhereCondition } from '@/types/model';
import type { KucEvent } from '@/types/my-kintone'; import type { KucEvent } from '@/types/my-kintone';
import type { ComboboxChangeEventDetail, TextInputEventDetail,MultiChoiceChangeEventDetail, TableChangeEventDetail } from 'kintone-ui-component'; import type { ComboboxChangeEventDetail, TextInputEventDetail, MultiChoiceChangeEventDetail } from 'kintone-ui-component';
import { defineProps, defineEmits, computed, type Ref, inject, provide, ref, watch, watchEffect } from 'vue'; import { defineProps, defineEmits, computed, type Ref, inject, provide, ref, watch, watchEffect } from 'vue';
const props = defineProps<{ const props = defineProps<{
@@ -64,10 +64,10 @@ provide('canSave', props.canSave);
const whereCondition = computed(() => search(props.whereConditions, props.id) as WhereCondition | undefined); const whereCondition = computed(() => search(props.whereConditions, props.id) as WhereCondition | undefined);
const needPlaceholderWidthClass = computed(() => placeholder.value ? 'kuc-text-input-placeholder-width' : '') const needPlaceholderWidthClass = computed(() => (placeholder.value ? 'kuc-text-input-placeholder-width' : ''));
const placeholder = computed(() => { const placeholder = computed(() => {
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '') const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
if (isType.GROUP_SELECT(field)) { if (isType.GROUP_SELECT(field)) {
return 'グループコードをカンマ区切りで指定'; return 'グループコードをカンマ区切りで指定';
} else if (isType.ORGANIZATION_SELECT(field)) { } else if (isType.ORGANIZATION_SELECT(field)) {
@@ -82,25 +82,24 @@ const multiChoiceItems = computed(()=>{
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, ''); const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
const items = [{ const items = [{
label: '--', label: '--',
value:'' value: '',
}]; }];
if(field && "options" in field){ if (field && isSelectType(field)) {
const opts = field.options; const opts = field.options;
const muiltOpts = Object.values(opts).map(opt=>{ const multiOpts = Object.values(opts).map((opt) => {
return { return {
label: opt.label, label: opt.label,
value:opt.label value: opt.label,
} };
}); });
items.push(...muiltOpts); items.push(...multiOpts);
} }
return items; return items;
}); });
const valueType = computed(() => { const valueType = computed(() => {
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, ''); const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
const vtype = getComponent(whereCondition.value?.condition || '', field) return getComponent(whereCondition.value?.condition || '', field);
return vtype;
}); });
type EmitData = { type EmitData = {
@@ -116,36 +115,36 @@ const updateValue = (event: KucEvent<ComboboxChangeEventDetail | TextInputEventD
emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || '' }); emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || '' });
}; };
const muiltValue = ref(isStringArray(props.modelValue.value) ? props.modelValue.value : []); const multiValue = ref(isStringArray(props.modelValue.value) ? props.modelValue.value : []);
watch( watch(
() => props.modelValue, () => props.modelValue,
() => { () => {
const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, ''); const field = getFieldObj(whereCondition.value?.field || '', props.selectedAppData.appFields, '');
const vType = valueType.value; const vType = valueType.value;
const moduleValue = props.modelValue.value; const moduleValue = props.modelValue.value;
if(field && "options" in field && (vType==='kuc-multichoice' )){ if (field && isSelectType(field) && vType === 'kuc-multichoice') {
muiltValue.value = isStringArray(moduleValue) ? moduleValue : []; multiValue.value = isStringArray(moduleValue) ? moduleValue : [];
} }
}); },
);
const muiltInput = ref(isStringArray(props.modelValue.value) ? props.modelValue.value as string[] : ["",""]); const multiInput = ref(isStringArray(props.modelValue.value) ? (props.modelValue.value as string[]) : ['', '']);
watchEffect(() => { watchEffect(() => {
const field = getFieldObj(whereCondition.value ?.field || '', props.selectedAppData.appFields, '');
const vType = valueType.value; const vType = valueType.value;
const moduleValue = props.modelValue.value; const moduleValue = props.modelValue.value;
if (vType === 'multi-input') { if (vType === 'multi-input') {
muiltInput.value = isStringArray(moduleValue) ? moduleValue as string[] : ["",""]; multiInput.value = isStringArray(moduleValue) ? (moduleValue as string[]) : ['', ''];
} }
}); });
const updateMuiltValue = (event: KucEvent<MultiChoiceChangeEventDetail>) => { const updateMultiValue = (event: KucEvent<MultiChoiceChangeEventDetail>) => {
let value = event.detail.value || [];
emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || [] }); emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || [] });
}; };
const updateTableValue = (event: KucEvent<string[]>) => { const updateTableValue = (event: KucEvent<string[]>) => {
let value = event.detail || ["",""]; let value = event.detail || ['', ''];
muiltInput.value = value; multiInput.value = value;
emit('update:modelValue', { obj: whereCondition.value, value: value }); emit('update:modelValue', { obj: whereCondition.value, value: value });
} };
</script> </script>

View File

@@ -96,7 +96,7 @@ const component = {
date: 'date', date: 'date',
datetime: 'datetime', datetime: 'datetime',
multiChoice: 'kuc-multichoice', multiChoice: 'kuc-multichoice',
multiInput :"multi-input" multiInput: 'multi-input',
}; };
export const isDateTimeType = (field: OneOf) => { export const isDateTimeType = (field: OneOf) => {
@@ -117,10 +117,9 @@ const MultiChoiceComponent:Partial<Record<FieldType, ComponentType>> = {
RADIO_BUTTON: 'multiChoice', RADIO_BUTTON: 'multiChoice',
MULTI_SELECT: 'multiChoice', MULTI_SELECT: 'multiChoice',
SINGLE_LINE_TEXT: 'multiInput', SINGLE_LINE_TEXT: 'multiInput',
LINK : 'multiInput' LINK: 'multiInput',
}; };
export type ComponentType = keyof typeof component; export type ComponentType = keyof typeof component;
export const getComponent = (value: ConditionValue, fieldObj: OneOf) => { export const getComponent = (value: ConditionValue, fieldObj: OneOf) => {
if (!value || !fieldObj) return; if (!value || !fieldObj) return;

View File

@@ -188,8 +188,8 @@ export function getMeta(fields: Properties, subTableCode?: string ,withNoSubTabl
let meta = fields; let meta = fields;
const table = meta[subTableCode]; const table = meta[subTableCode];
if (isType.SUBTABLE(table)) { if (isType.SUBTABLE(table)) {
const subFields = table.fields; ; const subFields = table.fields;
Object.values(subFields).forEach(field=>{ Object.values(subFields).forEach((field) => {
if (typeof field === 'object' && field !== null) { if (typeof field === 'object' && field !== null) {
(field as Record<string, any>).subField = true; (field as Record<string, any>).subField = true;
} }
@@ -204,8 +204,8 @@ export function getMeta(fields: Properties, subTableCode?: string ,withNoSubTabl
} }
export const isStringArray = (value: any) => { export const isStringArray = (value: any) => {
if(Array.isArray(value) && value.every(x=>typeof x ==='string')){ if (Array.isArray(value) && value.every((x) => typeof x === 'string')) {
return true; return true;
} }
return false; return false;
} };

View File

@@ -10,5 +10,5 @@ export type LinkProtocolType = 'WEB' | 'CALL' | 'MAIL';
export type SelectType = export type SelectType =
| KintoneFormFieldProperty.CheckBox | KintoneFormFieldProperty.CheckBox
| KintoneFormFieldProperty.RadioButton | KintoneFormFieldProperty.RadioButton
| KintoneFormFieldProperty.DropDown | KintoneFormFieldProperty.Dropdown
| KintoneFormFieldProperty.MultiSelect; | KintoneFormFieldProperty.MultiSelect;

View File

@@ -83,6 +83,6 @@ export default defineConfig({
assetFileNames: 'src/[ext]/[name].[ext]', assetFileNames: 'src/[ext]/[name].[ext]',
}, },
}, },
sourcemap: false, sourcemap: 'inline',
} }
}) })