HydEquipment.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace catchAdmin\hydraulic\model;
  3. use catchAdmin\equipment\model\EquipmentType;
  4. use catcher\base\CatchModel as Model;
  5. use catchAdmin\permissions\model\DataRangScopeTrait;
  6. use catchAdmin\system\model\SysDictData;
  7. class HydEquipment extends Model
  8. {
  9. use DataRangScopeTrait;
  10. // 表名
  11. public $name = 'hydraulic_equipment';
  12. // 数据库字段映射
  13. public $field = array(
  14. 'id',
  15. // 物料号
  16. 'material_number',
  17. // 设备类别
  18. 'equipment_type',
  19. // 工具名称
  20. 'name',
  21. // 设备型号
  22. 'equipment_model',
  23. // 发放单位
  24. 'issue_unit',
  25. // 固定资产编号
  26. 'fixed_asset_number',
  27. // 类固定资产编号
  28. 'fixed_asset_number2',
  29. // 序列号
  30. 'serial_number',
  31. // 出厂编号
  32. 'factory_number',
  33. // 上次校验时间
  34. 'check_last_time',
  35. // 下次校验时间
  36. 'check_next_time',
  37. // 校验状态
  38. 'check_status',
  39. // 状态
  40. 'status',
  41. // 创建人ID
  42. 'creator_id',
  43. // 创建时间
  44. 'created_at',
  45. // 更新时间
  46. 'updated_at',
  47. // 软删除
  48. 'deleted_at',
  49. );
  50. public function getList()
  51. {
  52. $res = $this->dataRange()
  53. ->catchSearch()
  54. ->append(['classification','equ_type_name', 'list'])
  55. ->order($this->aliasField('id'), 'desc')
  56. ->paginate();
  57. return $res;
  58. }
  59. public function getClassificationAttr()
  60. {
  61. $id = $this->getData('equipment_type');
  62. $eq = new EquipmentType();
  63. $name = $eq->getParentNamebyChildId($id);
  64. return $name;
  65. }
  66. public function getEquTypeNameAttr()
  67. {
  68. $id = $this->getData('equipment_type');
  69. $name = EquipmentType::where('id',$id)->value('name');
  70. return $name;
  71. }
  72. public function getCheckStatusAttr()
  73. {
  74. $id = $this->getData('check_status');
  75. $Dict = new SysDictData();
  76. $value = $Dict->getValueByCode('Check',$id);
  77. return $value;
  78. }
  79. public function getStatusAttr()
  80. {
  81. $id = $this->getData('status');
  82. $Dict = new SysDictData();
  83. $value = $Dict->getValueByCode('ToolStatus',$id);
  84. return $value;
  85. }
  86. public function getCheckLastTimeAttr()
  87. {
  88. $time = $this->getData('check_last_time');
  89. return date('Y-m-d',$time);
  90. }
  91. public function getCheckNextTimeAttr()
  92. {
  93. $time = $this->getData('check_next_time');
  94. return date('Y-m-d',$time);
  95. }
  96. }