mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-14 19:52:48 +00:00
up
This commit is contained in:
parent
d09a12489d
commit
e7a5f5d316
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user