|
- <?php
- use yii\helpers\Html;
- use yii\bootstrap\ActiveForm;
- use backend\modules\zzcs\logic\BaseTourist;
- use yii\helpers\Url;
- use backend\modules\zzcs\models\BaseArea;
- use kartik\file\FileInput;
-
- ?>
- <style>
- .form-horizontal .control-label {
- padding-top: 0px;
- margin-bottom: 0;
- text-align: right;
- float: left;
- width: 140px;
- }
-
- textarea {
- min-width: 550px;
- min-height: 150px;
- }
-
- .form-horizontal .form-group {
- margin-right: 0px;
- margin-left: 0px;
- }
-
- .combo-select {
- width: 100px;
- }
-
- .label-color {
- color: red;
- }
-
- /*.help-block{*/
- /*display: inherit!important;*/
- /*}*/
- #operatouristcommon-tp_start_area_id1 {
- display: none;
- }
-
- #operatouristcommon-start_area_id {
- display: none;
- }
-
- #tp_end_area_list {
- display: none;
- }
-
- </style>
-
-
- <?php $form = ActiveForm::begin([
- 'id' => 'msg-form',
- 'options' => ['class' => 'form-horizontal', "enctype" => "multipart/form-data"],
- 'enableAjaxValidation' => false,
- // 'validationUrl' => Url::toRoute(['validate-form','tourist_id'=>]),
- 'fieldConfig' => [
- 'template' => "<div class=\"form-inline\">{label}<div class=\"form-group\">{input}</div></div>",
- 'labelOptions' => ['class' => 'col-lg-1 control-label'],
- ],
- 'action' => ['/zzcs/tourist/add-tourist-base'],
- ]);
-
- ?>
- <div style="border-top: 1px solid white; border-bottom: none;">
- <legend class="valtype" data-valtype="text">基本信息</legend>
- </div>
- <div>
- <!--产品名称-->
- <?= $form->field($model_otc, 'tourist_name', [])->textInput(['class' => 'form-control', 'placeholder' => '产品名称', 'style' => 'width:250px'])->label('<span class="label-color">*</span>产品名称:'); ?>
- <!--内部编号-->
- <?= $form->field($model_otc, 'tourist_code', [])->textInput(['class' => 'form-control', 'placeholder' => '内部编号', 'style' => 'width:250px'])->label('<span class="label-color">*</span>内部编号:'); ?>
- <!--携程产品id-->
- <?= $form->field($model_ott, 'ctrip_prod_id', [])->textInput(['class' => 'form-control', 'placeholder' => '携程产品编号', 'style' => 'width:250px'])->label('携程产品编号:'); ?>
- <!--行程天数-->
- <?php if ($data['op'] != 'modify') { ?>
- <?= Html::hiddenInput('OperaTouristCommon[night_num]', -1) ?>
- <?= Html::hiddenInput('OperaTouristCommon[day_num]', -1) ?>
- <?php } ?>
- <!--出发城市-->
- <div class="form-inline" style="margin: 10px 0px 15px;">
- <div style="display: inline-block">
- <?= $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>出发城市:'); ?>
- </div>
-
- <div style="display: inline-block">
- <?php \yii\widgets\Pjax::begin(['id' => 'start_city']) ?>
- <?= $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) ?>
- <?php \yii\widgets\Pjax::end() ?>
- </div>
-
- </div>
- <!--目的地-->
- <div class="form-inline" style="margin: 10px 0px 15px;">
- <div style="display: inline-block">
- <?= $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>目的地:'); ?>
- </div>
- </div>
- <!--目的地标签-->
- <div id="area_label" style="margin-left: 140px;margin-bottom: 20px;margin-top: 20px">
- <?php
- if ($data['op'] == 'modify') {
- $area_id_arr = explode(',', substr($model_otc->end_area_list, 0, -1));
- $area_id_name_obj = BaseArea::find()->where(['in', 'ID', $area_id_arr])->all();
- foreach ($area_id_name_obj as $k => $v) {
- echo '<button type="button" class="btn btn-info" id="' . $v->ID . '" style="margin: 5px" onclick="deleteLabel(this)">' . $v->AREA_NAME . '</button>';
- }
- }
- ?>
-
- </div>
-
- <!--预订日期-->
- <div class="form-inline">
-
- <?= $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('预订截至:'); ?>
-
-
- <div id="time_id" class="timepicker_box" style="vertical-align: top">
- <span class="form-group timepicker">
- <input type="text" class="form-control" id="fin_order_time" name="OperaTouristCommon[pre_time]"
- value="<?= $model_otc->pre_time == '' ? '00:00' : $model_otc->pre_time ?>"
- readonly>
- <span class="glyphicon glyphicon-time"></span>
- </span>
- <div class="timepicker_select">
- <div class="select_hour_box"></div>
- <div class="select_minute_box"></div>
- </div>
- </div>
- </div>
-
- <!--退款截止日期-->
- <div class="form-inline" style="margin-top: 128px;width: 344px;">
-
- <?= $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('退款截至:'); ?>
-
- <div id="refund_time_id" class="timepicker_box" style="display: none;vertical-align: top;float: right">
- <span class="form-group timepicker">
- <input type="text" class="form-control" id="refund_limit_time" name="OperaTouristCommon[refund_limit_time]"
- value="<?= $model_otc->refund_limit_time == '' ? '00:00' : $model_otc->refund_limit_time ?>"
- readonly>
- <span class="glyphicon glyphicon-time"></span>
- </span>
- <div class="timepicker_select">
- <div class="select_hour_box"></div>
- <div class="select_minute_box"></div>
- </div>
- </div>
- </div>
-
- </div>
-
- <div style="border-top: 1px solid white; border-bottom: none;margin-top: 60px">
- <legend class="valtype" data-valtype="text">更多说明</legend>
- </div>
- <div>
- <?= $form->field($model_ote, 'hint_point', [])->textarea(['class' => 'form-control', 'placeholder' => '产品亮点'])->label('<span class="label-color">*</span>产品亮点:'); ?>
-
- <?= $form->field($model_ote, 'price_explain', [])->textarea(['class' => 'form-control', 'placeholder' => '费用说明'])->label('<span class="label-color">*</span>费用说明:');; ?>
-
- <?= $form->field($model_ote, 'must_read', [])->textarea(['class' => 'form-control', 'placeholder' => '预订须知'])->label('<span class="label-color">*</span>预订须知:');; ?>
-
- <!--短信模板-->
- <?= $form->field($model_otc, 'message', [])->textarea(['class' => 'form-control', 'placeholder' => '短信模板', 'style' => 'width:250px'])->label('短信模板:'); ?>
-
- </div>
-
- <div style="border-top: 1px solid white; border-bottom: none;margin-top: 60px">
- <legend class="valtype" data-valtype="text">产品图片</legend>
- </div>
- <div>
- <div class="form-inline">
- <div class="form-group">
- <label class="col-lg-1 control-label">
- <span class="label-color">*</span>封面图片:
- </label>
- <div class="col-lg-1 text-center" style="display: table-cell;padding-left: 0px">
- <div class="fileinput fileinput-new" data-provides="fileinput" style="vertical-align: top">
- <div class="fileinput-new thumbnail" style="height: 150px; width: 200px">
-
- <img data-trigger="openImage" src="<?php
- if ($data['op'] == 'modify') {
- $tp_url_arr = explode('.', $model_otc->top_image_url);
- if (count($tp_url_arr) > 1)
- echo Yii::$app->params['tourist_img_url'] . substr($tp_url_arr[0], '-10') . '.' . $tp_url_arr[1];
- }
-
- ?>"/></div>
- <div class="fileinput-preview fileinput-exists thumbnail" data-trigger="openDivImage"
- style="height: 150px; width: 200px"></div>
- <div>
- <?php echo $form->field($model_otc, "top_image_url", ['template' => '<span class="btn default btn-file">
- <span class="fileinput-new"> 选择图片 </span>
- <span class="fileinput-exists"> 重新选择 </span>
- {input}</span><a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput">
- 重置 </a><div style="display:-webkit-box;height: 30px">{error}</div>'])->fileInput();
- ?>
- </div>
- <?= Html::hiddenInput("OperaTouristCommon[top_image_url]", $model_otc->top_image_url) ?>
- <?= Html::hiddenInput("OperaTouristCommon[tourist_id]", $model_otc->tourist_id, ['id' => 'tourist_id']) ?>
- </div>
- </div>
- </div>
- </div>
-
- <div class="form-inline" id="img_list">
- <div class="form-group">
- <label class="col-lg-1 control-label">
- <span class="label-color">*</span>更多图片:
- </label>
- <?php foreach ($model_img as $k => $v) { ?>
- <div class="col-lg-1 text-center all_img" style="display: table-cell;padding-left: 0px;width: 200px" id="base_img<?= $k == 0 ? '' : $k ?>">
- <div class="fileinput fileinput-new" data-provides="fileinput" style="vertical-align: top">
- <div class="fileinput-new thumbnail" style="height: 150px; width: 200px">
- <img data-trigger="openImage"
- src="<?= $data['op'] == 'modify' && $v->image_name != '' ? Yii::$app->params['tourist_img_url'] . $v->image_name : '' ?>"/>
- </div>
- <div class="fileinput-preview fileinput-exists thumbnail" data-trigger="openDivImage" style="height: 150px; width: 200px"></div>
- <div style="text-align: center">
- <?php $template="<span class='btn default btn-file'>
- <span class='fileinput-new'> 选择图片 </span>
- <span class='fileinput-exists'> 重新选择 </span>
- {input}</span>
- <a href='javascript:;' class='btn red fileinput-new delete_img' onclick='DelImg(this,$v[id])'> 删除图片 </a>
- <a href='javascript:;' class='btn red fileinput-exists' data-dismiss='fileinput''>重置 </a>
- <a href='javascript:;' class='btn red fileinput-exists delete_img' onclick='DelImg(this,$v[id])'> 删除图片 </a>
- <div style='display:-webkit-box;height: 30px'>{error}</div>"?>
- <?php echo $form->field($model_img[$k], "[$k]image_url", ['template' => $template])->fileInput();
- ?>
- </div>
-
- </div>
- </div>
- <?= $data['op'] == 'modify' ? Html::hiddenInput("OperaTouristImg[$k][image_url_change]", $v->image_url) : '' ?>
- <?= $data['op'] == 'modify' ? Html::hiddenInput("OperaTouristImg[$k][image_name]", $v->image_name) : '' ?>
- <?php } ?>
- </div>
- <div class="form-group add_img" style="margin-bottom: 100px">
- <div class="col-lg-1 text-center" style="display: table-cell;padding-left: 0px;width: 200px" >
- <img src="/resource/img/add_img.png" onclick="addImg()"/>
- </div>
- </div>
- </div>
- </div>
-
-
- <!--提交按钮-->
-
- <div class="form-group" style="margin-left: 400px">
- <div class="col-lg-offset-1 col-lg-11">
- <?= Html::submitButton('保存', ['class' => 'btn btn-primary', 'name' => 'submit-button']) ?>
-
- <?= Html::button('取消', ['class' => 'btn btn-default']) ?>
- </div>
- </div>
- <?= $form->field($model_otc, 'end_area_list')->hiddenInput(['id' => 'end_area_list'])->label(false) ?>
- <?php ActiveForm::end(); ?>
-
-
- <script>
- var base_img = '';
- window.onload = function () {
- $('.city').comboSelect();
- $('.province').comboSelect();
- $('.day').comboSelect();
- $('.night').comboSelect();
- $('.destination').comboSelect();
- $('.select_screen').comboSelect();
- base_img = '<div class="form-group all_img" style="margin-right: 20px">' + $("#base_img").html() + '</div>';
- $(document).on('pjax:success', '#start_city', function () {
- $('.city').comboSelect();
- });
- if($('#operatouristcommon-refund_limit_day').val()!=-1){
- $('#refund_time_id').css('display','block')
- }
- }
- function addLabel(obj) {
- let value = $(obj).val();
- if (value.length > 2) {
- let label = '<button type="button" class="btn btn-info" id="[id]" style="margin: 5px" onclick="deleteLabel(this)">[info]</button>';
- let repeat_str = $('#end_area_list').val().substring(0, $('#end_area_list').val().length - 1);
- let repeat_arr = repeat_str.split(',');
- let value_arr = value.split('|');
- 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>';
- let value_id = value_arr[1].substring(1, value_arr[1].length - 1);
- let value_id_arr = value_id.split('}{');
- let value_name = value_arr[2].substring(1, value_arr[2].length - 1);
- let value_name_arr = value_name.split('}{');
- for (let i = 0; i < value_id_arr.length; i++) {
- if (repeat_arr.indexOf(value_id_arr[i]) < 0) {
- let tmp = label;
- tmp = tmp.replace('[info]', value_name_arr[i]);
- tmp = tmp.replace('[id]', value_id_arr[i]);
- label_html += tmp;
- }
- }
- $('#area_label').append(label_html);
- //获取值
- let fin_end_area_list = '';
- $('#area_label').find('button').each(function () {
- fin_end_area_list += $(this).attr('id') + ',';
- });
- $('#end_area_list').val(fin_end_area_list);
- }
- }
- function deleteLabel(obj) {
- $(obj).remove();
- let fin_end_area_list = '';
- $('#area_label').find('button').each(function () {
- fin_end_area_list += ',' + $(this).attr('id')
- });
- $('#end_area_list').val(fin_end_area_list);
- }
- function addImg() {
- let tp_base_img = base_img;
- let index = $('#img_list').find('.all_img').length;
- tp_base_img = tp_base_img.replace(/\[0\]/g, "[" + index + "]");
- $(".add_img").before(tp_base_img);
- $('img[data-trigger="openImage"]:last').attr('src','');
- $(".add_img").prev().find('.delete_img').attr('onclick','DelImg(this,"new")');
- }
- function changeArea(obj) {
- let area_id = $(obj).val();
- $.pjax.reload({
- container: '#start_city',
- data: {area_id: area_id},
- replace: false,
- timeout: false,
- })
- }
- function DelImg(obj,id){
- $(obj).closest('.fileinput').remove();
- if(isNaN(id)){
- return false;
- }
- console.log(id);
- $.ajax({
- url: '/zzcs/tourist/delete-img',
- data: {id: id},
- dataType: 'json',
- type: 'post',
- success: function (res) {
- // if (res.code == 0) {
- // easyAlert(res.msg, 'success')
- // } else {
- // easyAlert(res.msg, 'warning')
- // }
- },
- error: function (e) {
- easyAlert('请联系管理员', 'error')
- }
- });
- }
-
- function refund_time_display(){
- var refund_limit_day = $('#operatouristcommon-refund_limit_day').val();
- console.log(refund_limit_day);
- 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){
- $('#refund_time_id').css('display','block')
- }else{
- $('#refund_time_id').css('display','none')
- }
- //alert(refund_limit_day)
- }
- </script>
-
-
-
|