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. required: true,
  90. onChange: function (data) {
  91. },
  92. }, {
  93. name: 'tgPrice',
  94. label: '单价',
  95. readonly: context.isEdit ? true : false,
  96. maxlength: 6, validType: 'number',
  97. width: 450, height: 35,
  98. },
  99. ],
  100. [{
  101. name: 'tgGoods', label: '套餐描述',
  102. required: true, width: 900, height: 35,
  103. maxlength: 500,
  104. readonly: context.isEdit ? true : false,
  105. height: '100px', multiline: true,
  106. }],
  107. [{
  108. name: 'tgMinNum',
  109. label: '最低配送',
  110. readonly: context.isEdit ? true : false,
  111. maxlength: 4, validType: 'integer',
  112. width: 450, height: 35,
  113. }, {
  114. name: 'tgMaxNum',
  115. readonly: context.isEdit ? true : false,
  116. label: '配送上限', validType: 'integer',
  117. maxlength: 4, width: 450, height: 35,
  118. }],
  119. [{
  120. name: 'tgEndTime',
  121. label: '需求截止时间',
  122. readonly: context.isEdit ? true : false,
  123. xtype: 'datetimebox',
  124. required: true, width: 450, height: 35,
  125. }, {
  126. name: 'tgDeliverTime',
  127. multiline: true,
  128. readonly: context.isEdit ? true : false,
  129. xtype: 'datetimebox',
  130. label: '预计配货时间',
  131. required: true, width: 450, height: 35,
  132. },
  133. {
  134. name: 'tgPhoneNumber', validType: 'telNum',
  135. label: '联系电话', width: 450, height: 35,
  136. readonly: context.isEdit ? true : false,
  137. required: true, maxlength: 11,
  138. },
  139. {
  140. name: 'tgSupplier', width: 450, height: 35,
  141. label: '供应商', maxlength: 20,
  142. }],
  143. ],
  144. }
  145. },
  146. buttons: [
  147. {
  148. text: "保存", iconCls: "fa fa-save", onClick: function () {
  149. if ($form.formGet().uptownIds == '') {
  150. $.yvan.msg('请先选择小区');
  151. return;
  152. }
  153. if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
  154. $.yvan.msg('最大上限必须大于等于最小起订量');
  155. return;
  156. }
  157. if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
  158. $.yvan.msg('团购截止时间必须小于预计送货时间');
  159. return;
  160. }
  161. console.log($form.formGet());
  162. if (isLoading === true) {
  163. return;
  164. }
  165. else {
  166. isLoading = true;
  167. }
  168. $.yvan.postForm($form, {
  169. url: (context.isEdit ? api('/yeweihui/tgStatus') : api('/yeweihui/tgPublish')),
  170. success: function (data) {
  171. isLoading = false;
  172. console.log("返回数据", data);
  173. if (data.success == true) {
  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. });