25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

374 lines
17 KiB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\bootstrap\ActiveForm;
  4. use backend\modules\zzcs\logic\BaseTourist;
  5. use yii\helpers\Url;
  6. use backend\modules\zzcs\models\BaseArea;
  7. use kartik\file\FileInput;
  8. ?>
  9. <style>
  10. .form-horizontal .control-label {
  11. padding-top: 0px;
  12. margin-bottom: 0;
  13. text-align: right;
  14. float: left;
  15. width: 140px;
  16. }
  17. textarea {
  18. min-width: 550px;
  19. min-height: 150px;
  20. }
  21. .form-horizontal .form-group {
  22. margin-right: 0px;
  23. margin-left: 0px;
  24. }
  25. .combo-select {
  26. width: 100px;
  27. }
  28. .label-color {
  29. color: red;
  30. }
  31. /*.help-block{*/
  32. /*display: inherit!important;*/
  33. /*}*/
  34. #operatouristcommon-tp_start_area_id1 {
  35. display: none;
  36. }
  37. #operatouristcommon-start_area_id {
  38. display: none;
  39. }
  40. #tp_end_area_list {
  41. display: none;
  42. }
  43. </style>
  44. <?php $form = ActiveForm::begin([
  45. 'id' => 'msg-form',
  46. 'options' => ['class' => 'form-horizontal', "enctype" => "multipart/form-data"],
  47. 'enableAjaxValidation' => false,
  48. // 'validationUrl' => Url::toRoute(['validate-form','tourist_id'=>]),
  49. 'fieldConfig' => [
  50. 'template' => "<div class=\"form-inline\">{label}<div class=\"form-group\">{input}</div></div>",
  51. 'labelOptions' => ['class' => 'col-lg-1 control-label'],
  52. ],
  53. 'action' => ['/zzcs/tourist/add-tourist-base'],
  54. ]);
  55. ?>
  56. <div style="border-top: 1px solid white; border-bottom: none;">
  57. <legend class="valtype" data-valtype="text">基本信息</legend>
  58. </div>
  59. <div>
  60. <!--产品名称-->
  61. <?= $form->field($model_otc, 'tourist_name', [])->textInput(['class' => 'form-control', 'placeholder' => '产品名称', 'style' => 'width:250px'])->label('<span class="label-color">*</span>产品名称:'); ?>
  62. <!--内部编号-->
  63. <?= $form->field($model_otc, 'tourist_code', [])->textInput(['class' => 'form-control', 'placeholder' => '内部编号', 'style' => 'width:250px'])->label('<span class="label-color">*</span>内部编号:'); ?>
  64. <!--携程产品id-->
  65. <?= $form->field($model_ott, 'ctrip_prod_id', [])->textInput(['class' => 'form-control', 'placeholder' => '携程产品编号', 'style' => 'width:250px'])->label('携程产品编号:'); ?>
  66. <!--行程天数-->
  67. <?php if ($data['op'] != 'modify') { ?>
  68. <?= Html::hiddenInput('OperaTouristCommon[night_num]', -1) ?>
  69. <?= Html::hiddenInput('OperaTouristCommon[day_num]', -1) ?>
  70. <?php } ?>
  71. <!--出发城市-->
  72. <div class="form-inline" style="margin: 10px 0px 15px;">
  73. <div style="display: inline-block">
  74. <?= $form->field($model_otc, 'tp_start_area_id1', ['template' => "{label}<div class=\"form-group\">{input}</div>",])->dropDownList(BaseTourist::getArea(), ['class' => 'select_screen form-control province', 'style' => '', 'placeholder' => '行程天数', 'onchange' => 'changeArea(this)'])->label('<span class="label-color">*</span>出发城市:'); ?>
  75. </div>
  76. <div style="display: inline-block">
  77. <?php \yii\widgets\Pjax::begin(['id' => 'start_city']) ?>
  78. <?= $form->field($model_otc, 'start_area_id', ['template' => "{label}<div class=\"form-group\">{input}</div>",])->dropDownList($data['op'] == 'add' ? $data['area'] : BaseTourist::getArea($model_otc->tp_start_area_id1), ['class' => 'select_screen form-control city', 'placeholder' => '行程天数', 'style' => 'margin-left:10px'])->label(false) ?>
  79. <?php \yii\widgets\Pjax::end() ?>
  80. </div>
  81. </div>
  82. <!--目的地-->
  83. <div class="form-inline" style="margin: 10px 0px 15px;">
  84. <div style="display: inline-block">
  85. <?= $form->field($model_otc, 'tp_end_area_list')->dropDownList(BaseTourist::dealArea(), ['class' => 'select_screen form-control destination', 'placeholder' => '行程天数', 'onchange' => 'addLabel(this)', 'style' => 'width:250px', 'id' => 'tp_end_area_list'])->label('<span class="label-color">*</span>目的地:'); ?>
  86. </div>
  87. </div>
  88. <!--目的地标签-->
  89. <div id="area_label" style="margin-left: 140px;margin-bottom: 20px;margin-top: 20px">
  90. <?php
  91. if ($data['op'] == 'modify') {
  92. $area_id_arr = explode(',', substr($model_otc->end_area_list, 0, -1));
  93. $area_id_name_obj = BaseArea::find()->where(['in', 'ID', $area_id_arr])->all();
  94. foreach ($area_id_name_obj as $k => $v) {
  95. echo '<button type="button" class="btn btn-info" id="' . $v->ID . '" style="margin: 5px" onclick="deleteLabel(this)">' . $v->AREA_NAME . '</button>';
  96. }
  97. }
  98. ?>
  99. </div>
  100. <!--预订日期-->
  101. <div class="form-inline">
  102. <?= $form->field($model_otc, 'pre_days', ['template' => "{label}<div class=\"form-group\">{input}</div>",])->dropDownList(['0' => '请选择', 1 => '1天', 2 => '2天', 3 => '3天', 4 => '4天', 5 => '5天'], ['class' => 'select_screen form-control day', 'placeholder' => '行程天数'])->label('预订截至:'); ?>
  103. <div id="time_id" class="timepicker_box" style="vertical-align: top">
  104. <span class="form-group timepicker">
  105. <input type="text" class="form-control" id="fin_order_time" name="OperaTouristCommon[pre_time]"
  106. value="<?= $model_otc->pre_time == '' ? '00:00' : $model_otc->pre_time ?>"
  107. readonly>
  108. <span class="glyphicon glyphicon-time"></span>
  109. </span>
  110. <div class="timepicker_select">
  111. <div class="select_hour_box"></div>
  112. <div class="select_minute_box"></div>
  113. </div>
  114. </div>
  115. </div>
  116. <!--退款截止日期-->
  117. <div class="form-inline" style="margin-top: 128px;width: 344px;">
  118. <?= $form->field($model_otc, 'refund_limit_day', ['template' => "{label}<div class=\"form-group\">{input}</div>",])->dropDownList(['-1' => '不限', 0=>'0天',1 => '1天', 2 => '2天', 3 => '3天', 4 => '4天', 5 => '5天'], ['class' => 'select_screen form-control day','onchange'=>"refund_time_display()", 'placeholder' => '截止天数'])->label('退款截至:'); ?>
  119. <div id="refund_time_id" class="timepicker_box" style="display: none;vertical-align: top;float: right">
  120. <span class="form-group timepicker">
  121. <input type="text" class="form-control" id="refund_limit_time" name="OperaTouristCommon[refund_limit_time]"
  122. value="<?= $model_otc->refund_limit_time == '' ? '00:00' : $model_otc->refund_limit_time ?>"
  123. readonly>
  124. <span class="glyphicon glyphicon-time"></span>
  125. </span>
  126. <div class="timepicker_select">
  127. <div class="select_hour_box"></div>
  128. <div class="select_minute_box"></div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div style="border-top: 1px solid white; border-bottom: none;margin-top: 60px">
  134. <legend class="valtype" data-valtype="text">更多说明</legend>
  135. </div>
  136. <div>
  137. <?= $form->field($model_ote, 'hint_point', [])->textarea(['class' => 'form-control', 'placeholder' => '产品亮点'])->label('<span class="label-color">*</span>产品亮点:'); ?>
  138. <?= $form->field($model_ote, 'price_explain', [])->textarea(['class' => 'form-control', 'placeholder' => '费用说明'])->label('<span class="label-color">*</span>费用说明:');; ?>
  139. <?= $form->field($model_ote, 'must_read', [])->textarea(['class' => 'form-control', 'placeholder' => '预订须知'])->label('<span class="label-color">*</span>预订须知:');; ?>
  140. <!--短信模板-->
  141. <?= $form->field($model_otc, 'message', [])->textarea(['class' => 'form-control', 'placeholder' => '短信模板', 'style' => 'width:250px'])->label('短信模板:'); ?>
  142. </div>
  143. <div style="border-top: 1px solid white; border-bottom: none;margin-top: 60px">
  144. <legend class="valtype" data-valtype="text">产品图片</legend>
  145. </div>
  146. <div>
  147. <div class="form-inline">
  148. <div class="form-group">
  149. <label class="col-lg-1 control-label">
  150. <span class="label-color">*</span>封面图片:
  151. </label>
  152. <div class="col-lg-1 text-center" style="display: table-cell;padding-left: 0px">
  153. <div class="fileinput fileinput-new" data-provides="fileinput" style="vertical-align: top">
  154. <div class="fileinput-new thumbnail" style="height: 150px; width: 200px">
  155. <img data-trigger="openImage" src="<?php
  156. if ($data['op'] == 'modify') {
  157. $tp_url_arr = explode('.', $model_otc->top_image_url);
  158. if (count($tp_url_arr) > 1)
  159. echo Yii::$app->params['tourist_img_url'] . substr($tp_url_arr[0], '-10') . '.' . $tp_url_arr[1];
  160. }
  161. ?>"/></div>
  162. <div class="fileinput-preview fileinput-exists thumbnail" data-trigger="openDivImage"
  163. style="height: 150px; width: 200px"></div>
  164. <div>
  165. <?php echo $form->field($model_otc, "top_image_url", ['template' => '<span class="btn default btn-file">
  166. <span class="fileinput-new"> 选择图片 </span>
  167. <span class="fileinput-exists"> 重新选择 </span>
  168. {input}</span><a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput">
  169. 重置 </a><div style="display:-webkit-box;height: 30px">{error}</div>'])->fileInput();
  170. ?>
  171. </div>
  172. <?= Html::hiddenInput("OperaTouristCommon[top_image_url]", $model_otc->top_image_url) ?>
  173. <?= Html::hiddenInput("OperaTouristCommon[tourist_id]", $model_otc->tourist_id, ['id' => 'tourist_id']) ?>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="form-inline" id="img_list">
  179. <div class="form-group">
  180. <label class="col-lg-1 control-label">
  181. <span class="label-color">*</span>更多图片:
  182. </label>
  183. <?php foreach ($model_img as $k => $v) { ?>
  184. <div class="col-lg-1 text-center all_img" style="display: table-cell;padding-left: 0px;width: 200px" id="base_img<?= $k == 0 ? '' : $k ?>">
  185. <div class="fileinput fileinput-new" data-provides="fileinput" style="vertical-align: top">
  186. <div class="fileinput-new thumbnail" style="height: 150px; width: 200px">
  187. <img data-trigger="openImage"
  188. src="<?= $data['op'] == 'modify' && $v->image_name != '' ? Yii::$app->params['tourist_img_url'] . $v->image_name : '' ?>"/>
  189. </div>
  190. <div class="fileinput-preview fileinput-exists thumbnail" data-trigger="openDivImage" style="height: 150px; width: 200px"></div>
  191. <div style="text-align: center">
  192. <?php $template="<span class='btn default btn-file'>
  193. <span class='fileinput-new'> 选择图片 </span>
  194. <span class='fileinput-exists'> 重新选择 </span>
  195. {input}</span>
  196. <a href='javascript:;' class='btn red fileinput-new delete_img' onclick='DelImg(this,$v[id])'> 删除图片 </a>
  197. <a href='javascript:;' class='btn red fileinput-exists' data-dismiss='fileinput''>重置 </a>
  198. <a href='javascript:;' class='btn red fileinput-exists delete_img' onclick='DelImg(this,$v[id])'> 删除图片 </a>
  199. <div style='display:-webkit-box;height: 30px'>{error}</div>"?>
  200. <?php echo $form->field($model_img[$k], "[$k]image_url", ['template' => $template])->fileInput();
  201. ?>
  202. </div>
  203. </div>
  204. </div>
  205. <?= $data['op'] == 'modify' ? Html::hiddenInput("OperaTouristImg[$k][image_url_change]", $v->image_url) : '' ?>
  206. <?= $data['op'] == 'modify' ? Html::hiddenInput("OperaTouristImg[$k][image_name]", $v->image_name) : '' ?>
  207. <?php } ?>
  208. </div>
  209. <div class="form-group add_img" style="margin-bottom: 100px">
  210. <div class="col-lg-1 text-center" style="display: table-cell;padding-left: 0px;width: 200px" >
  211. <img src="/resource/img/add_img.png" onclick="addImg()"/>
  212. </div>
  213. </div>
  214. </div>
  215. </div>
  216. <!--提交按钮-->
  217. <div class="form-group" style="margin-left: 400px">
  218. <div class="col-lg-offset-1 col-lg-11">
  219. <?= Html::submitButton('保存', ['class' => 'btn btn-primary', 'name' => 'submit-button']) ?>
  220. <?= Html::button('取消', ['class' => 'btn btn-default']) ?>
  221. </div>
  222. </div>
  223. <?= $form->field($model_otc, 'end_area_list')->hiddenInput(['id' => 'end_area_list'])->label(false) ?>
  224. <?php ActiveForm::end(); ?>
  225. <script>
  226. var base_img = '';
  227. window.onload = function () {
  228. $('.city').comboSelect();
  229. $('.province').comboSelect();
  230. $('.day').comboSelect();
  231. $('.night').comboSelect();
  232. $('.destination').comboSelect();
  233. $('.select_screen').comboSelect();
  234. base_img = '<div class="form-group all_img" style="margin-right: 20px">' + $("#base_img").html() + '</div>';
  235. $(document).on('pjax:success', '#start_city', function () {
  236. $('.city').comboSelect();
  237. });
  238. if($('#operatouristcommon-refund_limit_day').val()!=-1){
  239. $('#refund_time_id').css('display','block')
  240. }
  241. }
  242. function addLabel(obj) {
  243. let value = $(obj).val();
  244. if (value.length > 2) {
  245. let label = '<button type="button" class="btn btn-info" id="[id]" style="margin: 5px" onclick="deleteLabel(this)">[info]</button>';
  246. let repeat_str = $('#end_area_list').val().substring(0, $('#end_area_list').val().length - 1);
  247. let repeat_arr = repeat_str.split(',');
  248. let value_arr = value.split('|');
  249. let label_html = '<button type="button" class="btn btn-info" id="' + value_arr[0].split(',')[0] + '" style="margin: 5px" onclick="deleteLabel(this)">' + value_arr[0].split(',')[1] + '</button>';
  250. let value_id = value_arr[1].substring(1, value_arr[1].length - 1);
  251. let value_id_arr = value_id.split('}{');
  252. let value_name = value_arr[2].substring(1, value_arr[2].length - 1);
  253. let value_name_arr = value_name.split('}{');
  254. for (let i = 0; i < value_id_arr.length; i++) {
  255. if (repeat_arr.indexOf(value_id_arr[i]) < 0) {
  256. let tmp = label;
  257. tmp = tmp.replace('[info]', value_name_arr[i]);
  258. tmp = tmp.replace('[id]', value_id_arr[i]);
  259. label_html += tmp;
  260. }
  261. }
  262. $('#area_label').append(label_html);
  263. //获取值
  264. let fin_end_area_list = '';
  265. $('#area_label').find('button').each(function () {
  266. fin_end_area_list += $(this).attr('id') + ',';
  267. });
  268. $('#end_area_list').val(fin_end_area_list);
  269. }
  270. }
  271. function deleteLabel(obj) {
  272. $(obj).remove();
  273. let fin_end_area_list = '';
  274. $('#area_label').find('button').each(function () {
  275. fin_end_area_list += ',' + $(this).attr('id')
  276. });
  277. $('#end_area_list').val(fin_end_area_list);
  278. }
  279. function addImg() {
  280. let tp_base_img = base_img;
  281. let index = $('#img_list').find('.all_img').length;
  282. tp_base_img = tp_base_img.replace(/\[0\]/g, "[" + index + "]");
  283. $(".add_img").before(tp_base_img);
  284. $('img[data-trigger="openImage"]:last').attr('src','');
  285. $(".add_img").prev().find('.delete_img').attr('onclick','DelImg(this,"new")');
  286. }
  287. function changeArea(obj) {
  288. let area_id = $(obj).val();
  289. $.pjax.reload({
  290. container: '#start_city',
  291. data: {area_id: area_id},
  292. replace: false,
  293. timeout: false,
  294. })
  295. }
  296. function DelImg(obj,id){
  297. $(obj).closest('.fileinput').remove();
  298. if(isNaN(id)){
  299. return false;
  300. }
  301. console.log(id);
  302. $.ajax({
  303. url: '/zzcs/tourist/delete-img',
  304. data: {id: id},
  305. dataType: 'json',
  306. type: 'post',
  307. success: function (res) {
  308. // if (res.code == 0) {
  309. // easyAlert(res.msg, 'success')
  310. // } else {
  311. // easyAlert(res.msg, 'warning')
  312. // }
  313. },
  314. error: function (e) {
  315. easyAlert('请联系管理员', 'error')
  316. }
  317. });
  318. }
  319. function refund_time_display(){
  320. var refund_limit_day = $('#operatouristcommon-refund_limit_day').val();
  321. console.log(refund_limit_day);
  322. if(refund_limit_day == 0||refund_limit_day == 1||refund_limit_day == 2||refund_limit_day == 3||refund_limit_day == 4||refund_limit_day == 5){
  323. $('#refund_time_id').css('display','block')
  324. }else{
  325. $('#refund_time_id').css('display','none')
  326. }
  327. //alert(refund_limit_day)
  328. }
  329. </script>