dialogTugou.js 6.0 KB

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