dialogUnitConver.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form;
  4. //获取单位信息
  5. function getUnitList() {
  6. var _datas = [];
  7. $.yvan.ajax({
  8. url: api('/sys/sysUnit/queryAll'),
  9. data: {unitType: context.unitType},
  10. method: 'post',
  11. async: false,
  12. success: function (data) {
  13. if (data.data != null && data.data != undefined) {
  14. for (var i = 0; i < data.data.length; i++) {
  15. _datas.push({
  16. "id": data.data[i].unitName,
  17. "text": data.data[i].unitName
  18. })
  19. }
  20. }
  21. }
  22. });
  23. return _datas;
  24. }
  25. function unitConver() {
  26. var unitVal = $form.formGet().unitVal;
  27. var unitA = $form.formGet().unitA;
  28. var unitB = $form.formGet().unitB;
  29. if (unitA == "" || unitB == "" || unitVal == "")
  30. return;
  31. var apiData = {
  32. unitVal: $form.formGet().unitVal,
  33. unitA: $form.formGet().unitA,
  34. unitB: $form.formGet().unitB,
  35. };
  36. $.yvan.ajax({
  37. method: 'post',
  38. url: api('/sys/sysUnitCv/getConverVal'),
  39. data: apiData,
  40. success: function (data) {
  41. //$form.setValue("unitConver", data.data.unitCv)
  42. //$.yvan.msg(data.data);
  43. $form.formSet({
  44. unitConver: data.data
  45. });
  46. }
  47. });
  48. }
  49. return {
  50. xtype: 'dialog',
  51. dialogId: 'dialogUnitConver',
  52. title: '换算信息',
  53. width: 900,
  54. height: 200,
  55. onOpen: function () {
  56. $dlg = $(this);
  57. },
  58. center: {
  59. items: {
  60. xtype: 'formgroup',
  61. onRender: function () {
  62. $form = $(this);
  63. },
  64. items: [[
  65. {
  66. name: 'unitVal', label: '换算值', required: true,
  67. onChange: function () {
  68. unitConver();
  69. }
  70. },
  71. {
  72. name: 'unitA',
  73. label: '',
  74. xtype: 'yvselect',
  75. required: true,
  76. value: context.unitA,
  77. panelHeight: 220,
  78. width: 100,
  79. data: getUnitList(),
  80. onChange: function () {
  81. unitConver();
  82. }
  83. },
  84. {
  85. name: 'unitB',
  86. label: '',
  87. xtype: 'yvselect',
  88. required: true,
  89. panelHeight: 220,
  90. width: 100,
  91. data: getUnitList(),
  92. onChange: function () {
  93. unitConver();
  94. }
  95. },
  96. {name: 'unitConver', label: '换算率'},
  97. ]]
  98. }
  99. },
  100. buttons: [
  101. {
  102. text: "提交", iconCls: "fa fa-save", onClick: function () {
  103. $.yvan.postForm($form, {
  104. url: api('/sys/sysUnitCv/getConverVal'),
  105. success: function (data) {
  106. alert(data);
  107. }
  108. });
  109. }
  110. }, {
  111. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  112. $dlg.dialog('close');
  113. }
  114. }
  115. ]
  116. };
  117. };
  118. });