Print_job.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\model\ps;
  3. use think\Model;
  4. class Print_job extends Model
  5. {
  6. // 表名
  7. protected $name = 'ps_print_job';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'status_text'
  17. ];
  18. public function getStatusList()
  19. {
  20. return ['previewed' => __('Previewed'), 'printed' => __('Printed'), 'canceled' => __('Canceled')];
  21. }
  22. public function getBizTypeList()
  23. {
  24. return ['product' => __('Product'), 'workorder' => __('Workorder')];
  25. }
  26. public function getLodopModeList()
  27. {
  28. return ['preview' => __('Preview'), 'print' => __('Print')];
  29. }
  30. public function factory()
  31. {
  32. return $this->belongsTo('Factory', 'factory_id', 'id', [], 'LEFT')->setEagerlyType(0);
  33. }
  34. public function getStatusTextAttr($value, $data)
  35. {
  36. $value = $value ?: ($data['status'] ?? '');
  37. $list = $this->getStatusList();
  38. return $list[$value] ?? '';
  39. }
  40. }