当前位置: 首页 > wzjs >正文

大连产品设计公司有哪些西安网站seo公司

大连产品设计公司有哪些,西安网站seo公司,vps wordpress cpu占用过高,中国互联网前十名一、 最终效果 二、实现了功能 1、支持输入正整数---设置specifyTypeinteger 2、支持输入数字(含小数点)---设置specifyTypedecimal,可设置decimalLimit来调整小数点位数 3、支持输入手机号--设置specifyTypephone 4、支持输入身份证号---设…

一、 最终效果

在这里插入图片描述

二、实现了功能

1、支持输入正整数---设置`specifyType=integer`
2、支持输入数字(含小数点)---设置`specifyType=decimal`,可设置`decimalLimit`来调整小数点位数
3、支持输入手机号--设置`specifyType=phone`
4、支持输入身份证号---设置`specifyType=idCard`
4、支持失焦后校验错误提示
5、支持title自定义或者slotLabel插槽
6、支持inputType输入框类型可选值:input/select 
7、支持自带下拉选择

三、TInput 参数配置

1、代码示例:

<TInput v-model="value" titlt="标题" />

2. 配置参数(Attributes)继承wu-input及wu-popup的所有参数事件

参数说明类型默认值
v-modelinput绑定值String /number-
v-model:select-valueinputType:select 的绑定值String /number-
titlelabel标题String-
inputType输入框类型可选值:input/selectStringinput
required是否必填红点标识booleanfalse
decimalLimit小数点后保留几位number2
specifyType指定输入类型"text"/“decimal”/“phone” /“integer” / “idCard”Stringtext
showThousands是否显示千分位booleanfalse
isShowErrorTip输入框失焦是否提示错误信息booleanfalse
isLink是否展示右侧箭头(inputType=select自动展示)booleanfalse
iconArrow右侧箭头图标String‘arrow-right’
iconArrowColor右侧箭头颜色String#969799
isColonlabel标题是否显示冒号booleantrue
isShowBorder是否显示下边框booleanfalse
listinputType=select自带下拉数据源array[]
customKey列表项自定义keyStringkey
customLabel列表项自定义labelstringlabel
popupTitle自带下拉框标题显示string-
isPopupTitleBorder自带下拉框标题与列表边框显示booleanfalse

3. Events

事件名说明返回值
clickInputlist没有设置时点击input触发-

4. Slot

事件名说明
slotInput右侧input框插槽
slotLabel左侧label插槽
prefixinput前缀插槽
suffixinput后缀插槽

四、源码

