repair_faultModel.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. class flow_repair_faultClassModel extends flowModel
  3. {
  4. public $hstate, $hcolor, $repair_type = [];
  5. public function initModel()
  6. {
  7. $this->hstate = array('未处理', '已处理');
  8. $this->hcolor = array('#ff6600','green');
  9. $this->defaultorder = 'handle_state,asc,optdt,desc';
  10. $repair_type = m("repair_type")->getall('1=1');
  11. for ($i = 0; $i < count($repair_type); $i++) {
  12. $type = $repair_type[$i];
  13. $this->repair_type[$type['id']]['name'] = $type['name'];
  14. $this->repair_type[$type['id']]['dept'] = $type['dept'];
  15. $this->repair_type[$type['id']]['head'] = $type['head'];
  16. }
  17. }
  18. // 初始化单据可替换其他属性,$lx,0默认,1详情展示,2列表显示,3打印页,4外部详情页
  19. public function flowrsreplace($rs, $lx=0)
  20. {
  21. $zt = $rs['handle_state'];
  22. $typeId = $rs['type_id'];
  23. // 将id转换为文字
  24. // $rs['handle_state'] = $this->getstatezt($zt);
  25. // $rs['handle_info'] = $this->getHandleInfo($typeId, $zt);
  26. $rs['handle_state'] = $this->getHandleInfo($rs);
  27. return $rs;
  28. }
  29. // $ors当前单据操作信息,$crs提交过来的信息
  30. public function flowoptmenu($ors, $crs)
  31. {
  32. // 处理维修
  33. if ($ors['num'] == 'noup') {
  34. // 动作名
  35. if ($ors['actname'] == "change_handle") {
  36. $sm = $crs['sm']; // 提交过来的说明
  37. $uname = $this->option->adminname;
  38. $curr_uid = $this->option->adminid;
  39. // 更新说明
  40. $this->update([
  41. "explain"=>$sm,
  42. "repairer"=>$uname,
  43. "repairer_id"=>$curr_uid,
  44. ], $this->id);
  45. }
  46. }
  47. }
  48. //显示操作菜单判断
  49. protected function flowgetoptmenu($num)
  50. {
  51. if (empty($this->id)) return false;
  52. $row = m("repair_fault")->getone("id={$this->id} and handle_state != 1");
  53. if (empty($row) || empty($row['type_id'])) return false;
  54. $type_id = $row['type_id'];
  55. // 获取当操作前用户id,如果有权限操作,则返回true
  56. $curr_uid = $this->option->adminid;
  57. $where = "id={$type_id} and FIND_IN_SET({$curr_uid},`head_id`)";
  58. $can = m("repair_type")->getone($where, 'head_id');
  59. if (empty($can)) {
  60. return false;
  61. } else {
  62. return true;
  63. }
  64. }
  65. //提交时调用
  66. protected function flowsubmit($na, $sm){
  67. // if ($na != '编辑') {
  68. // }
  69. $row = m("repair_fault")->getone("id={$this->id}");
  70. if (!empty($row) && $row['handle_state'] == 0 && $row['sms_state'] == 0) {
  71. $typeInfo = m("repair_type")->getone("id={$row['type_id']}");
  72. m("log")->addlog("故障记录", "发送短信给{$typeInfo['head']}");
  73. // 发送成功改变状态
  74. $this->update([
  75. "sms_state"=>1,
  76. ], $this->id);
  77. }
  78. }
  79. public function flowwesearchdata($lx)
  80. {
  81. if($lx==1) return m("repair_type")->getall("1=1");
  82. return array(
  83. 'typename' => '所有分类',
  84. 'searchmsg' => '标题/分类',
  85. );
  86. }
  87. // 移动端筛选
  88. protected function flowbillwhere($uid, $lx)
  89. {
  90. $key = $this->rock->post('key');
  91. if ($this->ismobile) {
  92. $typeid = (int)$this->rock->post('type_id','0');
  93. $keywere= '';
  94. if(!isempt($key))$keywere.=" and (`title` like '%$key%' or `type`='$key')";
  95. $whyere = '';
  96. if($typeid>0){
  97. $whyere.=" and `type_id`='$typeid'";
  98. }
  99. return array(
  100. 'order' => '`handle_state` asc,`optdt` desc',
  101. 'keywere' => $keywere,
  102. 'where' => $whyere,
  103. 'fields' => '*'
  104. );
  105. }
  106. return null;
  107. }
  108. public function getstatezt($zt)
  109. {
  110. $colors = ["#ff8b1a", "#00c959", "#ff4974"];
  111. if (isset($this->hstate[$zt])) {
  112. $html = '<font style="background-color:'.$colors[$zt].'; padding: 2px 8px; border-radius: 4px; color: #fff">'.$this->hstate[$zt].'</font>';
  113. return $html;
  114. } else {
  115. return null;
  116. }
  117. }
  118. public function getHandleInfo($rs) {
  119. $zt = $rs['handle_state'];
  120. $typeId = $rs['type_id'];
  121. if (isset($this->hstate[$zt])) {
  122. $colors = ["#ff8b1a", "#00c959", "#ff4974"];
  123. $html = '故障状态:';
  124. $html .= '<font style="background-color:'.$colors[$zt].'; padding: 2px 8px; border-radius: 4px; color: #fff">'.$this->hstate[$zt].'</font><br/ >';
  125. if (isset($this->repair_type[$typeId])) {
  126. $info = $this->repair_type[$typeId];
  127. $info['head'] = str_replace(',', '、', $info['head']);
  128. if ($zt == 1) {
  129. $html .= '处理人:';
  130. $html .= "<font style='color: #00c959; padding: 2px 8px; border-radius: 4px;'>【{$info['dept']}】{$rs['repairer']}</font>";
  131. } else {
  132. $html .= '负责人:';
  133. $html .= "<font style='color: #ff8b1a; padding: 2px 8px; border-radius: 4px;'>【{$info['dept']}】{$info['head']}</font>";
  134. }
  135. }
  136. return $html;
  137. } else {
  138. return null;
  139. }
  140. if (isset($this->hstate[$zt])) {
  141. $html = '<font style="background-color:'.$colors[$zt].'; padding: 2px 8px; border-radius: 4px; color: #fff">'.$this->hstate[$zt].'</font>';
  142. return $html;
  143. } else {
  144. return null;
  145. }
  146. // if (isset($this->repair_type[$typeId])) {
  147. // if ($zt == 1) {
  148. // $info = $this->repair_type[$typeId];
  149. // $info['head'] = str_replace(',', '、', $info['head']);
  150. // $html = "<font style='color: #ff8b1a; padding: 2px 8px; border-radius: 4px;'>【{$info['dept']}】{$info['head']}</font>";
  151. // return $html;
  152. // } else {
  153. // $info = $this->repair_type[$typeId];
  154. // $info['head'] = str_replace(',', '、', $info['head']);
  155. // $html = "<font style='color: #ff8b1a; padding: 2px 8px; border-radius: 4px;'>【{$info['dept']}】{$info['head']}</font>";
  156. // return $html;
  157. // }
  158. // } else {
  159. // return null;
  160. // }
  161. }
  162. }