dialogTugou.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form;
  4. function queryGrid1(data) {
  5. console.log(data);
  6. }
  7. //查询小区
  8. function queryGrid2() {
  9. var _datas = [];
  10. $.yvan.ajax({
  11. async: false,
  12. method: 'post',
  13. url: api('/getAllUptown'),
  14. data: {userId: 0},
  15. success: function (data) {
  16. if (data.data != null && data.data != undefined) {
  17. for (var i = 0; i < data.data.length; i++) {
  18. _datas.push({
  19. "id": data.data[i].uptownId,
  20. "text": data.data[i].uptownName
  21. })
  22. }
  23. }
  24. }
  25. });
  26. return _datas;
  27. }
  28. return {
  29. xtype: 'dialog',
  30. dialogId: 'dialogTugou',
  31. title: context.isEdit ? '取消团购信息' : '新增团购信息',
  32. width: '100%',
  33. height: '100%',
  34. onOpen: function () {
  35. $dlg = $(this);
  36. if (context.isEdit) {
  37. $.yvan.ajax({
  38. loadingMask: false,
  39. url: api('/getSelectOne'),
  40. type: 'POST',
  41. data: {jmId: context.jmId},
  42. success: function (data) {
  43. $dlg.find('form');
  44. $form.formSet(data.data);
  45. }
  46. });
  47. }
  48. },
  49. center: {
  50. items: {
  51. width: '100%',
  52. height: '100%',
  53. autoSizeColumns: true,
  54. xtype: 'formgroup',
  55. onRender: function () {
  56. $form = $(this);
  57. },
  58. items: [
  59. [{
  60. name: 'jmId',
  61. label: '组团id',
  62. xtype: 'hidden',
  63. },
  64. {
  65. xtype: 'yvselect',
  66. name: 'uptownIds',
  67. multiple: true,
  68. label: '小区',
  69. data: queryGrid2(),
  70. width: 900,
  71. height: 35,
  72. validType: 'isBlank',
  73. readonly: context.isEdit ? true : false,
  74. onChange: function (data) {
  75. queryGrid1(data);
  76. },
  77. }],
  78. [
  79. {
  80. name: 'tgTitle',
  81. label: '组团标题',
  82. required: true,
  83. maxlength: 20,
  84. readonly: context.isEdit ? true : false,
  85. width: 450,
  86. height: 35, validType: 'isBlank'
  87. },
  88. {
  89. name: 'tgSupplier', label: '组织者', maxlength: 20,
  90. width: 450, height: 35,
  91. required: true,value:'指挥部',
  92. readonly: true ,
  93. },
  94. [{
  95. name: 'tgGoods', label: '团购套餐',
  96. required: true, width: 900, height: 35,
  97. maxlength: 50,
  98. readonly: context.isEdit ? true : false,
  99. height: '100px', multiline: true,
  100. }],
  101. {
  102. name: 'tgPrice',
  103. label: '单价',
  104. readonly: context.isEdit ? true : false,
  105. maxlength: 4, validType: 'integer',
  106. required: true, width: 450, height: 35,
  107. },
  108. {
  109. name: 'tgMinNum',
  110. label: '最小起订量',
  111. readonly: context.isEdit ? true : false,
  112. maxlength: 4, validType: 'integer',
  113. required: true, width: 450, height: 35,
  114. },
  115. [{
  116. name: 'tgMaxNum',
  117. readonly: context.isEdit ? true : false,
  118. label: '最大上限', required: true, validType: 'integer',
  119. maxlength: 4, width: 450, height: 35,
  120. },
  121. {
  122. name: 'tgEndTime',
  123. label: '团购截止时间',
  124. readonly: context.isEdit ? true : false,
  125. xtype: 'datetimebox',
  126. required: true, width: 450, height: 35,
  127. },],
  128. [{
  129. name: 'tgDeliverTime',
  130. multiline: true,
  131. readonly: context.isEdit ? true : false,
  132. xtype: 'datetimebox',
  133. label: '预计送货时间',
  134. required: true, width: 450, height: 35,
  135. },
  136. {
  137. name: 'tgPhoneNumber', validType: 'telNum',
  138. label: '联系电话', width: 450, height: 35,
  139. readonly: context.isEdit ? true : false,
  140. required: true, maxlength: 11,
  141. }],
  142. [{
  143. name: 'remark',
  144. label: '备注',
  145. multiline: true,
  146. width: 900,
  147. height: '100px',
  148. maxlength: 100,
  149. }]]
  150. ],
  151. }
  152. },
  153. buttons: [
  154. {
  155. text: "保存", iconCls: "fa fa-save", onClick: function () {
  156. if ($form.formGet().uptownIds.trim() == '') {
  157. $.yvan.msg('请先选择小区');
  158. return;
  159. }
  160. if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
  161. $.yvan.msg('最大上线必须大于等于最小起订量');
  162. return;
  163. }
  164. if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
  165. $.yvan.msg('团购截止时间必须小于预计送货时间');
  166. return;
  167. }
  168. console.log($form.formGet())
  169. $.yvan.postForm($form, {
  170. url: (context.isEdit ? api('/yeweihui/tgStatus') : api('/yeweihui/tgPublish')),
  171. success: function (data) {
  172. if (data.data == 1) {
  173. $.yvan.msg('保存成功');
  174. $dlg.window('close');
  175. if ($.type(context.confirm) === 'function') {
  176. context.confirm();
  177. }
  178. } else {
  179. $.yvan.msg('保存失败');
  180. }
  181. }
  182. });
  183. }
  184. }, {
  185. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  186. $dlg.dialog('close');
  187. }
  188. }
  189. ]
  190. };
  191. };
  192. });