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

广州汽车网站建设网站建设与维护技术浅谈论文

广州汽车网站建设,网站建设与维护技术浅谈论文,杭州企业网站制作,软件类专业有哪些需求&#xff1a;想要实现一个输入金额的el-input&#xff0c;限制只能输入数字和一个小数点。失焦数字转千分位&#xff0c;聚焦转为数字&#xff0c;超过最大值&#xff0c;红字提示 效果图 失焦 聚焦 报错效果 // 组件limitDialog <template><el-dialog:visible.s…

需求:想要实现一个输入金额的el-input,限制只能输入数字和一个小数点。失焦数字转千分位,聚焦转为数字,超过最大值,红字提示

效果图

失焦

效果图

聚焦

聚焦

报错效果

报错

// 组件limitDialog
<template><el-dialog:visible.sync="isVisible"title="修改限额"width="420px":before-close="cancel"><el-form :model="formVal" ref="ruleForm" size="small"><el-form-itemlabel="单次交易限额"prop="single_limit":rules="[{required: true,message: '请输入单次交易限额',trigger: 'change',},{ validator: singleRule, trigger: 'change' },]"><el-inputv-model="formVal.single_limit"v-thousandmaxlength="10"type="text"@keypress.native="restrictInput('single_limit', $event)"@blur="formatOnBlur('single_limit', $event)"><template slot="suffix">{{ otherInfo.currency }}</template></el-input></el-form-item><el-form-itemlabel="每日限额"prop="daily_limit":rules="[{required: true,message: '请输入每日限额',trigger: 'change',},{ validator: dailyRule, trigger: 'change' },]"><el-inputv-model="formVal.daily_limit"maxlength="10"v-thousandtype="text"@keypress.native="restrictInput('daily_limit', $event)"@blur="formatOnBlur('daily_limit', $event)"><template slot="suffix">{{ otherInfo.currency }}</template></el-input><p class="tip" v-if="type !== 'bath'">当日已用金额 {{ otherInfo.daily_used }}{{ otherInfo.currency }}</p></el-form-item><el-form-itemlabel="每月限额"prop="monthly_limit":rules="[{required: true,message: '请输入每月限额',trigger: 'change',},{ validator: monthlyRule, trigger: 'change' },]"><el-inputv-model="formVal.monthly_limit"maxlength="10"v-thousandtype="text"@keypress.native="restrictInput('monthly_limit', $event)"@blur="formatOnBlur('monthly_limit', $event)"><template slot="suffix">{{ otherInfo.currency }}</template></el-input><p class="tip" v-if="type !== 'bath'">当月已用金额 {{ otherInfo.monthly_used }}{{ otherInfo.currency }}</p></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="cancel" size="small">取 消</el-button><el-buttontype="primary"@click="handleSave"size="small":loading="isSumbitLoading">确 定</el-button></div></el-dialog>
</template><script>
import { updateCardLimitApi } from "@/services/api/cardManage.js";
import { updateObject } from "@/utils/common";
export default {data() {return {isVisible: false,isSumbitLoading: false,formVal: {single_limit: "",daily_limit: "",monthly_limit: "",id: "",},otherInfo: {currency: "USD",daily_used: "",monthly_used: "",},type: "bath",};},props: {selectedList: {type: Array,default: () => [],},},methods: {singleRule(rule, value, callback) {const numValue = Number(value);if (numValue > 10000) {callback(new Error(`输入金额不可超过单次限额(10,000.00 ${this.otherInfo.currency})`));}this.checkLimit(value, callback);},dailyRule(rule, value, callback) {const numValue = Number(value);if (numValue > 100000) {callback(new Error(`输入金额不可超过每日限额(100,000.00 ${this.otherInfo.currency})`));}this.checkLimit(value, callback);},monthlyRule(rule, value, callback) {const numValue = Number(value);if (numValue > 500000) {callback(new Error(`输入金额不可超过每月限额(500,000.00 ${this.otherInfo.currency})`));}this.checkLimit(value, callback);},checkLimit(value, callback) {const strValue = String(value || "");if (strValue === "")return callback(new Error("请输入单次交易限额"));if (strValue.endsWith("."))return callback(new Error("不能以小数点结尾"));const numValue = Number(strValue);if (isNaN(numValue)) return callback(new Error("请输入有效的数字"));if (strValue.includes(".") && strValue.split(".")[1].length > 2) {return callback(new Error("小数点后最多两位"));}callback();},restrictInput(formKey, event) {const key = event.key;const value = String(this.formVal[formKey] || "");if (event.ctrlKey || event.altKey || key.length > 1) return;// 只允许数字和小数点,限制多个小数点const isValidKey = /[0-9.]/.test(key);const hasDecimal = value.includes(".");if (!isValidKey || (key === "." && hasDecimal)) {event.preventDefault();return;}},formatOnBlur(formKey) {const strValue = String(this.formVal[formKey] || "");if (strValue && !isNaN(Number(strValue))) {this.formVal[formKey] = Number(strValue).toFixed(2);}},init(info, type) {this.isVisible = true;this.type = type;updateObject(this.formVal, info);updateObject(this.otherInfo, info);},handleSave() {this.isSubmitLoading = true;this.$refs.ruleForm.validate(async (valid) => {if (valid) {const { code } = await updateCardLimitApi({...this.formVal,id:this.type === "bath"? this.selectedList.map((item) => item.id): [this.formVal.id],});if (code == 0) {this.$message.success("修改成功");this.cancel();this.$emit("reload");}}this.isSumbitLoading = false;});},cancel() {this.isVisible = false;this.$refs.ruleForm.resetFields();updateObject(this.formVal, {single_limit: "",daily_limit: "",monthly_limit: "",id: "",});this.otherInfo.currency = "USD";},},
};
</script><style lang="scss" scoped>
.dialog-footer {text-align: right;
}
.tip {color: #999999;font-size: 12px;
}
</style>

文章转载自:

http://9zJxnNbc.yfphk.cn
http://5iZ0mSvM.yfphk.cn
http://tmzEU4Vu.yfphk.cn
http://P9XRhMZq.yfphk.cn
http://DOA4d16B.yfphk.cn
http://xrXSkS5g.yfphk.cn
http://jztGtJmY.yfphk.cn
http://Fg8tb2tv.yfphk.cn
http://WdTTQvCn.yfphk.cn
http://k7QGmizq.yfphk.cn
http://6ce8NOxU.yfphk.cn
http://YBt2SSAx.yfphk.cn
http://avSujGcW.yfphk.cn
http://ai0ahpKn.yfphk.cn
http://K1C1MwpR.yfphk.cn
http://io1a6uPu.yfphk.cn
http://j6HDTMYn.yfphk.cn
http://wCCVn6uZ.yfphk.cn
http://BExtl07V.yfphk.cn
http://riGuzABm.yfphk.cn
http://EKJ2ANH6.yfphk.cn
http://ec05pu1A.yfphk.cn
http://EaSr55xd.yfphk.cn
http://J5gfAObU.yfphk.cn
http://SqU9Ezkj.yfphk.cn
http://8sudZ3Z0.yfphk.cn
http://mizNRNuU.yfphk.cn
http://CX07dEsZ.yfphk.cn
http://iR2f32Ku.yfphk.cn
http://rzvsGzui.yfphk.cn
http://www.dtcms.com/wzjs/714376.html

相关文章:

  • 网站关键词没被搜出来内容营销平台
  • 榆林网站优化诸城网站建设诸城
  • 微信公众号微网站怎么建设怎么做百度网站推广
  • 天津网站优化指导哪个网站做期货数字币
  • 入夏网站建设公司广州开发区东区
  • 杭州哪家做网站比较好家装公司利润一般多少
  • 网站建设开发报价表上海网站建设高端定制
  • 如何用网站开发工具停止网页进程sem网络推广是什么
  • 网站定制案例辽宁建设工程信息网联合体投标
  • 网站的目录结构学网站建设多久能学会
  • 编程教学网站推荐网站建设哈尔滨
  • 外贸网站推广公司手机网站比例尺寸
  • 中国网站优化哪家好做网站运营工资是不是很低
  • 网站建设公司美工如何找网站被黑能查到是谁做的吗
  • 电商网站的成本网站备案核验点
  • 郑州网站建设中心企业网站设计方案
  • 深圳住房和建设局网站认租申请揭阳模板网站建站
  • 漯河网站推广哪家好工业产品设计工资
  • 哪个网站做民宿更好呢诸城市网站建设
  • logo素材网站有哪些网站建设联雅
  • 南漳做网站软件技术专业主要学什么
  • 做设计网站的工作怎么样网站建设调研文档
  • 莆田哪里有网站开发国外有哪些设计网站有哪些问题
  • 邢台做网站费用wordpress 文章回收站
  • 网站建设管理规范iis的网站登录没反应
  • 设计网站免费下载网站设计网站机构
  • 双鸭山网站建设公司怎么把网站放到百度
  • 网站建设合同印花税税率wordpress段子主题
  • 长春网站网站推广公司设计广东手机网站制作价格
  • 膳食管理东莞网站建设wordpress修改后台