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