v1.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'datalist' . DS . 'v1.php';
  4. class demandBasicInfo extends wg
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array
  10. (
  11. 'demand' => '?object', // 当前需求。
  12. );
  13. protected function getItems()
  14. {
  15. global $lang, $config;
  16. $demand = $this->prop('demand', data('demand'));
  17. if(!$demand) return array();
  18. $demandpools = data('demandpools');
  19. $products = data('products');
  20. $users = data('users');
  21. $demands = data('demands');
  22. $productList = '';
  23. $mailtoList = '';
  24. foreach(explode(',', $demand->product) as $product) $productList .= zget($products, $product) . ', ';
  25. foreach(explode(',', $demand->mailto) as $user) $mailtoList .= zget($users, $user) . ', ';
  26. $items = array();
  27. if($config->vision == 'or') $items[$lang->demand->pool] = zget($demandpools, $demand->pool, '');
  28. if(!empty($demand->parent) && $demand->parent > 0)
  29. {
  30. $demandHtml = hasPriv('demand', 'view') ? div(setClass('flex'), a
  31. (
  32. zget($demands, $demand->parent),
  33. set::href(helper::createLink('demand', 'view', "demandID=$demand->parent")),
  34. set::title(zget($demands, $demand->parent)),
  35. setClass('basis-52 text-clip mr-2.5'),
  36. setData('toggle', 'modal'),
  37. setData('size', 'lg')
  38. ), $demand->parentVersion < $demand->parentInfo->version && common::hasPriv('demand', 'processDemandChange') ? span
  39. (
  40. ' (',
  41. $lang->story->storyChange . ' ',
  42. a(setClass('btn primary-pale border-primary size-xs ajax-submit'), set::href(createLink('demand', 'processDemandChange', "demandID={$demand->id}")), $lang->confirm),
  43. ')'
  44. ) : null) : zget($demands, $demand->parent);
  45. $items[$lang->demand->parent] = array
  46. (
  47. 'control' => 'div',
  48. 'content' => $demandHtml
  49. );
  50. }
  51. $productNames = trim($productList, ', ') ? trim($productList, ', ') : $lang->demand->undetermined;
  52. $items[$lang->demand->status] = array('control' => 'status', 'class' => 'status-story', 'status' => $demand->status, 'text' => zget($lang->demand->statusList, $demand->status));
  53. $items[$lang->demand->stage] = zget($lang->demand->stageList, $demand->stage);
  54. $items[$lang->demand->product] = array('control' => 'text', 'text' => $productNames, 'title' => $productNames, 'class' => 'whitespace-pre-line break-normal');
  55. $items[$lang->demand->pri] = array('control' => 'pri', 'text' => $lang->demand->priList, 'pri' => $demand->pri);
  56. $items[$lang->demand->category] = zget($lang->demand->categoryList, $demand->category);
  57. $items[$lang->demand->source] = zget($lang->demand->sourceList, $demand->source);
  58. $items[$lang->demand->sourceNote] = $demand->sourceNote;
  59. $items[$lang->demand->BSA] = zget($lang->demand->bsaList, $demand->BSA);
  60. $items[$lang->demand->duration] = zget($lang->demand->durationList, $demand->duration);
  61. $items[$lang->demand->feedbackedBy] = $demand->feedbackedBy;
  62. $items[$lang->demand->email] = $demand->email;
  63. $items[$lang->demand->keywords] = $demand->keywords;
  64. $items[$lang->demand->mailto] = trim($mailtoList, ', ');
  65. return $items;
  66. }
  67. protected function build()
  68. {
  69. return new datalist
  70. (
  71. set::className('demand-basec-info'),
  72. set::items($this->getItems())
  73. );
  74. }
  75. }