Add condition part
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
<script setup lang="ts">
|
||||
import type { CachedData, CachedSelectedAppData, SavedData, WhereCondition } from '@/types/model';
|
||||
import { defineProps, defineEmits, inject, computed, ref, reactive, render, h, watch, onMounted } from 'vue';
|
||||
import TableCombobox from './condition/TableCombobox.vue';
|
||||
import { getEmptyWhereCondition, getFieldsDropdownItems } from '@/js/helper';
|
||||
import { conditionList, getComponent, type ConditionValue } from '@/js/conditions';
|
||||
import TableCombobox from './TableCombobox.vue';
|
||||
import { getFieldsDropdownItems } from '@/js/helper';
|
||||
import type { ConditionValue } from '@/js/conditions';
|
||||
import TableCondition from './conditions/TableCondition.vue';
|
||||
import TableConditionValue from './conditions/TableConditionValue.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: WhereCondition[];
|
||||
@@ -25,13 +27,16 @@ const columns = [
|
||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||
const container = document.createElement('div');
|
||||
const vnode = h(TableCombobox, {
|
||||
items: getFieldsDropdownItems(selectedAppData.appFields, table.value),
|
||||
items: getFieldsDropdownItems(selectedAppData.appFields, {
|
||||
subTableCode: table.value,
|
||||
defaultLabel: 'すべてのレコード',
|
||||
}),
|
||||
modelValue: '',
|
||||
selectedAppData,
|
||||
'onUpdate:modelValue': (newValue: string) => {
|
||||
const res = getEmptyWhereCondition();
|
||||
res.field = newValue;
|
||||
props.modelValue[rowIndex] = res;
|
||||
props.modelValue[rowIndex].field = newValue;
|
||||
props.modelValue[rowIndex].condition = '';
|
||||
props.modelValue[rowIndex].data = '';
|
||||
},
|
||||
});
|
||||
render(vnode, container);
|
||||
@@ -43,16 +48,14 @@ const columns = [
|
||||
field: 'condition',
|
||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||
const container = document.createElement('div');
|
||||
const vnode = h(TableCombobox, {
|
||||
items: conditionList,
|
||||
const vnode = h(TableCondition, {
|
||||
modelValue: '',
|
||||
index: rowIndex,
|
||||
selectedAppData,
|
||||
whereConditions: props.modelValue,
|
||||
'onUpdate:modelValue': (newValue: string) => {
|
||||
const field = props.modelValue[rowIndex].field;
|
||||
const res = getEmptyWhereCondition();
|
||||
res.field = field;
|
||||
res.condition = newValue as ConditionValue;
|
||||
props.modelValue[rowIndex] = res;
|
||||
props.modelValue[rowIndex].condition = newValue as ConditionValue;
|
||||
props.modelValue[rowIndex].data = '';
|
||||
},
|
||||
});
|
||||
render(vnode, container);
|
||||
@@ -63,12 +66,12 @@ const columns = [
|
||||
title: '',
|
||||
field: 'data',
|
||||
render: (cellData: string, rowData: any, rowIndex: number) => {
|
||||
const vueComponent = getComponent(props.modelValue[rowIndex].condition);
|
||||
if (!vueComponent) return cellData;
|
||||
const container = document.createElement('div');
|
||||
const vnode = h(vueComponent, {
|
||||
const vnode = h(TableConditionValue, {
|
||||
modelValue: '',
|
||||
index: rowIndex,
|
||||
selectedAppData,
|
||||
whereConditions: props.modelValue,
|
||||
'onUpdate:modelValue': (newValue: string) => {
|
||||
props.modelValue[rowIndex].data = newValue;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user