engine4.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. define(function (require, exports, module) {
  2. return function () {
  3. var test1 = require('/yvanui/example/test1.js');
  4. var test2 = require('/yvanui/example/test2.js');
  5. var root = {
  6. center: {
  7. border: false,
  8. items: {
  9. xtype: 'div',
  10. id: 'thediv',
  11. items: [
  12. {
  13. xtype: 'toolbar',
  14. title: ' ',
  15. items: [{
  16. text: '读取', onClick: function () {
  17. console.log($(this).up('power').down('div').formGet());
  18. }
  19. }, {
  20. text: '找Item', onClick: function () {
  21. $(this).up('power').down('div').item('b1').textbox('setValue', '找到b1');
  22. $(this).up('power').down('div').item('c2').textbox('setValue', '找到c2');
  23. }
  24. }, {
  25. text: '改值1', onClick: function () {
  26. $(this).up('power').down('div').formSet({
  27. a1: 'aaaa1',
  28. a6: 'aaaa6',
  29. tf3: {
  30. c1: "ccc!c1-m1",
  31. c2: "ccc!c2-m2",
  32. c3: "ccc!c3-m2",
  33. c4: "ccc!c4-m2"
  34. },
  35. tf4: {
  36. beActive: 'Y'
  37. }
  38. });
  39. }
  40. }, {
  41. text: '改值2', onClick: function () {
  42. $(this).up('power').down('div').formSet({
  43. a1: '改了!a1',
  44. a6: '改了!a6',
  45. tf3: {
  46. c1: "改了!c1-m1",
  47. c2: "改了!c2-m2",
  48. c3: "改了!c3-m2",
  49. c4: "改了!c4-m2"
  50. },
  51. tf4: {
  52. beActive: 'N'
  53. }
  54. });
  55. }
  56. }, {
  57. text: '清空', onClick: function () {
  58. $(this).up('power').down('div').formClear();
  59. }
  60. }, {
  61. text: 'Combobox1', onClick: function () {
  62. $('#cgg1').formSet({
  63. cb1: 'v11',
  64. cb2: 'v21',
  65. cb3: 'v31'
  66. });
  67. }
  68. }, {
  69. text: 'Combobox2', onClick: function () {
  70. $('#cgg1').formSet({
  71. cb1: 'v13',
  72. cb2: 'v23',
  73. cb3: 'v33'
  74. });
  75. }
  76. }]
  77. },
  78. {
  79. xtype: 'group',
  80. title: 'Combobox', items: {
  81. xtype: 'form', id: 'cgg1', items: [[
  82. {
  83. label: 'cb1', name: 'cb1', xtype: 'combobox', data: test1,
  84. required: true,
  85. }, {
  86. label: 'cb2', name: 'cb2', xtype: 'combobox', data: test2,
  87. required: true,
  88. }, {
  89. label: 'cb3', name: 'cb3', xtype: 'combobox',
  90. required: true,
  91. data: [
  92. { id: 'v31', text: 't31' },
  93. { id: 'v32', text: 't32' },
  94. { id: 'v33', text: 't33' },
  95. { id: 'v34', text: 't34' }
  96. ]
  97. },
  98. ]]
  99. }
  100. },
  101. {
  102. xtype: 'group',
  103. title: '平级对象', items: {
  104. //如果 form 没名字,视为当前对象
  105. xtype: 'form', items: [[
  106. { label: 'a1', name: 'a1', value: 'a1' },
  107. {
  108. xtype: 'form', items: [[
  109. { label: 'a2', name: 'a2', value: 'a2' },
  110. { label: 'a3', name: 'a3', value: 'a3' }
  111. ]]
  112. },
  113. { label: 'a4', name: 'a4', value: 'a4' },
  114. { label: 'a5', name: 'a5', value: 'a5' },
  115. { label: 'a6', name: 'a6', value: 'a6' }
  116. ]]
  117. }
  118. },
  119. {
  120. xtype: 'group',
  121. title: '独立表单-tf1', items: {
  122. //如果 form 有名字,则视为子对象
  123. xtype: 'form', id: 'tf1', name: 'tf1', items: [[
  124. { label: 'b1', name: 'b1', value: 'b1' },
  125. { label: 'b2', name: 'b2', value: 'b2' },
  126. { label: 'b3', name: 'b3', value: 'b3' }
  127. ]]
  128. }
  129. },
  130. {
  131. xtype: 'group',
  132. title: '独立表单-tf2', items: {
  133. //如果 form 有名字,则视为子对象
  134. xtype: 'form', name: 'tf2', items: [[
  135. { label: 'b2', name: 'b2', value: 'b2' },
  136. { label: 'b3', name: 'b3', value: 'b3' },
  137. { label: 'b4', name: 'b4', value: 'b4' }
  138. ]]
  139. }
  140. },
  141. {
  142. xtype: 'group',
  143. title: '合并表单1-tf3', items: {
  144. //如果 form 有相同名字,视为合并
  145. xtype: 'form', name: 'tf3', items: [[
  146. { label: 'c1', name: 'c1', value: 'c1-m1' },
  147. { label: 'c2', name: 'c2', value: 'c2-m1' },
  148. { label: 'c3', name: 'c3', value: 'c3-m1' }
  149. ]]
  150. }
  151. },
  152. {
  153. xtype: 'group',
  154. title: '合并表单2-tf3', items: {
  155. //如果 form 有相同名字,视为合并
  156. xtype: 'form', name: 'tf3', items: [[
  157. { label: 'c2', name: 'c2', value: 'c2-m2' },
  158. { label: 'c3', name: 'c3', value: 'c3-m2' },
  159. { label: 'c4', name: 'c4', value: 'c4-m2' }
  160. ]]
  161. }
  162. },
  163. {
  164. xtype: 'group',
  165. title: '表单重名视为数组-tf4', items: {
  166. //如果 form 有相同名字,视为合并
  167. xtype: 'form', name: 'tf4', items: [[
  168. { label: 'd1', name: 'd1', value: 'd1-m1' },
  169. { label: 'd1', name: 'd1', value: 'd1-m2' },
  170. { label: 'd4', name: 'd4', value: 'd4' },
  171. {
  172. xtype: 'combobox', name: 'beActive', label: '是否活动',
  173. data: [
  174. { id: 'Y', text: '是' },
  175. { id: 'N', text: '否' }
  176. ]
  177. }
  178. ]]
  179. }
  180. }]
  181. }
  182. }
  183. };
  184. return root;
  185. };
  186. });