index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import Cron from "./cron";
  2. import Base from "./base";
  3. export default {
  4. name: "cl-cron",
  5. mixins: [Base],
  6. components: {
  7. Cron
  8. },
  9. props: {
  10. value: String,
  11. placeholder: {
  12. type: String,
  13. default: "请输入定时策略"
  14. }
  15. },
  16. data() {
  17. return {
  18. cronPopover: false,
  19. cron: ""
  20. };
  21. },
  22. watch: {
  23. cron: {
  24. handler(val) {
  25. this.fieldValue = val;
  26. this.$emit("change", val);
  27. }
  28. },
  29. value: {
  30. immediate: true,
  31. handler(val) {
  32. this.cron = val;
  33. }
  34. },
  35. fieldValue: {
  36. immediate: true,
  37. handler(val) {
  38. this.cron = val;
  39. }
  40. }
  41. },
  42. methods: {
  43. changeCron(val) {
  44. this.cron = val;
  45. },
  46. hidePopover() {
  47. this.cronPopover = false;
  48. }
  49. },
  50. render() {
  51. const vnode = (
  52. <el-popover vModel={this.cronPopover} disabled={this.disabled || this.readonly}>
  53. <Cron
  54. {...{
  55. props: { i18n: "cn" },
  56. on: {
  57. change: this.changeCron,
  58. close: this.hidePopover
  59. }
  60. }}></Cron>
  61. <el-input
  62. slot="reference"
  63. clearable={true}
  64. disabled={this.disabled}
  65. readonly={this.readonly}
  66. vModel={this.cron}
  67. placeholder={this.placeholder}></el-input>
  68. </el-popover>
  69. );
  70. return this.renderComponent(vnode);
  71. }
  72. };