v1.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * The searchForm widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author sunhao<sunhao@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. /**
  13. * 搜索面板(searchForm)部件类
  14. * The searchForm widget class
  15. */
  16. class searchForm extends wg
  17. {
  18. /**
  19. * Define widget properties.
  20. *
  21. * @var array
  22. * @access protected
  23. */
  24. protected static $defineProps = array
  25. (
  26. 'id?: string', // ID,可以与 searchToggle 配合使用。
  27. 'module: string', // 模块。
  28. 'container?: string', // 容器元素选择器,当被打开时在容器元素上显示类 show-search-form。
  29. 'show?: boolean', // 是否默认展示。
  30. 'simple?: boolean', // 是否为简单模式,不包含保存搜索条件和已保存的查询条件侧边栏。
  31. 'setting?: array', // 默认配置。
  32. 'url?: string', // 配置加载地址,默认为 search-buildForm-module。
  33. 'searchUrl?: string', // 搜索时提交表单的 URL。
  34. 'searchLoader?: string|array' // 搜索时 loadPage 参数。
  35. );
  36. /**
  37. * Build widget.
  38. *
  39. * @access protected
  40. * @return mixed
  41. */
  42. protected function build()
  43. {
  44. global $config;
  45. if(isset($config->zin->mode) && $config->zin->mode == 'compatible')
  46. {
  47. if(!$this->hasProp('url')) $this->setProp('url', createLink('search', 'buildZinForm', 'module=' . $this->prop('module')));
  48. if(!$this->hasProp('searchUrl')) $this->setProp('searchUrl', createLink('search', 'buildZinQuery'));
  49. }
  50. return zui::searchForm
  51. (
  52. inherit($this),
  53. set::_children
  54. (
  55. on::init()->do('$element.attr("data-last-url", $.apps.getAppUrl())'),
  56. on::skipMorph()
  57. ->beginIf('$.apps.getAppUrl() !== $element.attr("data-last-url")')
  58. ->do
  59. (
  60. '$element.attr("data-last-url", $.apps.getAppUrl())',
  61. 'zui.SearchForm.get($element).$.load(true)'
  62. )
  63. ->endIf()
  64. )
  65. );
  66. }
  67. }