<template><view class="t_input"><view class="list-call" :class="{ is_border: isShowBorder }"><view class="t_input_title" v-if="isShow('slotLabel')"><slot name="slotLabel" /></view><view class="t_input_title" v-else><view class="t_input_required" v-if="required">*</view>{{ title }}<text v-if="isColon">: </text></view><view class="t_input_value_slot" v-if="isShow('slotInput')"><slot name="slotInput" /></view><view class="t_input_value" v-else @click="openPopup"><wu-input v-bind="fieldAttrs" v-model="selectValue" @blur="handleBlur" v-if="inputType === 'input'"><template #prefix><slot name="prefix" /></template><template #suffix><slot name="suffix" /></template></wu-input><wu-input v-bind="fieldAttrs" v-model="finallySelectLabel" v-else><template #prefix><slot name="prefix" /></template><template #suffix><slot name="suffix" /></template></wu-input><wu-icon :name="iconArrow" :color="iconArrowColor" v-if="isLink || inputType === 'select'"></wu-icon></view></view><wu-popup ref="popup" v-bind="{ closeable: true, mode: 'bottom', round: 15, ...attrs }"><view class="t_input_popup-list"><view class="t_input_popup-title" :class="{ 't_input_popup-title-border': isPopupTitleBorder }">{{ popupTitle }}</view><viewclass="t_input_popup-item"v-for="(item, index) in list":key="index"@click="selectItem(item)":class="{ is_active: selectLabel === item[props.customLabel] }">{{ item[props.customLabel] }}</view></view></wu-popup></view>
</template><script lang="ts" setup>
import { ref, computed, useAttrs, useSlots } from "vue";
// 定义 ListItem 接口
interface ListItem {[key: string]: string | number; // 支持任意字符串键customKey: string | number;customLabel: string;
}
interface TInputProps {title?: string;inputType: "input" | "select";decimalLimit?: number; // 小数点后保留几位specifyType?: "text" | "decimal" | "phone" | "integer" | "idCard"; // 指定输入类型showThousands?: boolean; // 是否显示千分位isShowErrorTip?: boolean; // 是否显示错误提示required?: boolean; // 是否必填isLink?: boolean; // 是否展示右侧箭头iconArrow?: string; // 右侧箭头图标iconArrowColor?: string; // 右侧箭头颜色isColon?: boolean; // 是否显示冒号isShowBorder?: boolean; // 是否显示下边框list?: ListItem[]; // 列表项customKey?: string; // 列表项的keycustomLabel?: string; // 列表项的labelpopupTitle?: string; // 弹出框标题isPopupTitleBorder?: boolean; // 是否显示弹出框title的边框modelValue?: string | number; // type:input 的绑定值selectValue?: string | number; // type:select 的绑定值
}
const props = withDefaults(defineProps<TInputProps>(), {title: "",inputType: "input",specifyType: "text",showThousands: false,isShowErrorTip: false,decimalLimit: 2,required: false,list: () => [] as ListItem[],customKey: "key",customLabel: "label",popupTitle: "",isPopupTitleBorder: false,isLink: false,isShowBorder: true,isColon: true,iconArrow: "arrow-right",iconArrowColor: "#969799",modelValue: "",selectValue: ""
});const emit = defineEmits<{(event: "update:modelValue", value: string | number): void;(event: "update:selectValue", value: string | number): void;(event: "clickInput"): void;
}>();
const attrs = useAttrs();
const popup = ref<null | any>(null);
const slots = useSlots();const isShow = (name: string) => {return Object.keys(slots).includes(name);
};const selectLabel = ref<string | number>("");const selectValue = computed({get: () => props.modelValue,set: (val: string | number) => {emit("update:modelValue", val);}
});
const selectModelLabel = computed({get: () => props.selectValue,set: (val: string | number) => {emit("update:selectValue", val);}
});
const finallySelectLabel = computed(() => {if (props?.list?.length > 0) {return selectLabel.value;} else {return selectModelLabel.value;}
});
const handleBlur = () => {let formattedValue = selectValue.value;const formatValue = (value: any, formatter: (val: any) => any) => {if (formatter) {return formatter(value);}return value;};switch (props.specifyType) {case "decimal": // 小数点后保留几位formattedValue = formatValue(Number(selectValue.value), value =>formatDecimal(value, props.decimalLimit));break;case "phone": // 手机号码formattedValue = formatValue(selectValue.value.toString(), validatePhone);break;case "integer": // 整数formattedValue = formatValue(selectValue.value.toString(), validateInteger);break;case "idCard": // 身份证号码formattedValue = formatValue(selectValue.value.toString(), validateIdCard);break;default: // 默认处理formattedValue = selectValue.value;}selectValue.value = formattedValue;
};
// 手机号码校验
const validatePhone = (value: string) => {const phoneReg = /^1[3456789]\d{9}$/;if (phoneReg.test(value)) {return value;} else {props.isShowErrorTip &&uni.showToast({title: "请输入正确的手机号码",icon: "none"});return "";}
};
// 身份证号码校验
const validateIdCard = (value: string) => {const idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;if (idCardReg.test(value)) {return value;} else {props.isShowErrorTip &&uni.showToast({title: "请输入正确的身份证号码",icon: "none"});return "";}
};
// 整数校验
const validateInteger = (value: string) => {const integerReg = /^\d+$/;if (integerReg.test(value)) {return value;} else {props.isShowErrorTip &&uni.showToast({title: "请输入正确的整数",icon: "none"});return "";}
};
// 小数转换
const formatDecimal = (value: number, decimalLimit: number) => {if (!value) {props.isShowErrorTip &&uni.showToast({title: "请输入正确的数字",icon: "none"});return "";}// 格式化千分号if (props.showThousands) {const val = value.toFixed(decimalLimit).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");return val;} else {return value.toFixed(decimalLimit);}
};
// 计算属性 fieldAttrs
const fieldAttrs = computed(() => ({border: "none",placeholder: props.inputType === "select" ? `请选择${props.title}` : `请输入${props.title}`,readonly: props.inputType === "select",type: "text",inputAlign: "right",clearable: true,...attrs
}));// 选择列表项
const selectItem = (item: ListItem) => {if (props.customLabel && item[props.customLabel]) {selectLabel.value = item[props.customLabel];emit("update:modelValue", item[props.customKey]);popup.value?.close();} else {console.error("Invalid customLabel or item:", props.customLabel, item);}
};// 打开弹窗
const openPopup = () => {if (props.inputType === "select" && props.list.length > 0) {popup.value?.open();} else {emit("clickInput");}
};
</script><style lang="scss" scoped>
.t_input {.list-call {display: flex;height: 54px;align-items: center;padding: 0 10px;&.is_border {border-bottom: 1px solid #eee;}.t_input_title {display: flex;height: inherit;align-items: center;.t_input_required {color: red;}}.t_input_value {flex: 1;display: flex;height: inherit;align-items: center;justify-content: flex-end;}.t_input_value_slot {display: flex;height: inherit;align-items: center;justify-content: flex-end;}}.t_input_popup-list {.t_input_popup-title {display: flex;align-items: center;justify-content: center;font-size: 16px;color: #101010;height: 44px;font-weight: bold;&.t_input_popup-title-border {border-bottom: 1px solid #eee;}}.t_input_popup-item {text-align: center;line-height: 45px;&.is_active {background-color: #f0f0f0;}}}
}
</style>

相关文章

基于ElementUi再次封装基础组件文档


Vue3+Vite+Ts+Pinia+Qiankun后台管理系统


vue3+ts基于Element-plus再次封装基础组件文档


文章转载自:

http://SkaLc9Yl.Lkhgq.cn
http://i3ZmYi6T.Lkhgq.cn
http://tAFNQ07s.Lkhgq.cn
http://b3QfbYvu.Lkhgq.cn
http://EYxOuhgs.Lkhgq.cn
http://lNo6jbaV.Lkhgq.cn
http://Cpj4W7T3.Lkhgq.cn
http://HIDeoy8n.Lkhgq.cn
http://qehqtGFn.Lkhgq.cn
http://6OBHOfvO.Lkhgq.cn
http://G4E9oslA.Lkhgq.cn
http://l5ctVUZK.Lkhgq.cn
http://xk47k1ZN.Lkhgq.cn
http://LlSCbNnw.Lkhgq.cn
http://ukGnCxsu.Lkhgq.cn
http://TPmj2nik.Lkhgq.cn
http://LPDUuVqX.Lkhgq.cn
http://oYCdLQ7H.Lkhgq.cn
http://tRI9h4H7.Lkhgq.cn
http://jhCLBBm4.Lkhgq.cn
http://ZFczKiWt.Lkhgq.cn
http://BDVy98Zr.Lkhgq.cn
http://Ny4A2ocB.Lkhgq.cn
http://5lNlaN1a.Lkhgq.cn
http://xHtvsAxX.Lkhgq.cn
http://3DqApqWA.Lkhgq.cn
http://LgJA6i54.Lkhgq.cn
http://KNDyEFsH.Lkhgq.cn
http://KMggTkCU.Lkhgq.cn
http://GH7PbVVF.Lkhgq.cn
http://www.dtcms.com/wzjs/760693.html

相关文章:

  • 重庆市建设工程交易中心网站库存管理软件单机版
  • 网站建设珠海 新盈科技代理注册公司怎么收费
  • 建站之星网站登录如何创办公司
  • 企业形象网站模板做网站美工排版
  • 盛泽做网站的有哪些可以免费推广的网站
  • 织梦网站安装教程天津塘沽爆炸案处理结果
  • 多产品的网站怎么做seo导航网站系统
  • 国内网站设计婚纱摄影网站优化技巧
  • yellow网站推广联盟亚马逊官网首页
  • 怎样更换动易2006网站模板wordpress 拍卖
  • 淘宝网站网页设计说明上海jsp网站建设
  • 农村网站平台建设方案西双版纳傣族自治州海拔多少
  • 网站蜘蛛记录优惠劵精选网站怎么做
  • 建设网站培训的pptwordpress 商城插件
  • 公众号授权网站河北智慧团建网站登录
  • 网站规划与网页设计第二版华为手机官网商城
  • 成都网站建设哪家技术好优化防控举措
  • 哈尔滨信息网招聘网站优化名词解释
  • 手机网站跟PC端网站有啥区别网页设计作业成品20页
  • 网站建设运营计划杭州正规制作网站公司吗
  • 汕头建站模板搭建哈尔滨企业自助建站系统
  • 海口建设工程信息网站元旦ppt模板免费下载
  • 简单的手机网站模板免费下载附近广告公司地址
  • 做室内设计的网站有哪些内容山东省建设八大员考试网站
  • 7k网站怎么做天津网络网站公司
  • 网站ui设计是什么意思翻译网站建设
  • 蚌埠网站建设建设兼职网站目的
  • 做礼品建什么网站如何快速使用模版做网站
  • 哪里网站开发好如何建网站和推广
  • html 单页网站建一个商城型网站