正在显示
1 个修改的文件
包含
28 行增加
和
0 行删除
@@ -1683,6 +1683,8 @@ Handling Information | @@ -1683,6 +1683,8 @@ Handling Information | ||
1683 | <el-form-item> | 1683 | <el-form-item> |
1684 | <el-input minlength="1" maxlength="20" onkeyup="this.value=this.value.toUpperCase()" | 1684 | <el-input minlength="1" maxlength="20" onkeyup="this.value=this.value.toUpperCase()" |
1685 | @keyup.native="addForm.hbs.hbs_manifest_description.replace(/[^A-Za-z0-9\s]/g,'')" | 1685 | @keyup.native="addForm.hbs.hbs_manifest_description.replace(/[^A-Za-z0-9\s]/g,'')" |
1686 | + :max-length="15" | ||
1687 | + @paste.native="handlePaste($event, 15)" | ||
1686 | v-model="addForm.hbs.hbs_manifest_description" auto-complete="off" placeholder="货物品名" size="mini"></el-input> | 1688 | v-model="addForm.hbs.hbs_manifest_description" auto-complete="off" placeholder="货物品名" size="mini"></el-input> |
1687 | </el-form-item> | 1689 | </el-form-item> |
1688 | </el-col> | 1690 | </el-col> |
@@ -2384,6 +2386,32 @@ Handling Information | @@ -2384,6 +2386,32 @@ Handling Information | ||
2384 | } | 2386 | } |
2385 | }, | 2387 | }, |
2386 | methods:{ | 2388 | methods:{ |
2389 | + handlePaste(event, maxLength) { | ||
2390 | + // 阻止默认的粘贴行为 | ||
2391 | + event.preventDefault(); | ||
2392 | + // 获取粘贴的内容 | ||
2393 | + let pasteData = (event.clipboardData || window.clipboardData).getData('text').toUpperCase(); | ||
2394 | + // 获取当前输入框的内容 | ||
2395 | + let currentValue = this.addForm.hbs.hbs_manifest_description; | ||
2396 | + // 计算总长度 | ||
2397 | + let totalLength = currentValue.length + pasteData.length; | ||
2398 | + if (totalLength > 15) { | ||
2399 | + // 如果总长度超过15,只粘贴允许的部分 | ||
2400 | + pasteData = pasteData.slice(0, 15 - currentValue.length); | ||
2401 | + } | ||
2402 | + // 更新输入框的内容 | ||
2403 | + this.addForm.hbs.hbs_manifest_description += pasteData; | ||
2404 | + // 再次限制总长度 | ||
2405 | + this.addForm.hbs.hbs_manifest_description = this.limitInputLength(this.addForm.hbs.hbs_manifest_description); | ||
2406 | + }, | ||
2407 | + | ||
2408 | + limitInputLength(value, maxLength) { | ||
2409 | + // 如果输入值的长度超过15,则截取前15个字符 | ||
2410 | + if (value.length > 15) { | ||
2411 | + return value.slice(0, 15); | ||
2412 | + } | ||
2413 | + return value; | ||
2414 | + }, | ||
2387 | handleInput(value) { | 2415 | handleInput(value) { |
2388 | // 这里可以进一步处理输入值,例如去空格等 | 2416 | // 这里可以进一步处理输入值,例如去空格等 |
2389 | this.form.bill.waybillNum = value.trim(); | 2417 | this.form.bill.waybillNum = value.trim(); |
-
请 注册 或 登录 后发表评论