index.php
6.29 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
use yii\helpers\Url;
use app\ht\widgets\LinkPager;
$this->title = '回访问题设置';
$this->params['breadcrumbs'][] = '平台设置';
$this->params['breadcrumbs'][] = ['label' => $this->title, 'url' => ['#']];
?>
<div class="panel panel-default">
<div class="panel-heading">
<a href="<?php echo Url::toRoute('/setting/repair-order-questions/create'); ?>" class="btn btn-success pull-left">添加</a>
<a href="javascript:void(0)" class="btn btn-success sort-table">执行排序</a>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<?php if (!empty($dataList)) : ?>
<table class="table table-striped table-bordered" id="brand-table">
<thead>
<tr>
<th style="width:5%;" class="text-center align-middle hqy-all-select">ID</th>
<th style="width:25%;">问题</th>
<th style="width:15%;">类型</th>
<th style="width:15%;">排序</th>
<th style="width:15%;">添加时间</th>
<th style="width:35%;">操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($dataList as $item) : ?>
<tr id="tr-<?= $item['id'] ?>">
<td class="text-center align-middle hqy-row-select"><?= $item['id'] ?></td>
<td >
<?= $item['title'] ?> <br/>
<?= $item['optionsStr']?>
</td>
<td >
<?php if ($item['type'] == 1) {echo "单选";} elseif ($item['type'] == 2) {echo "多选";} elseif ($item['type'] == 3) {echo "多行输入";} else {echo "单行输入";} ?>
</td>
<td >
<input style="width: 50px;" type="number" class="sort-input" value="<?= $item['sort_order'] ?>" data-id="<?= $item['id'] ?>" name="sort-<?= $item['id'] ?>" />
</td>
<td>
<?=Yii::$app->formatter->asTime($item['created_at'],"yyyy-MM-dd HH:mm:ss"); ?>
</td>
<td >
<button class="btn btn-info btn-sm btn_edit" aid="<?=$item['id'] ?>">编辑</button>
<?php if ($item['is_deleted'] == 1): ?>
<button class="btn btn-warning btn-sm btn_reset" aid="<?=$item['id'] ?>">恢复</button>
<?php else: ?>
<button class="btn btn-danger btn-sm btn_delete" aid="<?=$item['id'] ?>">删除</button>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<p class="text-center">
没有找到数据
</p>
<?php endif; ?>
</div>
<div class="panel-footer">
<div class="hqy-panel-pager">
<?= LinkPager::widget([
'pagination' => $pages,
]); ?>
<div class="clearfix"></div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$(".btn_edit").bind("click", function () {
location.href = "<?=Url::toRoute(['/setting/repair-order-questions/update'])?>?Id=" + $(this).attr("aid");
});
$(".btn_delete").bind("click", function () {
if (confirm("你是否确认删除?")) {
var Id = $(this).attr("aid");
if (Id == "") {
alert("缺少必要参数不能被删除!");
return false;
}
$.ajax({
type: "post",
url: "do-delete",
dataType: "json",
data: $.csrf({"Id": Id}),
success: function (msg) {
alert(msg['msg']);
if (msg['status'] == 1) {
window.location.reload();
} else {
alert("删除失败");
}
}, error: function (msg) {
}
});
}
});
$(".btn_reset").bind("click", function () {
if (confirm("你是否确认恢复?")) {
var Id = $(this).attr("aid");
if (Id == "") {
alert("缺少必要参数不能被删除!");
return false;
}
$.ajax({
type: "post",
url: "do-reset",
dataType: "json",
data: $.csrf({"Id": Id}),
success: function (msg) {
alert(msg['msg']);
if (msg['status'] == 1) {
window.location.reload();
} else {
alert("恢复失败");
}
}, error: function (msg) {
}
});
}
});
$(".sort-table").bind("click", function () {
if (confirm("你是否执行排序?")) {
var sort_json = {};
$(".sort-input").each(function () {
id = $(this).attr('data-id');
val = $(this).val();
if (val == null || val == '')val = 0;
sort_json[id] = val;
});
$.ajax({
type: "post",
url: "do-sort",
dataType: "json",
data: sort_json,
success: function (msg) {
alert(msg['msg']);
if (msg['status'] == 1) {
window.location.reload();
} else {
alert("执行失败");
}
}, error: function (msg) {
}
});
}
});
});
</script>