hookehuyr

fix: 修复CheckboxField组件默认值处理和iframe传值openid逻辑

修复CheckboxField组件中未处理component_props为undefined的情况,确保默认值正确处理
调整iframe传值openid的获取位置,避免重复声明和逻辑错误
......@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-26 23:52:36
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-06-04 16:34:33
* @LastEditTime: 2025-06-10 13:47:08
* @FilePath: /data-table/src/App.vue
* @Description:
-->
......@@ -79,8 +79,10 @@ onMounted(async () => {
const force_back = getUrlParams(location.href) ? getUrlParams(location.href).force_back : ''; // force_back=1 时,强制按照后台用户模式检查权限
const x_cycle = getUrlParams(location.href) ? getUrlParams(location.href).x_cycle : ''; // 周期ID标识
const volunteer_source = getUrlParams(location.href) ? getUrlParams(location.href).volunteer_source : ''; // 义工来源
// iframe传值openid
const iframe_openid = getUrlParams(location.href) ? getUrlParams(location.href).openid : '';
// 数据收集设置
const { data } = await getFormSettingAPI({ form_code: code, page_type, data_id, flow_node_code, force_back, x_cycle, volunteer_source });
const { data } = await getFormSettingAPI({ form_code: code, page_type, data_id, flow_node_code, force_back, x_cycle, volunteer_source, openid: iframe_openid });
const form_setting = {};
if (data.length) {
Object.assign(form_setting, data[0]['property_list'], data[0]['extend']);
......@@ -114,7 +116,6 @@ onMounted(async () => {
// 没有授权判断
let open_auth = form_setting.wxzq_enable && !form_setting.x_field_weixin_openid;
// iframe传值openid
const iframe_openid = getUrlParams(location.href) ? getUrlParams(location.href).openid : '';
if (iframe_openid) { // 如果获取到iframe传值openid 不再校验授权
open_auth = false;
}
......
<!--
* @Date: 2022-08-30 11:34:19
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-03 15:27:44
* @LastEditTime: 2025-06-10 14:21:45
* @FilePath: /data-table/src/components/CheckboxField/index.vue
* @Description: 多项选择控件
-->
......@@ -35,7 +35,7 @@
</template>
</van-checkbox>
</van-config-provider>
<van-field v-if="checkbox_value.includes(x.value) && x.is_input" :name="'_' + item.key" @blur="onBlur(x)" v-model="x.affix"
<van-field v-if="checkbox_value?.includes(x.value) && x.is_input" :name="'_' + item.key" @blur="onBlur(x)" v-model="x.affix"
label=" " label-width="5px" :placeholder="x.input_placeholder" :rules="x.input_required ? rules : ''"
:required="x.input_required" :readonly="item.component_props.readonly" class="affix-input" />
</div>
......@@ -65,7 +65,7 @@ const themeVars = {
};
onMounted(() => {
// 默认值为数组
props.item.value = props.item.component_props.default;
props.item.value = props.item.component_props?.default ? props.item.component_props.default : [];
});
// 隐藏显示
const HideShow = computed(() => {
......@@ -94,7 +94,7 @@ const validatorMessage = (val, rule) => {
const rules = [{ validator, message: validatorMessage }];
const emit = defineEmits(["active"]);
const checkbox_value = ref(props.item.component_props.default);
const checkbox_value = ref(props.item.component_props?.default);
const affix_value = ref({});
const onClick = (item) => {
......@@ -139,8 +139,8 @@ const handleEmit = (item) => {
}
onMounted(() => {
// TAG:默认值处理
let arr = props.item.component_props.default;
let hasColonSome = arr.some(item => item.includes(':')); // 检查是否有元素包含冒号
let arr = props.item.component_props.default ? props.item.component_props.default : [];
let hasColonSome = arr?.some(item => item.includes(':')); // 检查是否有元素包含冒号
if (hasColonSome) { // 带补充信息输入框
// 提取冒号前的部分生成新的数组
let titles = arr.map(item => {
......