新增子表单竖向模式
parent
64f7050e65
commit
0f83d1bee4
|
|
@ -1,26 +1,33 @@
|
|||
<template>
|
||||
<view :class="'flex-col ' + (propDirection == 'row' ? '' : 'gap-10')">
|
||||
<view class="flex-row align-c" :style="com_data.common_style + propStyle" @tap="open_ragion">
|
||||
<text v-if="province_name" class="flex-1 text-line-1">{{ province_name }}{{ city_name ? ' / ' + city_name : '' }}{{ county_name ? ' / ' + county_name : '' }}</text>
|
||||
<text v-else class="cr-gray flex-1 text-line-1">{{ placeholder }}</text>
|
||||
<template v-if="propDirection == 'row'">
|
||||
<iconfont name="icon-arrow-right" size="24rpx" color="#666" propContainerDisplay="flex"></iconfont>
|
||||
</template>
|
||||
<template v-else>
|
||||
<iconfont name="icon-arrow-bottom" size="24rpx" color="#666" propContainerDisplay="flex" ></iconfont>
|
||||
</template>
|
||||
</view>
|
||||
<view v-if="propDirection == 'row' && address_type == 'detailed'" class="border-line"></view>
|
||||
<view v-if="address_type == 'detailed'" class="flex-row">
|
||||
<textarea :value="detailed_value" class="uni-input flex-1 ht-auto" :style="com_data.common_style + propStyle + 'min-height:100rpx;' + (propDirection == 'row' ? '' : 'padding: 18rpx 22rpx;')" placeholder="请输入详细地址" @input="input_value_event" />
|
||||
<view>
|
||||
<view :class="'flex-col ' + (propDirection == 'row' ? '' : 'gap-10')">
|
||||
<view class="flex-row align-c" :style="com_data.common_style + propStyle" @tap="open_region">
|
||||
<text v-if="province_name" class="flex-1 text-line-1">{{ province_name }}{{ city_name ? ' / ' + city_name : '' }}{{ county_name ? ' / ' + county_name : '' }}</text>
|
||||
<text v-else class="cr-gray flex-1 text-line-1">{{ placeholder }}</text>
|
||||
<template v-if="propDirection == 'row'">
|
||||
<iconfont name="icon-arrow-right" size="24rpx" color="#666" propContainerDisplay="flex"></iconfont>
|
||||
</template>
|
||||
<template v-else>
|
||||
<iconfont name="icon-arrow-bottom" size="24rpx" color="#666" propContainerDisplay="flex" ></iconfont>
|
||||
</template>
|
||||
</view>
|
||||
<view v-if="propDirection == 'row' && address_type == 'detailed'" class="border-line"></view>
|
||||
<view v-if="address_type == 'detailed'" class="flex-row">
|
||||
<textarea :value="detailed_value" class="uni-input flex-1 ht-auto" :style="com_data.common_style + propStyle + 'min-height:100rpx;' + (propDirection == 'row' ? '' : 'padding: 18rpx 22rpx;')" placeholder="请输入详细地址" @input="input_value_event" />
|
||||
</view>
|
||||
</view>
|
||||
<component-region-picker :propProvinceId="province_id" :propCityId="city_id" :propCountyId="county_id" :propShow="region_picker_show" @onclose="close_event" @callBackEvent="region_event"></component-region-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { get_format_checks, isEmpty, formatNumber } from '@/common/js/common/common.js';
|
||||
import componentRegionPicker from '@/pages/common/components/region-picker/region-picker';
|
||||
const app = getApp();
|
||||
export default {
|
||||
components: {
|
||||
componentRegionPicker,
|
||||
},
|
||||
props: {
|
||||
propValue: {
|
||||
type: Object,
|
||||
|
|
@ -102,8 +109,42 @@
|
|||
form_value: value,
|
||||
});
|
||||
},
|
||||
open_ragion() {
|
||||
this.$emit('openRegion', { id: this.propDataId, province_id: this.province_id, city_id: this.city_id, county_id: this.county_id});
|
||||
// 打开地区选择器
|
||||
open_region(e) {
|
||||
this.setData({
|
||||
region_picker_show: true,
|
||||
});
|
||||
this.z_index_change(this.propDataId);
|
||||
},
|
||||
// 地区选择器关闭事件
|
||||
close_event(e) {
|
||||
this.setData({
|
||||
region_picker_show: false
|
||||
});
|
||||
this.z_index_change('');
|
||||
},
|
||||
// 地区选择器提交事件
|
||||
region_event(e) {
|
||||
let data = uni.getStorageSync(app.globalData.data.cache_region_picker_choice_key) || {};
|
||||
if((data.province || null) == null) {
|
||||
data.province = {};
|
||||
}
|
||||
if((data.city || null) == null) {
|
||||
data.city = {};
|
||||
}
|
||||
if((data.areal || null) == null) {
|
||||
data.areal = {};
|
||||
}
|
||||
this.setData({
|
||||
province_id: data.province.id || null,
|
||||
city_id: data.city.id || null,
|
||||
county_id: data.areal.id || null,
|
||||
province_name: data.province.name || '',
|
||||
city_name: data.city.name || '',
|
||||
county_name: data.areal.name || '',
|
||||
});
|
||||
// 改变对应id的数据
|
||||
this.$emit('regionEvent', { value: [ data.province.id, data.city.id, data.areal.id ], province_name: data.province.name, city_name: data.city.name, county_name: data.areal.name, id: this.propDataId });
|
||||
},
|
||||
data_check(val) {
|
||||
const { is_error = '0', error_text = '' } = get_format_checks(this.com_data, val, true, 'number');
|
||||
|
|
@ -115,6 +156,12 @@
|
|||
detailed_value: e.detail.value,
|
||||
});
|
||||
this.$emit('dataAddressChange', { value: e.detail.value, id: this.propDataId });
|
||||
},
|
||||
/**
|
||||
* 有值的时候就是将当前组件的层级调到最高,没有值的时候就是将当前组件的层级调回原样,避免弹出框出来的时候被其他组件盖住或悬浮在弹出框外部
|
||||
*/
|
||||
z_index_change(e) {
|
||||
this.$emit('zIndexChange', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
@helpIconEvent="help_icon_event"
|
||||
@subformHelpIconEvent="subform_help_icon_event"
|
||||
@zIndexChange="z_index_change"
|
||||
@regionEvent="region_event"
|
||||
@subformDataChange="subform_data_change"
|
||||
/>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
|
@ -48,7 +50,6 @@
|
|||
<uni-popup ref="popup" type="center" border-radius="20rpx">
|
||||
<view class="popup-content">{{ popup_help_content }}</view>
|
||||
</uni-popup>
|
||||
<component-region-picker :propProvinceId="province_id" :propCityId="city_id" :propCountyId="county_id" :propShow="region_picker_show" @onclose="close_event" @callBackEvent="region_event"></component-region-picker>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -56,12 +57,10 @@
|
|||
<script>
|
||||
import { isEmpty, common_form_styles_computer } from '@/common/js/common/common.js';
|
||||
const app = getApp();
|
||||
import componentRegionPicker from '@/pages/common/components/region-picker/region-picker';
|
||||
import componentShow from '@/pages/form-input/components/form-input/modules/component-show/index.vue';
|
||||
export default {
|
||||
name: 'formInput',
|
||||
components: {
|
||||
componentRegionPicker,
|
||||
componentShow
|
||||
},
|
||||
props: {
|
||||
|
|
@ -96,12 +95,6 @@ export default {
|
|||
submit_bg_color: '',
|
||||
bottom_fixed_style: '',
|
||||
popup_help_content: '',
|
||||
// 地址弹出框的处理
|
||||
address_id: '',
|
||||
province_id: '',
|
||||
city_id: '',
|
||||
county_id: '',
|
||||
region_picker_show: false,
|
||||
scrollTop: 0,
|
||||
z_index_id: '',
|
||||
};
|
||||
|
|
@ -155,6 +148,25 @@ export default {
|
|||
data.config.diy_data.forEach(item => {
|
||||
// 边框样式处理
|
||||
item.com_data.common_style = this.get_form_border_style(item.com_data.common_config, mobile.flex_direction || 'row', overall_config.type_value);
|
||||
// 子表单需要统一规整一下数据
|
||||
if (item.key == 'subform') {
|
||||
const { com_data } = item;
|
||||
item.com_data.data_list = [];
|
||||
let data_list = [];
|
||||
com_data.form_value.forEach(item => {
|
||||
const data = JSON.parse(JSON.stringify(com_data?.children || []));
|
||||
data.forEach(child => {
|
||||
if (!isEmpty(item[child.id])) {
|
||||
child.com_data.form_value = item[child.id];
|
||||
}
|
||||
});
|
||||
data_list.push({
|
||||
is_expand: false,
|
||||
data_list: data
|
||||
});
|
||||
});
|
||||
item.com_data.data_list = data_list;
|
||||
}
|
||||
});
|
||||
this.setData({
|
||||
z_index_id: '',
|
||||
|
|
@ -277,45 +289,30 @@ export default {
|
|||
this.setData({ popup_help_content: e });
|
||||
this.$refs.popup.open();
|
||||
},
|
||||
// 打开地区选择器
|
||||
open_region(e) {
|
||||
this.setData({
|
||||
region_picker_show: true,
|
||||
province_id: e?.province_id || '',
|
||||
city_id: e?.city_id || '',
|
||||
county_id: e?.county_id || '',
|
||||
address_id: e?.id || '',
|
||||
});
|
||||
},
|
||||
// 地区选择器关闭事件
|
||||
close_event(e) {
|
||||
this.setData({
|
||||
region_picker_show: false
|
||||
});
|
||||
},
|
||||
// 地区选择器提交事件
|
||||
region_event(e) {
|
||||
let data = uni.getStorageSync(app.globalData.data.cache_region_picker_choice_key) || {};
|
||||
if((data.province || null) == null) {
|
||||
data.province = {};
|
||||
}
|
||||
if((data.city || null) == null) {
|
||||
data.city = {};
|
||||
}
|
||||
if((data.areal || null) == null) {
|
||||
data.areal = {};
|
||||
}
|
||||
const { value, id, province_name, city_name, county_name } = e;
|
||||
// 改变对应id的数据
|
||||
const data_list = [...this.data_list];
|
||||
data_list.forEach(item => {
|
||||
if (item.id == this.address_id && item.com_data) {
|
||||
item.com_data.form_value = [ data.province.id, data.city.id, data.areal.id ];
|
||||
item.com_data.province_name = data.province.name || '';
|
||||
item.com_data.city_name = data.city.name || '';
|
||||
item.com_data.county_name = data.areal.name || '';
|
||||
const data = [...this.data_list];
|
||||
data.forEach(item => {
|
||||
if (item.id == id && item.com_data) {
|
||||
item.com_data.form_value = value;
|
||||
item.com_data.province_name = province_name;
|
||||
item.com_data.city_name = city_name;
|
||||
item.com_data.county_name = county_name;
|
||||
}
|
||||
});
|
||||
this.setData({ data_list: data_list });
|
||||
this.setData({ data_list: data });
|
||||
},
|
||||
subform_data_change(e, id) {
|
||||
// 改变对应id的数据
|
||||
const data = [...this.data_list];
|
||||
data.forEach(item => {
|
||||
if (item.id == id && item.com_data) {
|
||||
item.com_data.data_list = e
|
||||
}
|
||||
});
|
||||
this.setData({ data_list: data });
|
||||
},
|
||||
z_index_change(e) {
|
||||
this.setData({
|
||||
|
|
|
|||
|
|
@ -27,78 +27,115 @@
|
|||
</view>
|
||||
<!-- #endif -->
|
||||
<view class="flex-1 wh-auto ht-auto flex-col gap-5 oh">
|
||||
<!-- 输入框 -->
|
||||
<view v-if="['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'single-text'" :style="item.com_data.common_style">
|
||||
<component-input :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-input>
|
||||
</view>
|
||||
<!-- 多行输入框 -->
|
||||
<view v-else-if="item.key == 'multi-text'" :style="item.com_data.common_style + 'padding: 18rpx 22rpx;'">
|
||||
<component-textarea :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-textarea>
|
||||
</view>
|
||||
<!-- 复选按钮组 -->
|
||||
<view v-else-if="['select-multi', 'checkbox'].includes(item.key) && item.com_data.type == 'checkbox' && propDirection !== 'row'">
|
||||
<component-checkbox :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @dataOptionChange="data_option_change"></component-checkbox>
|
||||
</view>
|
||||
<!-- 单选按钮组 -->
|
||||
<view v-else-if="['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'radio-btns' && propDirection !== 'row'">
|
||||
<component-radio :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-radio>
|
||||
</view>
|
||||
<!-- 下拉框 -->
|
||||
<view v-else-if="(['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'select') || (['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'radio-btns' && propDirection == 'row')" :style="item.com_data.common_style">
|
||||
<component-select :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propDirection="propDirection" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-select>
|
||||
</view>
|
||||
<!-- 下拉复选框 -->
|
||||
<view v-else-if="(['select-multi', 'checkbox'].includes(item.key) && item.com_data.type == 'select-multi') || (['select-multi', 'checkbox'].includes(item.key) && item.com_data.type == 'checkbox' && propDirection == 'row')" :style="item.com_data.common_style">
|
||||
<component-select-multi :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propDirection="propDirection" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @dataOptionChange="data_option_change" @zIndexChange="z_index_change"></component-select-multi>
|
||||
</view>
|
||||
<!-- 数字 -->
|
||||
<view v-else-if="item.key == 'number'" :style="item.com_data.common_style">
|
||||
<component-number :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-number>
|
||||
</view>
|
||||
<!-- 时间选择器 -->
|
||||
<view v-else-if="item.key == 'date'" :style="item.com_data.common_style">
|
||||
<component-date :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-date>
|
||||
</view>
|
||||
<!-- 时间选择器组 -->
|
||||
<view v-else-if="item.key == 'date-group'" :style="item.com_data.common_style">
|
||||
<component-date-group :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-date-group>
|
||||
</view>
|
||||
<!-- 地址 -->
|
||||
<view v-else-if="item.key == 'address'">
|
||||
<component-address :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change" @openRegion="open_region" @dataAddressChange="data_address_change"></component-address>
|
||||
<component-address :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change" @regionEvent="region_event" @dataAddressChange="data_address_change" @zIndexChange="z_index_change"></component-address>
|
||||
</view>
|
||||
<!-- 手机 -->
|
||||
<view v-else-if="item.key == 'phone'">
|
||||
<component-phone :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change" @dataCodeCheck="data_code_check" @dataCodeChage="data_code_chage" @zIndexChange="z_index_change"></component-phone>
|
||||
<component-phone :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change" @dataCodeCheck="data_code_check" @dataCodeChage="data_code_change" @zIndexChange="z_index_change"></component-phone>
|
||||
</view>
|
||||
<!-- 密码 -->
|
||||
<view v-else-if="item.key == 'pwd'" :style="item.com_data.common_style">
|
||||
<component-pwd :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change"></component-pwd>
|
||||
</view>
|
||||
<!-- 评分 -->
|
||||
<view v-else-if="item.key == 'score'">
|
||||
<component-score :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change"></component-score>
|
||||
</view>
|
||||
<!-- 图片 -->
|
||||
<view v-else-if="item.key == 'img'" :class="propIsCustom ? 'wh-auto ht-auto' : ''">
|
||||
<component-image :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" :propIsCustom="propIsCustom"></component-image>
|
||||
</view>
|
||||
<!-- 视频 -->
|
||||
<view v-else-if="item.key == 'video'" :class="propIsCustom ? 'wh-auto ht-auto' : ''">
|
||||
<component-video :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" :propIsCustom="propIsCustom"></component-video>
|
||||
</view>
|
||||
<!-- 文本 -->
|
||||
<view v-else-if="item.key == 'text'">
|
||||
<component-text :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection"></component-text>
|
||||
</view>
|
||||
<!-- 文件 -->
|
||||
<view v-else-if="item.key == 'attachments'">
|
||||
<component-attachments :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection"></component-attachments>
|
||||
</view>
|
||||
<!-- 辅助线 -->
|
||||
<view v-else-if="item.key == 'auxiliary-line'">
|
||||
<component-auxiliary-line :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection"></component-auxiliary-line>
|
||||
</view>
|
||||
<!-- 上传视频或图片 -->
|
||||
<view v-else-if="['upload-img', 'upload-video'].includes(item.key)" :class="propDirection == 'row' ? 'padding-vertical-sm' : ''">
|
||||
<component-upload :propValue="item.com_data" :propType="item.key == 'upload-img' ? 'img' : ( item.key == 'upload-video' ? 'video' : 'file')" :propKey="propKey" :propDataFormId="propDataFormId" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-upload>
|
||||
</view>
|
||||
<!-- 定位 -->
|
||||
<view v-else-if="item.key == 'position'">
|
||||
<component-position :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-position>
|
||||
</view>
|
||||
<!-- 圆形和矩形 -->
|
||||
<view v-else-if="['rect', 'round'].includes(item.key)" :class="propIsCustom ? 'wh-auto ht-auto' : ''">
|
||||
<component-rect-or-round :propValue="item.com_data" :propKey="propKey"></component-rect-or-round>
|
||||
</view>
|
||||
<!-- 子表单 -->
|
||||
<view v-else-if="item.key == 'subform'">
|
||||
<component-subform :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" :propTitleStyle="propTitleStyle" :propHelpIconStyle="propHelpIconStyle" @subformHelpIconEvent="subform_help_icon_event"></component-subform>
|
||||
<component-subform
|
||||
:propValue="item.com_data"
|
||||
:propKey="propKey"
|
||||
:propDataId="item.id"
|
||||
:propMobile="propMobile"
|
||||
:propStyle="propComponentStyle"
|
||||
:propDirection="propDirection"
|
||||
:propTitleStyle="propTitleStyle"
|
||||
:propHelpIconStyle="propHelpIconStyle"
|
||||
:propFieldLabelStyle="propFieldLabelStyle"
|
||||
:propDataFormId="propDataFormId"
|
||||
@subformHelpIconEvent="subform_help_icon_event"
|
||||
@subformDataChange="subform_data_change"
|
||||
/>
|
||||
</view>
|
||||
<!-- #ifdef H5 || MP-WEIXIN || MP-QQ -->
|
||||
<!-- 上传文件 -->
|
||||
<view v-else-if="item.key == 'upload-attachments'">
|
||||
<component-upload :propValue="item.com_data" propType="file" :propKey="propKey" :propDataFormId="propDataFormId" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-upload>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU -->
|
||||
<!-- 富文本 -->
|
||||
<view v-else-if="item.key == 'rich-text'" :style="item.com_data.common_style + 'padding:0;'">
|
||||
<component-rich-text :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-rich-text>
|
||||
</view>
|
||||
|
|
@ -256,8 +293,11 @@ export default {
|
|||
data_address_change(e) {
|
||||
this.$emit('dataAddressChange', e);
|
||||
},
|
||||
open_region(e) {
|
||||
this.$emit('openRegion', e);
|
||||
subform_data_change(e, id) {
|
||||
this.$emit('subformDataChange', e, id);
|
||||
},
|
||||
region_event(e) {
|
||||
this.$emit('regionEvent', e);
|
||||
},
|
||||
z_index_change(e) {
|
||||
this.setData({
|
||||
|
|
|
|||
|
|
@ -0,0 +1,297 @@
|
|||
<template>
|
||||
<view class="wh-auto ht-auto pr">
|
||||
<view v-for="(item, index) in data_list" :key="index" :class="(propIsCustom ? 'pa ' : (propDirection == 'row' ? 'row-item ' : 'column-item mb-10 ')) + (item.com_data.common_config.is_error == '1' ? ' item_error' : '')" :data-id="item.id" :data-location-x="item.location.x" :data-location-y="item.location.y" :style="(item.key == 'auxiliary-line' ? 'border-bottom: 0rpx; ' : '') + (propIsCustom ? ('left:' + item.location.x + 'px;top:' + item.location.y + 'px;width:' + item.com_data.com_width + 'px;height:' + item.com_data.com_height + 'px;z-index:' + (z_index_id == item.id ? '999' : (item.is_enable == '1' ? (data_list.length - 1 > 0 ? (data_list.length - 1) - index : 0) : -999)) + ';') : '')">
|
||||
<view :class="'wh-auto ht-auto ' + (propDirection == 'row' ? (['video', 'img', 'upload-img', 'upload-video', 'multi-text'].includes(item.key) ? 'flex-row align-s gap-10' : 'flex-row align-b gap-10') : 'flex-col gap-10')">
|
||||
<view v-if="(!propIsCustom && !['rich-text', 'auxiliary-line', 'upload-attachments', 'subform'].includes(item.key)) || (propIsCustom && !['img', 'video', 'auxiliary-line', 'rect', 'round', 'rich-text', 'upload-attachments', 'subform'].includes(item.key))" class="field-label flex-row align-c gap-10" :style="propFieldLabelStyle + (propDirection == 'row' && ['upload-img', 'upload-video'].includes(item.key) ? 'padding-top: 12rpx;line-height: 120rpx;' : '') + (propDirection == 'row' && ['multi-text'].includes(item.key) ? 'padding-top: 18rpx;' : '')">
|
||||
<view class="flex-row align-c" :style="propTitleStyle">{{ item.com_data.title }}<view v-if="item.com_data.is_required == '1'" class="required">*</view></view>
|
||||
<view v-if="item.com_data.common_config.help_is_show == '1' && !isEmpty(item.com_data.common_config.help_explain)" :data-value="item.com_data.common_config.help_explain" @tap="help_icon_event">
|
||||
<iconfont name="icon-miaosha-hdgz" :size="propHelpIconStyle" color="#999"></iconfont>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上传文件仅支持H5、微信小程序、QQ小程序 -->
|
||||
<!-- #ifdef H5 || MP-WEIXIN || MP-QQ -->
|
||||
<view v-if="item.key == 'upload-attachments'" class="field-label flex-row align-c gap-10" :style="propFieldLabelStyle">
|
||||
<view class="flex-row align-c" :style="propTitleStyle">{{ item.com_data.title }}<view v-if="item.com_data.is_required == '1'" class="required">*</view></view>
|
||||
<view v-if="item.com_data.common_config.help_is_show == '1' && !isEmpty(item.com_data.common_config.help_explain)" :data-value="item.com_data.common_config.help_explain" @tap="help_icon_event">
|
||||
<iconfont name="icon-miaosha-hdgz" :size="propHelpIconStyle" color="#999"></iconfont>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<view class="flex-1 wh-auto ht-auto flex-col gap-5 oh">
|
||||
<!-- 输入框 -->
|
||||
<view v-if="['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'single-text'" :style="item.com_data.common_style">
|
||||
<component-input :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-input>
|
||||
</view>
|
||||
<!-- 多行输入框 -->
|
||||
<view v-else-if="item.key == 'multi-text'" :style="item.com_data.common_style + 'padding: 18rpx 22rpx;'">
|
||||
<component-textarea :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-textarea>
|
||||
</view>
|
||||
<!-- 复选按钮组 -->
|
||||
<view v-else-if="['select-multi', 'checkbox'].includes(item.key) && item.com_data.type == 'checkbox' && propDirection !== 'row'">
|
||||
<component-checkbox :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @dataOptionChange="data_option_change"></component-checkbox>
|
||||
</view>
|
||||
<!-- 单选按钮组 -->
|
||||
<view v-else-if="['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'radio-btns' && propDirection !== 'row'">
|
||||
<component-radio :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-radio>
|
||||
</view>
|
||||
<!-- 下拉框 -->
|
||||
<view v-else-if="(['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'select') || (['single-text', 'radio-btns', 'select'].includes(item.key) && item.com_data.type == 'radio-btns' && propDirection == 'row')" :style="item.com_data.common_style">
|
||||
<component-select :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propDirection="propDirection" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-select>
|
||||
</view>
|
||||
<!-- 下拉复选框 -->
|
||||
<view v-else-if="(['select-multi', 'checkbox'].includes(item.key) && item.com_data.type == 'select-multi') || (['select-multi', 'checkbox'].includes(item.key) && item.com_data.type == 'checkbox' && propDirection == 'row')" :style="item.com_data.common_style">
|
||||
<component-select-multi :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propDirection="propDirection" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @dataOptionChange="data_option_change" @zIndexChange="z_index_change"></component-select-multi>
|
||||
</view>
|
||||
<!-- 数字 -->
|
||||
<view v-else-if="item.key == 'number'" :style="item.com_data.common_style">
|
||||
<component-number :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change"></component-number>
|
||||
</view>
|
||||
<!-- 时间选择器 -->
|
||||
<view v-else-if="item.key == 'date'" :style="item.com_data.common_style">
|
||||
<component-date :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-date>
|
||||
</view>
|
||||
<!-- 时间选择器组 -->
|
||||
<view v-else-if="item.key == 'date-group'" :style="item.com_data.common_style">
|
||||
<component-date-group :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-date-group>
|
||||
</view>
|
||||
<!-- 地址选择器 -->
|
||||
<view v-else-if="item.key == 'address'">
|
||||
<component-address :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change" @regionEvent="region_event" @dataAddressChange="data_address_change" @zIndexChange="z_index_change"></component-address>
|
||||
</view>
|
||||
<!-- 手机 -->
|
||||
<view v-else-if="item.key == 'phone'">
|
||||
<component-phone :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change" @zIndexChange="z_index_change"></component-phone>
|
||||
</view>
|
||||
<!-- 密码 -->
|
||||
<view v-else-if="item.key == 'pwd'" :style="item.com_data.common_style">
|
||||
<component-pwd :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change"></component-pwd>
|
||||
</view>
|
||||
<!-- 评分 -->
|
||||
<view v-else-if="item.key == 'score'">
|
||||
<component-score :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataCheck="data_check" @dataChange="data_change"></component-score>
|
||||
</view>
|
||||
<!-- 图片 -->
|
||||
<view v-else-if="item.key == 'img'" :class="propIsCustom ? 'wh-auto ht-auto' : ''">
|
||||
<component-image :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" :propIsCustom="propIsCustom"></component-image>
|
||||
</view>
|
||||
<!-- 视频 -->
|
||||
<view v-else-if="item.key == 'video'" :class="propIsCustom ? 'wh-auto ht-auto' : ''">
|
||||
<component-video :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" :propIsCustom="propIsCustom"></component-video>
|
||||
</view>
|
||||
<!-- 文本 -->
|
||||
<view v-else-if="item.key == 'text'">
|
||||
<component-text :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection"></component-text>
|
||||
</view>
|
||||
<!-- 文件 -->
|
||||
<view v-else-if="item.key == 'attachments'">
|
||||
<component-attachments :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection"></component-attachments>
|
||||
</view>
|
||||
<!-- 分割线 -->
|
||||
<view v-else-if="item.key == 'auxiliary-line'">
|
||||
<component-auxiliary-line :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection"></component-auxiliary-line>
|
||||
</view>
|
||||
<!-- 上传视频或图片 -->
|
||||
<view v-else-if="['upload-img', 'upload-video'].includes(item.key)" :class="propDirection == 'row' ? 'padding-vertical-sm' : ''">
|
||||
<component-upload :propValue="item.com_data" :propType="item.key == 'upload-img' ? 'img' : ( item.key == 'upload-video' ? 'video' : 'file')" :propKey="propKey" :propDataFormId="propDataFormId" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-upload>
|
||||
</view>
|
||||
<!-- 定位 -->
|
||||
<view v-else-if="item.key == 'position'">
|
||||
<component-position :propValue="item.com_data" :propKey="propKey" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-position>
|
||||
</view>
|
||||
<!-- #ifdef H5 || MP-WEIXIN || MP-QQ -->
|
||||
<!-- 上传文件 -->
|
||||
<view v-else-if="item.key == 'upload-attachments'">
|
||||
<component-upload :propValue="item.com_data" propType="file" :propKey="propKey" :propDataFormId="propDataFormId" :propDataId="item.id" :propMobile="propMobile" :propStyle="propComponentStyle" :propDirection="propDirection" @dataChange="data_change"></component-upload>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<view v-if="!isEmpty(item.com_data.common_config.error_text)" class="field-invalid-info">{{ item.com_data.common_config.error_text }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isEmpty } from '@/common/js/common/common.js';
|
||||
import componentInput from '@/pages/form-input/components/form-input/input.vue';
|
||||
import componentTextarea from '@/pages/form-input/components/form-input/textarea.vue';
|
||||
import componentCheckbox from '@/pages/form-input/components/form-input/checkbox.vue';
|
||||
import componentRadio from '@/pages/form-input/components/form-input/radio.vue';
|
||||
import componentSelect from '@/pages/form-input/components/form-input/select.vue';
|
||||
import componentNumber from '@/pages/form-input/components/form-input/number.vue';
|
||||
import componentDate from '@/pages/form-input/components/form-input/date.vue';
|
||||
import componentDateGroup from '@/pages/form-input/components/form-input/date-group.vue';
|
||||
import componentAddress from '@/pages/form-input/components/form-input/address.vue';
|
||||
import componentSelectMulti from '@/pages/form-input/components/form-input/select-multi.vue';
|
||||
import componentPhone from '@/pages/form-input/components/form-input/phone.vue';
|
||||
import componentPwd from '@/pages/form-input/components/form-input/pwd.vue';
|
||||
import componentScore from '@/pages/form-input/components/form-input/score.vue';
|
||||
import componentImage from '@/pages/form-input/components/form-input/image.vue';
|
||||
import componentVideo from '@/pages/form-input/components/form-input/video.vue';
|
||||
import componentText from '@/pages/form-input/components/form-input/text.vue';
|
||||
import componentAttachments from '@/pages/form-input/components/form-input/attachments.vue';
|
||||
import componentAuxiliaryLine from '@/pages/form-input/components/form-input/auxiliary-line.vue';
|
||||
import componentRichText from '@/pages/form-input/components/form-input/rich-text.vue';
|
||||
import componentUpload from '@/pages/form-input/components/form-input/upload.vue';
|
||||
import componentPosition from '@/pages/form-input/components/form-input/position.vue';
|
||||
import componentRectOrRound from '@/pages/form-input/components/form-input/rect-or-round.vue';
|
||||
import componentSubform from '@/pages/form-input/components/form-input/subform.vue';
|
||||
export default {
|
||||
name: 'formInput',
|
||||
components: {
|
||||
componentInput,
|
||||
componentTextarea,
|
||||
componentCheckbox,
|
||||
componentRadio,
|
||||
componentNumber,
|
||||
componentSelect,
|
||||
componentSelectMulti,
|
||||
componentDate,
|
||||
componentDateGroup,
|
||||
componentAddress,
|
||||
componentPhone,
|
||||
componentPwd,
|
||||
componentScore,
|
||||
componentImage,
|
||||
componentVideo,
|
||||
componentText,
|
||||
componentAttachments,
|
||||
componentAuxiliaryLine,
|
||||
componentRichText,
|
||||
componentUpload,
|
||||
componentPosition,
|
||||
componentRectOrRound,
|
||||
componentSubform
|
||||
},
|
||||
props: {
|
||||
propValue: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
propFieldLabelStyle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propTitleStyle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propHelpIconStyle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propDataFormId: {
|
||||
type: [String, Number],
|
||||
default: '',
|
||||
},
|
||||
propKey: {
|
||||
type: [String, Number],
|
||||
default: 0,
|
||||
},
|
||||
propDirection: {
|
||||
type: String,
|
||||
default: 'row',
|
||||
},
|
||||
propMobile: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
propComponentStyle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propIsCustom: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
propIndex: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
data_list: [],
|
||||
z_index_id: '',
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
propValue: {
|
||||
handler(newVal) {
|
||||
this.init();
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
propKey(val) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
isEmpty,
|
||||
init() {
|
||||
this.setData({
|
||||
data_list: this.propValue,
|
||||
z_index_id: '',
|
||||
})
|
||||
},
|
||||
help_icon_event(e) {
|
||||
this.$emit('helpIconEvent', e.currentTarget.dataset.value);
|
||||
},
|
||||
subform_help_icon_event(e) {
|
||||
this.$emit('subformHelpIconEvent', e, this.propIndex);
|
||||
},
|
||||
data_change(e) {
|
||||
this.$emit('dataChange', e, this.propIndex);
|
||||
},
|
||||
data_check(e) {
|
||||
this.$emit('dataCheck', e, this.propIndex);
|
||||
},
|
||||
data_option_change(e) {
|
||||
this.$emit('dataOptionChange', e, this.propIndex);
|
||||
},
|
||||
open_region(e) {
|
||||
this.$emit('openRegion', e, this.propIndex);
|
||||
},
|
||||
region_event(e) {
|
||||
this.$emit('regionEvent', e, this.propIndex);
|
||||
},
|
||||
z_index_change(e) {
|
||||
this.setData({
|
||||
z_index_id: e
|
||||
});
|
||||
this.$emit('zIndexChange', e, this.propIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.row-item {
|
||||
padding: 10rpx 15rpx;
|
||||
border-bottom: 2rpx solid #eee;
|
||||
overflow: hidden;
|
||||
}
|
||||
.row-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.column-item {
|
||||
padding: 20rpx 15rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
.item_error {
|
||||
background: #fef6e6;
|
||||
}
|
||||
.field-invalid-info {
|
||||
color: #FF5353;
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
.required {
|
||||
color: #FF5353;
|
||||
font-weight: 700;
|
||||
padding-left: 6rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -9,25 +9,60 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="flex-row align-c gap-10">
|
||||
<button class="title_btn">
|
||||
<button class="title_btn" @tap="add_item">
|
||||
<iconfont name="icon-add" size="24rpx" color="#2196F3" propContainerDisplay="flex"></iconfont>
|
||||
</button>
|
||||
<button class="title_btn flex-row align-c gap-10">全部收起<iconfont name="icon-arrow-top" size="24rpx" color="#2196F3" propContainerDisplay="flex"></iconfont></button>
|
||||
<button v-if="!isEmpty(data_list)" class="title_btn flex-row align-c gap-10" :data-value="is_all_away" @tap="expand_all">{{ is_all_away ? '全部收起' : '全部展开' }}<iconfont :name="is_all_away ? 'icon-arrow-top' : 'icon-arrow-bottom'" size="24rpx" color="#2196F3" propContainerDisplay="flex"></iconfont></button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="mobile.arrange == 'direction'">
|
||||
<view v-for="(item, index) in form_value" :key="index" class="direction-style">
|
||||
<view v-if="mobile.arrange == 'direction'" class="direction-style">
|
||||
<view v-for="(item, index) in data_list" :key="index" class="subform-line oh" :style="'height:' + (item.is_expand ? '100%;' : '150rpx;')">
|
||||
<!-- 标题操作 -->
|
||||
<view class="subform-title-btns flex-row align-c jc-sb">
|
||||
<span class="subform-number">{{ index + 1 }}</span>
|
||||
<view class="flex-row align-c gap-10">
|
||||
<view class="cr-blue size-12" :data-index="index">更多</view>
|
||||
<view class="cr-blue size-12" :data-index="index">删除</view>
|
||||
<view class="cr-blue size-12" :data-index="index">展开</view>
|
||||
<view class="cr-blue size-12" :data-index="index" @tap="more_click">更多</view>
|
||||
<view class="cr-blue size-12" :data-index="index" @tap="delete_item">删除</view>
|
||||
<view class="cr-blue size-12 flex-row align-c gap-5" :data-index="index" @tap="expand_or_collapse">{{ item.is_expand ? '收起' : '展开' }}<iconfont :name="item.is_expand ? 'icon-arrow-top' : 'icon-arrow-bottom'" size="24rpx" color="#2196F3" propContainerDisplay="flex"></iconfont></view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<template v-if="!item.is_expand">
|
||||
<view :class="'flex-row align-c jc-s gap-5 expand-title text-line-1 nowrap' + (is_error(item.data_list) ? ' required-error' : '')">
|
||||
<template v-if="!isEmpty(show_list(item.data_list))">
|
||||
<view v-for="(briefing_item, briefing_index) in show_list(item.data_list)" :key="briefing_index" class="flex-row align-c gap-5">
|
||||
<view :class="data_conversion(briefing_item) == 'empty_conversion' ? 'empty' : ''">{{ data_conversion(briefing_item) == 'empty_conversion' ? '暂无内容' : data_conversion(briefing_item) }}</view><span v-if="briefing_index < show_list(item.data_list).length - 1" class="empty">|</span>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
暂无数据
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<subform-component-show
|
||||
:propValue="filteredDiyData(item.data_list)"
|
||||
:propFieldLabelStyle="propFieldLabelStyle"
|
||||
:propTitleStyle="propTitleStyle"
|
||||
:propHelpIconStyle="propHelpIconStyle"
|
||||
:propDataFormId="propDataFormId"
|
||||
:propKey="propKey"
|
||||
:propIndex="index"
|
||||
propDirection="row"
|
||||
:propMobile="propMobile"
|
||||
:propComponentStyle="propStyle"
|
||||
@dataChange="data_change"
|
||||
@dataCheck="data_check"
|
||||
@dataOptionChange="data_option_change"
|
||||
@openRegion="open_region"
|
||||
@helpIconEvent="help_icon_event"
|
||||
@regionEvent="region_event"
|
||||
@zIndexChange="z_index_change"
|
||||
/>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
<view class="direction-bottom flex-row align-c jc-c gap-10 cr-blue">
|
||||
<view class="direction-bottom flex-row align-c jc-c gap-10 cr-blue" :style="( data_list.length > 0 ? 'border-top: 2rpx solid #ccc;' : '')" @tap="add_item">
|
||||
<iconfont name="icon-add" size="32rpx" color="#2196F3" propContainerDisplay="flex"></iconfont>
|
||||
添加记录
|
||||
</view>
|
||||
|
|
@ -35,12 +70,27 @@
|
|||
<view v-else>
|
||||
|
||||
</view>
|
||||
<!-- 弹窗 -->
|
||||
<uni-popup ref="morePopup" type="bottom" class="popup-bottom" background-color="#fff" :animation="true" @maskClick="quick_close_event">
|
||||
<view class="bg-white popup-content action-sheet">
|
||||
<view class="action-sheet-item" data-value="copy" @tap="copy">复制到下一行</view>
|
||||
<view class="action-sheet-item" data-value="copy_last" @tap="copy">复制到最后一行</view>
|
||||
<view class="action-sheet-item" data-value="insert_up" @tap="copy">向上插入记录</view>
|
||||
<view class="action-sheet-item" data-value="insert_down" @tap="copy" >向下插入记录</view>
|
||||
<view class="action-sheet-segment"></view>
|
||||
<view class="action-sheet-item" @tap="quick_close_event">取消</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isEmpty } from '@/common/js/common/common.js';
|
||||
import subformComponentShow from '@/pages/form-input/components/form-input/modules/subform-component-show/index.vue';
|
||||
export default {
|
||||
components: {
|
||||
subformComponentShow
|
||||
},
|
||||
props: {
|
||||
propValue: {
|
||||
type: Object,
|
||||
|
|
@ -58,6 +108,10 @@
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propFieldLabelStyle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
propTitleStyle: {
|
||||
type: String,
|
||||
default: '',
|
||||
|
|
@ -66,12 +120,25 @@
|
|||
type: String,
|
||||
default: '20rpx',
|
||||
},
|
||||
propDataFormId: {
|
||||
type: [String, Number],
|
||||
default: '',
|
||||
},
|
||||
propMobile: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
com_data: {},
|
||||
form_value: [],
|
||||
mobile: {}
|
||||
data_list: [],
|
||||
children_list: [],
|
||||
mobile: {},
|
||||
direction_fixed: 'the_first_three',
|
||||
briefing_field: [],
|
||||
more_index: 0,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
|
@ -80,6 +147,65 @@
|
|||
this.init();
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
is_all_away() {
|
||||
if (this.data_list.length == 0) {
|
||||
return true;
|
||||
}
|
||||
const list = this.data_list.filter(item => item.is_expand);
|
||||
return list.length == this.data_list.length;
|
||||
},
|
||||
filteredDiyData() {
|
||||
return (children_item) => {
|
||||
const componentMap = new Map(children_item.map((item) => [item.id, item]));
|
||||
|
||||
// 取出所有设置显隐规则的组件
|
||||
const list = children_item.filter((item) => ['single-text', 'select', 'radio-btns'].includes(item.key) && ['select', 'radio-btns'].includes(item.com_data.type) && item.com_data.show_hidden_list.length > 0);
|
||||
const list_map = list.map((item) => ({ id: item.id, list: item.com_data.show_hidden_list }));
|
||||
return children_item.filter((item) => {
|
||||
// 优先判断是否启用
|
||||
if (item.is_enable !== '1') return false;
|
||||
|
||||
if (list_map.length === 0) return true;
|
||||
// 将所有的内容的组件进行筛选
|
||||
const isShownByRule = list_map.some((list_item) => {
|
||||
const targetComponent = componentMap.get(list_item.id);
|
||||
// 判断显隐规则对应的组件是否存在
|
||||
if (!targetComponent) return false;
|
||||
return list_item.list.some(hidden_item => {
|
||||
// 判断当前组件是否在显隐规则中,如果不在,直接显示,否则的话判断值是否存在
|
||||
if (hidden_item.is_show.includes(item.id)) {
|
||||
return targetComponent.com_data.form_value.includes(hidden_item.value);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
return isShownByRule;
|
||||
});
|
||||
}
|
||||
},
|
||||
show_list() {
|
||||
return (children_item) => {
|
||||
// 去除当前参数不符合条件显示的数据
|
||||
const list = this.filteredDiyData(children_item);
|
||||
// 去除收起不显示的数据
|
||||
const new_list = list.filter(item => !['video', 'img', 'auxiliary-line', 'upload-video', 'upload-attachments', 'upload-img', 'rich-text'].includes(item.key))
|
||||
if (this.direction_fixed == 'the_first_three') {
|
||||
return new_list.slice(0, 3);
|
||||
} else {
|
||||
return new_list.filter(item => this.briefing_field.includes(item.id));
|
||||
}
|
||||
}
|
||||
},
|
||||
is_error() {
|
||||
return (children_item) => {
|
||||
// 去除当前参数不符合条件显示的数据
|
||||
const list = this.filteredDiyData(children_item);
|
||||
return list.some(item1 => item1.com_data.common_config.is_error == '1');
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
|
|
@ -88,15 +214,209 @@
|
|||
// 初始化数据
|
||||
init() {
|
||||
const com_data = this.propValue;
|
||||
// 子表单数据
|
||||
const children_list = JSON.parse(JSON.stringify(com_data?.children || []));
|
||||
// 移动端配置参数
|
||||
const mobile = com_data.mobile || {};
|
||||
this.setData({
|
||||
com_data: com_data,
|
||||
mobile: com_data.mobile || {},
|
||||
direction_fixed: mobile.direction_fixed,
|
||||
briefing_field: mobile?.briefing_field || [],
|
||||
data_list: com_data?.data_list || [],
|
||||
mobile: mobile,
|
||||
form_value: com_data?.form_value || [],
|
||||
children: com_data?.children || [],
|
||||
children_list: children_list,
|
||||
});
|
||||
},
|
||||
help_icon_event(e) {
|
||||
this.$emit('helpIconEvent', e.currentTarget.dataset.value);
|
||||
},
|
||||
// 子表单校验逻辑
|
||||
data_check(e, index) {
|
||||
const { is_error, error_text, value, id } = e;
|
||||
// 改变对应id的数据
|
||||
const data = [...this.data_list];
|
||||
data.forEach((item, index1) => {
|
||||
if (index1 == index) {
|
||||
item.data_list.forEach(item1 => {
|
||||
if (item1.id == id && item1.com_data && item1.com_data.common_config) {
|
||||
item1.com_data.form_value = value;
|
||||
item1.com_data.common_config.is_error = is_error;
|
||||
item1.com_data.common_config.error_text = error_text;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.setData({
|
||||
data_list: data
|
||||
})
|
||||
this.$emit('subformDataChange', data, this.propDataId);
|
||||
},
|
||||
// 子表单内容参数修改
|
||||
data_change(e, index) {
|
||||
const { value, id } = e;
|
||||
// 改变对应id的数据
|
||||
const data = [...this.data_list];
|
||||
data.forEach((item, index1) => {
|
||||
if (index1 == index) {
|
||||
item.data_list.forEach(item1 => {
|
||||
if (item1.id == id && item1.com_data) {
|
||||
item1.com_data.form_value = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.setData({
|
||||
data_list: data
|
||||
})
|
||||
this.$emit('subformDataChange', data, this.propDataId);
|
||||
},
|
||||
// 子表单新增选项变化时的处理
|
||||
data_option_change(e, index) {
|
||||
const { list, value, id } = e;
|
||||
// 改变对应id的数据
|
||||
const data = [...this.data_list];
|
||||
data.forEach((item, index1) => {
|
||||
if (index1 == index) {
|
||||
item.data_list.forEach(item1 => {
|
||||
if (item1.id == id && item1.com_data) {
|
||||
item1.com_data.form_value = value;
|
||||
item1.com_data.custom_option_list = list;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.setData({
|
||||
data_list: data
|
||||
})
|
||||
this.$emit('subformDataChange', data, this.propDataId);
|
||||
},
|
||||
// 地区选择器提交事件
|
||||
region_event(e, index) {
|
||||
const { value, id, province_name, city_name, county_name } = e;
|
||||
// 改变对应id的数据
|
||||
const data = [...this.data_list];
|
||||
data.forEach((item, index) => {
|
||||
if (index1 == index) {
|
||||
item.data_list.forEach(item1 => {
|
||||
if (item1.id == id && item1.com_data) {
|
||||
item1.com_data.form_value = value;
|
||||
item1.com_data.province_name = province_name;
|
||||
item1.com_data.city_name = city_name;
|
||||
item1.com_data.county_name = county_name;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.setData({ data_list: data });
|
||||
this.$emit('subformDataChange', data, this.propDataId);
|
||||
},
|
||||
expand_or_collapse(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const data = [...this.data_list];
|
||||
data[index].is_expand = !data[index].is_expand;
|
||||
this.setData({ data_list: data });
|
||||
},
|
||||
more_click(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
this.setData({
|
||||
more_index: index
|
||||
});
|
||||
this.$refs.morePopup.open();
|
||||
},
|
||||
quick_close_event() {
|
||||
this.$refs.morePopup.close();
|
||||
},
|
||||
copy(e) {
|
||||
const { value } = e.currentTarget.dataset;
|
||||
const data = [...this.data_list];
|
||||
const data_index = data[this.more_index];
|
||||
if (value == 'copy') {
|
||||
// 复制到下一行
|
||||
data.splice(this.more_index + 1, 0, JSON.parse(JSON.stringify(data_index)));
|
||||
} else if (value == 'copy_last') {
|
||||
// 复制到最后一行
|
||||
data.splice(data.length, 0, JSON.parse(JSON.stringify(data_index)));
|
||||
} else if (value == 'insert_up') {
|
||||
// 向上插入记录
|
||||
data.splice(this.more_index, 0, {
|
||||
is_expand: data_index.is_expand,
|
||||
data_list: JSON.parse(JSON.stringify(this.children_list))
|
||||
});
|
||||
} else if (value == 'insert_down') {
|
||||
// 向下插入记录
|
||||
data.splice(this.more_index + 1, 0, {
|
||||
is_expand: data_index.is_expand,
|
||||
data_list: JSON.parse(JSON.stringify(this.children_list))
|
||||
});
|
||||
}
|
||||
this.$refs.morePopup.close();
|
||||
this.setData({ data_list: data });
|
||||
this.$emit('subformDataChange', data, this.propDataId);
|
||||
},
|
||||
// 添加记录
|
||||
add_item() {
|
||||
const data = [...this.data_list];
|
||||
const list = this.data_list.filter(item => item.is_expand);
|
||||
data.push({
|
||||
is_expand: list.length == this.data_list.length,
|
||||
data_list: JSON.parse(JSON.stringify(this.children_list))
|
||||
});
|
||||
this.setData({ data_list: data });
|
||||
},
|
||||
expand_all(e) {
|
||||
const { value } = e.currentTarget.dataset;
|
||||
const data = [...this.data_list];
|
||||
data.forEach(item => {
|
||||
item.is_expand = !value;
|
||||
});
|
||||
this.setData({ data_list: data });
|
||||
},
|
||||
// 删除某一个子表单数据
|
||||
delete_item(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const data = [...this.data_list];
|
||||
data.splice(index, 1);
|
||||
this.setData({
|
||||
data_list: data
|
||||
})
|
||||
this.$emit('subformDataChange', data, this.propDataId);
|
||||
},
|
||||
// 获取选择的中文名称
|
||||
data_conversion(item) {
|
||||
if (!isEmpty(item.com_data.form_value)) {
|
||||
const value = item.com_data.form_value;
|
||||
if (['single-text', 'radio-btns', 'select'].includes(item.key)) {
|
||||
if (item.com_data.type !== 'single-text') {
|
||||
const list = item.com_data?.option_list.concat(item.com_data?.custom_option_list || []) || [];
|
||||
const name = list.find(item => item.value == value)?.name || 'empty_conversion';
|
||||
return name;
|
||||
}
|
||||
return value;
|
||||
} else if (['select-multi', 'checkbox'].includes(item.key)) {
|
||||
const list = item.com_data?.option_list.concat(item.com_data?.custom_option_list || []) || [];
|
||||
const new_list = list.filter(item => value.includes(item.value));
|
||||
if (new_list.length > 0) {
|
||||
return new_list.map(item => item.name).join(',');
|
||||
} else {
|
||||
return 'empty_conversion'
|
||||
}
|
||||
} else if (item.com_data.type == 'address') {
|
||||
const { province_name, city_name, county_name } = item.com_data;
|
||||
if (province_name) {
|
||||
return (province_name + (city_name ? ' / ' + city_name : '') + (county_name ? ' / ' + county_name : ''))
|
||||
} else {
|
||||
return 'empty_conversion'
|
||||
}
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
} else {
|
||||
return 'empty_conversion';
|
||||
}
|
||||
},
|
||||
z_index_change(e) {
|
||||
this.$emit('zIndexChange', e);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -108,16 +428,21 @@
|
|||
}
|
||||
.direction-style {
|
||||
border: 2rpx solid #ccc;
|
||||
border-top-left-radius: 8rpx;
|
||||
border-top-right-radius: 8rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
// .subform-line {
|
||||
// transition: height 0.1s linear;
|
||||
// }
|
||||
.subform-line+.subform-line {
|
||||
border-top: 2rpx solid #ccc;
|
||||
border-top-left-radius: 20rpx;
|
||||
border-top-right-radius: 20rpx;
|
||||
margin-top: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
.direction-bottom {
|
||||
border: 2rpx solid #ccc;
|
||||
border-top: 0;
|
||||
padding: 20rpx;
|
||||
border-bottom-left-radius: 8rpx;
|
||||
border-bottom-right-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.subform-title-btns {
|
||||
|
|
@ -134,4 +459,36 @@
|
|||
align-items: center;
|
||||
}
|
||||
}
|
||||
.ml-5 {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
.expand-title {
|
||||
padding: 14rpx;
|
||||
font-size: 20rpx;
|
||||
color: #141e31;
|
||||
.empty {
|
||||
color: #838892;
|
||||
}
|
||||
}
|
||||
.action-sheet {
|
||||
.action-sheet-item {
|
||||
color: #141e31;
|
||||
font-size: 28rpx;
|
||||
background: #fff;
|
||||
border-bottom: 2rpx solid #ebecee;
|
||||
padding: 24rpx 18rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.action-sheet-item:nth-child(4), .action-sheet-item:nth-child(6){
|
||||
border-bottom: none;
|
||||
}
|
||||
.action-sheet-segment {
|
||||
background: #f8f8f8;
|
||||
height: 20rpx;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.required-error {
|
||||
background: #fef6e6;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue