代码语言:javascript复制
<?php
use commonmodelsOrder;
use imxiangliselect2Select2Widget;
use yiihelpersHtml;
use yiihelpersUrl;
use yiiwebJsExpression;
$this->title = '订单管理';
$this->params['breadcrumbs'] = [$this->title];
/** @var yiidataDataProviderInterface $dataProvider */
/** @var commonmodelsOrder[] $models */
/** @var backendmodelsOrderSearch $searchModel */
$models = $dataProvider->getModels();
$pagination = $dataProvider->getPagination();
$virtualOrderModel = new commonmodelsVirtualOrder();
?>
<div class="row">
<div class="col-lg-12">
<div class="tabs-container">
<?= $this->render('nav-tabs') ;?>
</div>
<div class="tab-content">
<div class="ibox">
<div class="ibox-content page-select2-area">
<?php
$categoryUrl = yiihelpersUrl::to(['product-category/ajax-list', 'parent_id' => '__parent_id__']);
$cityUrl = yiihelpersUrl::to(['region/ajax-cities', 'province_id' => '__province_id__']);
$districtUrl = yiihelpersUrl::to(['region/ajax-districts', 'city_id' => '__city_id__']);
$labelOptions = ['labelOptions' => ['class' => false]];
$form = yiibootstrapActiveForm::begin([
'action' => ['list'],
'layout' => 'inline',
'method' => 'get',
]); ?>
<?= $form->field($searchModel, 'top_category_id', $labelOptions)->widget(Select2Widget::className(), [
'serverUrl' => yiihelpersUrl::to(['product-category/ajax-list']),
'itemsName' => 'categories',
'selectedItem' => $searchModel->topCategory ? [$searchModel->topCategory->id => $searchModel->topCategory->name] : [],
'options' => ['prompt'=>'选择类目', 'class' => 'form-control'],
'placeholderId' => '0',
'placeholder' => '选择类目',
'eventSelect' => new JsExpression("
$('#category_id').val('0').trigger('change');
")
])?>
<?= $form->field($searchModel, 'category_id')->widget(Select2Widget::className(), [
'serverUrl' => yiihelpersUrl::to(['product-category/ajax-list']),
'itemsName' => 'categories',
'selectedItem' => $searchModel->category ? [$searchModel->category->id => $searchModel->category->name] : [],
'options' => ['prompt'=>'选择类目', 'class' => 'form-control'],
'placeholderId' => '0',
'placeholder' => '选择类目',
'eventOpening' => new JsExpression("
var id = $('#top_category_id').val();
serverUrl = '{$categoryUrl}'.replace('__parent_id__', id ? id : '-1');
")
])?>
<?= $form->field($searchModel, 'province_id', $labelOptions)->widget(Select2Widget::className(), [
'serverUrl' => yiihelpersUrl::to(['region/ajax-provinces']),
'itemsName' => 'provinces',
'selectedItem' => $searchModel->province ? [$searchModel->province->id => $searchModel->province->province_name] : [],
'options' => ['class' => 'form-control', 'prompt'=>'请选择省份'],
'placeholderId' => '0',
'placeholder' => '请选择省份',
'eventSelect' => new JsExpression("
$('#city_id').val('0').trigger('change');
$('#district_id').val('0').trigger('change');
")
]); ?>
<?= $form->field($searchModel, 'city_id')->widget(Select2Widget::className(), [
'serverUrl' => yiihelpersUrl::to(['region/ajax-cities', 'province_id' => '__province_id__']),
'itemsName' => 'cities',
'selectedItem' => $searchModel->city ? [$searchModel->city->id => $searchModel->city->name] : [],
'options' => ['class' => 'form-control', 'prompt'=>'请选择城市'],
'placeholderId' => '0',
'placeholder' => '请选择城市',
'eventSelect' => new JsExpression("
$('#district_id').val('0').trigger('change');
"),
'eventOpening' => new JsExpression("
var id = $('#province_id').val();
serverUrl = '{$cityUrl}'.replace('__province_id__', id ? id : '-1');
")
]); ?>
<?= $form->field($searchModel, 'district_id')->widget(Select2Widget::className(), [
'serverUrl' => yiihelpersUrl::to(['region/ajax-districts', 'city_id' => '__city_id__']),
'selectedItem' => $searchModel->district ? [$searchModel->district->id => $searchModel->district->name] : [],
'options' => ['class' => 'form-control', 'prompt'=>'请选择地区'],
'placeholderId' => '0',
'placeholder' => '请选择地区',
'itemsName' => 'districts',
'eventOpening' => new JsExpression("
var id = $('#city_id').val();
serverUrl = '{$districtUrl}'.replace('__city_id__', id ? id : '-1');
")
]); ?>
<?= $form->field($searchModel, 'type', $labelOptions)->widget(Select2Widget::className(), [
'selectedItem' => backendmodelsOrderSearch::getTypes(),
'placeholderId' => '0',
'placeholder' => '请选择类型',
'options' => ['class' => 'form-control', 'prompt'=>'请选择类型'],
'static' => true,
]) ?>
<?= $form->field($searchModel, 'keyword', $labelOptions)->textInput() ?>
<?= Html::activeHiddenInput($searchModel,'status',array('value'=>$status)) ?>
<button type="submit" class="btn btn-default">搜索</button>
<?php yiibootstrapActiveForm::end(); ?>
</div>
<div class="ibox-content">
<div class="table-responsive">
<table class="footable table table-striped">
<thead>
<tr>
<th>下单时间</th>
<th>订单号</th>
<th>客户姓名/联系方式</th>
<th>公司名称</th>
<th>所购商品</th>
<th>地区</th>
<th>业务人员</th>
<th>嘟嘟妹</th>
<th>客服</th>
<th>服务人员</th>
<th>订单金额</th>
<th>订单状态</th>
<th class="text-right" data-sort-ignore="true">操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($models as $model): ?>
<tr>
<td><?= Yii::$app->formatter->asDatetime($model->created_at);?></td>
<td><?= $model->sn; ?></td>
<td><?= $model->user->name;?>/<?= $model->user->phone;?></td>
<td><?= $model->company_name ;?></td>
<td><?= $model->product_name ;?></td>
<td><?= $model->province_name ;?>-<?= $model->city_name ;?>-<?= $model->district_name ;?></td>
<td><?= $model->creator_name ;?></td>
<td><?= $model->supervisor_name;?></td>
<td>
<?= $model->customer_service_name ;?>
<?php if($model->status == Order::STATUS_PENDING_PAY || $model->status == Order::STATUS_PENDING_ALLOT || $model->status == Order::STATUS_PENDING_SERVICE || $model->status == Order::STATUS_IN_SERVICE): ?>
<!--不同的状态下的客服状态-->
<button class="btn btn-xs btn-primary customer_service-btn" data-target="#customer-service-modal"
data-toggle="modal" data-id="<?= $model->id ?>">修改
</button>
<?php endif; ?>
</td>
<td>
<?= $model->clerk_name ;?>
<?php if($model->status == Order::STATUS_PENDING_SERVICE || $model->status == Order::STATUS_IN_SERVICE): ?>
<!--不同的状态下的服务人员状态-->
<button class="btn btn-xs btn-primary clerk-btn" data-target="#clerk-modal"
data-toggle="modal" data-id="<?= $model->id ?>" data-product-id="<?= $model->product_id ?>" data-district-id="<?= $model->district_id ?>">修改
</button>
<?php endif; ?>
</td>
<td><?= $model->price ;?></td>
<!--todo 获取虚拟订单的数据,暂时存放,待优化-->
<?php $virtualModel = $virtualOrderModel->find()->where(['id'=> $model->virtual_order_id])->one();?>
<!--以下是订单状态-->
<td class="status">
<?php if($model->isRefund() && $model->refund_status == Order::REFUND_STATUS_APPLY): ?>
<!--退款中的状态-->
<div>退款原因:<?= backendmodelsRefundOrderForm::getRefundReasonList()[$model->refund_reason] ;?></div>
<div>退款金额:<?= $model->refund_amount ;?></div>
<?php elseif($model->status == Order::STATUS_PENDING_PAY && $virtualModel->status == 2): ?>
<!--todo 获取虚拟订单的数据,暂时存放,待优化-->
<!--todo 未付清,待联表,虚拟订单表,数据需要在模型操作完毕传递过来,暂时为了调试-->
<div>未付清</div>
<div>已付金额:<?= $virtualModel->payment_amount ;?></div>
<div>未付金额:<?= bcsub($virtualModel->total_amount, $virtualModel->payment_amount);?></div>
<?php elseif($model->status == Order::STATUS_IN_SERVICE): ?>
<!--todo 服务中的状态调取当前流程节点的后台提示内容标题-->
调取当前流程节点的后台提示内容标题
<?php elseif($model->status == Order::STATUS_BREAK_SERVICE): ?>
已取消
<?php else: ?>
<?= $model->getStatusName(); ?>
<?php endif; ?>
</td>
<!--以下是操作部分-->
<td class="text-right">
<?php if($model->isRefund()): ?>
<!--退款中的操作-->
<?php if($model->refund_status == Order::REFUND_STATUS_APPLY):?>
<button id="add-flow-node" class="btn btn-xs btn-primary refund-btn" data-target="#refund-order-modal"
data-toggle="modal" data-id="<?= $model->id ?>">审核
</button>
<?php elseif($model->refund_status == Order::REFUND_STATUS_AUDITED): ?>
<button class="btn btn-xs btn-primary" data-target="#refund-modal"
data-toggle="modal" data-id="<?= $model->id ?>">确认退款
</button>
<?php endif ?>
<a href="<?= Url::to(['info', 'id' => $model->id])?>" class="btn btn-xs btn-primary">查看详情</a>
<?php elseif($model->status == Order::STATUS_PENDING_ALLOT && !$model->clerk_id): ?>
<button class="btn btn-xs btn-primary clerk-allot-btn" data-target="#clerk-modal"
data-toggle="modal" data-id="<?= $model->id ?>">派单
</button>
<button class="btn btn-xs btn-primary" data-target="#refund-modal"
data-toggle="modal" data-id="<?= $model->id ?>">退款
</button>
<button class="btn btn-xs btn-primary cancel-order-btn" data-target="#cancel-order-modal"
data-toggle="modal" data-id="<?= $model->id ?>">取消订单
</button>
<?php elseif($model->status == Order::STATUS_PENDING_SERVICE): ?>
<button class="btn btn-xs btn-primary start-service-btn" data-target="#order-start-service-modal"
data-toggle="modal" data-id="<?= $model->id ?>">开始服务
</button>
<button class="btn btn-xs btn-primary" data-target="#refund-modal"
data-toggle="modal" data-id="<?= $model->id ?>">退款
</button>
<?php elseif($model->status == Order::STATUS_IN_SERVICE): ?>
<a href="<?= Url::to(['info', 'id' => $model->id])?>" class="btn btn-xs btn-primary">查看详情</a>
<button class="btn btn-xs btn-primary refund" data-target="#refund-modal"
data-toggle="modal" data-id="<?= $model->id ?>">退款
</button>
<?php elseif($model->status == Order::STATUS_COMPLETE_SERVICE || $model->status == Order::STATUS_BREAK_SERVICE): ?>
<a href="<?= Url::to(['info', 'id' => $model->id])?>" class="btn btn-xs btn-primary">查看详情</a>
<?php else: ?>
<span class="btn btn-xs btn-primary see-district-price-detail" data-target="#district-price-detail-add-modal" data-toggle="modal" data-id="<?= $model->id ?>">跟进记录</span>
<!-- <span class="btn btn-xs btn-link btn-primary order-follow-record" data-target="#order-follow-record-modal" data-toggle="modal" data-id="">跟进记录</span>-->
<button class="btn btn-xs btn-primary sure-payment-btn" data-target="#payment-modal"
data-toggle="modal" data-id="<?= $model->id ?>">确认付款
</button>
<button class="btn btn-xs btn-primary cancel-order-btn" data-target="#cancel-order-modal"
data-toggle="modal" data-id="<?= $model->id ?>">取消订单
</button>
<?php if($model->status == Order::STATUS_PENDING_PAY): ?>
<div class="text-left">下次跟进时间:</div>
<?php endif; ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<td colspan="6">
<?=
yiiwidgetsLinkPager::widget([
'pagination' => $pagination,
'options' => [
'class' => 'pagination pull-right'
],
]);
?>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!--确认付款弹框-->
<div class="modal fade" id="up-down-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">确认付款</h4>
</div>
<div class="modal-body">
确定付款了吗?
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default cancel-btn" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary sure-btn">确定</button>
</div>
</div>
</div>
</div>
<!--审核弹框start-->
<div class="modal fade" id="refund-order-modal" tabindex="-1" role="dialog" aria-labelledby="modal-title">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title">退款审核</h4>
</div>
<div class="modal-body input_box">
<?php
$refundOrderForm = new backendmodelsRefundOrderForm();
$form = yiibootstrapActiveForm::begin([
'action' => ['order/ajax-refund-order', 'order_id' => '__order_id__'],
'id' => 'refund-order-form',
'layout' => 'horizontal',
'fieldConfig' => [
'horizontalCssClasses' => [
'label' => 'col-sm-3',
'offset' => 'col-sm-offset-3',
'wrapper' => 'col-sm-8',
],
],
]);
?>
<?= $form->field($refundOrderForm, 'refund_reason')->dropDownList($refundOrderForm->getRefundReasonList()) ?>
<?= $form->field($refundOrderForm, 'refund_amount')->textInput() ?>
<?= $form->field($refundOrderForm, 'is_cancel')->checkbox() ?>
<?= $form->field($refundOrderForm, 'refund_explain')->textarea(['maxlength'=>80]) ?>
<?= $form->field($refundOrderForm, 'refund_remark')->textarea(['maxlength'=>80]) ?>
<?php yiibootstrapActiveForm::end(); ?>
<?php
$categoryUrl = yiihelpersUrl::to(['product-category/ajax-list', 'parent_id' => '__parent_id__']);
$cityUrl = yiihelpersUrl::to(['region/ajax-cities', 'province_id' => '__province_id__']);
$districtUrl = yiihelpersUrl::to(['region/ajax-districts', 'city_id' => '__city_id__']);
$labelOptions = ['labelOptions' => ['class' => false]];
$form = yiibootstrapActiveForm::begin([
'action' => ['list'],
'layout' => 'inline',
'method' => 'get',
]); ?>
<?= $form->field($searchModel, 'top_category_id', $labelOptions)->widget(Select2Widget::className(), [
'serverUrl' => yiihelpersUrl::to(['product-category/ajax-list']),
'itemsName' => 'categories',
'selectedItem' => $searchModel->topCategory ? [$searchModel->topCategory->id => $searchModel->topCategory->name] : [],
'options' => ['prompt'=>'选择类目', 'class' => 'form-control', 'id' => 'q121kj1k2jk1j2k1'],
'placeholderId' => '0',
'placeholder' => '选择类目',
'eventSelect' => new JsExpression("
$('#category_id').val('0').trigger('change');
")
])?>
<?= $form->field($searchModel, 'keyword', $labelOptions)->textInput() ?>
<?= Html::activeHiddenInput($searchModel,'status',array('value'=>$status)) ?>
<button type="submit" class="btn btn-default">搜索</button>
<?php yiibootstrapActiveForm::end(); ?>
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary refund-sure-btn">保存</button>
</div>
</div>
</div>
</div>
<!--审核弹框end-->
<!--修改客服start-->
<div class="modal fade" id="customer-service-modal" tabindex="-1" role="dialog" aria-labelledby="modal-title">
<?php
$changeOrderCustomerServiceForm = new backendmodelsChangeOrderCustomerServiceForm();
$form = yiibootstrapActiveForm::begin([
'action' => ['order/change-customer-service', 'order_id' => '__order_id__'],
'id' => 'customer-service-form',
'layout' => 'horizontal',
'fieldConfig' => [
'horizontalCssClasses' => [
'label' => 'col-sm-3',
'offset' => 'col-sm-offset-3',
'wrapper' => 'col-sm-8',
],
],
]);
?>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title">修改客服</h4>
</div>
<div class="modal-body input_box customer-service-div">
<div class="ibox-content change-customer-service-table">
<div class="table-responsive">
<table class="footable table table-striped ">
<thead>
<tr>
<th>选择</th>
<th>姓名</th>
<th>手机号</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary customer_service-sure-btn">保存</button>
</div>
</div>
</div>
<?php yiibootstrapActiveForm::end(); ?>
</div>
<!--修改客服end-->
<!--修改服务人员start-->
<div class="modal fade" id="clerk-modal" tabindex="-1" role="dialog" aria-labelledby="modal-title">
<?php
$changeOrderClerkForm = new backendmodelsChangeOrderClerkForm();
$form = yiibootstrapActiveForm::begin([
'action' => ['order/change-clerk', 'order_id' => '__order_id__'],
'id' => 'clerk-form',
'layout' => 'horizontal',
'fieldConfig' => [
'horizontalCssClasses' => [
'label' => 'col-sm-3',
'offset' => 'col-sm-offset-3',
'wrapper' => 'col-sm-8',
],
],
]);
?>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title">派单给服务人员</h4>
</div>
<div class="modal-body input_box clerk-div">
<div class="ibox-content change-clerk-table">
<div class="table-responsive">
<table class="footable table table-striped ">
<thead>
<tr>
<th>选择</th>
<th>姓名</th>
<th>手机号</th>
<th>地区</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary clerk-sure-btn">保存</button>
</div>
</div>
</div>
<?php yiibootstrapActiveForm::end(); ?>
</div>
<!--修改服务人员end-->
<!--开始服务start-->
<div class="modal fade" id="order-start-service-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">开始服务</h4>
</div>
<div class="modal-body">
确定正式开始服务吗?
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default cancel-btn" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary sure-btn">确定</button>
</div>
</div>
</div>
</div>
<!--开始服务end-->
<!--确认付款start-->
<div class="modal fade" id="payment-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">确认付款</h4>
</div>
<div class="modal-body">
确定该笔订单款项已支付吗?
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default cancel-btn" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary sure-btn">确定</button>
</div>
</div>
</div>
</div>
<!--确认付款end-->
<!--取消订单start-->
<div class="modal fade" id="cancel-order-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">取消订单</h4>
</div>
<div class="modal-body">
确定取消订单吗?
</div>
<div class="modal-footer">
<span class="text-danger warning-active"></span>
<button type="button" class="btn btn-default cancel-btn" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary sure-btn">确定</button>
</div>
</div>
</div>
</div>
<!--取消订单end-->
<!--跟进记录start-->
<div class="modal fade" data-id="" id="district-price-detail-add-modal" role="dialog" aria-labelledby="modal-title">
<div class="modal-dialog" role="document">
<div class="modal-content">
<?php
// $priceDetailForm = new backendmodelsPriceDetailForm();
$followRecordForm = new backendmodelsFollowRecordForm();
$form = yiibootstrapActiveForm::begin([
'action' => ['order/ajax-save-follow-record', 'order_id' => '__order_id__'],
'validationUrl' => ['product/validation-price-detail'],
'enableAjaxValidation' => true,
'id' => 'district-price-detail-form',
'layout' => 'horizontal',
'fieldConfig' => [
'horizontalCssClasses' => [
'label' => 'col-sm-2',
'offset' => 'col-sm-offset-2',
'wrapper' => 'col-sm-8',
'hint' => 'col-sm-offset-2 col-sm-8',
],
],
]); ?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title">跟进记录</h4>
</div>
<div class="modal-body input_box">
<p id="delete-district-price-detail-hint">确定删除吗?</p>
<table class="table table-bordered table-hover district-price-detail-list">
<thead><tr><th>跟进时间</th><th>跟进状态</th><th>备注信息</th></tr></thead>
<tbody></tbody>
<tfoot><tr><td colspan="6"><span class="btn btn-default district-price-detail-add">添加跟进记录</span></td></tr></tfoot>
</table>
<div class="district-price-add-form">
<?= $form->field($followRecordForm, 'is_follow')->checkbox() ?>
<?= $form->field($followRecordForm, 'follow_time')->textInput() ?>
<?= $form->field($followRecordForm, 'follow_remark')->textarea(['maxlength'=>80]) ?>
</div>
</div>
<div class="modal-footer">
<div class="save-btn-detail-price" style="display: none;">
<button type="button" class="btn btn-default cancel-add-district-price">取消跟进</button>
<button type="submit" class="btn btn-primary" id="confirm-district-price-add">确定跟进</button>
</div>
<div class="delete-btn-detail-price" style="display: none;">
<button type="button" class="btn btn-default cancel-delete-district-price">取消</button>
<button type="button" class="btn btn-primary" id="confirm-district-price-delete">确定</button>
</div>
</div>
<?php yiibootstrapActiveForm::end(); ?>
</div>
</div>
</div>
<!--跟进记录end-->
<?php
$changeCustomerServiceTemplate = '<tr><td><input name="customer_service_id" type="radio" value="{id}" /></td><td>{name}</td><td>{phone}</td></tr>';
$changeClerkTemplate = '<tr><td><input name="clerk_id" type="radio" value="{id}" /></td><td>{name}</td><td>{phone}</td><td>{area}</td></tr>';
$ajaxRefundInfoUrl = yiihelpersUrl::to(['ajax-refund-info', 'id' => '__id__']);
$ajaxChangeCustomerServiceInfoUrl = yiihelpersUrl::to(['ajax-change-customer-service-info']);
$ajaxClerkListUrl = yiihelpersUrl::to(['clerk/ajax-list']);
$startServiceUrl = Url::to(['order/ajax-start-service']);
$paymentUrl = Url::to(['order/ajax-payment']);
$cancelOrderUrl = Url::to(['order/ajax-cancel-order']);
$districtPriceTemplate = '';
$this->registerJs(<<<JS
$.fn.modal.Constructor.prototype.enforceFocus = function () { };
//审核通过
$('.refund-btn').click(function(){
var id = $(this).attr('data-id');
var form = $('#refund-order-form');
form.attr('action', form.attr('action').replace('__order_id__', id));
$.get('{$ajaxRefundInfoUrl}'.replace('__id__', id),function(rs){
if(rs.status==200){
//默认为订单金额
$('#refundorderform-refund_amount').val(rs.model.price);
$('#refundorderform-refund_reason').val(rs.model.refund_reason);
$('#refundorderform-is_cancel').val(rs.model.is_cancel);
$('#refundorderform-refund_explain').val(rs.model.refund_explain);
$('#refundorderform-refund_remark').val(rs.model.refund_remark);
}
},'json');
});
//修改客服
$('.customer_service-btn').click(function(){
var changeCustomerServiceTemplate = '{$changeCustomerServiceTemplate}';
var id = $(this).attr('data-id');
var form = $('#customer-service-form');
$('.customer_service-btn').unbind('click');
form.attr('action', form.attr('action').replace('__order_id__', id));
$.post('{$ajaxChangeCustomerServiceInfoUrl}',function(rs){
if(rs.status==200){
for(var i = 0;i < rs.model.length; i ) {
var item = changeCustomerServiceTemplate.replace('{id}', rs.model[i].id).replace('{phone}', rs.model[i].phone).replace('{name}', rs.model[i].name);
$('.change-customer-service-table table tbody').append(item);
}
}
},'json');
});
//修改服务人员
$('.clerk-btn').click(function(){
//清空表格内容
$('.change-clerk-table table tbody').empty();
$('#clerk-form .modal-title').text('修改服务人员');
var changeClerkTemplate = '{$changeClerkTemplate}';
var id = $(this).attr('data-id');
var product_id = $(this).attr('data-product-id');
var district_id = $(this).attr('data-district-id');
var form = $('#clerk-form');
form.attr('action', form.attr('action').replace('__order_id__', id));
//console.log('{$ajaxClerkListUrl}');
$.get('{$ajaxClerkListUrl}', {product_id: product_id,district_id: district_id}, function(rs){
if(rs.status==200){
for(var i = 0;i < rs.models.length; i ) {
var item = changeClerkTemplate.replace('{id}', rs.models[i].id).replace('{phone}', rs.models[i].phone).replace('{name}', rs.models[i].name).replace('{area}', rs.models[i].areas);
$('.change-clerk-table table tbody').append(item);
form.trigger('reset.yiiActiveForm');
}
}
},'json');
});
//派单服务人员
$('.clerk-allot-btn').click(function(){
//清空表格内容
$('.change-clerk-table table tbody').empty();
$('#clerk-form .modal-title').text('派单给服务人员');
var changeClerkTemplate = '{$changeClerkTemplate}';
var id = $(this).attr('data-id');
var form = $('#clerk-form');
form.attr('action', form.attr('action').replace('__order_id__', id));
$.post('',function(rs){
if(rs.status==200){
for(var i = 0;i < rs.models.length; i ) {
var item = changeClerkTemplate.replace('{id}', rs.models[i].id).replace('{phone}', rs.models[i].phone).replace('{name}', rs.models[i].name).replace('{area}', rs.models[i].areas);
$('.change-clerk-table table tbody').append(item);
form.trigger('reset.yiiActiveForm');
}
}
},'json');
});
//开始服务
$('.start-service-btn').on('click', function(){
var id = $(this).attr('data-id');
var btn = $('#order-start-service-modal .sure-btn');
btn.unbind('click');
btn.click(function(){
$.post('{$startServiceUrl}', {order_id: id}, function(rs){
if(rs.status == 200)
{
window.location.reload();
$('#order-start-service-modal').modal('hide');
}
else
{
$('#order-start-service-modal .warning-active').text(rs.message);
}
}, 'json');
});
});
//确认付款
$('.sure-payment-btn').on('click', function(){
var id = $(this).attr('data-id');
var btn = $('#payment-modal .sure-btn');
btn.unbind('click');
btn.click(function(){
$.post('{$paymentUrl}', {order_id: id}, function(rs){
if(rs.status == 200)
{
window.location.reload();
$('#payment-modal').modal('hide');
}
else
{
$('#payment-modal .warning-active').text(rs.message);
}
}, 'json');
});
});
//取消订单
$('.cancel-order-btn').on('click', function(){
var id = $(this).attr('data-id');
var btn = $('#cancel-order-modal .sure-btn');
btn.unbind('click');
btn.click(function(){
$.post('{$cancelOrderUrl}', {order_id: id}, function(rs){
if(rs.status == 200)
{
window.location.reload();
$('#cancel-order-modal').modal('hide');
}
else
{
$('#cancel-order-modal .warning-active').text(rs.message);
}
}, 'json');
});
});
JS
);
?>
<!--调试跟进记录-->
<?php
$priceDetailDeleteUrl = '';
$priceChangeStatusUrl = '';
$priceDistrictPriceDeleteUrl = '';
$priceDistrictPriceDetailUrl = '';
$this->registerJs(<<<JS
$.fn.select2.defaults.set('width', '100%');
//是否跟进
$('.field-followrecordform-follow_time').hide();
$('#followrecordform-is_follow').click(function(){
if($('#followrecordform-is_follow').is(':checked'))
{
$('.field-followrecordform-follow_time').show();
}else{
$('.field-followrecordform-follow_time').hide();
}
});
initPrice();
//是否区域及价格
$('#priceform-is_area_price').click(function(){
initPrice();
});
function initPrice()
{
if($('#priceform-is_bargain').is(':checked'))
{
hidePrice();
hideAreaPrice();
hideAreaPriceControl();
}
else if($('#priceform-is_area_price').is(':checked'))
{
hidePrice();
showAreaPrice();
showAreaPriceControl()
}
else
{
showPrice();
hideAreaPrice();
showAreaPriceControl()
}
}
function showPrice()
{
$('.field-priceform-price').show();
$('.field-priceform-tax').show();
$('.field-priceform-original_price').show();
$('.field-priceform-price_detail').show();
$('.field-priceform-city_id').show();
}
function hidePrice()
{
$('.field-priceform-price').hide();
$('.field-priceform-tax').hide();
$('.field-priceform-original_price').hide();
$('.field-priceform-price_detail').hide();
$('.field-priceform-is_area_price').hide();
$('.field-priceform-city_id').hide();
}
function showAreaPrice()
{
$('.field-priceform-district_price').show();
}
function hideAreaPrice()
{
$('.field-priceform-district_price').hide();
}
function showAreaPriceControl() {
$('.field-priceform-is_area_price').show();
}
function hideAreaPriceControl() {
$('.field-priceform-is_area_price').hide();
}
$('#price-detail-list').on('click', '.price-detail-delete', function(){
var id = $(this).attr('data-id');
var key = $(this).parents('tr').attr('data-key');
$('#delete-price-detail .sure-btn').unbind('click');
$('#delete-price-detail .sure-btn').on('click',function(){
$.post('{$priceDetailDeleteUrl}',{id:id, key:key},function(rs){
if(rs.status == 200){
$("#price-detail-list table tbody tr[data-key='" key "']").remove();
setPrice(rs.total_price, rs.total_tax);
$('#delete-price-detail').modal('hide');
}else{
}
},'json')
});
});
function setPrice(price, tax) {
$('#priceform-price').val(price);
$('#priceform-tax').val(tax);
}
$('#district-price-add-modal').on('show.bs.modal', function(){
//$('#district-price-form').trigger('reset.yiiActiveForm');
$('#districtpriceform-province_id').trigger('change');
$('#districtpriceform-city_id').trigger('change');
$('#districtpriceform-district_id').trigger('change');
});
$('#district-price-form').on('beforeSubmit', function(){
var districtPriceTemplate = '{$districtPriceTemplate}';
$.post($(this).attr('action'), $('#district-price-form').serialize(), function(rs){
if(rs.status == 200)
{
$('#district-price-add-modal').modal('hide');
var item = districtPriceTemplate.replace('{id}', rs.productPrice.id).replace('{district_name}',
rs.productPrice.province_name ' ' rs.productPrice.city_name ' ' rs.productPrice.district_name).replace('{price}', rs.productPrice.price)
.replace('{original_price}', rs.productPrice.original_price)
.replace('{tax}', rs.productPrice.tax).replace('{status}', rs.productPrice.status)
.replace('{statusName}', rs.productPrice.status != 0 ? '禁用' : '启用');
$('#district-price-list table tbody').append(item);
$('#district-price-form').trigger('reset.yiiActiveForm');
$('#district-price-add-modal').unbind('hidden.bs.modal');
setTimeout(function(){
$('#district-price-detail-add-modal').attr('data-id', rs.productPrice.id);
$('#district-price-detail-add-modal').modal('show');
}, 400);
}
else
{
$('#district-price-add-modal .warning-active').text(rs.message);
}
}, 'json');
return false;
});
//删除地区及价格
$('#district-price-list').on('click', '.district-price-delete', function(){
var row = $(this).parents('tr');
var id = row.attr('data-id');
$('#district-price-delete-modal .sure-btn').unbind('click');
$('#district-price-delete-modal .sure-btn').on('click',function(){
$.post('{$priceDistrictPriceDeleteUrl}',{id:id},function(rs){
if(rs.status == 200){
row.remove();
setPrice(rs.total_price, rs.total_tax);
$('#district-price-delete-modal').modal('hide');
}else{
$('#district-price-delete-modal .warning-active').text(rs.message);
}
},'json')
});
});
//todo ajax获取数据展示出来
$('#district-price-detail-add-modal').on('show.bs.modal', function() {
var id = $(this).attr('data-id');
$(this).find('table tbody').empty();
$.get('{$priceDistrictPriceDetailUrl}', {order_id:id}, function(rs){
if(rs.status == 200)
{
for(var i in rs.priceDetail)
{
$('#district-price-detail-add-modal table tbody').append(item);
}
}
else
{
$('#district-price-detail-add-modal .warning-active').text(rs.message);
}
}, 'json');
});
$('.district-price-detail-add').click(function(){
$('#district-price-detail-form').trigger('reset.yiiActiveForm');
showAddDistrictPriceDetail();
});
$('.cancel-add-district-price').click(function(){
showList();
});
showList();
function showList()
{
$('#district-price-detail-add-modal .modal-title').text('跟进记录');
$('.district-price-add-form').hide();
$('.district-price-detail-list').show();
$('.save-btn-detail-price').hide();
$('.delete-btn-detail-price').hide();
$('#delete-district-price-detail-hint').hide();
$('#district-price-detail-add-modal .warning-active').text('');
}
function showAddDistrictPriceDetail()
{
$('#district-price-detail-add-modal .modal-title').text('添加跟进记录');
$('.district-price-add-form').show();
$('.save-btn-detail-price').show();
$('.district-price-detail-list').hide();
$('.delete-btn-detail-price').hide();
$('#delete-district-price-detail-hint').hide();
$('#district-price-detail-add-modal .warning-active').text('');
}
function showDeleteDistrictPriceDetail()
{
$('#district-price-detail-add-modal .modal-title').text('删除价格明细');
$('.delete-btn-detail-price').show();
$('.district-price-add-form').hide();
$('.save-btn-detail-price').hide();
$('.district-price-detail-list').hide();
$('#delete-district-price-detail-hint').show();
$('#district-price-detail-add-modal .warning-active').text('');
}
$('#district-price-list').on('click', '.see-district-price-detail', function(){
var id = $(this).parents('tr').attr('data-id');
$('#district-price-detail-add-modal').attr('data-id', id);
});
$('#district-price-detail-form').on('beforeSubmit', function(){
var order_id = $('#district-price-detail-add-modal').attr('data-id');
var _form = $(this);
$.post(_form.attr('action').replace('__order_id__', order_id), $(this).serialize(), function(rs){
if(rs.status == 200)
{
showList();
$('#district-price-detail-add-modal table tbody').append(item);
_form.trigger('reset.yiiActiveForm');
}
else
{
$('#district-price-detail-add-modal .warning-active').text(rs.message);
}
}, 'json');
return false;
});
function setDistrictPrice(order_id, price, tax) {
var row = $('#district-price-list table tbody tr[data-id="' order_id '"]');
row.find('.price').text(price);
row.find('.tax').text(tax);
}
$('.district-price-detail-list').on('click', '.price-detail-delete', function(){
showDeleteDistrictPriceDetail();
var id = $('#district-price-detail-add-modal').attr('data-id');
var key = $(this).parents('tr').attr('data-key');
$('#confirm-district-price-delete').unbind('click');
$('#confirm-district-price-delete').on('click',function(){
$.post('{$priceDetailDeleteUrl}',{order_id:id, key:key},function(rs){
if(rs.status == 200){
$(".district-price-detail-list tbody tr[data-key='" key "']").remove();
setDistrictPrice(id, rs.total_price, rs.total_tax);
showList();
}else{
$('#district-price-detail-add-modal .warning-active').text(rs.message);
}
},'json')
return false;
});
return false;
});
$('.cancel-delete-district-price').click(function(){
showList();
});
$('#district-price-detail-add-modal').on('show.bs.modal', function(){
showList();
});
JS
);
?>
增加class='page-select2-area';
代码语言:javascript复制.page-select2-area .select2-container{
z-index: 1000;
}