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