v1.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace zin;
  3. class detailBody extends wg
  4. {
  5. /**
  6. * @var mixed[]
  7. */
  8. protected static $defineProps = array(
  9. 'isForm?: bool=false',
  10. 'hasExtraMain?: bool=true' // 是否展示工作流扩展字段
  11. );
  12. /**
  13. * @var mixed[]
  14. */
  15. protected static $defineBlocks = array(
  16. 'main' => array('map' => 'sectionList'),
  17. 'side' => array('map' => 'detailSide'),
  18. 'bottom' => array('map' => 'history,fileList'),
  19. 'floating' => array('map' => 'floatToolbar')
  20. );
  21. public static function getPageCSS()
  22. {
  23. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  24. }
  25. public static function getPageJS()
  26. {
  27. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  28. }
  29. protected function buildExtraMain()
  30. {
  31. global $app;
  32. $app->control->loadModel('flow');
  33. $isForm = $this->prop('isForm');
  34. $object = data($app->getModuleName());
  35. $fields = $app->control->appendExtendForm('info', $object);
  36. $extraMain = array();
  37. foreach($fields as $field)
  38. {
  39. $fieldValue = !$isForm ? $app->control->flow->getFieldValue($field, $object) : null;
  40. $extraMain[] = section
  41. (
  42. !empty($field->control['control']) && $field->control['control'] == 'fileSelector' && $object->files ? fileList
  43. (
  44. set::files($object->files),
  45. set::extra($field->field),
  46. set::fieldset(false),
  47. set::showEdit(true),
  48. set::showDelete(true)
  49. ) : null,
  50. set::title($field->name),
  51. set::required($field->required),
  52. !$isForm ? (div(!empty($field->control['control']) && $field->control['control'] == 'editor' ? html($fieldValue) : $fieldValue)) : formGroup
  53. (
  54. set::id($field->field),
  55. set::name($field->field),
  56. set::disabled((bool)$field->readonly),
  57. set::control($field->control),
  58. set::items($field->items),
  59. set::value($field->value),
  60. set::placeholder($field->placeholder)
  61. )
  62. );
  63. }
  64. return empty($extraMain) ? null : sectionList($extraMain);
  65. }
  66. protected function build()
  67. {
  68. global $app;
  69. $main = $this->block('main');
  70. $side = $this->block('side');
  71. $bottom = $this->block('bottom');
  72. $floating = $this->block('floating');
  73. $isForm = $this->prop('isForm');
  74. $hasExtraMain = $this->prop('hasExtraMain');
  75. $extraMain = $hasExtraMain ? $this->buildExtraMain() : null;
  76. if(!$isForm)
  77. {
  78. return div
  79. (
  80. setClass('detail-body rounded flex gap-1'),
  81. set($this->getRestProps()),
  82. div
  83. (
  84. setClass('col gap-1 grow min-w-0'),
  85. $main,
  86. $extraMain,
  87. $bottom,
  88. empty($floating) ? null : center(setClass('pt-6 sticky bottom-0'), $floating)
  89. ),
  90. $side,
  91. html($app->control->appendExtendCssAndJS('', '', data($app->getModuleName())))
  92. );
  93. }
  94. return formBase
  95. (
  96. set::actionsClass('h-14 flex flex-none items-center justify-center shadow'),
  97. setClass('detail-body rounded col overflow-y-hidden bg-white'),
  98. set($this->getRestProps()),
  99. div
  100. (
  101. setClass('flex-auto overflow-y-auto'),
  102. div
  103. (
  104. setClass('flex'),
  105. setStyle('min-height', '100%'),
  106. div
  107. (
  108. setClass('col grow min-w-0'),
  109. $main,
  110. $extraMain,
  111. $bottom
  112. ),
  113. div
  114. (
  115. setClass('w-1'),
  116. setStyle('background', 'var(--zt-page-bg)')
  117. ),
  118. $side
  119. )
  120. ),
  121. html($app->control->appendExtendCssAndJS('', '', data($app->getModuleName())))
  122. );
  123. }
  124. }