作者 董瑞恩
1 个管道 的构建 通过 耗费 0 秒

interface

  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: ruidiudiu
  5 + * Date: 2018/11/23
  6 + * Time: 11:57
  7 + */
  8 +
  9 +namespace app\portal\controller;
  10 +
  11 +
  12 +use app\portal\model\EquipmentModel;
  13 +use cmf\controller\AdminBaseController;
  14 +use think\Db;
  15 +
  16 +/**
  17 + * Class AdminFaultAuditController
  18 + * @package app\portal\controller
  19 + * @adminMenuRoot(
  20 + * 'name' =>'故障审核',
  21 + * 'action' =>'index',
  22 + * 'parent' =>'',
  23 + * 'display'=> true,
  24 + * 'order' => 1,
  25 + * 'icon' =>'th',
  26 + * 'remark' =>'故障审核'
  27 + * )
  28 + */
  29 +class AdminFaultAuditController extends AdminBaseController{
  30 +
  31 + public function index(){
  32 + $param=$this->request->param();
  33 + $where=array();
  34 + if (!empty($param['fault_type'])){
  35 + $where['fault_type']=$param['fault_type'];
  36 + }
  37 + $data=Db::name('fault')
  38 + ->alias('a')
  39 + ->field('a.*,b.serial_number,b.hospital')
  40 + ->join('equipment b','a.eq_name=b.name')
  41 + ->where($where)
  42 + ->order('a.state','ase')
  43 + ->order('a.create_time','desc')
  44 + ->paginate(10);
  45 +
  46 + $this->assign('data',$data);
  47 + $this->assign('fault_type', isset($param['fault_type']) ? $param['fault_type'] : '');
  48 + return $this->fetch();
  49 + }
  50 +
  51 + //保修
  52 + public function warranty(){
  53 + $id=$this->request->param('id');
  54 +
  55 + $fault=Db::name('fault')->where('id',$id)->find();
  56 +
  57 + try{
  58 + Db::startTrans();
  59 + Db::name('equipment')->where('name',$fault['eq_name'])->update(['state'=>2]);
  60 + Db::name('fault')->where('id',$id)->update(['state'=>2]);
  61 + }catch (\Exception $exception){
  62 + Db::rollback();
  63 + $this->error('错误:'.$exception->getMessage());
  64 + }
  65 + Db::commit();
  66 + $this->success('处理完成');
  67 +
  68 + }
  69 +
  70 + //恢复设备
  71 + public function reply(){
  72 + $id=$this->request->param('id');
  73 +
  74 + $fault=Db::name('fault')->where('id',$id)->find();
  75 +
  76 + try{
  77 + Db::startTrans();
  78 + Db::name('equipment')->where('name',$fault['eq_name'])->update(['state'=>1]);
  79 + Db::name('fault')->where('id',$id)->update(['state'=>3]);
  80 + }catch (\Exception $exception){
  81 + Db::rollback();
  82 + $this->error('错误:'.$exception->getMessage());
  83 + }
  84 + Db::commit();
  85 + $this->success('处理完成');
  86 +
  87 + }
  88 +
  89 +
  90 + //结束计费
  91 + public function bill_error(){
  92 + $id=$this->request->param('id');
  93 +
  94 + $fault=Db::name('fault')->where('id',$id)->find();
  95 +
  96 + $order=Db::name('order')->where(['users_id'=>$fault['users_id'],'state'=>1])->find();
  97 + if (empty($order)){
  98 + $this->error('没有未完成订单');
  99 + }else{
  100 + $time=ceil(($fault['create_time']-$order['start_time'])/3600);
  101 + $getPrice=new OrderController();
  102 + $price=$getPrice->getPrice($fault['users_id'],$order['start_time'],$fault['create_time']);
  103 + $data=[
  104 + 'end_time'=>$fault['create_time'],
  105 + 'time'=>$time,
  106 + 'price'=>$price,
  107 + 'state'=>2
  108 + ];
  109 + try{
  110 + Db::startTrans();
  111 + Db::name('users')->where('id',$fault['users_id'])->update(['is_use'=>0]);
  112 + Db::name('equipment')->where('name',$fault['eq_name'])->update(['use'=>0]);
  113 + Db::name('order')->where('id',$order['id'])->update($data);
  114 + Db::name('fault')->where('id',$id)->update(['state'=>3]);
  115 + }catch (\Exception $exception){
  116 + Db::rollback();
  117 + $this->error('错误:'.$exception->getMessage());
  118 + }
  119 + Db::commit();
  120 + $this->success('处理完成');
  121 + }
  122 + }
  123 +
  124 +
  125 +
  126 +
  127 +
  128 +
  129 +}
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="javascript:;">故障列表</a></li>
  7 + </ul>
  8 + <form class="well form-inline margin-top-20" method="post" action="{:url('AdminFaultAuditController/index')}">
  9 + 故障分类:
  10 + <select class="form-control" name="fault_type" style="width: 140px;">
  11 + <option value='0'>全部</option>
  12 + <option value='1' <if condition="$fault_type eq 1">selected </if>>计费</option>
  13 + <option value='2' <if condition="$fault_type eq 2">selected </if>>床体</option>
  14 + <option value='3' <if condition="$fault_type eq 3">selected </if>>床锁</option>
  15 + <option value='4' <if condition="$fault_type eq 4">selected </if>>其他</option>
  16 + </select> &nbsp;&nbsp;
  17 + <input type="submit" class="btn btn-primary" value="搜索"/>
  18 + <a class="btn btn-danger" href="{:url('AdminFaultAuditController/index')}">清空</a>
  19 + </form>
  20 + <form class="js-ajax-form" action="" method="post">
  21 + <div class="table-actions">
  22 + <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
  23 + data-action="{:url('AdminFaultAuditController/publish',array('yes'=>1))}" data-subcheck="true">批量新增
  24 + </button>
  25 + </div>
  26 + <table class="table table-hover table-bordered table-list">
  27 + <thead>
  28 + <tr>
  29 + <th width="15">
  30 + <label>
  31 + <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
  32 + </label>
  33 + </th>
  34 + <th width="50">ID</th>
  35 + <th>设备名称</th>
  36 + <th>设备锁编号</th>
  37 + <th>所在医院</th>
  38 + <th>故障类型</th>
  39 + <th>故障描述</th>
  40 + <th>故障状态</th>
  41 + <th>图片</th>
  42 + <th width="150">操作</th>
  43 + </tr>
  44 + </thead>
  45 + <foreach name="data" item="vo">
  46 + <tr>
  47 + <td>
  48 + <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
  49 + value="{$vo.id}" title="ID:{$vo.id}">
  50 + </td>
  51 + <td><b>{$vo.id}</b></td>
  52 + <td>{$vo.eq_name}</td>
  53 + <td>{$vo.serial_number}</td>
  54 + <td>{$vo.hospital}</td>
  55 + <td>
  56 + <switch name="$vo.fault_type">
  57 + <case value="1">计费</case>
  58 + <case value="2">床体</case>
  59 + <case value="3">床锁</case>
  60 + <case value="4">其他</case>
  61 + </switch>
  62 + </td>
  63 + <td>{$vo.fault_describe}</td>
  64 + <td>
  65 + <switch name="$vo.state">
  66 + <case value="1"><span class="label label-danger">未处理</span></case>
  67 + <case value="2"><span class="label label-warning">处理中</span></case>
  68 + <case value="3"><span class="label label-success">已处理</span></case>
  69 + </switch>
  70 + </td>
  71 + <td>
  72 + <img style="width: 50px;height: 50px" src="{:cmf_get_image_preview_url($vo.img)}">
  73 + <!--<a href="{:url('AdminFault/edit',array('id'=>$vo['id']))}">查看图片</a>-->
  74 + </td>
  75 + <td>
  76 + <a href="{:url('AdminFaultAuditController/warranty',array('id'=>$vo['id']))}" class="js-ajax-delete">保修</a><br/>
  77 + <a href="{:url('AdminFaultAuditController/reply',array('id'=>$vo['id']))}" class="js-ajax-delete">保修完成</a><br/>
  78 + <a href="{:url('AdminFaultAuditController/bill_error',array('id'=>$vo['id']))}" class="js-ajax-delete">终止订单计费</a><br/>
  79 + </td>
  80 + </tr>
  81 + </foreach>
  82 + </table>
  83 + <!--<div class="table-actions">-->
  84 + <!--<notempty name="category">-->
  85 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  86 + <!--data-action="{:url('AdminArticle/listOrder')}">{:lang('SORT')}-->
  87 + <!--</button>-->
  88 + <!--</notempty>-->
  89 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  90 + <!--data-action="{:url('AdminArticle/publish',array('yes'=>1))}" data-subcheck="true">发布-->
  91 + <!--</button>-->
  92 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  93 + <!--data-action="{:url('AdminArticle/publish',array('no'=>1))}" data-subcheck="true">取消发布-->
  94 + <!--</button>-->
  95 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  96 + <!--data-action="{:url('AdminArticle/top',array('yes'=>1))}" data-subcheck="true">置顶-->
  97 + <!--</button>-->
  98 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  99 + <!--data-action="{:url('AdminArticle/top',array('no'=>1))}" data-subcheck="true">取消置顶-->
  100 + <!--</button>-->
  101 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  102 + <!--data-action="{:url('AdminArticle/recommend',array('yes'=>1))}" data-subcheck="true">推荐-->
  103 + <!--</button>-->
  104 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  105 + <!--data-action="{:url('AdminArticle/recommend',array('no'=>1))}" data-subcheck="true">取消推荐-->
  106 + <!--</button>-->
  107 + <!--&lt;!&ndash;-->
  108 + <!--<notempty name="category">-->
  109 + <!--<button class="btn btn-primary btn-sm js-articles-move" type="button">批量移动</button>-->
  110 + <!--</notempty>-->
  111 + <!--<button class="btn btn-primary btn-sm js-articles-copy" type="button">批量复制</button>-->
  112 + <!--&ndash;&gt;-->
  113 + <!--<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"-->
  114 + <!--data-action="{:url('AdminArticle/delete')}" data-subcheck="true" data-msg="您确定删除吗?">-->
  115 + <!--{:lang('DELETE')}-->
  116 + <!--</button>-->
  117 + <!--</div>-->
  118 + <ul class="pagination">{$page|default=''}</ul>
  119 + </form>
  120 +</div>
  121 +<script src="__STATIC__/js/admin.js"></script>
  122 +<script>
  123 +
  124 + function reloadPage(win) {
  125 + win.location.reload();
  126 + }
  127 +
  128 + $(function () {
  129 + setCookie("refersh_time", 0);
  130 + Wind.use('ajaxForm', 'artDialog', 'iframeTools', function () {
  131 + //批量复制
  132 + $('.js-articles-copy').click(function (e) {
  133 + var ids = [];
  134 + $("input[name='ids[]']").each(function () {
  135 + if ($(this).is(':checked')) {
  136 + ids.push($(this).val());
  137 + }
  138 + });
  139 +
  140 + if (ids.length == 0) {
  141 + art.dialog.through({
  142 + id: 'error',
  143 + icon: 'error',
  144 + content: '您没有勾选信息,无法进行操作!',
  145 + cancelVal: '关闭',
  146 + cancel: true
  147 + });
  148 + return false;
  149 + }
  150 +
  151 + ids = ids.join(',');
  152 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=copy&ids=" + ids, {
  153 + title: "批量复制",
  154 + width: "300px"
  155 + });
  156 + });
  157 + //批量移动
  158 + $('.js-articles-move').click(function (e) {
  159 + var ids = [];
  160 + $("input[name='ids[]']").each(function () {
  161 + if ($(this).is(':checked')) {
  162 + ids.push($(this).val());
  163 + }
  164 + });
  165 +
  166 + if (ids.length == 0) {
  167 + art.dialog.through({
  168 + id: 'error',
  169 + icon: 'error',
  170 + content: '您没有勾选信息,无法进行操作!',
  171 + cancelVal: '关闭',
  172 + cancel: true
  173 + });
  174 + return false;
  175 + }
  176 +
  177 + ids = ids.join(',');
  178 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=move&old_term_id={$term.term_id|default=0}&ids=" + ids, {
  179 + title: "批量移动",
  180 + width: "300px"
  181 + });
  182 + });
  183 + });
  184 + });
  185 +</script>
  186 +</body>
  187 +</html>