BarLargeModel.class.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace Admin\Model;
  3. use Common\Model\ModelModel;
  4. /**
  5. * 配置模型
  6. *
  7. */
  8. class BarLargeModel extends ModelModel
  9. {
  10. /**
  11. * 数据库表名
  12. *
  13. */
  14. protected $tableName = 'bar_large';
  15. /**
  16. * 自动验证规则
  17. *
  18. */
  19. protected $_validate = array(
  20. /*array('code', 'require', '产品代码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
  21. array('code', '4,6', '产品代码长度为4-6个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
  22. array('code', '', '产品代码已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
  23. array('title', 'require', '自定义名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
  24. array('title', '', '自定义名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),*/
  25. );
  26. /**
  27. * 自动完成规则
  28. *
  29. */
  30. protected $_auto = array(
  31. );
  32. /**
  33. * 获取大件
  34. * @return array 配置数组
  35. *
  36. */
  37. public function getList($where = [],$p)
  38. {
  39. $list = $this->where($where)->order('id desc')->limit($p->firstRow, $p->listRows)->select();
  40. return $list;
  41. }
  42. public function slectById($id){
  43. $list = $this->where('id ='.$id)->select();
  44. return $list;
  45. }
  46. public function getById($list){
  47. header("Content-type: text/html; charset=utf-8");
  48. $where = array();
  49. $where['id'] = array('in',$list);
  50. $field = "sn,name,time,num,standard,inspector,batch_number,board_no,tray_no,quality_no";
  51. $data = $this->field($field)->where($where)->select();
  52. $new = array();
  53. foreach($data as $v){
  54. $arr = array();
  55. $arr = $v;
  56. $arr['custome_name'] = '湖北中烟工业有限公司';
  57. $arr['date'] = date('Y',$v['time']).'年'.date('m',$v['time']).'月'.date('d',$v['time']).'日';
  58. $arr['sn'] = preg_replace("/[\(\)]/","",$v['sn']);
  59. unset( $arr['time']);
  60. $new[]= $arr;
  61. }
  62. return $new;
  63. }
  64. /*保存产品信息*/
  65. public function save1($data){
  66. $id = $data['id'];
  67. if($id){
  68. //执行更新
  69. $return = $this->where('id ='.$id)->save($data);
  70. }else{
  71. //执行增加
  72. unset($data['id']);
  73. $return = $this->add($data);
  74. }
  75. if($return!==false){
  76. return true;
  77. }
  78. return false;
  79. }
  80. }