dialogSysUnit.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form;
  4. return {
  5. xtype: 'dialog',
  6. dialogId: 'dialogSysUnit',
  7. title: '单位信息维护',
  8. width: 650,
  9. height: 350,
  10. onOpen: function () {
  11. $dlg = $(this);
  12. if (context.isEdit) {
  13. $.yvan.ajax({
  14. loadingMask: false,
  15. url: api('/sys/sysUnit/getById'),
  16. type: 'GET',
  17. data: {
  18. unitId: context.unitId
  19. },
  20. success: function (data) {
  21. $dlg.find('form');
  22. if (!isNotNull(data) || !isNotNull(data.data)) {
  23. return;
  24. }
  25. $form.formSet(data.data);
  26. }
  27. });
  28. } else {
  29. $form.formSet({
  30. beActive: 'Y',
  31. status: 1,
  32. isBase: 0,
  33. unitType: context.unitType
  34. });
  35. }
  36. },
  37. center: {
  38. items: {
  39. xtype: 'formgroup',
  40. subLabelWidth: '100',
  41. subControlWidth: '200',
  42. onRender: function () {
  43. $form = $(this);
  44. },
  45. items: [[
  46. {name: 'unitId', xtype: 'hidden'}, // no hidden: true
  47. {
  48. name: 'unitType', label: '单位类型', xtype: 'yvselect', required: true,
  49. data: $.yvan.sysDict('unitType').combo(),
  50. onChange: function (data) {
  51. var apiData = {
  52. unitType: $form.formGet().unitType
  53. };
  54. $.yvan.ajax({
  55. method: 'get',
  56. url: api('/sys/sysUnit/getUnitBase'),
  57. data: apiData,
  58. success: function (data) {
  59. var unitName = "";
  60. if (data.data != null) {
  61. unitName = data.data.unitName;
  62. $form.formSet({
  63. unitBase: unitName,
  64. isBase: 0
  65. });
  66. }
  67. }
  68. });
  69. }
  70. },
  71. {
  72. name: 'isBase', label: '基础单位', xtype: 'yvselect', required: true,
  73. data: $.yvan.sysDict('yesOrNo').combo()
  74. },
  75. {name: 'unitName', label: '单位名称', required: true, ff: 500},
  76. {name: 'unitMark', label: '符号', required: true, ff: 500},
  77. {name: 'unitVal', label: '转换值'},
  78. {name: 'unitBase', label: '基础单位', readonly: true},
  79. {name: 'sort', label: '排序'},
  80. {
  81. name: 'status', label: '状态', xtype: 'yvselect', required: true,
  82. data: $.yvan.sysDict('status').combo()
  83. },
  84. {name: 'remark', label: '备注', span: 2, height: 45, multiline: true, ff: 500},
  85. ]]
  86. }
  87. },
  88. buttons: [
  89. {
  90. text: "提交", iconCls: "fa fa-save", onClick: function () {
  91. $.yvan.postForm($form, {
  92. url: (context.isEdit ? api('/sys/sysUnit/update') : api('/sys/sysUnit/insert')),
  93. success: function () {
  94. $.yvan.msg('操作成功');
  95. if (context.isEdit) {
  96. $dlg.window('close');
  97. }
  98. if ($.type(context.confirm) === 'function') {
  99. context.confirm();
  100. }
  101. },
  102. error: function (data) {
  103. }
  104. });
  105. }
  106. }, {
  107. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  108. $dlg.dialog('close');
  109. }
  110. }
  111. ]
  112. };
  113. };
  114. });