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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
| import { defineComponent, h, ref, watch } from "vue";
| import Cron from "./cron.vue";
|
| export default defineComponent({
| name: "cl-cron",
|
| components: {
| Cron
| },
|
| props: {
| modelValue: {
| type: String,
| default: ""
| },
| placeholder: {
| type: String,
| default: "请输入定时策略"
| },
| disabled: Boolean,
| readonly: Boolean
| },
|
| emits: ["update:modelValue", "change"],
|
| setup(props, { emit }) {
| const cron = ref<string>("");
| const visible = ref<boolean>(false);
|
| function open() {
| visible.value = true;
| }
|
| function close() {
| visible.value = false;
| }
|
| watch(cron, (val: string) => {
| emit("update:modelValue", val);
| emit("change", val);
| });
|
| watch(
| () => props.modelValue,
| (val: string) => {
| cron.value = val;
| },
| {
| immediate: true
| }
| );
|
| return {
| cron,
| visible,
| open,
| close
| };
| },
|
| render(ctx: any) {
| const ElPopover = (
| <el-popover
| visible={ctx.visible}
| disabled={ctx.disabled || ctx.readonly}
| width="600px"
| ></el-popover>
| );
|
| return (
| <div class="cl-cron">
| {h(
| ElPopover,
| {
| "onUpdate:visible"(v: any) {
| if (!v) {
| ctx.close();
| }
| }
| },
| {
| default() {
| return <cron v-model={ctx.cron} onClose={ctx.close}></cron>;
| },
| reference() {
| return (
| <el-input
| clearable
| disabled={ctx.disabled}
| readonly={ctx.readonly}
| v-model={ctx.cron}
| placeholder={ctx.placeholder}
| onClick={ctx.open}
| ></el-input>
| );
| }
| }
| )}
| </div>
| );
| }
| });
|
|