UNPKG

@cqmcui/cqmcui

Version:

轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)

158 lines (157 loc) 5.32 kB
import { ref, reactive, computed, onMounted, watch, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, createVNode, withCtx, Fragment, renderList, createBlock, createTextVNode, toDisplayString, withDirectives, vModelText, createCommentVNode } from "vue"; import { c as createComponent } from "./component-81a4c1d0.js"; import Form from "./Form.js"; import FormItem from "./FormItem.js"; import { _ as _sfc_main$1 } from "./index.vue_vue_type_script_lang-442e4704.js"; import { _ as _sfc_main$2 } from "./index.vue_vue_type_script_lang-22dfc112.js"; import Button from "./Button.js"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js"; import "../locale/lang"; import "./CellGroup.js"; import "./pxCheck-c6b9f6b7.js"; import "./Cell.js"; import "./index-54d03fc1.js"; import "@cqmcui/icons-vue"; const { componentName, create } = createComponent("invoice"); const _sfc_main = create({ components: { [Form.name]: Form, [FormItem.name]: FormItem, [_sfc_main$1.name]: _sfc_main$1, [_sfc_main$2.name]: _sfc_main$2, [Button.name]: Button }, props: { data: { type: Array, default: () => [] }, formValue: { type: Object, default: {} }, submit: { type: Boolean, default: true } }, emits: ["onSubmit", "scroll-bottom"], setup(props, { emit }) { const formRef = ref(); const list = ref([]); const state = reactive({ // list: [] }); const classes = computed(() => { const prefixCls = componentName; return { [prefixCls]: true }; }); onMounted(() => { init(); }); const init = () => { list.value = props.data; }; const submitFun = () => { formRef.value.validate().then(({ valid, errors }) => { emit("onSubmit", valid, errors); }); }; watch( () => props.data, () => init(), { deep: true } ); return { ...toRefs(state), classes, formRef, list, submitFun }; } }); const _hoisted_1 = ["placeholder", "onUpdate:modelValue"]; const _hoisted_2 = { key: 0, class: "cqmc-invoice__submit" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_nut_radio = resolveComponent("cqmc-radio"); const _component_nut_radio_group = resolveComponent("cqmc-radio-group"); const _component_nut_form_item = resolveComponent("cqmc-form-item"); const _component_nut_form = resolveComponent("cqmc-form"); const _component_nut_button = resolveComponent("cqmc-button"); return openBlock(), createElementBlock("view", { class: normalizeClass(_ctx.classes) }, [ createVNode(_component_nut_form, { "model-value": _ctx.formValue, ref: "formRef" }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item, index2) => { return openBlock(), createBlock(_component_nut_form_item, { key: index2, label: item.label, required: item.required, rules: item.rules, prop: item.formItemProp }, { default: withCtx(() => [ item.type === "radio" ? (openBlock(), createBlock(_component_nut_radio_group, { key: 0, modelValue: _ctx.formValue[item.formItemProp], "onUpdate:modelValue": ($event) => _ctx.formValue[item.formItemProp] = $event }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(item.radioLabel, (radioItem, radioIndex) => { return openBlock(), createBlock(_component_nut_radio, { key: radioIndex, shape: "button", label: radioItem.label }, { default: withCtx(() => [ createTextVNode(toDisplayString(radioItem.label), 1) ]), _: 2 }, 1032, ["label"]); }), 128)) ]), _: 2 }, 1032, ["modelValue", "onUpdate:modelValue"])) : withDirectives((openBlock(), createElementBlock("input", { key: 1, class: "cqmc-input-text", placeholder: item.placeholder, "onUpdate:modelValue": ($event) => _ctx.formValue[item.formItemProp] = $event, type: "text" }, null, 8, _hoisted_1)), [ [vModelText, _ctx.formValue[item.formItemProp]] ]) ]), _: 2 }, 1032, ["label", "required", "rules", "prop"]); }), 128)) ]), _: 1 }, 8, ["model-value"]), _ctx.submit ? (openBlock(), createElementBlock("div", _hoisted_2, [ createVNode(_component_nut_button, { type: "primary", block: "", onClick: _ctx.submitFun }, { default: withCtx(() => [ createTextVNode("提交审批") ]), _: 1 }, 8, ["onClick"]) ])) : createCommentVNode("", true) ], 2); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };