InkBook.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * author xtj
  4. * createtime 2020/6/3 0003 上午 9:25
  5. * return array obj json bool
  6. * param
  7. */
  8. namespace app\admin\controller;
  9. use app\common\controller\Backend;
  10. use think\Db;
  11. use think\Where;
  12. //油墨指令书
  13. class InkBook extends Backend{
  14. //订单列表页
  15. public function index(){
  16. //设置过滤方法
  17. $this->request->filter(['strip_tags']);
  18. if ($this->request->isAjax()) {
  19. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  20. $total = Db::name('formula_book')
  21. ->where($where)
  22. ->order($sort, $order)
  23. ->count();
  24. $list = Db::name('formula_book')
  25. ->where($where)
  26. ->order($sort, $order)
  27. ->limit($offset, $limit)
  28. ->select();
  29. $result = array("total" => $total, "rows" => $list);
  30. return json($result);
  31. }
  32. return $this->view->fetch();
  33. }
  34. //详情
  35. public function read(){
  36. //设置过滤方法
  37. $this->request->filter(['strip_tags']);
  38. if ($this->request->isAjax()) {
  39. $params = $this->request->request();
  40. $filter = json_decode($params['filter'],true);
  41. $pid = $filter['id'];
  42. $limit = $params['limit'];
  43. $offset = $params['offset'];
  44. $total = Db::name('formula_book_detail')
  45. ->where('pid',$pid)
  46. ->count();
  47. $list = Db::name('formula_book_detail')
  48. ->where('pid',$pid)
  49. ->limit($offset, $limit)
  50. ->field('id,create,formula,big_number,small_number')
  51. ->select();
  52. $result = array("total" => $total, "rows" => $list);
  53. return json($result);
  54. }
  55. return $this->view->fetch();
  56. }
  57. //查看,渲染基础数据
  58. public function detail(){
  59. $params = input('ids');
  60. if (empty($params)){
  61. $this->error('未知数据格式');
  62. }
  63. $result = Db::name('formula_book_detail')->where('id',$params)->find();
  64. return $this->view->fetch('',compact('result'));
  65. }
  66. //渲染表格里配方和大小盒计划数据
  67. public function doDetail(){
  68. $params = input('id');
  69. if (empty($params)){
  70. $this->error('未知数据格式');
  71. }
  72. $result = Db::name('formula_book_detail')->where('id',$params)->find();
  73. $formula = json_decode($result['warehousing'],true);
  74. $consume = json_decode($result['consume'],true);
  75. $formulaSpan = json_decode($result['formula_span'],true);
  76. $formulaSpanData = [];
  77. $i = 0;
  78. foreach ($formulaSpan as $key=>$value){
  79. $formulaSpanData[$key]['beginRow'] = $i;
  80. $count = $value;
  81. $formulaSpanData[$key]['rowSpan'] = $value;
  82. $i = $count + $i;
  83. }
  84. return array('status'=>1,'data'=>$formula,'consume'=>$consume,'formulaSpanData'=>$formulaSpanData,'consumeSpan'=>$result['consume_span']);
  85. }
  86. }