index.vue
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!--
* @Date: 2022-08-30 13:46:51
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-07-26 22:16:14
* @FilePath: /data-table/src/components/PickerField/index.vue
* @Description: 单列选择器组件
-->
<template>
<div v-if="HideShow" class="picker-field-page">
<div class="label">
<span v-if="item.component_props.required" style="color: red"> *</span>
<span :class="[ReadonlyShow ? 'readonly-show' : '']">{{ item.component_props.label }}</span>
</div>
<van-field :name="item.name" :rules="item.rules" style="padding: 0;">
<template #input>
<my-component @active="onActive" />
</template>
</van-field>
</div>
</template>
<script setup>
import { useRoute } from "vue-router";
import MyComponent from './MyComponent.vue';
const $route = useRoute();
const props = defineProps({
item: Object,
});
const emit = defineEmits(["active"]);
// 注入子组件属性
provide('props', props.item);
// 隐藏显示
const HideShow = computed(() => {
return !props.item.component_props.disabled
});
// 只读显示-流程模式
const ReadonlyShow = computed(() => {
return $route.query.page_type === 'flow' && props.item.component_props.readonly;
});
// 子组件通信,适配规则触发
const onActive = (val) => {
emit("active", val);
};
</script>
<style lang="less" scoped>
.picker-field-page {
margin: 1rem;
.label {
// padding: 1rem 1rem 0 0;
font-size: 0.9rem;
font-weight: bold;
}
}
:deep(.van-cell--clickable) {
border: 1px solid #eaeaea;
border-radius: 0.25rem;
padding: 0.25rem 0.5rem;
margin-top: 0.5rem;
}
</style>