conditons (FROM_TODAY)

This commit is contained in:
2025-01-27 17:41:02 +08:00
parent dfcb522951
commit 8d4ab48b89
6 changed files with 197 additions and 57 deletions

View File

@@ -12,13 +12,20 @@
<plugin-row class="footer-row border">
<kuc-button text="キャンセル" type="normal" @click="cancel" />
<kuc-button text="保存する" class="save-btn" type="submit" @click="save" />
<kuc-button :disabled="!canSave" text="保存する" class="save-btn" type="submit" @click="save" />
</plugin-row>
<kuc-spinner :container="mainArea" ref="spinner"></kuc-spinner>
</template>
<script setup lang="ts">
import { createEmptyJoinTable, loadApps, loadAppFieldsAndLayout, EMPTY_OPTION, getEmptyOnCondition, getMeta } from '@/js/helper';
import {
createEmptyJoinTable,
loadApps,
loadAppFieldsAndLayout,
EMPTY_OPTION,
getEmptyOnCondition,
getMeta,
} from '@/js/helper';
import { isType, type OneOf, type Properties } from '@/js/kintone-rest-api-client';
import type { CachedData, FieldsInfo, JoinTable, SavedData } from '@/types/model';
import type { Spinner } from 'kintone-ui-component';
@@ -27,6 +34,7 @@ import { onMounted, watch, provide, reactive, ref, shallowRef, nextTick } from '
const props = defineProps<{ pluginId: string }>();
const loading = ref(false);
const canSave = ref(true);
const data: SavedData = reactive({
buttonName: '',
joinTables: [createEmptyJoinTable()],
@@ -38,6 +46,9 @@ const cachedData: CachedData = reactive({
});
provide('savedData', data);
provide('canSave', (data: boolean) => {
canSave.value = data;
});
provide('cachedData', cachedData);
const mainArea = shallowRef<HTMLElement | null>(null);
@@ -65,6 +76,7 @@ watch(loading, (load) => {
watch(
() => data.joinTables.length,
(newLength) => {
console.log(data.joinTables);
if (newLength === 1) {
data.joinTables[0].onConditions = [getEmptyOnCondition()];
}
@@ -75,7 +87,7 @@ function save() {
const currentAppMeta = cachedData.currentAppFields.fields;
const convertJoinTables = JSON.parse(JSON.stringify(data.joinTables)) as JoinTable<OneOf | string>[];
convertJoinTables.forEach((item) => {
const meta = getMeta(item.meta as Properties, item.table,true);
const meta = getMeta(item.meta as Properties, item.table, true);
// Process onConditions
item.onConditions.forEach((condition) => {