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

View File

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

View File

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

View File

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

View File

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