|
@@ -18,7 +18,7 @@
|
|
|
<div class="layui-form-item">
|
|
|
<label class="layui-form-label" style="width: 16%">元素名</label>
|
|
|
<div class="layui-input-inline" style="width: 76%">
|
|
|
- <input type="text" name="elementName" required lay-verify="required" placeholder="请输入元素名" autocomplete="off" class="layui-input">
|
|
|
+ <input type="text" name="elementName" required lay-verify="required|elementName" placeholder="请输入元素名" autocomplete="off" class="layui-input">
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-form-item">
|
|
@@ -37,7 +37,7 @@
|
|
|
<div class="layui-form-item">
|
|
|
<label class="layui-form-label" style="width: 20%">IOS端定位</label>
|
|
|
<div class="layui-input-inline" style="width: 18%">
|
|
|
- <select name="IOSType" >
|
|
|
+ <select name="IOSType">
|
|
|
<option value=""></option>
|
|
|
<option value="predicate">predicate</option>
|
|
|
<option value="xpath">xpath</option>
|
|
@@ -77,7 +77,7 @@
|
|
|
//提交
|
|
|
form.on('submit(preAddElement)', function (data) {
|
|
|
data.field.elementAndroidLocate = "'" + data.field.androidType + "': '" + data.field.elementAndroidLocate + "'";
|
|
|
- data.field.elementIOSLocate = "'" + data.field.IOSType + "': '"+ data.field.elementIOSLocate + "'";
|
|
|
+ data.field.elementIOSLocate = "'" + data.field.IOSType + "': '" + data.field.elementIOSLocate + "'";
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/element/add',
|
|
@@ -100,6 +100,25 @@
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
+ form.verify({
|
|
|
+ elementName: function (value, item) { //value:表单的值、item:表单的DOM对象
|
|
|
+ let code = 500;
|
|
|
+ $.ajax({
|
|
|
+ async: false,
|
|
|
+ url: '/element/verifyName',
|
|
|
+ type: 'GET',
|
|
|
+ data: {elementName: value},
|
|
|
+ dataType: 'json',
|
|
|
+ timeout: 30000,
|
|
|
+ success: function (response) {
|
|
|
+ code = response.code;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (code === 500) {
|
|
|
+ return '元素重名啦~';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
function child(obj) {
|