define(function (require) { return function () { var $form, $select1; var data1 = [ { id: '千米', text: '千米(km)' }, { id: '米', text: '米(m)' }, { id: '分米', text: '分米(dm)' }, { id: '厘米', text: '厘米(cm)' }, { id: '毫米', text: '毫米(mm)' }, { id: '微米', text: '微米(um)' }, { id: '纳米', text: '纳米(nm)' }, { id: '皮米', text: '皮米(pm)' }, { id: '光年', text: '光年(ly)' }, { id: '天文单位', text: '天文单位(AU)' }, { id: '英寸', text: '英寸(in)' }, { id: 'inch', text: 'inch(in)' }, { id: '英尺', text: '英尺(ft)' }, { id: '码', text: '码(yd)' }, { id: '英里', text: '英里(mi)' }, { id: '海里', text: '海里(nmi)' }, { id: '英寻', text: '英寻(fm)' }, { id: '弗隆', text: '弗隆(fur)' }, { id: '里', text: '里' }, { id: '丈', text: '丈' }, { id: '尺', text: '尺' }, { id: '寸', text: '寸' }, { id: '分', text: '分' }, { id: '厘', text: '厘' }, { id: '毫', text: '毫' }, ]; var data2 = [ { text: '公制', children: [ { id: '千米', text: '千米(km)' }, { id: '米', text: '米(m)' }, { id: '分米', text: '分米(dm)' }, { id: '厘米', text: '厘米(cm)' }, { id: '毫米', text: '毫米(mm)' }, { id: '微米', text: '微米(um)' }, { id: '纳米', text: '纳米(nm)' }, { id: '皮米', text: '皮米(pm)' }, { id: '光年', text: '光年(ly)' }, { id: '天文单位', text: '天文单位(AU)' }, ], }, { text: '英制', children: [ { id: '英寸', text: '英寸(in)' }, { id: 'inch', text: 'inch(in)' }, { id: '英尺', text: '英尺(ft)' }, { id: '码', text: '码(yd)' }, { id: '英里', text: '英里(mi)' }, { id: '海里', text: '海里(nmi)' }, { id: '英寻', text: '英寻(fm)' }, { id: '弗隆', text: '弗隆(fur)' }, ], }, { text: '市制', children: [ { id: '里', text: '里' }, { id: '丈', text: '丈' }, { id: '尺', text: '尺' }, { id: '寸', text: '寸' }, { id: '分', text: '分' }, { id: '厘', text: '厘' }, { id: '毫', text: '毫' }, ], } ]; return { center: { items: { xtype: 'form', onRender: function () { $form = $(this); }, items: [ [ { xtype: 'yvselect', name: 'packingType', label: '系统标准', required: true, onRender: function () { $select1 = $(this); }, data: data1, onChange: function (newValue, e) { console.log('packingType onChange:"' + newValue + '"', e); } }, ], [ { xtype: 'yvselect', name: 'unit', label: '单位转换', required: true, data: data2, onChange: function (newValue, e) { console.log('unit onChange:"' + newValue + '"', e); } }, ], [ { xtype: 'yvselect', name: 'unit2', label: '多选', required: true, span: 2, multiple: true, minTagLength: 1, maxTagLength: 3, data: data2, onChange: function (newValue, e) { console.log('unit2 onChange:"' + newValue + '"', e); } }, ], [ { xtype: 'textbox', name: 'custom', label: '自定义', required: true }, { xtype: 'textbox', name: 'custom2', label: '自定义2', required: true }, ], [ { xtype: 'offset' }, { xtype: 'button', text: '设值', onClick: function () { $form.formSet({ custom: '自定义1', custom2: '自定义2', packingType: '米', unit: '英寸', unit2: '米,光年' }); } }, { xtype: 'button', text: '取值', onClick: function () { $.yvan.alert(JSON.stringify( $form.formGet(), null, " ")); } }, { xtype: 'button', text: '清空', onClick: function () { $form.formClear(); } }, { xtype: 'button', text: '校验', onClick: function () { $.yvan.postForm($form, { url: demoApi('/aaa') }); } } ], [ { xtype: 'offset' }, { xtype: 'button', text: 'mulpGet', onClick: function () { var $unit2 = $form.item('unit2'); $.yvan.alert(JSON.stringify( $unit2.yvselect('getValue'), null, " ")); } }, { xtype: 'button', text: 'mulpSet', onClick: function () { var $unit2 = $form.item('unit2'); $unit2.yvselect('setValue', ['米', '千米']); } }, ], [ { xtype: 'offset' }, { xtype: 'button', text: '动态更改', onClick: function () { $select1.yvselect({ data: data2 }); } }, ] ] } } }; }; });