设备编号校验,只能为字母和数字

This commit is contained in:
kerwincui
2022-08-06 01:23:48 +08:00
parent 1947a67827
commit 6924802b1f
2 changed files with 78 additions and 59 deletions

View File

@@ -230,7 +230,7 @@
</div>
<div style="display:table;">
<div style="width:70px;font-weight: bold;display:table-cell;">赞助用户</div>
<div style="display:table-cell;line-height:22px;"><b style="color:#F56C6C">可用于商业用途并提供移动端源码包含一年的更新</b>但是不能低价或批量转售源码不能随意分发源码目前赞助费为3000元项目不断完善后会对应增加费用</div>
<div style="display:table-cell;line-height:22px;"><b style="color:#F56C6C">可用于商业用途并提供移动端源码包含一年的更新</b>但是不能低价或批量转售源码不能随意分发源码目前赞助费为3500元项目不断完善后会对应增加费用</div>
</div>
</el-card>
<el-card shadow="hover" style="padding:20px 0;margin-bottom:40px;font-size:14px;">

View File

@@ -15,7 +15,7 @@
<template slot="label">
<span style="color:red;">* </span>设备编号
</template>
<el-input v-model="form.serialNumber" placeholder="请输入设备编号" :disabled="form.status!=1">
<el-input v-model="form.serialNumber" placeholder="请输入设备编号" :disabled="form.status!=1" maxlength="32">
<el-button slot="append" @click="generateNum" :loading="genDisabled" :disabled="form.status!=1">生成</el-button>
</el-input>
</el-form-item>
@@ -271,6 +271,11 @@ export default {
required: true,
message: "设备名称不能为空",
trigger: "blur"
}, {
min: 2,
max: 5,
message: '设备名称长度在 2 到 5 个字符',
trigger: 'blur'
}],
firmwareVersion: [{
required: true,
@@ -429,6 +434,20 @@ export default {
},
/** 提交按钮 */
submitForm() {
if (this.form.serialNumber == null || this.form.serialNumber == 0) {
this.$modal.alertError("设备编号不能为空");
return;
}
let reg = /^[0-9a-zA-Z]+$/;
if (!reg.test(this.form.serialNumber)) {
this.$modal.alertError("设备编号只能是字母和数字");
return;
}
if (this.form.productId == null || this.form.productId == 0) {
this.$modal.alertError("所属产品不能为空");
return;
}
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deviceId != 0) {