addDoor.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form, isEdit = false;
  4. var widgets = {
  5. // 小区搜索
  6. selectUptownWidget: {
  7. url: '/app/whepi/scan/uptownWidget.js',
  8. bind: {
  9. uptownId: 'uptownId',
  10. uptownName: 'uptownName'
  11. }
  12. },
  13. };
  14. return {
  15. xtype: 'dialog',
  16. dialogId: 'dialogEnvLog',
  17. title: context.isEdit ? '编辑大门基本信息' : '新增大门基本信息',
  18. width: 450,
  19. height: 300,
  20. onOpen: function () {
  21. $dlg = $(this);
  22. if (context.isEdit) {
  23. $.yvan.ajax({
  24. loadingMask: false,
  25. url: api('/qrImg/getDoorById'),
  26. type: 'GET',
  27. data: {doorId: context.doorId},
  28. success: function (data) {
  29. $dlg.find('form');
  30. $form.formSet(data.data);
  31. }
  32. });
  33. }
  34. },
  35. center: {
  36. items: {
  37. width: 450,
  38. height: 756,
  39. autoSizeColumns: true,
  40. xtype: 'formgroup',
  41. onRender: function () {
  42. $form = $(this);
  43. },
  44. items: [
  45. [
  46. {name: 'doorId', xtype: 'hidden'},
  47. {label: '小区ID', name: 'uptownId', xtype: 'hidden', widget: widgets.selectUptownWidget},
  48. {
  49. name: 'uptownName',
  50. label: '小区名称',
  51. xtype: 'searchbox',
  52. maxlength: 60,
  53. width: 350,
  54. required: true,
  55. widget: widgets.selectUptownWidget
  56. },
  57. {
  58. name: 'doorName',
  59. label: '大门名称',
  60. required: true,
  61. maxlength: 60,
  62. width: 350,
  63. },]
  64. ],
  65. }
  66. },
  67. buttons: [
  68. {
  69. text: "保存", iconCls: "fa fa-save", onClick: function () {
  70. $.yvan.postForm($form, {
  71. url: (context.isEdit ? api('/qrImg/updateDoor') : api('/qrImg/insertDoor')),
  72. success: function (data) {
  73. if (data.data == 1) {
  74. $.yvan.msg('保存成功');
  75. $dlg.window('close');
  76. if ($.type(context.confirm) === 'function') {
  77. context.confirm();
  78. }
  79. }
  80. }
  81. });
  82. }
  83. }, {
  84. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  85. $dlg.dialog('close');
  86. }
  87. }
  88. ]
  89. };
  90. };
  91. });