dialogSysUnitConver.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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, unitId: context.unitIdA},
  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].unitId,
  17. "text": data.data[i].unitName
  18. })
  19. }
  20. }
  21. }
  22. });
  23. return _datas;
  24. }
  25. return {
  26. xtype: 'dialog',
  27. dialogId: 'dialogSysUnitConver',
  28. title: '换算信息',
  29. width: 900,
  30. height: 200,
  31. onOpen: function () {
  32. $dlg = $(this);
  33. if (context.isEdit) {
  34. $.yvan.ajax({
  35. loadingMask: false,
  36. url: api('/sys/sysUnitCv/getById'), // 需要改,不然不能显示非数据库中的字段信息
  37. type: 'GET',
  38. data: {
  39. converId: context.converId,
  40. },
  41. success: function (data) {
  42. $dlg.find('form');
  43. if (!isNotNull(data) || !isNotNull(data.data)) {
  44. return;
  45. }
  46. $form.formSet(data.data);
  47. }
  48. });
  49. } else {
  50. $form.formSet({
  51. beActive: 'Y'
  52. });
  53. }
  54. },
  55. center: {
  56. items: {
  57. xtype: 'formgroup',
  58. onRender: function () {
  59. $form = $(this);
  60. },
  61. items: [[
  62. {name: 'converId', xtype: 'hidden'},
  63. {name: 'numa', label: '转换单位A', required: true},
  64. {name: 'unitIda', label: '转换单位A', value: context.unitIdA, xtype: 'hidden'},
  65. {name: 'numb', label: context.unitNameA + '=', required: true},
  66. {
  67. name: 'unitIdb',
  68. label: '转换单位B',
  69. xtype: 'yvselect',
  70. required: true,
  71. panelHeight: 220,
  72. data: getUnitList(),
  73. ff: 500,
  74. },
  75. ]]
  76. }
  77. },
  78. buttons: [
  79. {
  80. text: "提交", iconCls: "fa fa-save", onClick: function () {
  81. $.yvan.postForm($form, {
  82. url: (context.isEdit ? api('/sys/sysUnitCv/update') : api('/sys/sysUnitCv/insert')),
  83. success: function () {
  84. $.yvan.msg('操作成功');
  85. if (context.isEdit) {
  86. $dlg.window('close');
  87. }
  88. if ($.type(context.confirm) === 'function') {
  89. context.confirm();
  90. }
  91. }
  92. });
  93. }
  94. }, {
  95. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  96. $dlg.dialog('close');
  97. }
  98. }
  99. ]
  100. };
  101. };
  102. });