@fecp/mobile
Version:
163 lines (162 loc) • 6.61 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
;/* empty css */
const vue = require("vue");
const index = require("../field/index.js");
const optionUtil = require("../../../utils/optionUtil.js");
const index$2 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/picker/index.js");
const index$1 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/popup/index.js");
const index$3 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/icon/index.js");
const _sfc_main = {
__name: "FieldPicker",
props: {
// optionType: {
// type: String,
// default: "static",
// },
// dicKey: {
// type: String,
// default: "",
// },
// dicList: {
// type: Array,
// default: [],
// },
// dataSource: {
// type: String,
// default: "",
// },
// dataSourceParams: {
// type: Object,
// default: {},
// },
pickerOptions: {
type: Array,
default: []
},
treeOptionsFieldNames: {
type: Object,
default: {
text: "text",
value: "value"
}
},
modelValue: {
type: String,
default: ""
},
disabled: {
type: Boolean,
default: false
},
readonly: {
type: Boolean,
default: false
},
"is-link": false
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const props = __props;
const attrs = vue.useAttrs();
const finalOptions = vue.ref([]);
optionUtil.getOptions({
...attrs,
staticOptions: props.pickerOptions,
optionsFieldNames: props.treeOptionsFieldNames
}).then((data) => {
finalOptions.value = data;
});
const fieldTextValue = vue.ref("");
const showPicker = vue.ref(false);
const emit = __emit;
const pickerValue = vue.computed({
get: () => {
const value = props.modelValue;
return [value];
},
set: (val) => {
emit("update:modelValue", val);
}
});
vue.watch(
[() => props.modelValue, finalOptions],
([value, options]) => {
if (!value) {
fieldTextValue.value = "";
return;
}
const optionItem = options.find((item) => item.value == value);
fieldTextValue.value = optionItem == null ? void 0 : optionItem.text;
},
{ immediate: true }
);
const onConfirm = ({ selectedValues, selectedOptions }) => {
pickerValue.value = selectedValues[0];
showPicker.value = false;
};
return (_ctx, _cache) => {
const _component_van_icon = index$3.Icon;
const _component_van_picker = index$2.Picker;
const _component_van_popup = index$1.Popup;
return vue.openBlock(), vue.createBlock(vue.unref(index.MobileField), vue.mergeProps(_ctx.$attrs, {
modelValue: vue.unref(fieldTextValue),
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vue.isRef(fieldTextValue) ? fieldTextValue.value = $event : null),
isLink: __props.readonly ? false : true,
readonly: "",
disabled: __props.disabled,
onOpenPicker: _cache[4] || (_cache[4] = () => {
if (!__props.readonly) {
showPicker.value = true;
}
})
}), vue.createSlots({
default: vue.withCtx(() => [
vue.createVNode(_component_van_popup, {
show: vue.unref(showPicker),
"onUpdate:show": _cache[2] || (_cache[2] = ($event) => vue.isRef(showPicker) ? showPicker.value = $event : null),
"destroy-on-close": "",
position: "bottom"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_van_picker, vue.mergeProps(_ctx.$attrs, {
columns: vue.unref(finalOptions),
"model-value": vue.unref(pickerValue),
readonly: false,
onConfirm,
onCancel: _cache[1] || (_cache[1] = ($event) => showPicker.value = false)
}), null, 16, ["columns", "model-value"])
]),
_: 1
}, 8, ["show"])
]),
_: 2
}, [
!__props.readonly && !__props.disabled && vue.unref(fieldTextValue) ? {
name: "right-icon",
fn: vue.withCtx(() => [
vue.createVNode(_component_van_icon, {
name: "clear",
class: "custom-close-icon",
onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => pickerValue.value = null, ["stop"]))
})
]),
key: "0"
} : void 0
]), 1040, ["modelValue", "isLink", "disabled"]);
};
}
};
exports.default = _sfc_main;