update.php
2.8 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
<?php
use yii\helpers\Url;
$this->title = '编辑型号';
$this->params['breadcrumbs'][] = '设备管理';
$this->params['breadcrumbs'][] = ['label' => '设备列表', 'url' => ['/device/device/index']];
$this->params['breadcrumbs'][] = ['label' => '型号管理', 'url' => ['/device/model/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<form action="" name="brandForm" id="brandForm" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading bg-success">
当前型号:<?php echo $info; ?>
</div>
<div class="panel-body">
<div class="form-group col-sm-12">
<label for="modelName" class="col-sm-4 control-label text-right">型号:</label>
<div class="col-sm-4 text-left">
<input type="text" class="form-control col-sm-3" id="modelName" placeholder="请输入型号" value="<?=$model['model'] ?>">
<input type="hidden" value="<?=$model['id'] ?>" id="modelId">
<input type="hidden" value="<?=$model['brand_id'] ?>" id="brandId">
<input type="hidden" value="<?=$model['device_cat_id'] ?>" id="deviceCatId">
</div>
</div>
</div>
<div class="panel-footer text-center">
<button type="button" class="btn btn-primary" id="save">提 交</button>
<a class="btn btn-default" href="<?php echo Url::toRoute(['/device/model/update', 'id' => $model['id']]); ?>">重 置</a>
</div>
</div>
</form>
<script>
$(document).ready(function(){
$("#save").bind("click",function(){
var modelName = $("#modelName").val();
var modelId = $("#modelId").val();
var brandId = $("#brandId").val();
var deviceCatId = $("#deviceCatId").val();
if (modelId == null || modelId == ""){
alert("丢失参数,无法提交");
return false;
}
if (modelName == null || modelName == ""){
alert("请输入类型名");
$("#modelName").focus();
return false;
}
$.ajax({
type: "post",
url: "do-update",
dataType:"json",
data: $.csrf({"modelName":modelName,"modelId":modelId,"brandId":brandId,"deviceCatId":deviceCatId}),
success:function(msg){
alert(msg['msg']);
if (msg['status'] == 1){
location.href="<?php echo Url::toRoute(['/device/model/index']); ?>";
}else{
//提示确认失败
}
},
error:function(msg){
//提示确认失败
}
});
});
});
</script>