define(function (require) { return function (context) { var $dlg, $form; //获取单位信息 function getUnitList() { var _datas = []; $.yvan.ajax({ url: api('/sys/sysUnit/queryAll'), data: {unitType: context.unitType}, method: 'post', async: false, success: function (data) { if (data.data != null && data.data != undefined) { for (var i = 0; i < data.data.length; i++) { _datas.push({ "id": data.data[i].unitName, "text": data.data[i].unitName }) } } } }); return _datas; } function unitConver() { var unitVal = $form.formGet().unitVal; var unitA = $form.formGet().unitA; var unitB = $form.formGet().unitB; if (unitA == "" || unitB == "" || unitVal == "") return; var apiData = { unitVal: $form.formGet().unitVal, unitA: $form.formGet().unitA, unitB: $form.formGet().unitB, }; $.yvan.ajax({ method: 'post', url: api('/sys/sysUnitCv/getConverVal'), data: apiData, success: function (data) { //$form.setValue("unitConver", data.data.unitCv) //$.yvan.msg(data.data); $form.formSet({ unitConver: data.data }); } }); } return { xtype: 'dialog', dialogId: 'dialogUnitConver', title: '换算信息', width: 900, height: 200, onOpen: function () { $dlg = $(this); }, center: { items: { xtype: 'formgroup', onRender: function () { $form = $(this); }, items: [[ { name: 'unitVal', label: '换算值', required: true, onChange: function () { unitConver(); } }, { name: 'unitA', label: '', xtype: 'yvselect', required: true, value: context.unitA, panelHeight: 220, width: 100, data: getUnitList(), onChange: function () { unitConver(); } }, { name: 'unitB', label: '', xtype: 'yvselect', required: true, panelHeight: 220, width: 100, data: getUnitList(), onChange: function () { unitConver(); } }, {name: 'unitConver', label: '换算率'}, ]] } }, buttons: [ { text: "提交", iconCls: "fa fa-save", onClick: function () { $.yvan.postForm($form, { url: api('/sys/sysUnitCv/getConverVal'), success: function (data) { alert(data); } }); } }, { text: "关闭", iconCls: "fa fa-times", onClick: function () { $dlg.dialog('close'); } } ] }; }; });