UNPKG

@icreate/ics-mui

Version:

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

92 lines (91 loc) 3.48 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); import { defineComponent, reactive, computed, openBlock, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, createBlock, resolveDynamicComponent, toDisplayString } from "vue"; import { Q as w, R as L, Z, T as m, U as m$1, W as g } from "../style_icon-C4_0S-Vm.js"; import { w as withInstall } from "../with-install-DWwOiZS3.js"; const _hoisted_1 = { class: "nut-facegraph" }; const _hoisted_2 = ["onClick"]; const _hoisted_3 = { class: "nut-facegraph__icon" }; const _hoisted_4 = { class: "nut-facegraph__text" }; const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, { name: "IcsFaceGraph" }), { __name: "index", props: { modelValue: { type: Number, default: 0 } }, emits: ["update:modelValue", "click"], setup(__props, { emit: __emit }) { const props = __props; const iconComponents = { LpWutong: w, LpQingdu: L, LpZhongdu: Z, LpQingwei: m, LpYanzhong: m$1, LpJulie: g }; const list = reactive([ { text: "无痛", icon: "LpWutong", score: 0 }, { text: "轻微疼痛", icon: "LpQingwei", score: 2 }, { text: "轻度疼痛", icon: "LpQingdu", score: 4 }, { text: "中度疼痛", icon: "LpZhongdu", score: 6 }, { text: "重度疼痛", icon: "LpYanzhong", score: 8 }, { text: "剧烈疼痛", icon: "LpJulie", score: 10 } ]); const emits = __emit; const selectScore = computed({ get() { return Number(props.modelValue) || 0; }, set(value) { emits("update:modelValue", value); } }); const handleClick = (index) => { emits("update:modelValue", list[index].score); emits("click", list[index]); }; return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ (openBlock(true), createElementBlock(Fragment, null, renderList(list, (item, index) => { return openBlock(), createElementBlock("div", { key: item.text, class: normalizeClass(["nut-facegraph__item", selectScore.value === item.score ? "nut-facegraph__item--checked" : ""]), onClick: ($event) => handleClick(index) }, [ createElementVNode("div", _hoisted_3, [ (openBlock(), createBlock(resolveDynamicComponent(iconComponents[item.icon]))) ]), createElementVNode("span", _hoisted_4, toDisplayString(item.text), 1) ], 10, _hoisted_2); }), 128)) ]); }; } })); withInstall(_sfc_main); export { _sfc_main as FaceGraph, _sfc_main as default };