123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- define(function (require) {
- return function (context) {
- var $dlg, $form;
- var isLoading = false;
- function queryGrid1(data) {
- console.log(data);
- }
- //查询小区
- function queryGrid2() {
- var _datas = [];
- $.yvan.ajax({
- async: false,
- method: 'post',
- url: api('/getAllUptown'),
- data: {userId: 0},
- success: function (data) {
- if (data.data != null && data.data != undefined) {
- for (var i = 0; i < data.data.length; i++) {
- _datas.push({
- "id": data.data[i].uptownId,
- "text": data.data[i].uptownName
- })
- }
- }
- }
- });
- return _datas;
- }
- return {
- xtype: 'dialog',
- dialogId: 'dialogTugou',
- title: context.isEdit ? '取消团购信息' : '新增团购信息',
- width: '100%',
- height: '100%',
- onOpen: function () {
- $dlg = $(this);
- if (context.isEdit) {
- $.yvan.ajax({
- loadingMask: false,
- url: api('/getSelectOne'),
- type: 'POST',
- data: {jmId: context.jmId},
- success: function (data) {
- $dlg.find('form');
- $form.formSet(data.data);
- }
- });
- }
- },
- center: {
- items: {
- width: '100%',
- height: '100%',
- autoSizeColumns: true,
- xtype: 'formgroup',
- onRender: function () {
- $form = $(this);
- },
- items: [
- [{
- name: 'jmId',
- label: '组团id',
- xtype: 'hidden',
- },
- {
- xtype: 'yvselect',
- name: 'uptownIds',
- multiple: true,
- label: '发布小区',
- data: queryGrid2(),
- width: 900,
- height: 35,
- validType: 'isBlank',
- readonly: context.isEdit ? true : false,
- onChange: function (data) {
- queryGrid1(data);
- },
- }],
- [{
- xtype: 'yvselect',
- name: 'uptownIds',
- label: '需求类型',
- data: [{id: '1', text: '食蔬采购'}, {id: '2', text: '药品采购'}, {id: '3', text: '医疗服务'}, {
- id: '4',
- text: '生活用品'
- }, {id: '5', text: '其他服务'}],
- width: 450,
- height: 35,
- onChange: function (data) {
- },
- },{
- name: 'tgPrice',
- label: '单价',
- readonly: context.isEdit ? true : false,
- maxlength: 4, validType: 'integer',
- width: 450, height: 35,
- }
- /*{
- name: 'tgTitle',
- label: '发布标题',
- readonly: true,
- value: value,
- width: 450,
- height: 35, validType: 'isBlank',
- onRender: function () {
- $combRow = $(this);
- }
- }*/
- ],
- [{
- name: 'tgGoods', label: '套餐描述',
- required: true, width: 900, height: 35,
- maxlength: 500,
- readonly: context.isEdit ? true : false,
- height: '100px', multiline: true,
- }],
- /* [{
- name: 'tgPrice',
- label: '单价',
- readonly: context.isEdit ? true : false,
- maxlength: 4, validType: 'integer',
- required: true, width: 450, height: 35,
- }],*/
- [{
- name: 'tgMinNum',
- label: '最低配送',
- readonly: context.isEdit ? true : false,
- maxlength: 4, validType: 'integer',
- width: 450, height: 35,
- }, {
- name: 'tgMaxNum',
- readonly: context.isEdit ? true : false,
- label: '配送上限', validType: 'integer',
- maxlength: 4, width: 450, height: 35,
- }],
- [{
- name: 'tgEndTime',
- label: '需求截止时间',
- readonly: context.isEdit ? true : false,
- xtype: 'datetimebox',
- required: true, width: 450, height: 35,
- }, {
- name: 'tgDeliverTime',
- multiline: true,
- readonly: context.isEdit ? true : false,
- xtype: 'datetimebox',
- label: '预计配货时间',
- required: true, width: 450, height: 35,
- },
- {
- name: 'tgPhoneNumber', validType: 'telNum',
- label: '联系电话', width: 450, height: 35,
- readonly: context.isEdit ? true : false,
- required: true, maxlength: 11,
- }],
- /* [{
- name: 'remark',
- label: '备注',
- multiline: true,
- width: 900,
- height: '100px',
- maxlength: 100,
- }]*/
- ],
- }
- },
- buttons: [
- {
- text: "保存", iconCls: "fa fa-save", onClick: function () {
- if (isLoading === true) {
- return;
- }
- else {
- isLoading = true;
- }
- if ($form.formGet().uptownIds.trim() == '') {
- $.yvan.msg('请先选择小区');
- return;
- }
- if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
- $.yvan.msg('最大上限必须大于等于最小起订量');
- return;
- }
- if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
- $.yvan.msg('团购截止时间必须小于预计送货时间');
- return;
- }
- console.log($form.formGet())
- $.yvan.postForm($form, {
- url: (context.isEdit ? api('/yeweihui/tgStatus') : api('/yeweihui/tgPublish')),
- success: function (data) {
- isLoading = false;
- if (data.data == 1) {
- $.yvan.msg('保存成功');
- $dlg.window('close');
- if ($.type(context.confirm) === 'function') {
- context.confirm();
- }
- } else {
- $.yvan.msg('保存失败');
- }
- }
- });
- }
- }, {
- text: "关闭", iconCls: "fa fa-times", onClick: function () {
- $dlg.dialog('close');
- }
- }
- ]
- }
- ;
- };
- });
|