@lcap/nasl
Version:
NetEase Application Specific Language
55 lines • 2.63 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.genEnumSelectBlock = void 0;
const config_1 = require("../config");
/**
* 生成枚举选择框区块
* @param enumeration 枚举实例
* @param vModel v-model 的内容
* @param size 尺寸属性的内容
* @param placeholder 占位符的内容
*/
function genEnumSelectBlock(enumeration, vModel, size, placeholder, hiddenAll, frontendType) {
const namespace = enumeration?.getNamespace() || '';
const name = enumeration?.name || '';
const enumTypeAnnotationStr = `__enumTypeAnnotation_${namespace}.${name}`;
if ((frontendType || config_1.config.scope) === 'h5')
return `<van-pickerson type="list" :showToolbar="true" ${vModel ? ` v-model="${vModel}"` : ''}${placeholder ? ` title="${placeholder}" placeholder="${placeholder}"` : ''}
:dataSource="$utils.EnumToList('${enumTypeAnnotationStr}')" :pageSize="50" ${hiddenAll ? ':notitleblock="true"' : ''}><template #title><van-text text="${!hiddenAll ? placeholder || '' : ''}"></van-text></template>
<template #pannel-title>
<van-text text="${!hiddenAll ? placeholder || '' : ''}"></van-text>
</template>
<template #picker-top>
<van-picker-action-slot targetMethod="cancel">
<van-iconv name="left-arrow" icotype="only"></van-iconv>
</van-picker-action-slot>
<van-picker-action-slot targetMethod="confirm"></van-picker-action-slot>
</template>
<template #picker-bottom>
<van-picker-action-slot targetMethod="cancel">
<van-button
type="info_secondary"
size="normal"
text="取消"
squareroud="round"
></van-button>
</van-picker-action-slot>
<van-picker-action-slot targetMethod="confirm">
<van-button
type="info"
size="normal"
text="确认"
squareroud="round"
></van-button>
</van-picker-action-slot>
</template></van-pickerson>`;
return `<u-select :clearable="true"${vModel ? ` v-model="${vModel}"` : ''}${size ? ` size="${size}"` : ''}${placeholder ? ` placeholder="${placeholder}"` : ''}
:dataSource="$utils.EnumToList('${enumTypeAnnotationStr}')" :pageSize="50" :emptyValueIsNull="true"
textField="text"
valueField="value" >
${hiddenAll ? '' : '<u-select-item text="全部"></u-select-item>'}
</u-select>`;
}
exports.genEnumSelectBlock = genEnumSelectBlock;
exports.default = genEnumSelectBlock;
//# sourceMappingURL=genEnumSelectBlock.js.map