刘妍 2024-06-01 15:04:33 +08:00
commit b7cdf2ca27
3 changed files with 73 additions and 14 deletions

View File

@ -21,7 +21,7 @@
<template v-for="(childItem, childIndex) in item.columns[0].children" :key="childIndex">
<a-row style="width: 100%;margin-bottom: 10px">
<a-col :span="childItem?.colProps?.span || 24">
<CallModalFormItem :data="childItem"/>
<CallModalCardFormItem :data="childItem" :parent="item.field" :record="cardLayoutData"/>
</a-col>
</a-row>
</template>
@ -56,10 +56,14 @@
</template>
</a-table>
<!-- todo 创建/修改 /时间 -->
<template v-for="(item, index) in createOrModifyList" :key="index">
<CreateOrModifyComponent :data="item"/>
</template>
</BasicModal>
</template>
<script lang="ts" setup>
import { unref, ref, reactive } from 'vue';
import { unref, ref, reactive, toRaw } from 'vue';
import { FormSchema } from '@/components/Table';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
@ -70,7 +74,9 @@
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import { v4 as uuidv4 } from 'uuid';
import FormItem from './ShowFormModal/FormItem/index.vue';
import CallModalFormItem from './CallModalFormItem/index.vue';
import CallModalCardFormItem from './CallModalFormItem/index.vue';
import CreateOrModifyComponent from './CreateOrModifyComponent/index.vue'
import dayjs from 'dayjs';
const emit = defineEmits(['success']);
const { createMessage } = useMessage();
@ -94,6 +100,7 @@
const subTableList: any = ref([]);
const scrollValue = ref();
const cardLayout = ref([])
const cardLayoutData = ref([])
const createOrModifyList = ref([])
const [registerModal, { setModalProps, closeModal }] = useModalInner((data: any) => {
console.log('daaaaa', data);
@ -113,6 +120,11 @@
formColumns.push(item);
if(item.component === "Card"){
cardLayout.value.push(item)
let obj = {}
item.columns[0].children.forEach(data => {
obj[data.field] = ""
})
cardLayoutData.value[item.field] = obj
}
if(['createuser','createtime','modifyuser','modifytime'].includes(item.type)){
createOrModifyList.value.push(item)
@ -227,6 +239,10 @@
try {
const values = await validate();
let query = values;
let cardLayoutKeys = Object.keys(cardLayoutData.value)
cardLayoutKeys.forEach((key) => {
query[key] = cardLayoutData.value[key]
})
let saveSubTableList = [];
subTableList.value.forEach((item) => {
let emptyObj = {};
@ -236,7 +252,9 @@
}
saveSubTableList.push(emptyObj);
});
query[subTableId.value] = JSON.stringify(saveSubTableList);
if(subTableId.value){
query[subTableId.value] = JSON.stringify(saveSubTableList);
}
let params: any = {
schemeId: primaryQuery.value.id,
isUpdate: isUpdate.value,
@ -245,6 +263,14 @@
console.log('params', params);
if (unref(isUpdate)) {
params.pkeyValue = primaryQuery.value.keyValue;
createOrModifyList.value.forEach(item => {
if(item.field.indexOf('modify_user') !== -1){
query[item.field] = localStorage.getItem('fireUserLoginName');
}
if(item.field.indexOf('modify_time') !== -1){
query[item.field] = dayjs().format('YYYY-MM-DD HH:mm:ss')
}
})
} else {
addQuery.value.forEach((item) => {
if (item.type == 'main') {
@ -254,6 +280,15 @@
query[item.field] = item.value;
}
});
createOrModifyList.value.forEach(item => {
// console.log('item',item)
if(item.field.indexOf('user') !== -1){
query[item.field] = localStorage.getItem('fireUserLoginName');
}
if(item.field.indexOf('time') !== -1){
query[item.field] = dayjs().format('YYYY-MM-DD HH:mm:ss')
}
})
}
params.data = JSON.stringify(query);
console.log('query222', query);

View File

@ -4,8 +4,15 @@
{{ props.data.label }}
</div>
<Comp
v-if="props.data.component === 'Switch'"
:options="props.data.componentProps.options"
v-model:checked="props.record[props.parent][props.data.field]"
/>
<Comp
v-else
:style="props.data.component === 'Select' ? 'width:120px' : ''"
:options="props.data.componentProps.options"
v-model:value="props.record[props.parent][props.data.field]"
/>
</div>
@ -14,8 +21,7 @@
<script setup lang="ts">
import { defineProps, defineEmits, ref } from 'vue';
import { componentMap } from '@/components/Form/src/componentMap';
const props = defineProps(['data', 'record']);
console.log(props.data,'props.data')
const props = defineProps(['data', 'record','parent']);
const Comp = componentMap.get(props.data.component);
</script>

View File

@ -1,17 +1,35 @@
<template>
<a-input v-model:value="isTime? nowTime: userName" readOnly>
<template #suffix>
<UserOutlined />
</template>
</a-input>
<a-row v-if="isTime && show" style="width:100%;margin-bottom:10px;">
<a-col flex="100px" style="display: flex;align-items: center;justify-content: right;padding-right: 7px;">{{ props.data.label }}</a-col>
<a-col flex="auto">
<a-input v-model:value="nowTime" readOnly>
<template #suffix>
<FieldTimeOutlined />
</template>
</a-input>
</a-col>
</a-row>
<a-row v-else-if="!isTime && show" style="width:100%;margin-bottom:10px;" >
<a-col flex="100px" style="display: flex;align-items: center;justify-content: right;padding-right: 7px;">{{ props.data.label }}</a-col>
<a-col flex="auto">
<a-input v-model:value="userName" readOnly>
<template #suffix>
<UserOutlined />
</template>
</a-input>
</a-col>
</a-row>
</template>
<script setup lang="ts">
import { ref, defineProps } from 'vue'
import { UserOutlined } from '@ant-design/icons-vue';
import { UserOutlined, FieldTimeOutlined } from '@ant-design/icons-vue';
import dayjs from 'dayjs';
const props = defineProps(['type'])
const isTime = props.type === 'time'
const props = defineProps(['data'])
const show = props.data.display
const isTime = ['createtime', 'modifytime'].includes(props.data.type)
const nowTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'))
const userName = localStorage.getItem('fireUserLoginName')
</script>