index.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2017/3/17 0017
  6. * Time: 上午 10:52
  7. */
  8. use yii\helpers\Url;
  9. use yii\widgets\LinkPager;
  10. ?>
  11. <div class="panel panel-default">
  12. <div class="ibox-title">
  13. <h5><?= $name ?></h5>
  14. <div class="ibox-tools">
  15. <button type="button" class="btn btn-default btn-sm " onclick="window.history.go(-1)">返回</button>
  16. </div>
  17. </div>
  18. <table class="table ">
  19. <tr>
  20. <th>操作</th>
  21. <th>公司名称</th>
  22. <th>业主</th>
  23. <th>电话号码</th>
  24. <th>小区名称</th>
  25. <th>城市归属</th>
  26. <th>订单状态</th>
  27. <th>派单时间</th>
  28. </tr>
  29. <?php if(!empty($models)): ?>
  30. <?php foreach ($models as $vo):?>
  31. <tr id="tr_<?=$vo->id?>">
  32. <td>
  33. <div class="btn-group">
  34. <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle btn-sm " aria-expanded="false">操作 <span class="caret"></span>
  35. </button>
  36. <ul class="dropdown-menu">
  37. <li><a url="<?=Url::toRoute(['sendorder-log/update-status','id'=>$vo->id]);?>" data-id="<?=$vo->id?>" href="javascript:void(0);" class="font-bold">编辑状态</a>
  38. </li>
  39. <li class="divider" ></li>
  40. <li><a href="javascript:void(0);" data-id="<?= $vo->id?>" class="opera" data-type="cancel">取消订单</a>
  41. </li>
  42. <li>
  43. <a href="javascript:void(0);" data-uid="<?=$vo->uid ?>" class="opera" data-type="send">短信通知</a>
  44. </li>
  45. </ul>
  46. </div>
  47. </td>
  48. <td><?= !empty($vo->company)?$vo->company->company :"" ?></td>
  49. <td><?= $modelSendOrder->name?></td>
  50. <td><?= $modelSendOrder->tel ?></td>
  51. <td><?= $modelSendOrder->house_name ?></td>
  52. <td><?= \common\models\Area::queryAdminProvinceName($modelSendOrder->province).\common\models\Area::queryAdminCityName($modelSendOrder->city) ?></td>
  53. <td id="status_name_<?=$vo->id?>"><?= !empty(\common\models\SendOrderLog::status_list()[$vo->status]) ? \common\models\SendOrderLog::status_list()[$vo->status] : "" ?></td>
  54. <td><?=date('Y-m-d H:i',$vo->c_time);?></td>
  55. </tr>
  56. <?php endforeach;?>
  57. <?php else :?>
  58. <tr class="no-records-found" style="text-align: center;"><td colspan="8">没有找到匹配的记录</td></tr>
  59. <?php endif; ?>
  60. </table>
  61. </div>
  62. <?=LinkPager::widget(['pagination' => $pages]); ?>
  63. <input type="hidden" id="status" >
  64. <script type="text/javascript">
  65. $('.font-bold').on('click',function () {
  66. $("#status").val("");
  67. var url = $(this).attr('url');
  68. var id = $(this).attr('data-id');
  69. layer.open({
  70. title : '编辑状态',
  71. type: 2,
  72. area: ['500px', '200px'],
  73. fixed: false, //不固定
  74. maxmin: false,
  75. content:url,
  76. btn: ['确定','取消'],//自定义按钮,默认第一个为确定按钮
  77. btnAlign: 'c',//按钮显示方式 'l' 按钮左对齐 'c' 按钮居中对齐 'r' 按钮右对齐(默认)
  78. yes:function(index, content){
  79. var status = $("#status").val();//选择状态
  80. if(status=='')
  81. {
  82. layer.msg("请选择状态");
  83. return false;
  84. }
  85. $.ajax({
  86. url:'<?=Url::toRoute(['sendorder-log/update-status']);?>',
  87. type:'POST',
  88. dataType:'json',
  89. data:{id:id,status:status,'<?=Yii::$app->request->csrfParam;?>':'<?= Yii::$app->request->csrfToken;?>'},
  90. success:function(data){
  91. console.log(data);
  92. if(data.sign==1){
  93. if(data.status!='')
  94. $('#status_name_'+id).html(data.status);
  95. toastr.success("", data.msg);
  96. }else{
  97. swal("", data.msg, "error");
  98. }
  99. }
  100. })
  101. layer.close(index);
  102. }
  103. });
  104. });
  105. /**
  106. * 取消订单,给装修公司发送短信
  107. */
  108. $('.opera').on('click',function () {
  109. var type = $(this).attr('data-type');
  110. if(type =='cancel')
  111. {
  112. var id = $(this).attr('data-id');
  113. var data = {id:id,'<?=Yii::$app->request->csrfParam;?>':'<?=Yii::$app->request->csrfToken;?>'};
  114. var title = "确定要取消对当前公司的派单吗?";
  115. var url = '<?=Url::toRoute(['sendorder-log/cancel']);?>';
  116. }else
  117. {
  118. var uid = $(this).attr('data-uid');
  119. var data = {uid:uid,'<?=Yii::$app->request->csrfParam;?>':'<?=Yii::$app->request->csrfToken;?>'};
  120. var title ="确定要短信通知吗?";
  121. var url = '<?=Url::toRoute(['sendorder-log/send-message']);?>';
  122. }
  123. swal({
  124. title: title,
  125. type: "warning",
  126. showCancelButton: true,
  127. confirmButtonColor: "#DD6B55",
  128. confirmButtonText: "确定",
  129. cancelButtonText: "取消",
  130. closeOnConfirm: true,
  131. closeOnCancel: true
  132. },
  133. function(isConfirm){
  134. if (isConfirm) {
  135. $.ajax({
  136. url:url,
  137. type:'POST',
  138. dataType:'json',
  139. data:data,
  140. success:function(data){
  141. if(data.sign==1){
  142. toastr.success("", data.msg);
  143. if(type=='cancel')
  144. $('#tr_'+id).remove();
  145. }else{
  146. swal("", data.msg, "error");
  147. }
  148. }
  149. })
  150. }
  151. });
  152. });
  153. toastr.options={ "closeButton": true};
  154. </script>