form input
parent
d78b04f2f7
commit
c4bde16ea2
|
|
@ -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 });
|
||||
}
|
||||
},
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue