update.php
6.14 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
110
111
112
113
114
115
116
117
118
119
<?php
use yii\helpers\Url;
$this->title = '编辑回访问题';
$this->params['breadcrumbs'][] = '平台设置';
$this->params['breadcrumbs'][] = ['label' => '回访问题设置', 'url' => ['/setting/repair-order-questions/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<form name="brandForm" id="brandForm" action="do-update" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="pannel-header text-center">
<h3>编辑回访问题</h3>
</div>
<div class="panel-body ">
<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" class="form-control col-sm-3" id="title" name="title" value="<?=$info["title"]; ?>" placeholder="请输入回访问题">
</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-3 text-left">
<select class="form-control" id="type" name="type">
<option value="0" <?php if ($info["type"] === 0) { echo "selected";} ?>>单行输入</option>
<option value="1" <?php if ($info["type"] == 1) { echo "selected";} ?>>单选</option>
<option value="2" <?php if ($info["type"] == 2) { echo "selected";} ?>>多选</option>
<option value="3" <?php if ($info["type"] == 3) { echo "selected";} ?>>多行输入</option>
</select>
</div>
<div class="col-sm-1 text-left">
<a href="javascript:void(0);" class="btn btn-default" id="btnAddOption" <?php if ($info['type'] === 0) { ?> style="display: none"<?php }?> name="btnAddOption">添加项</a>
</div>
</div>
<div id="options" name="options" >
<?php foreach ($interviewItems as $item) { ?>
<div class="form-group col-sm-12" style="padding: 0px">
<label for="item" class="col-sm-4 control-label text-right"></label>
<div class="col-sm-4 text-left">
<input type="hidden" class="" id="item_id[]" name="item_id[]" value="<?=$item['id']?>"/>
<label for="item" class=" control-label text-right">问题项:</label>
<input type="text" class="" id="item_title[]" name="item_title[]" value="<?=$item['content']?>" placeholder="请输入回访问题">
<label for="item" class=" control-label text-right">排序:</label>
<input type="number" style="width:60px;" id="item_sort_order[]" value="<?=$item['sort_order']?>" name="item_sort_order[]" value="1" placeholder="请输入排序">
<a href="javascript:void(0);" option_id="<?=$item['id'] ?>" class="btn btn-danger btn-delete">删</a>
</div>
</div>
<?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="number" min="1" max="999" class="form-control col-sm-3" id="sort_order" value="<?=$info["sort_order"]; ?>" name="sort_order" placeholder="请输入排序">
</div>
</div>
</div>
<div class="panel-footer text-center">
<input type="hidden" id="Id" name="Id" value="<?=$info["id"] ?>">
<button type="submit" class="btn btn-primary" id="save">提 交</button>
</div>
</div>
</form>
<div id="template_item" style="display: none">
<div class="form-group col-sm-12" style="padding: 0px">
<label for="item" class="col-sm-4 control-label text-right"></label>
<div class="col-sm-4 text-left">
<input type="hidden" class="" id="item_id[]" name="item_id[]" value=""/>
<label for="item" class=" control-label text-right">问题项:</label>
<input type="text" class="" id="item_title[]" name="item_title[]" placeholder="请输入回访问题">
<label for="item" class=" control-label text-right">排序:</label>
<input type="number" style="width:60px;" id="item_sort_order[]" name="item_sort_order[]" value="1" placeholder="请输入排序">
<a href="javascript:void(0);" option_id="" class="btn btn-danger btn-delete">删</a>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$("#btnAddOption").bind("click",function () {
$("#options").append($("#template_item").html());
});
$(document).on("click",".btn-delete",function () {
var optionId = $(this).attr("option_id");
if (optionId) {
var me = $(this);
$.ajax({
type: "post",
url: "do-delete-option",
dataType:"json",
data: $.csrf({"Id":optionId}),
success:function(msg){
alert(msg['msg']);
if (msg['status'] == 1){
me.parent().parent().remove();
}else{
//提示确认失败
}
},
error:function(msg){
//提示确认失败
}
});
} else {
$(this).parent().parent().remove();
}
});
$("#type").change(function () {
if ($("#type").val() == 0 || $("#type").val() == 3) {
$("#btnAddOption").hide();
}else{
$("#btnAddOption").show();
}
})
});
</script>