68 lines
2.8 KiB
JavaScript
68 lines
2.8 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../common/vendor.js");
|
||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||
__name: "hs-radio",
|
||
props: [
|
||
"valueModel",
|
||
"Enums",
|
||
"size",
|
||
"radioStyle",
|
||
"selectStyle",
|
||
"disableds"
|
||
// 不可选数组 6-7 kfyy ,7.40 cook,
|
||
],
|
||
emits: ["update:valueModel", "onChange"],
|
||
setup(__props, { emit }) {
|
||
const props = __props;
|
||
const selectValue = common_vendor.ref("");
|
||
const getEnums = () => {
|
||
let list = Object.entries(props == null ? void 0 : props.Enums).map(
|
||
([_key, value]) => ({
|
||
text: value.text,
|
||
value: value.value
|
||
})
|
||
);
|
||
return list;
|
||
};
|
||
common_vendor.watch(
|
||
() => props == null ? void 0 : props.valueModel,
|
||
() => {
|
||
console.log("mounted2", props == null ? void 0 : props.valueModel);
|
||
selectValue.value = props == null ? void 0 : props.valueModel;
|
||
}
|
||
);
|
||
const onClick = (e) => {
|
||
var _a;
|
||
if ((_a = props == null ? void 0 : props.disableds) == null ? void 0 : _a.includes(e == null ? void 0 : e.value)) {
|
||
return false;
|
||
}
|
||
selectValue.value = e == null ? void 0 : e.value;
|
||
emit("update:valueModel", e == null ? void 0 : e.value);
|
||
emit("onChange", e);
|
||
};
|
||
common_vendor.onMounted(() => {
|
||
console.log("mounted1", props == null ? void 0 : props.valueModel);
|
||
if (props == null ? void 0 : props.valueModel) {
|
||
selectValue.value = props == null ? void 0 : props.valueModel;
|
||
}
|
||
});
|
||
return (_ctx, _cache) => {
|
||
return {
|
||
a: common_vendor.f(getEnums(), (i, index, i0) => {
|
||
var _a;
|
||
return {
|
||
a: common_vendor.t(i == null ? void 0 : i.text),
|
||
b: `item_${index}`,
|
||
c: common_vendor.n(`item item_${props == null ? void 0 : props.size} ${(i == null ? void 0 : i.value) === (props == null ? void 0 : props.valueModel) || (i == null ? void 0 : i.value) === selectValue.value ? "active" : ""} ${((_a = props == null ? void 0 : props.disableds) == null ? void 0 : _a.includes(i == null ? void 0 : i.value)) ? "disabled" : ""}`),
|
||
d: common_vendor.s((i == null ? void 0 : i.value) === (props == null ? void 0 : props.valueModel) || (i == null ? void 0 : i.value) === selectValue.value ? props == null ? void 0 : props.selectStyle : ""),
|
||
e: common_vendor.o(($event) => onClick(i), `item_${index}`)
|
||
};
|
||
}),
|
||
b: common_vendor.s(props == null ? void 0 : props.radioStyle)
|
||
};
|
||
};
|
||
}
|
||
});
|
||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-252f0ac0"], ["__file", "/Users/zsq/Sources/github/2025property-pay/pay-customer/src/components/hs-radio/hs-radio.vue"]]);
|
||
wx.createComponent(Component);
|