控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 表单信息管理
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\controller\formguide;
  15. use app\admin\model\formguide\Formguide as FormguideModel;
  16. use app\common\controller\Adminbase;
  17. use think\Db;
  18. class Info extends AdminBase
  19. {
  20. /**
  21. * @var FormguideModel
  22. */
  23. private $FormguideModel;
  24. protected function initialize()
  25. {
  26. parent::initialize();
  27. $this->FormguideModel = new FormguideModel;
  28. }
  29. //信息列表
  30. public function index()
  31. {
  32. $formid = $this->request->param('formid/d', 0);
  33. if ($this->request->isAjax()) {
  34. $modelCache = cache("Model");
  35. $tableName = $modelCache[$formid]['tablename'];
  36. $this->modelClass = Db::name($tableName);
  37. list($page, $limit, $where) = $this->buildTableParames();
  38. $total = Db::name($tableName)->where($where)->count();
  39. $_list = Db::name($tableName)->where($where)->page($page, $limit)->order(['id' => 'desc'])->select();
  40. $result = ["code" => 0, "count" => $total, "data" => $_list];
  41. return json($result);
  42. } else {
  43. $fieldList = Db::name('ModelField')->where('modelid', $formid)->where('status', 1)->select();
  44. $this->assign('formStr', $this->getTableList($fieldList));
  45. $this->assign('formid', $formid);
  46. return $this->fetch();
  47. }
  48. }
  49. //删除信息
  50. public function del()
  51. {
  52. $formid = $this->request->param('formid/d', 0);
  53. $ids = $this->request->param('id/a', null);
  54. if (empty($ids) || !$formid) {
  55. $this->error('参数错误!');
  56. }
  57. if (!is_array($ids)) {
  58. $ids = [0 => $ids];
  59. }
  60. try {
  61. foreach ($ids as $id) {
  62. $this->FormguideModel->deleteInfo($formid, $id);
  63. }
  64. } catch (\Exception $ex) {
  65. $this->error($ex->getMessage());
  66. }
  67. $this->success('删除成功!');
  68. }
  69. //信息查看
  70. public function public_view()
  71. {
  72. $id = $this->request->param('id', 0);
  73. $formid = $this->request->param('formid', 0);
  74. $fieldList = $this->FormguideModel->getFieldInfo($formid, $id);
  75. $this->assign([
  76. 'fieldList' => $fieldList,
  77. ]);
  78. return $this->fetch();
  79. }
  80. private function getTableList($fieldList = [])
  81. {
  82. $htmlstr = "";
  83. foreach ($fieldList as $k => $v) {
  84. if ($v['type'] == "datetime") {
  85. $htmlstr .= "{ field: '" . $v['name'] . "',title: '" . $v['title'] . "',templet: function(d){ return yzn.formatDateTime(d." . $v['name'] . ") } },\n";
  86. } elseif ($v['type'] == "image") {
  87. $htmlstr .= "{ field: '" . $v['name'] . "',title: '" . $v['title'] . "',templet: yznTable.formatter.image },\n";
  88. } elseif ($v['type'] != "images" && $v['type'] != "files") {
  89. $htmlstr .= "{ field: '" . $v['name'] . "', align: 'left',title: '" . $v['title'] . "' },\n";
  90. }
  91. }
  92. return $htmlstr;
  93. }
  94. }