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

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>
<div style="display:table;"> <div style="display:table;">
<div style="width:70px;font-weight: bold;display:table-cell;">赞助用户</div> <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> </div>
</el-card> </el-card>
<el-card shadow="hover" style="padding:20px 0;margin-bottom:40px;font-size:14px;"> <el-card shadow="hover" style="padding:20px 0;margin-bottom:40px;font-size:14px;">

View File

@@ -15,7 +15,7 @@
<template slot="label"> <template slot="label">
<span style="color:red;">* </span>设备编号 <span style="color:red;">* </span>设备编号
</template> </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-button slot="append" @click="generateNum" :loading="genDisabled" :disabled="form.status!=1">生成</el-button>
</el-input> </el-input>
</el-form-item> </el-form-item>
@@ -152,7 +152,7 @@
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
<div style="border:1px solid #ccc;width:200px;text-align: center;margin-left:20px;margin-top:-10px;"> <div style="border:1px solid #ccc;width:200px;text-align: center;margin-left:20px;margin-top:-10px;">
<vue-qr :text="qrText" :size="200" ></vue-qr> <vue-qr :text="qrText" :size="200"></vue-qr>
<div style="padding-bottom:10px;">设备二维码</div> <div style="padding-bottom:10px;">设备二维码</div>
</div> </div>
</el-col> </el-col>
@@ -232,7 +232,7 @@ export default {
data() { data() {
return { return {
// 二维码内容 // 二维码内容
qrText:'wumei-smart', qrText: 'wumei-smart',
// 打开设备配置对话框 // 打开设备配置对话框
openSummary: false, openSummary: false,
// 是否加载完成 // 是否加载完成
@@ -271,6 +271,11 @@ export default {
required: true, required: true,
message: "设备名称不能为空", message: "设备名称不能为空",
trigger: "blur" trigger: "blur"
}, {
min: 2,
max: 5,
message: '设备名称长度在 2 到 5 个字符',
trigger: 'blur'
}], }],
firmwareVersion: [{ firmwareVersion: [{
required: true, required: true,
@@ -429,6 +434,20 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { 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 => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.deviceId != 0) { if (this.form.deviceId != 0) {
@@ -476,13 +495,13 @@ export default {
}, },
/**关闭物模型 */ /**关闭物模型 */
openSummaryDialog() { openSummaryDialog() {
let json={ let json = {
type:1,// 1=扫码关联设备 type: 1, // 1=扫码关联设备
deviceNumber:this.form.serialNumber, deviceNumber: this.form.serialNumber,
productId:this.form.productId, productId: this.form.productId,
productName:this.form.productName, productName: this.form.productName,
}; };
this.qrText=JSON.stringify(json); this.qrText = JSON.stringify(json);
this.openSummary = true; this.openSummary = true;
}, },
/**关闭物模型 */ /**关闭物模型 */