form input

master
gongfuxiang 2025-10-22 16:01:31 +08:00
parent d78b04f2f7
commit c4bde16ea2
3 changed files with 51 additions and 35 deletions

View File

@ -620,21 +620,21 @@ export default {
return { ...item, ...match };
});
this.setData({ data_list: data_list });
this.$emit('onSubmitEvent', { type: 'error', submit_data: {}, message: message });
return { forminput_id: this.propFormInputId, type: 'error', submit_data: {}, message: message };
} else {
this.submit_data_parameter_handle();
return this.submit_data_parameter_handle();
}
} catch (error) {
this.$emit('onSubmitEvent', { type: 'error', submit_data: {}, message: '数据错误'});
return { forminput_id: this.propFormInputId, type: 'error', submit_data: {}, message: '数据错误'};
}
},
/*
* 表单提交参数处理
*/
submit_data_parameter_handle() {
try {
let forminput_id = this.propFormInputId;
try {
const submit_data = {};
// const filter_data = ['video', 'img', 'auxiliary-line', 'position', 'rect', 'round', 'text', 'attachments'];
//
this.filteredDiyData.forEach((item) => {
if (!this.filter_data.includes(item.key)) {
@ -682,9 +682,9 @@ export default {
}
}
});
this.$emit('onSubmitEvent', { type: 'success', submit_data: submit_data, message: ''});
return { forminput_id: forminput_id, type: 'success', submit_data: submit_data, message: ''};
} catch (error) {
this.$emit('onSubmitEvent', { type: 'error', submit_data: {}, message: '数据错误'});
return { forminput_id: forminput_id, type: 'error', submit_data: {}, message: '数据错误'};
}
},
/*
@ -744,7 +744,7 @@ export default {
//
com_data.data_list.forEach((form_item, index) => {
//
const form_data = this.filtered_Data(form_item.data_list);
const form_data = this.filtered_data(form_item.data_list);
form_data.forEach((data_item) => {
//
if (data_item.com_data.is_required !== '1') return;
@ -827,7 +827,7 @@ export default {
/*
* 子表单显隐规则数据处理
*/
filtered_Data(children) {
filtered_data(children) {
const componentMap = new Map(children.map((item) => [item.id, item]));
//
@ -910,7 +910,7 @@ export default {
const data = this.data_list.find((item) => item.id == e.id);
//
if (data) {
this.$emit('onItemEvent', { type: e.is_error == '1' ? 'error' : 'success', message: e.error_text, value: e.value, form_name: data.form_name });
this.$emit('onItemEvent', { forminput_id: this.propFormInputId, type: e.is_error == '1' ? 'error' : 'success', message: e.error_text, value: e.value, form_name: data.form_name, form_title: data.com_data.title });
}
},
/*

View File

@ -10,7 +10,7 @@
<view v-if="is_show_heading_title == '1'" class="head-title flex-row bg-white" :style="heading_title_style + (overall_config.type_value == 'default' ? '' : ('width:' + overall_config.custom_width * 2 + 'rpx;'))">{{ form_name }}</view>
<view class="data-list bg-white" :style="overall_config.type_value == 'default' ? '' : ('width:' + overall_config.custom_width * 2 + 'rpx;height:' + overall_config.custom_height * 2 + 'rpx')">
<!-- form表单子组件显示 -->
<form-input-base ref="componentForm" :propKey="propKey" :propConfig="propValue.config" :propFormInputId="propFormInputId" @onSubmitEvent="submit_event" />
<form-input-base ref="component_form" :propKey="propKey" :propConfig="propValue.config" :propFormInputId="propFormInputId" />
</view>
</view>
<!-- #endif -->
@ -29,7 +29,7 @@
<view v-if="is_show_heading_title == '1'" class="head-title flex-row bg-white" :style="heading_title_style + (overall_config.type_value == 'default' ? '' : ('width:' + overall_config.custom_width * 2 + 'rpx;'))">{{ form_name }}</view>
<view class="data-list bg-white" :style="overall_config.type_value == 'default' ? '' : ('width:' + overall_config.custom_width * 2 + 'rpx;height:' + overall_config.custom_height * 2 + 'rpx')">
<!-- form表单子组件显示 -->
<form-input-base ref="componentForm" :propKey="propKey" :propConfig="propValue.config" :propFormInputId="propFormInputId" @onSubmitEvent="submit_event" />
<form-input-base ref="component_form" :propKey="propKey" :propConfig="propValue.config" :propFormInputId="propFormInputId" />
</view>
</view>
</scroll-view>
@ -177,12 +177,7 @@ export default {
* 点击提交按钮触发方法
*/
on_submit_event() {
this.$refs.componentForm.on_submit_event();
},
/*
* 表单校验完成之后返回的数据内容
*/
submit_event(e) {
const e = this.$refs.component_form.on_submit_event();
const { type = 'success', message = '', submit_data = {}} = e;
if (type == 'error') {
app.globalData.showToast(message);

View File

@ -1,26 +1,15 @@
<template>
<view :class="theme_view">
<view v-if="data.length > 0" class="plugins-ordergoodsform-buy oh margin-top-sm">
<view v-for="(item, index) in data" :key="index" class="item pr oh">
<view class="title dis-block single-text text-size-sm pa">{{item.title}}</view>
<view class="value dis-block pa">
<view v-if="propIsRead">{{item.content}}</view>
<input v-else :type="((item.element_arr || null) == null || (item.element_arr[1] || null) == null) ? 'text' : item.element_arr[1]"
:placeholder="(item.placeholder || null) == null ? item.title : item.placeholder"
:data-index="index"
:value="item.default_value || ''"
@blur="input_value_event"
@confirm="input_value_event"
placeholder-class="cr-grey"
:class="'radius text-size-sm padding-horizontal-sm '+((item.check_status === undefined || item.check_status === true) ? 'br' : 'br-red')"
/>
</view>
</view>
<block v-for="(item, index) in data" :key="index">
<form-input-base ref="component_form" :propKey="index" :propConfig="item.config" :propFormInputId="item.id" @onItemEvent="item_change_event"/>
</block>
</view>
</view>
</template>
<script>
const app = getApp();
const app = getApp();
import formInputBase from '@/pages/form-input/components/form-input/form-input-base.vue';
export default {
data() {
return {
@ -28,7 +17,9 @@
data: [],
};
},
components: {},
components: {
formInputBase
},
props: {
propData: {
type: [Array],
@ -50,6 +41,32 @@
});
},
methods: {
//
item_change_event(e) {
console.log(e);
// var res = this.$refs.component_form[0].on_submit_event();
// console.log(res);
if(e.type == 'success') {
//
uni.request({
url: app.globalData.get_request_url('save', 'goods', 'ordergoodsform'),
method: 'POST',
data: {
goods_id: this.propGoodsID,
form_id: e.forminput_id,
content: e.value
},
dataType: 'json'
});
} else {
app.globalData.showToast(e.message);
}
},
//
input_value_event(e) {
//
@ -153,6 +170,10 @@
//
data_check() {
var res = this.$refs.component_form[0].on_submit_event();
console.log(res)
return false;
var status = true;
for(var i in this.data) {
var res = this.input_value_check(this.data[i], i);