UNPKG

asp-smart-ui-plus-test

Version:

A Component Library for Vue 3

308 lines (303 loc) 14.6 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var common = require('../../../../../utils/utils/common.js'); var pluginVue_exportHelper = require('../../../../../_virtual/plugin-vue_export-helper.js'); const _hoisted_1 = { key: 0, class: "title selector-item" }; const _hoisted_2 = { key: 0, class: "custom" }; const _hoisted_3 = { key: 0, class: "text" }; const _hoisted_4 = { key: 1, class: "selector" }; const _hoisted_5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-arrow-down" }, null, -1); const _hoisted_6 = ["onUpdate:modelValue"]; const _hoisted_7 = ["value"]; const _hoisted_8 = { key: 0, class: "selector" }; const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-arrow-down" }, null, -1); const _hoisted_10 = ["onUpdate:modelValue"]; const _hoisted_11 = ["value"]; const _hoisted_12 = { key: 1, class: "text" }; const _hoisted_13 = { key: 2, class: "selector" }; const _hoisted_14 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-arrow-down" }, null, -1); const _hoisted_15 = ["onUpdate:modelValue"]; const _hoisted_16 = ["value"]; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "radio-group-select", props: { selectAttributes: { type: null, required: false }, radioGroups: { type: Array, required: true } }, emits: [ "visibleChange", "radioChange", "input", "cusclearable" ], setup(__props, { expose, emit }) { const props = __props; const selectRadioValue = vue.ref(""); const initSelectRadioValue = () => { selectRadioValue.value = ""; props.radioGroups.forEach((item, index) => { var _a, _b, _c, _d, _e, _f; const radioItem = props.radioGroups[index].options.find( (subItem) => subItem.value === item.radioValue ); if (!radioItem) return; let label = ""; if (radioItem.custom) { if (!radioItem.inputValue && (radioItem.type === "first" || !radioItem.type) || !radioItem.inputLeftValue && !radioItem.inputRightValue && radioItem.type === "second") { label = radioItem.label; } else { if (radioItem.type === "second") { const tmpLeftValue = radioItem.selectLeftValue; const LeftLabel = radioItem.inputLeftValue ? radioItem.inputLeftValue + ((_b = (_a = radioItem.selectLeftOptions) == null ? void 0 : _a.find( (item2) => item2.value === tmpLeftValue )) == null ? void 0 : _b.label) : ""; const rightLabel = radioItem.inputRightValue ? ((_d = (_c = radioItem.selectRightOptions) == null ? void 0 : _c.find( (item2) => item2.value === radioItem.selectRightValue )) == null ? void 0 : _d.label) + radioItem.inputRightValue : ""; label = LeftLabel + (radioItem.text || "") + rightLabel; } else { label = (radioItem.text || "") + ((_f = (_e = radioItem.selectOptions) == null ? void 0 : _e.find( (item2) => item2.value === radioItem.selectValue )) == null ? void 0 : _f.label) + radioItem.inputValue; } } } else { label = radioItem.label; } selectRadioValue.value += label + (index === props.radioGroups.length - 1 ? "" : "\uFF1B"); }); }; const visibleChange = (value) => { emit("visibleChange", value); }; const radioChange = (value) => { initSelectRadioValue(); emit("radioChange", value); emit("input", selectRadioValue.value); }; const selectChange = (value) => { initSelectRadioValue(); emit("radioChange", value); emit("input", selectRadioValue.value); }; let inputChange = (value) => { initSelectRadioValue(); emit("radioChange", value); emit("input", selectRadioValue.value); }; const setValue = (value) => { selectRadioValue.value = value; }; const getModel = () => { if (!props.radioGroups) return []; const model = []; props.radioGroups.forEach((item) => { const params = { radioValue: "", selectLeftValue: "", selectRightValue: "", inputLeftValue: "", inputRightValue: "", selectValue: "", inputValue: "" }; params.radioValue = item.radioValue; const radioItem = item.options.find( (subItem) => subItem.value === item.radioValue ); if (radioItem && radioItem.custom) { if (radioItem.type === "second") { params.selectLeftValue = radioItem.selectLeftValue; params.selectRightValue = radioItem.selectRightValue; params.inputLeftValue = radioItem.inputLeftValue; params.inputRightValue = radioItem.inputRightValue; } else if (radioItem.type === "first") { params.selectValue = radioItem.selectValue; params.inputValue = radioItem.inputValue; } } model.push(params); }); return model; }; expose({ setValue, getModel }); const cusclearable = () => { emit("cusclearable"); }; inputChange = common.aspDebounce(inputChange, 500, false); vue.onMounted(() => { initSelectRadioValue(); }); return (_ctx, _cache) => { const _component_asp_option = vue.resolveComponent("asp-option"); const _component_asp_radio = vue.resolveComponent("asp-radio"); const _component_asp_input = vue.resolveComponent("asp-input"); const _component_asp_radio_group = vue.resolveComponent("asp-radio-group"); const _component_asp_select = vue.resolveComponent("asp-select"); return vue.openBlock(), vue.createBlock(_component_asp_select, vue.mergeProps({ ref: "select" }, __props.selectAttributes, { modelValue: selectRadioValue.value, "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => selectRadioValue.value = $event), class: "asp-radio-group-select", multiple: false, "popper-class": "query-form-selector query-form-selector-radio", "popper-append-to-body": false, onClear: cusclearable, onVisibleChange: visibleChange }), { default: vue.withCtx(() => [ vue.createVNode(_component_asp_option, { label: "\u9690\u85CF", class: "display-none", style: { "display": "none" }, value: "0" }), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.radioGroups, (item, index) => { return vue.openBlock(), vue.createBlock(_component_asp_radio_group, vue.mergeProps(item.radioGroupAttributes, { key: index, modelValue: item.radioValue, "onUpdate:modelValue": ($event) => item.radioValue = $event, onChange: radioChange }), { default: vue.withCtx(() => [ item.title ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, vue.toDisplayString(item.title), 1)) : vue.createCommentVNode("v-if", true), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item.options, (cell, index2) => { return vue.openBlock(), vue.createElementBlock("div", { key: cell.label + index2, class: "selector-item", onClick: _cache[0] || (_cache[0] = vue.withModifiers(() => { }, ["stop"])) }, [ vue.createVNode(_component_asp_radio, vue.mergeProps({ label: cell.value }, cell.radioAttributes), { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(cell.label), 1) ]), _: 2 }, 1040, ["label"]), cell.custom ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [ cell.type === void 0 || cell.type === "first" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [ cell.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, vue.toDisplayString(cell.text || ""), 1)) : vue.createCommentVNode("v-if", true), cell.selectOptions ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4, [ _hoisted_5, vue.withDirectives(vue.createElementVNode("select", { ref_for: true, ref: "select", "onUpdate:modelValue": ($event) => cell.selectValue = $event, onChange: selectChange }, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(cell.selectOptions, (item2) => { return vue.openBlock(), vue.createElementBlock("option", { key: String(item2.value), value: item2.value }, vue.toDisplayString(item2.label), 9, _hoisted_7); }), 128)) ], 40, _hoisted_6), [ [vue.vModelSelect, cell.selectValue] ]) ])) : vue.createCommentVNode("v-if", true), vue.createVNode(_component_asp_input, { modelValue: cell.inputValue, "onUpdate:modelValue": ($event) => cell.inputValue = $event, type: cell.inputType || "number", placeholder: "\u8BF7\u8F93\u5165", onInput: vue.unref(inputChange) }, null, 8, ["modelValue", "onUpdate:modelValue", "type", "onInput"]), vue.createElementVNode("div", null, vue.toDisplayString(cell.unit || ""), 1) ], 64)) : vue.createCommentVNode("v-if", true), cell.type === "second" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [ vue.createVNode(_component_asp_input, { modelValue: cell.inputLeftValue, "onUpdate:modelValue": ($event) => cell.inputLeftValue = $event, type: cell.inputType || "number", placeholder: "\u8BF7\u8F93\u5165", onInput: vue.unref(inputChange) }, null, 8, ["modelValue", "onUpdate:modelValue", "type", "onInput"]), cell.selectLeftOptions ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [ _hoisted_9, vue.withDirectives(vue.createElementVNode("select", { ref_for: true, ref: "select", "onUpdate:modelValue": ($event) => cell.selectLeftValue = $event, onChange: selectChange }, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(cell.selectLeftOptions, (item2) => { return vue.openBlock(), vue.createElementBlock("option", { key: String(item2.value), value: item2.value }, vue.toDisplayString(item2.label), 9, _hoisted_11); }), 128)) ], 40, _hoisted_10), [ [vue.vModelSelect, cell.selectLeftValue] ]) ])) : vue.createCommentVNode("v-if", true), cell.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12, vue.toDisplayString(cell.text || ""), 1)) : vue.createCommentVNode("v-if", true), cell.selectRightOptions ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, [ _hoisted_14, vue.withDirectives(vue.createElementVNode("select", { ref_for: true, ref: "select", "onUpdate:modelValue": ($event) => cell.selectRightValue = $event, onChange: selectChange }, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(cell.selectRightOptions, (item2) => { return vue.openBlock(), vue.createElementBlock("option", { key: String(item2.value), value: item2.value }, vue.toDisplayString(item2.label), 9, _hoisted_16); }), 128)) ], 40, _hoisted_15), [ [vue.vModelSelect, cell.selectRightValue] ]) ])) : vue.createCommentVNode("v-if", true), vue.createVNode(_component_asp_input, { modelValue: cell.inputRightValue, "onUpdate:modelValue": ($event) => cell.inputRightValue = $event, type: cell.inputType || "number", placeholder: "\u8BF7\u8F93\u5165", onInput: vue.unref(inputChange) }, null, 8, ["modelValue", "onUpdate:modelValue", "type", "onInput"]), vue.createElementVNode("div", null, vue.toDisplayString(cell.unit || ""), 1) ], 64)) : vue.createCommentVNode("v-if", true) ])) : vue.createCommentVNode("v-if", true) ]); }), 128)) ]), _: 2 }, 1040, ["modelValue", "onUpdate:modelValue"]); }), 128)) ]), _: 1 }, 16, ["modelValue"]); }; } }); var RadioGroupSelect = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "E:\\code\\SmartUIPlus\\asp-packages\\components\\pc\\advanced\\radio-group-select\\src\\radio-group-select.vue"]]); exports["default"] = RadioGroupSelect;