Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2024-07-01 13:02:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4ad25ec1ce728857dd65b6838b80d5af3001f14a
4ad25ec1
1 parent
34d3f40a
下拉框控件适配规则
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
src/components/PickerField/MyComponent.vue
src/components/PickerField/index.vue
src/views/index.vue
src/components/PickerField/MyComponent.vue
View file @
4ad25ec
<!--
* @Date: 2023-03-29 14:55:46
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-0
6-06 15:53:10
* @LastEditTime: 2024-0
7-01 11:53:37
* @FilePath: /data-table/src/components/PickerField/MyComponent.vue
* @Description: 文件描述
-->
...
...
@@ -34,6 +34,7 @@ import { useCustomFieldValue } from '@vant/use';
// 获取父组件传值
const props = inject('props');
const emit = defineEmits(["active"]);
const showPicker = ref(false);
const picker_value = ref(props.component_props.default);
...
...
@@ -45,11 +46,12 @@ const onClick = () => {
};
const onConfirm = ({ selectedOptions }) => {
// console.warn(props);
picker_value.value = selectedOptions[0]?.value;
showPicker.value = false;
// 触发点自定义监听事件,配合规则显示隐藏其他字段
// props.item.value = { key: props.item
.key, value: picker_value.value, type: "picker" };
// emit("active", props.item
.value);
props.value = { key: props
.key, value: picker_value.value, type: "picker" };
emit("active", props
.value);
// if (add_info_key.value === props.item.value) {
// has_add_info.value = true;
// }
...
...
src/components/PickerField/index.vue
View file @
4ad25ec
<!--
* @Date: 2022-08-30 13:46:51
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 202
3-03-29 15:07:12
* @LastEditTime: 202
4-07-01 12:33:33
* @FilePath: /data-table/src/components/PickerField/index.vue
* @Description: 单列选择器组件
-->
...
...
@@ -13,7 +13,7 @@
</div>
<van-field :name="item.name" :rules="item.rules" style="padding: 0;">
<template #input>
<my-component />
<my-component
@active="onActive"
/>
</template>
</van-field>
</div>
...
...
@@ -25,6 +25,7 @@ import MyComponent from './MyComponent.vue';
const props = defineProps({
item: Object,
});
const emit = defineEmits(["active"]);
// 注入子组件属性
provide('props', props.item);
...
...
@@ -32,7 +33,12 @@ provide('props', props.item);
// 隐藏显示
const HideShow = computed(() => {
return !props.item.component_props.disabled
})
});
// 子组件通信,适配规则触发
const onActive = (val) => {
emit("active", val);
};
</script>
...
...
src/views/index.vue
View file @
4ad25ec
<!--
* @Date: 2022-07-18 10:22:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-0
6-28 17:07:28
* @LastEditTime: 2024-0
7-01 12:32:31
* @FilePath: /data-table/src/views/index.vue
* @Description: 首页
-->
...
...
@@ -831,6 +831,9 @@ const onActive = (item) => {
if (item?.type === "volunteer_group") { // 义工组别选择控件
postData.value = _.assign(postData.value, { [item.key]: item.affix ? item.affix : item.value });
}
if (item?.type === "picker") { // 下拉框控件
postData.value[item.key] = item.value;
}
// 检查规则,会影响字段显示
checkRules();
};
...
...
Please
register
or
login
to post a comment