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

@@ -27,29 +27,29 @@
:disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading" :disabled="selectedAppData.loading == undefined ? false : selectedAppData.loading"
/> />
<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)) {
@@ -78,29 +78,28 @@ const placeholder = computed(() => {
return ''; return '';
}); });
const multiChoiceItems = computed(()=>{ 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 moduleValue = props.modelValue.value;
if (field && isSelectType(field) && vType === 'kuc-multichoice') {
multiValue.value = isStringArray(moduleValue) ? moduleValue : [];
}
},
);
const multiInput = ref(isStringArray(props.modelValue.value) ? (props.modelValue.value as string[]) : ['', '']);
watchEffect(() => {
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 (vType === 'multi-input') {
muiltValue.value = isStringArray(moduleValue) ? moduleValue : []; multiInput.value = isStringArray(moduleValue) ? (moduleValue as string[]) : ['', ''];
} }
}); });
const muiltInput = ref(isStringArray(props.modelValue.value) ? props.modelValue.value as string[] : ["",""]); const updateMultiValue = (event: KucEvent<MultiChoiceChangeEventDetail>) => {
watchEffect(()=>{ emit('update:modelValue', { obj: whereCondition.value, value: event.detail.value || [] });
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[] : ["",""];
}
});
const updateMuiltValue = (event: KucEvent<MultiChoiceChangeEventDetail>) => {
let 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

@@ -30,8 +30,8 @@ export const conditionList: ConditionItem[] = [
{ value: '>', label: '> (より後)', type: (field) => dateTimeComponent[field.type] || 'input' }, { value: '>', label: '> (より後)', type: (field) => dateTimeComponent[field.type] || 'input' },
{ value: 'like', label: '次のキーワードを含む', type: 'input' }, { value: 'like', label: '次のキーワードを含む', type: 'input' },
{ value: 'not like', label: '次のキーワードを含まない', type: 'input' }, { value: 'not like', label: '次のキーワードを含まない', type: 'input' },
{ value: 'in', label: '次のいずれかを含む', type: (field)=>MultiChoiceComponent[field.type] || 'input' }, { value: 'in', label: '次のいずれかを含む', type: (field) => MultiChoiceComponent[field.type] || 'input' },
{ value: 'not in', label: '次のいずれも含まない', type: (field)=>MultiChoiceComponent[field.type] || 'input' }, { value: 'not in', label: '次のいずれも含まない', type: (field) => MultiChoiceComponent[field.type] || 'input' },
]; ];
// search from conditionList // search from conditionList
@@ -95,8 +95,8 @@ const component = {
time: 'kuc-time', time: 'kuc-time',
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) => {
@@ -111,16 +111,15 @@ const dateTimeComponent: Partial<Record<FieldType, ComponentType>> = {
UPDATED_TIME: 'datetime', UPDATED_TIME: 'datetime',
}; };
const MultiChoiceComponent:Partial<Record<FieldType, ComponentType>> = { const MultiChoiceComponent: Partial<Record<FieldType, ComponentType>> = {
CHECK_BOX: 'multiChoice', CHECK_BOX: 'multiChoice',
DROP_DOWN: 'multiChoice', DROP_DOWN: 'multiChoice',
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

@@ -181,31 +181,31 @@ export function getFieldObj(fieldCode: string, { fields }: FieldsInfo, subTableC
return meta[fieldCode]; return meta[fieldCode];
} }
export function getMeta(fields: Properties, subTableCode?: string ,withNoSubTableField = true) { export function getMeta(fields: Properties, subTableCode?: string, withNoSubTableField = true) {
if (!fields || !subTableCode) { if (!fields || !subTableCode) {
return fields; return fields;
} }
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;
} }
}); });
if(withNoSubTableField){ if (withNoSubTableField) {
meta={ ...fields, ...subFields }; meta = { ...fields, ...subFields };
}else{ } else {
meta=subFields; meta = subFields;
} }
} }
return meta; return meta;
} }
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

@@ -26,8 +26,8 @@ function replaceKucTagsPlugin() {
const keyPascal = key.split('-') const keyPascal = key.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) .map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(''); .join('');
if(key==='multi-choice'){ if (key === 'multi-choice') {
key='multichoice'; key = 'multichoice';
} }
importScript += `import * as Kuc${keyPascal} from "kintone-ui-component/lib/${key}";` importScript += `import * as Kuc${keyPascal} from "kintone-ui-component/lib/${key}";`
}); });
@@ -83,6 +83,6 @@ export default defineConfig({
assetFileNames: 'src/[ext]/[name].[ext]', assetFileNames: 'src/[ext]/[name].[ext]',
}, },
}, },
sourcemap: false, sourcemap: 'inline',
} }
}) })