dialogTugou.js 6.6 KB

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