Commit 9ae38b3436336417ef8d8abcc37ce283864acd6b

Authored by vking
1 parent 7e6b06d2

master-rewrite-addnew

@@ -11,12 +11,17 @@ Component({ @@ -11,12 +11,17 @@ Component({
11 }, 11 },
12 lifetimes: { 12 lifetimes: {
13 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 13 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
14 - attached: function () {  
15 - this.initView()  
16 - }, 14 + attached: function () {},
17 moved: function () { }, 15 moved: function () { },
18 detached: function () { }, 16 detached: function () { },
19 }, 17 },
  18 + observers:{
  19 + time:function(time){
  20 + if(time>0){
  21 + this.initView()
  22 + }
  23 + },
  24 + },
20 /** 25 /**
21 * 组件的初始数据 26 * 组件的初始数据
22 */ 27 */
@@ -20,7 +20,8 @@ Page({ @@ -20,7 +20,8 @@ Page({
20 */ 20 */
21 data: { 21 data: {
22 type:1, // type 1/2/3 新增/修改/桌位 22 type:1, // type 1/2/3 新增/修改/桌位
23 - time:0,//当前时间戳,或修改到店,或桌位预订时间 23 + time:0,//组件最终构造的到店时间
  24 + runTime:0,//当前时间戳,或修改到店,或桌位预订时间
24 form: JSON.parse(JSON.stringify(formTpl)), 25 form: JSON.parse(JSON.stringify(formTpl)),
25 tables: [], 26 tables: [],
26 grand: [ 27 grand: [
@@ -59,14 +60,15 @@ Page({ @@ -59,14 +60,15 @@ Page({
59 this.getCustomRemark(); 60 this.getCustomRemark();
60 if(options.id>0){ 61 if(options.id>0){
61 //修改 62 //修改
62 - return; 63 + this.reserve_id=options.id
  64 + return this.initModify();
63 } 65 }
64 - if(options.tid){ 66 + if(options.hasQuick==1){
65 //桌位预订 67 //桌位预订
66 - return; 68 + return this.initQuick();
67 } 69 }
68 this.setData({ 70 this.setData({
69 - time:parseInt(new Date()/1000), 71 + runTime:parseInt(new Date()/1000),
70 type:1 72 type:1
71 }) 73 })
72 }, 74 },
@@ -405,7 +407,7 @@ Page({ @@ -405,7 +407,7 @@ Page({
405 } catch (e) {} 407 } catch (e) {}
406 408
407 form.ddate = this.time; 409 form.ddate = this.time;
408 - form.ddate_solt=this.ddate_solt 410 + form.ddate_solt=parseInt(this.ddate_solt)+1
409 form.is_set_ddate=1 411 form.is_set_ddate=1
410 App.Reserve.SetReserveInfo(form).then(res => { 412 App.Reserve.SetReserveInfo(form).then(res => {
411 if (res.ret == 200) { 413 if (res.ret == 200) {
@@ -414,7 +416,8 @@ Page({ @@ -414,7 +416,8 @@ Page({
414 this.setData({ 416 this.setData({
415 form: JSON.parse(JSON.stringify(formTpl)), 417 form: JSON.parse(JSON.stringify(formTpl)),
416 tables: [], 418 tables: [],
417 - timePickerIndex: [0, 0, 0], 419 + runTime:parseInt(new Date()/1000),
  420 + type:1
418 }) 421 })
419 this.checkedTables={}; 422 this.checkedTables={};
420 App.Reserve.Detail({rid: _id, openid: ''}, 'clear') 423 App.Reserve.Detail({rid: _id, openid: ''}, 'clear')
@@ -428,4 +431,54 @@ Page({ @@ -428,4 +431,54 @@ Page({
428 } catch (e) { 431 } catch (e) {
429 } 432 }
430 }, 433 },
  434 +
  435 + /**
  436 + * 修改初始化
  437 + */
  438 + async initModify(){
  439 + try {
  440 + let res = await App.Reserve.Detail({rid: this.options.id, openid: ''});
  441 + let form=this.data.form
  442 + form.pnum = res.data.pnum || 6;
  443 + form.rname = res.data.rname;
  444 + form.phone = res.data.phone || "";
  445 + form.sex = res.data.sex;
  446 + form.cusdem = res.data.cusdem;
  447 + form.rid = this.options.id;
  448 + form.tid = [];
  449 + let tablesed = [];
  450 + res.data.tables.forEach((t, ti) => {
  451 + form.tid.push(t.id)
  452 + if (ti >= 3) return;
  453 + t.isselect = true
  454 + t["isselected"] = 1
  455 + tablesed.push(t);
  456 + this.checkedTables[t.id]=t.name;
  457 + })
  458 + this.setData({
  459 + type:2,//修改
  460 + runTime: res.data.ddate,//到店时间
  461 + ddate_solt:res.data.ddate_solt,
  462 + form: form,
  463 + })
  464 + } catch (e) {
  465 + console.log('initModify', e)
  466 + }
  467 + },
  468 + /**
  469 + * 快速预订初始化
  470 + * tid
  471 + * tname
  472 + * ddate
  473 + * pnum
  474 + */
  475 + initQuick(){
  476 + let options=this.options
  477 + this.checkedTables[options.tid]=options.tname
  478 + this.setData({
  479 + [`form.tid`]: [options.tid],
  480 + runTime:options.ddate.substr(0,10),
  481 + type:3
  482 + })
  483 + },
431 }) 484 })
@@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
2 <wxs src="../../../utils/util.wxs" module="util" /> 2 <wxs src="../../../utils/util.wxs" module="util" />
3 <nav>录入订座信息</nav> 3 <nav>录入订座信息</nav>
4 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page"> 4 <view class="page" style="margin-bottom: {{pageMarginBottom}}rpx;" id="j_page">
5 - <view class="base-info" wx:if="{{time}}"> 5 + <view class="base-info" wx:if="{{runTime}}">
6 <view class="section"> 6 <view class="section">
7 - <add-date time="{{time}}" type="{{type}}"></add-date> 7 + <add-date time="{{runTime}}" type="{{type}}"></add-date>
8 </view> 8 </view>
9 <view class="section"> 9 <view class="section">
10 <add-time-dur></add-time-dur> 10 <add-time-dur></add-time-dur>
@@ -530,7 +530,7 @@ @@ -530,7 +530,7 @@
530 "id": 64, 530 "id": 64,
531 "name": "pack-book/pages/book/b_addnew 桌位进入", 531 "name": "pack-book/pages/book/b_addnew 桌位进入",
532 "pathName": "pack-book/pages/book/b_addnew", 532 "pathName": "pack-book/pages/book/b_addnew",
533 - "query": "", 533 + "query": "id=52064",
534 "scene": null 534 "scene": null
535 }, 535 },
536 { 536 {