ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts" setup>
import { ref, unref, watch } from 'vue';
 
import { propTypes } from '@jnpf/utils';
 
import { Button, Form } from 'ant-design-vue';
 
import { cronEmits, cronProps } from './easy.cron.data';
import EasyCronModal from './EasyCronModal.vue';
 
defineOptions({ inheritAttrs: false, name: 'JnpfCron' });
 
const props = defineProps({
  ...cronProps,
  exeStartTime: propTypes.oneOfType([propTypes.number, propTypes.string, propTypes.object]).def(0),
  placeholder: propTypes.string.def('Cron表达式'),
});
const emit = defineEmits([...cronEmits]);
const editCronValue = ref(props.value);
const formItemContext = Form.useInjectFormItemContext();
const easyCronModalRef = ref();
 
watch(
  () => unref(props.value),
  (newVal) => {
    if (newVal !== editCronValue.value) {
      editCronValue.value = newVal;
    }
  },
);
 
function showConfigModal() {
  if (props.disabled) return;
  easyCronModalRef.value?.openModal();
}
function handleSubmit() {
  emit('change', editCronValue.value);
  emit('update:value', editCronValue.value);
  formItemContext.onFieldChange();
}
</script>
 
<template>
  <div class="jnpf-easy-cron-input">
    <a-input-search v-model:value="value" :placeholder="placeholder" readonly @search="showConfigModal">
      <template #enterButton>
        <Button>
          <template #icon> <i class="icon-ym icon-ym-btn-edit"></i> </template>
        </Button>
      </template>
    </a-input-search>
    <EasyCronModal
      ref="easyCronModalRef"
      v-model:value="editCronValue"
      :exe-start-time="exeStartTime"
      :hide-second="hideSecond"
      :hide-year="hideYear"
      :remote="remote"
      @ok="handleSubmit" />
  </div>
</template>
 
<style lang="scss">
@use './easy.cron.input' as *;
</style>