dialogTugou.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: 4, validType: 'integer',
  97. width: 450, height: 35,
  98. },
  99. {
  100. name: 'tgSupplier',
  101. label: '指挥部',
  102. xtype: 'hidden',
  103. value:'指挥部',
  104. }
  105. ],
  106. [{
  107. name: 'tgGoods', label: '套餐描述',
  108. required: true, width: 900, height: 35,
  109. maxlength: 500,
  110. readonly: context.isEdit ? true : false,
  111. height: '100px', multiline: true,
  112. }],
  113. [{
  114. name: 'tgMinNum',
  115. label: '最低配送',
  116. readonly: context.isEdit ? true : false,
  117. maxlength: 4, validType: 'integer',
  118. width: 450, height: 35,
  119. }, {
  120. name: 'tgMaxNum',
  121. readonly: context.isEdit ? true : false,
  122. label: '配送上限', validType: 'integer',
  123. maxlength: 4, width: 450, height: 35,
  124. }],
  125. [{
  126. name: 'tgEndTime',
  127. label: '需求截止时间',
  128. readonly: context.isEdit ? true : false,
  129. xtype: 'datetimebox',
  130. required: true, width: 450, height: 35,
  131. }, {
  132. name: 'tgDeliverTime',
  133. multiline: true,
  134. readonly: context.isEdit ? true : false,
  135. xtype: 'datetimebox',
  136. label: '预计配货时间',
  137. required: true, width: 450, height: 35,
  138. },
  139. {
  140. name: 'tgPhoneNumber', validType: 'telNum',
  141. label: '联系电话', width: 450, height: 35,
  142. readonly: context.isEdit ? true : false,
  143. required: true, maxlength: 11,
  144. }],
  145. ],
  146. }
  147. },
  148. buttons: [
  149. {
  150. text: "保存", iconCls: "fa fa-save", onClick: function () {
  151. if ($form.formGet().uptownIds == '') {
  152. $.yvan.msg('请先选择小区');
  153. return;
  154. }
  155. if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
  156. $.yvan.msg('最大上限必须大于等于最小起订量');
  157. return;
  158. }
  159. if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
  160. $.yvan.msg('团购截止时间必须小于预计送货时间');
  161. return;
  162. }
  163. console.log($form.formGet());
  164. if (isLoading === true) {
  165. return;
  166. }
  167. else {
  168. isLoading = true;
  169. }
  170. $.yvan.postForm($form, {
  171. url: (context.isEdit ? api('/yeweihui/tgStatus') : api('/yeweihui/tgPublish')),
  172. success: function (data) {
  173. isLoading = false;
  174. console.log("返回数据", data);
  175. if (data.success == true) {
  176. $.yvan.msg('保存成功');
  177. $dlg.window('close');
  178. if ($.type(context.confirm) === 'function') {
  179. context.confirm();
  180. }
  181. } else {
  182. $.yvan.msg('保存失败');
  183. }
  184. }
  185. });
  186. }
  187. }, {
  188. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  189. $dlg.dialog('close');
  190. }
  191. }
  192. ]
  193. }
  194. ;
  195. };
  196. });