edit.php
4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
use yii\helpers\Url;
if ($isCreateSuccess) {
$this->title = '创建账号';
} else {
$this->title = '编辑厂商';
}
$this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<form action="<?php echo Url::toRoute(['/manufacturer/manufacturer/do-add']); ?>" name="myFrom" id="myFrom" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-body">
<div style="margin-bottom: 15px;text-align: right;">
<a href="<?=Url::toRoute("/manufacturer/manufacturer/create")?>" class="btn btn-success"> + 创建厂商账号</a>
</div>
<div class="form-group col-sm-12" style="text-align: center">
<?php if ($isCreateSuccess) { ?>
<h3>厂商创建成功!</h3>
<?php } else { ?>
<h3>编辑厂商</h3>
<?php } ?>
</div>
<div class="form-group col-sm-12">
<label for="skillName" class="col-sm-4 control-label text-right">厂商名称:</label>
<div class="col-sm-4 text-left">
<input type="text" value="<?= isset($info["name"]) ? $info["name"] : "" ?>" name="name" placeholder="请填写厂商名称" class="form-control" autocomplete="off">
</div>
</div>
<div class="form-group col-sm-12">
<label for="skillName" class="col-sm-4 control-label text-right">厂商电话:</label>
<div class="col-sm-4 text-left">
<input type="text" value="<?= isset($info["phone"]) ? $info["phone"] : "" ?>" name="phone" placeholder="请填写联系电话" class="form-control" autocomplete="off">
</div>
</div>
<div class="form-group col-sm-12">
<label for="skillName" class="col-sm-4 control-label text-right">账号:</label>
<div class="col-sm-4 text-left">
<input type="text" value="<?= isset($info["username"]) ? $info["username"] : "" ?>" name="username" placeholder="请填写账号名称" class="form-control" autocomplete="off">
</div>
</div>
<div class="form-group col-sm-12">
<label for="skillName" class="col-sm-4 control-label text-right">密码:</label>
<div class="col-sm-4 text-left">
<input type="text" value="<?= isset($info["password"]) ? $info["password"] : "1234567" ?>" name="password" placeholder="请填写密码" class="form-control" >
</div>
</div>
</div>
<div class="panel-footer text-center">
<input type="hidden" value="<?= isset($info["id"]) ? $info["id"] : "" ?>" name="mid" class="form-control"">
<button type="button" class="btn btn-primary ladda-button" data-style="slide-up" id="save">确 定</button>
<a class="btn btn-default" href="<?=Url::toRoute("/manufacturer/manufacturer/index")?>">返 回</a>
</div>
</div>
</form>
<script>
// 表单提交验证
seajs.use("base/1.0.0/unit/validate/custom-1.0.0",function () {
var validator = $("#myFrom").validate({
//debug:true,
rules: {
}
});
});
$("#save").bind("click", function () {
var getUrl = '<?=Url::toRoute("/manufacturer/manufacturer/do-edit")?>';
$('#myFrom').attr('action', getUrl);
var a = $("input[name='name']").val();
var b = $("input[name='phone']").val();
var c = $("input[name='username']").val();
var d = $("input[name='password']").val();
if ($.trim(a) == ""){
alert("用户名称不能为空");
return false;
}
if (!new RegExp("^0?(13|15|18|14|17)[0-9]{9}$").test(b)){
alert("请填写正确的手机号码");
return false;
}
if ($.trim(c) == ""){
alert("账号不能为空");
$("input[name='username']").focus();
return false;
}
if ($.trim(d) == ""){
alert("密码不能为空");
return false;
}
if (d.length < 7 || d.length > 20){
alert("密码应该在7位到20位之间");
return false;
}
var cb = $("#myFrom").validate().form();
if (!cb){
return;
}
var submit = $('#myFrom').submit();
var l = $.ladda(this);
l.start();
return false;
});
</script>