UNPKG

dm-vue3-ui

Version:

This Components Library will help get you started developing in Vue 3.

185 lines (184 loc) 7.02 kB
import { InputSearch, TabPane, Tabs } from "ant-design-vue/es"; import { defineComponent, ref, reactive, watch, openBlock, createElementBlock, createElementVNode, Fragment, renderList, unref, toDisplayString, createVNode, withCtx, createTextVNode, createBlock } from "vue"; import CronBase from "./cron-base.vue"; import { DEFAULT_CRON_EXPRESSION, FIELDS } from "../constant"; import { $t } from "../../i18n/index"; const _hoisted_1 = { class: "cron-wrapper" }; const _hoisted_2 = { class: "expression" }; const _hoisted_3 = { class: "expression-title" }; const _hoisted_4 = { class: "title-cron" }; const _hoisted_5 = { class: "expression-title expression-content" }; const _hoisted_6 = { class: "title-item" }; const _hoisted_7 = ["value"]; const _hoisted_8 = { class: "title-item" }; const _hoisted_9 = ["value"]; const _hoisted_10 = { class: "title-item" }; const _hoisted_11 = ["value"]; const _hoisted_12 = { class: "title-item" }; const _hoisted_13 = ["value"]; const _hoisted_14 = { class: "title-item" }; const _hoisted_15 = ["value"]; const _hoisted_16 = { class: "title-item" }; const _hoisted_17 = ["value"]; const _hoisted_18 = { class: "title-cron" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "pop-tab", props: { modelValue: { type: String, default: DEFAULT_CRON_EXPRESSION } }, emits: ["update:modelValue", "parse"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const activeKey = ref(FIELDS[0].value); const cron = reactive({ second: "", minute: "", hour: "", date: "", month: "", week: "" }); const contabValue = ref(""); watch( () => props.modelValue, (newVal) => { let [second, minute, hour, date, month, week] = newVal.split(" "); Object.assign(cron, { second: second || "*", minute: minute || "*", hour: hour || "*", date: date || "*", month: month || "*", week: week || "?" }); }, { immediate: true } ); watch( cron, (newVal) => { contabValue.value = Object.values(newVal).join(" "); emits("update:modelValue", Object.values(newVal).join(" ")); }, { deep: true, immediate: true } ); const getSearch = (val) => { let [second, minute, hour, date, month, week] = val.split(" "); Object.assign(cron, { second, minute, hour, date, month, week }); emits("parse", contabValue.value); }; return (_ctx, _cache) => { const _component_a_input_search = InputSearch; const _component_a_tab_pane = TabPane; const _component_a_tabs = Tabs; return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("div", _hoisted_2, [ createElementVNode("div", _hoisted_3, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(FIELDS), (field) => { return openBlock(), createElementBlock("div", { class: "title-item", key: field.value }, toDisplayString(field.label), 1); }), 128)), createElementVNode("div", _hoisted_4, toDisplayString(unref($t)("cronPicker.cronExpression")), 1) ]), createElementVNode("div", _hoisted_5, [ createElementVNode("div", _hoisted_6, [ createElementVNode("input", { type: "text", class: "tab-input", value: cron.second, readonly: "" }, null, 8, _hoisted_7) ]), createElementVNode("div", _hoisted_8, [ createElementVNode("input", { type: "text", class: "tab-input", value: cron.minute, readonly: "" }, null, 8, _hoisted_9) ]), createElementVNode("div", _hoisted_10, [ createElementVNode("input", { type: "text", class: "tab-input", value: cron.hour, readonly: "" }, null, 8, _hoisted_11) ]), createElementVNode("div", _hoisted_12, [ createElementVNode("input", { type: "text", class: "tab-input", value: cron.date, readonly: "" }, null, 8, _hoisted_13) ]), createElementVNode("div", _hoisted_14, [ createElementVNode("input", { type: "text", class: "tab-input", value: cron.month, readonly: "" }, null, 8, _hoisted_15) ]), createElementVNode("div", _hoisted_16, [ createElementVNode("input", { type: "text", class: "tab-input", value: cron.week, readonly: "" }, null, 8, _hoisted_17) ]), createElementVNode("div", _hoisted_18, [ createVNode(_component_a_input_search, { placeholder: unref($t)("cronPicker.cronInput"), "enter-button": unref($t)("cronPicker.parse"), value: contabValue.value, "onUpdate:value": _cache[0] || (_cache[0] = ($event) => contabValue.value = $event), onSearch: getSearch }, null, 8, ["placeholder", "enter-button", "value"]) ]) ]) ]), createVNode(_component_a_tabs, { class: "cron-tabs", activeKey: activeKey.value, "onUpdate:activeKey": _cache[1] || (_cache[1] = ($event) => activeKey.value = $event) }, { leftExtra: withCtx(() => [ createTextVNode(toDisplayString(unref($t)("cronPicker.ruleType")), 1) ]), default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(FIELDS), (field) => { return openBlock(), createBlock(_component_a_tab_pane, { tab: field.label, key: field.value }, { default: withCtx(() => [ createVNode(CronBase, { modelValue: cron[field.value], "onUpdate:modelValue": ($event) => cron[field.value] = $event, field }, null, 8, ["modelValue", "onUpdate:modelValue", "field"]) ]), _: 2 }, 1032, ["tab"]); }), 128)) ]), _: 1 }, 8, ["activeKey"]) ]); }; } }); const popTab_vue_vue_type_style_index_0_scoped_81b11e20_lang = ""; const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; const popTab = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-81b11e20"]]); export { popTab as default };