dialogId.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg;
  4. return {
  5. xtype: 'dialog',
  6. dialogId: 'dialogld',
  7. title: context.isEdit ? '新增' : '编辑' + 'ID标识',
  8. width: 400,
  9. height: 460,
  10. onOpen: function () {
  11. console.log('onBeforeClose');
  12. $dlg = $(this);
  13. $dlg.formSet(context.row);
  14. },
  15. center: {
  16. items: {
  17. xtype: 'form',
  18. items: [
  19. [{name: 'idName', label: 'ID标识', required: true}],
  20. [{name: 'idDesc', label: '标识说明', required: true}],
  21. [{name: 'idType', label: '编号生成规则', labelWidth: 'auto'}],
  22. [{name: 'idExpress', label: '序号类型', required: true}]
  23. ]
  24. }
  25. },
  26. buttons: [
  27. {
  28. text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
  29. //关闭方法
  30. $dlg.window('close');
  31. }
  32. },
  33. {
  34. text: '保存', iconCls: 'fa fa-save', onClick: function () {
  35. var newData = $dlg.formGet();
  36. if (newData.idName === null || newData.idName === '') {
  37. $.yvan.msg('请填ID标识');
  38. return;
  39. }
  40. if (newData.idDesc === null || newData.idDesc === '') {
  41. $.yvan.msg('请填标识说明');
  42. return;
  43. }
  44. // if (newData.idType === null || newData.idType === '') {
  45. // $.yvan.msg('请填编号生成规则');
  46. // return;
  47. // }
  48. if (newData.idExpress === null || newData.idExpress === '') {
  49. $.yvan.msg('请填序号类型');
  50. return;
  51. }
  52. var url = '/sys/Code/edit';
  53. if (context.isEdit === false) {
  54. url = '/sys/Code/add';
  55. }
  56. $.yvan.ajax({
  57. url: api(url),
  58. contentType: "application/json; charset=utf-8",
  59. data: JSON.stringify(newData),
  60. method: 'post',
  61. success: function (data) {
  62. $.yvan.msg(data.msg);
  63. $dlg.window('close');
  64. context.ok();
  65. },
  66. error: function (data) {
  67. $.yvan.msg(data.msg);
  68. }
  69. });
  70. }
  71. }
  72. ]
  73. }
  74. }
  75. });