This commit is contained in:
全栈小学生 2025-03-14 18:33:34 +08:00
parent d09a12489d
commit e7a5f5d316
3 changed files with 193 additions and 195 deletions

View File

@ -6,21 +6,19 @@
</view>
</template>
<script lang="ts" setup>
import { ref, reactive, onMounted } from 'vue';
import diyGroup from '@/addon/components/diy/group/index.vue'
import { getFormRecord } from '@/app/api/diy_form';
import { ref, reactive, onMounted } from 'vue';
import diyGroup from '@/addon/components/diy/group/index.vue'
import { getFormRecord } from '@/app/api/diy_form';
const props = defineProps(['record_id','completeLayout']);
const emits = defineEmits(['callback'])
const loading = ref(true);
const diyFormData: any = reactive({
const props = defineProps(['record_id', 'completeLayout']);
const emits = defineEmits(['callback'])
const loading = ref(true);
const diyFormData: any = reactive({
global: {},
value: []
})
})
onMounted(() => {
onMounted(() => {
getFormRecord({
record_id: props.record_id
}).then((res: any) => {
@ -55,5 +53,5 @@
loading.value = false;
emits('callback', [])
})
})
})
</script>

View File

@ -7,27 +7,27 @@
</view>
</template>
<script lang="ts" setup>
import { ref, reactive, computed, onMounted, watch } from 'vue';
import { useDiyForm } from '@/hooks/useDiyForm'
import { deepClone,getValidTime } from '@/utils/common'
import diyGroup from '@/addon/components/diy/group/index.vue'
import { ref, reactive, computed, onMounted, watch } from 'vue';
import { useDiyForm } from '@/hooks/useDiyForm'
import { deepClone, getValidTime } from '@/utils/common'
import diyGroup from '@/addon/components/diy/group/index.vue'
const props = defineProps(['form_id', 'relate_id', 'storage_name', 'form_border']);
const props = defineProps(['form_id', 'relate_id', 'storage_name', 'form_border']);
const diy = useDiyForm({
const diy = useDiyForm({
form_id: props.form_id,
needLogin: false //
})
})
const diyGroupRef = ref(null)
const diyGroupRef = ref(null)
const requestData = computed(() => {
const requestData = computed(() => {
return diy.requestData;
})
})
const diyFormData: any = reactive({})
const diyFormData: any = reactive({})
onMounted(() => {
onMounted(() => {
diy.getData(() => {
diyFormData.status = diy.data.status;
if (diyFormData.status) {
@ -38,7 +38,7 @@
diyFormData.global.bottomTabBarSwitch = false; //
}
let value: any = [];
if(props.form_border == 'none'){
if (props.form_border == 'none') {
diyFormData.global.borderControl = false;
}
//
@ -53,9 +53,9 @@
watchFormData();
}
})
})
})
const watchFormData = () => {
const watchFormData = () => {
watch(
() => diyFormData.value,
(newValue, oldValue) => {
@ -66,7 +66,7 @@
};
newValue.forEach((item: any) => {
//
if (item.componentType == 'diy_form' && item.componentName != 'FormSubmit') {
if (item.componentType == 'diy_form' && item.componentName != 'FormSubmit' && item.field.cache) {
//
let field = deepClone(item.field);
//
@ -90,11 +90,11 @@
},
{ deep: true }
)
}
}
const verify = () => {
if(!diyFormData.status) return true;
if(!diyFormData.value) return true;
const verify = () => {
if (!diyFormData.status) return true;
if (!diyFormData.value) return true;
let allPass = true; //
let componentRefs = diyGroupRef.value.getFormRef().componentRefs;
@ -138,46 +138,46 @@
uni.setStorageSync(props.storage_name, data)
}
return allPass;
}
}
//
const getData = ()=> {
//
const getData = () => {
return {
form_id: props.form_id,
value: diyFormData.value,
relate_id: props.relate_id || 0 // id
}
}
}
const clearStorage = (keys: any=[]) => {
const clearStorage = (keys: any = []) => {
uni.removeStorageSync('diyFormStorage_' + props.form_id)
if (props.storage_name) uni.removeStorageSync(props.storage_name)
if(keys) {
if (keys) {
keys.forEach((key: any) => {
uni.removeStorageSync(key)
})
}
}
}
//
diy.onHide();
//
diy.onHide();
//
diy.onUnload();
//
diy.onUnload();
//
// diy.onPageScroll()
//
// diy.onPageScroll()
defineExpose({
defineExpose({
verify,
getData,
clearStorage
})
})
</script>
<style lang="scss">
.diy-template-wrap {
.diy-template-wrap {
/* #ifdef MP */
.child-diy-template-wrap {
::v-deep .diy-group {
@ -186,6 +186,7 @@
}
}
}
/* #endif */
}
}
</style>

View File

@ -112,7 +112,6 @@
<template v-if="component.componentName == 'FormFile'">
<diy-form-file ref="diyFormFileRef" :component="component" :global="data.global" :index="index" />
</template>
</view>
</view>
<template v-if="diyStore.mode == '' && data.global && data.global.bottomTabBarSwitch">