post.html
16.3 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
{template 'common/header'}
{php load()->func('tpl')}
<style type="text/css">
.form .alert{width:700px;}
</style>
<ul class="nav nav-tabs">
<li><a href="{php echo $this->createWebUrl('display')}">预约活动列表</a></li>
<li{if !$reid} class="active"{/if}><a href="{php echo $this->createWebUrl('post')}">新建预约活动</a></li>
{if $reid}<li class="active"><a href="{php echo $this->createWebUrl('post', array('id' => $reid))}">编辑预约活动</a></li>{/if}
</ul>
<div class="main">
<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data" onsubmit="return validate(this);">
<div class="panel panel-default">
<div class="panel-heading">
预约活动 <span class="text-muted">通过预约你可以实现服务预约, 在线咨询, 在线调查等功能</span>
</div>
<div class="panel-body">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">预约名称</label>
<div class="col-xs-12 col-sm-9">
<input type="text" class="form-control" placeholder="" name="activity" value="{$activity['title']}" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">简介</label>
<div class="col-xs-12 col-sm-9">
<textarea style="height:200px;" class="form-control" id="description" name="description" cols="70">{$activity['description']}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">预约内容</label>
<div class="col-xs-12 col-sm-9">
<textarea id="content" type="text" class="form-control richtext-clone" placeholder="" name="content">{$activity['content']}</textarea>
<span class="help-block">此预约活动的说明信息. 例如: 请提交你的联系方式, 和要咨询的产品信息. 我们会尽快联系你</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提交提示信息</label>
<div class="col-xs-12 col-sm-9">
<textarea type="text" class="form-control" placeholder="" name="information">{$activity['information']}</textarea>
<span class="help-block">预约提交成功以后提示的信息. 例如: 您的信息我们已经收到, 很快会有专人联系你. </span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">预约活动封面</label>
<div class="col-xs-12 col-sm-9">
{php echo tpl_form_field_image('thumb',$activity['thumb']);}
<span class="help-block">用一张图片来更好的表现你的预约主题</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">每人可预约次数</label>
<div class="col-xs-12 col-sm-9">
<input type="text" class="form-control" name="pretotal" value="{if !empty($activity['pretotal'])}{$activity['pretotal']}{else}1{/if}" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">预约总人数</label>
<div class="col-xs-12 col-sm-9">
<input type="text" class="form-control" name="alltotal" value="{if !empty($activity['alltotal'])}{$activity['alltotal']}{else}1{/if}" />
<span class="help-block">预约总人数限制,超过该人数活动将自动结束</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
<div class="col-xs-12 col-sm-9">
<label class="radio-inline"><input type="radio" name="status" value="1" {if $activity['status'] == 1 || empty($activity['status'])} checked="checked"{/if} /> 开始</label>
<label class="radio-inline"><input type="radio" name="status" value="0" {if !empty($activity) && $activity['status'] == 0} checked="checked"{/if} /> 停止</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">开始时间</label>
<div class="col-xs-12 col-sm-9">
{php echo tpl_form_field_date('starttime', $activity['starttime'], true)}
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结束时间</label>
<div class="col-xs-12 col-sm-9">
{php echo tpl_form_field_date('endtime', $activity['endtime'], true)}
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">微站首页展示</label>
<div class="col-xs-12 col-sm-9">
<label class="radio-inline"><input type="radio" name="inhome" value="1" {if $activity['inhome'] == 1} checked="checked"{/if} /> 显示</label>
<label class="radio-inline"><input type="radio" name="inhome" value="0" {if empty($activity) || $activity['inhome'] == 0} checked="checked"{/if} /> 不显示</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">接收通知Email</label>
<div class="col-xs-12 col-sm-9">
<input type="text" class="form-control" name="noticeemail" value="{$activity['noticeemail']}" />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">接收通知手机号</label>
<div class="col-xs-12 col-sm-9">
<input type="text" class="form-control" name="mobile" value="{$activity['mobile']}" maxlength="11" />
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
调研内容管理
</div>
<div class="panel-body table-responsive">
<div class="alert-new">
<table class="table table-hover">
<thead>
<tr>
<th style="width:45%;">调查项目</th>
<th style="width:15%;text-align:center;">排序</th>
<th style="width:8%;text-align:center;">是否必填</th>
<th style="width:12%;">类型</th>
<th style="width:10%;">关联默认值</th>
<th style="width:10%;">操作</th>
</tr>
</thead>
<tbody id="re-items">
{loop $ds $r}
<tr>
<td><input name="title[]" type="text" class="form-control" value="{$r['title']}"/></td>
<td><input type="text" name="displayorder[]" class="form-control" value="{$r['displayorder']}" /></td>
<td style="text-align:center;"><input name="essential[]" type="checkbox" title="必填项" {if $r['essential']} checked="checked"{/if}/></td>
<td>
<select name="type[]" class="form-control category">
{loop $types $k $v}
<option value="{$k}"{if $k == $r['type']} selected="selected"{/if}>{$v}</option>
{/loop}
</select>
</td>
<td>
<select name="bind[]" class="form-control bind">
<option value="">不关联粉丝数据</option>
{loop $fields $k $v}
<option value="{$k}"{if $k == $r['bind']} selected="selected"{/if}>{$v}</option>
{/loop}
</select>
<input type="hidden" name="value[]" value="{$r['value']}"/>
<input type="hidden" name="desc[]" value="{$r['description']}"/>
<input type="hidden" name="essentialvalue[]" value="{if $r['essential']}true{else}false{/if}"/>
</td>
<td>
{if !$hasData}
<a href="javascript:;" onclick="deleteItem(this)" data-toggle="tooltip" data-placement="bottom" title="删除此条目" class="btn btn-default btn-sm"><i class="fa fa-times"></i></a>
<a href="javascript:;" data-toggle="tooltip" data-placement="bottom" title="设置详细信息" onclick="setValues(this);" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
{/if}
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
<div class="alert alert-block alert-new">
{if $hasData}
<a href="{php echo $this->createWebUrl('manage', array('id' => $reid));}" target="_blank">已经存在调查数据, 不能修改调查条目信息</a>
{else}
<a href="javascript:;" onclick="addItem();">添加调查条目 <i class="fa fa-plus" title="添加调查条目"></i></a>
{/if}
</div>
<span class="help-block">预约成功启动以后(已经有粉丝用户提交给预约信息), 将不能再修改调查项目, 请仔细编辑. </span>
</div>
</div>
<div class="form-group col-sm-12">
<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
<input type="hidden" name="token" value="{$_W['token']}" />
</div>
</form>
</div>
<div id="dialog" class="modal fade" tabindex="-1">
<div class="modal-dialog" style='width: 920px;'>
<div class="modal-content">
<div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>设置选项</h3></div>
<div class="modal-body" >
<div class="well">
<textarea id="re-desc" class="form-control" rows="3"></textarea>
<span class="help-block"><strong>设置此条目的说明信息</strong></span>
</div>
<div class="well re-value hide">
<textarea id="re-value" class="form-control" rows="6"></textarea>
<span class="help-block"><strong>设置预约条目的选项(如果有需要的话.) 每行一条记录, 例如: 性别 男, 女</strong></span>
</div>
<div id="module-menus" style="padding-top:5px;"></div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-primary btn-ok" data-dismiss="modal" aria-hidden="true">确 定</a>
<a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关 闭</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
require(['util'],function(util){
util.editor($('.richtext-clone')[0]);
})
var currentItem = null;
$(function(){
require(['jquery','jquery.ui'],function($,j){
$('#re-items').sortable({handle: '.fa-move'});
})
$('#dialog .btn-ok').on('click', function(){
if(currentItem == null) return;
var v = $('#dialog #re-value').val();
$(currentItem).parent().prev().find(':hidden[name="value[]"]').val(encodeURIComponent(v.replace(/\n/g, ',')));
var v = $('#dialog #re-desc').val();
$(currentItem).parent().prev().find(':hidden[name="desc[]"]').val(encodeURIComponent(v));
});
{if $hasData}
$('#re-items').find(':text,:checkbox,select').attr('disabled', 'disabled');
{/if}
});
function setValues(o) {
var v = $(o).parent().prev().find(':hidden[name="value[]"]').val();
v = decodeURIComponent(v);
$('#dialog #re-value').val(v.replace(/,/g, '\n'));
var v = $(o).parent().prev().find(':hidden[name="desc[]"]').val();
v = decodeURIComponent(v);
$('#dialog #re-desc').val(v);
var v = $(o).parent().prev().prev().find('select[name="type[]"]').val();
if(v == 'radio' || v == 'checkbox' || v == 'select') {
$('.well.re-value').removeClass('hide');
} else {
$('.well.re-value').addClass('hide');
}
$('#dialog').modal({keyboard: false});
currentItem = o;
}
$('.main').on('change', '.bind', function() {
if ($(this).val() != '') {
$(this).parent().prev().find('.category').val('text');
if ($(this).val() == 'resideprovince') {
$(this).parent().prev().find('.category').val('reside');
}
if ($(this).val() == 'birthyear') {
$(this).parent().prev().find('.category').val('calendar');
}
if ($(this).val() == 'gender') {
$(this).parent().prev().find('.category').val('radio');
}
$(this).parent().prev().find('.category').attr('readonly', true);
if ($(this).val() != 'gender') {
$('#re-value').parent().hide();
} else {
$('#re-value').parent().show();
}
$('#re-value').val('');
} else {
$(this).parent().prev().find('.category').attr('readonly', false);
if ($(this).parent().prev().find('.category').val() == 'checkbox') {
$('#re-value').parent().show();
}
}
});
$('.main').on('change', '.category', function() {
var bind = $(this).parent().next().find('.bind').val();
if (bind != '') {
$(this).val('text');
if (bind == 'resideprovince') {
$(this).val('reside');
}
if (bind == 'birthyear') {
$(this).val('calendar');
}
if (bind == 'gender') {
$(this).val('radio');
}
}
});
function addItem() {
var html = '' +
'<tr>' +
'<td><input name="title[]" type="text" class="form-control" /></td>' +
'<td><input type="text" name="displayorder[]" class="form-control" /></td>' +
'<td style="text-align:center;"><input name="essential[]" type="checkbox" title="必填项" /></td>' +
'<td>' +
'<select name="type[]" class="form-control category">' +
{loop $types $k $v}
'<option value="{$k}">{$v}</option>' +
{/loop}
'</select>' +
'</td>' +
'<td>' +
'<select name="bind[]" class="form-control bind">' +
'<option value="">不关联粉丝数据</option>' +
{loop $fields $k $v}
{if !empty($v)}
'<option value="{$k}">{$v}</option>' +
{/if}
{/loop}
'</select>' +
'<input type="hidden" name="value[]" />' +
'<input type="hidden" name="desc[]" />' +
'<input type="hidden" name="essentialvalue[]" />' +
'</td>' +
'<td>' +
'<a href="javascript:;" data-toggle="tooltip" data-placement="bottom" onclick="deleteItem(this)" title="删除此条目"><i class="fa fa-times"></i></a> ' +
'<a href="javascript:;" data-toggle="tooltip" data-placement="bottom" title="设置详细信息" onclick="setValues(this);"><i class="fa fa-edit"></i></a>' +
'</td>' +
'</tr>';
$('#re-items').append(html);
}
function deleteItem(o) {
$(o).parent().parent().remove();
}
function message(msg){
require(['util'],function(util){
util.message(msg);
});
}
function validate() {
if($.trim($(':text[name="activity"]').val()) == '') {
message('必须填写预约活动标题.', '', 'error');
return false;
}
if($.trim($('textarea[name="information"]').val()) == '') {
message('必须填写预约活动成功提示信息.', '', 'error');
return false;
}
{if empty($reid)}
if($.trim($(':input[name="thumb"]').val()) == '') {
message('必须上传预约活动封面.', '', 'error');
return false;
}
{/if}
if($(':text[name="title[]"]').length == 0) {
message('必须设定预约活动的调查条目.', '', 'error');
return false;
}
var isError = false;
$(':text[name="title[]"]').each(function(){
if($.trim($(this).val()) == '') {
isError = true;
}
});
if(isError) {
message('必须要设定每个调查条目的标题.', '', 'error');
return false;
}
var isError = false;
$('#re-items tr').each(function(){
var t = $(this).find('select[name="type[]"]').val();
if(t == 'radio' || t == 'checkbox' || t == 'select') {
if($.trim($(this).find(':hidden[name="value[]"]').val()) == '') {
isError = true;
}
}
});
if(isError) {
message('单选, 多选或下拉选择项目必须要设定备选项.', '', 'error');
return false;
}
$(':checkbox').each(function(){
if($(this).get(0).checked) {
$(this).parent().parent().find(':hidden[name="essentialvalue[]"]').val('true');
} else {
$(this).parent().parent().find(':hidden[name="essentialvalue[]"]').val('false');
}
});
return true;
}
</script>
{template 'common/footer'}