ソースを参照

优化预约订单创建

yuhao 1 年間 前
コミット
812012e0e2
共有2 個のファイルを変更した47 個の追加57 個の削除を含む
  1. 44 54
      src/pages/home/createOrder/index.vue
  2. 3 3
      src/pages/revenueManage/index.vue

+ 44 - 54
src/pages/home/createOrder/index.vue

@@ -1,12 +1,7 @@
1 1
 <template>
2 2
   <div>
3 3
     <div class="filterPop">
4
-      <el-dialog
5
-        top="130px"
6
-        :visible.sync="orderShow"
7
-        width="52.5%"
8
-        :close-on-click-modal="false"
9
-      >
4
+      <el-dialog top="130px" :visible.sync="orderShow" width="52.5%" :close-on-click-modal="false">
10 5
         <span slot="title" class="slot-title">
11 6
           <i @click="closeFilterPop" class="el-icon-arrow-left"></i>
12 7
           创建订单
@@ -21,8 +16,8 @@
21 16
               v-model="value1"
22 17
               type="date"
23 18
               placeholder="选择日期"
24
-            >
25
-            </el-date-picker>
19
+              @change="changeDate"
20
+            ></el-date-picker>
26 21
             <el-time-select
27 22
               :editable="false"
28 23
               :disabled="value1 == '' ? true : false"
@@ -34,8 +29,7 @@
34 29
                 end: '23:00',
35 30
                 minTime: this.nowTime,
36 31
               }"
37
-            >
38
-            </el-time-select>
32
+            ></el-time-select>
39 33
             <el-time-select
40 34
               :editable="false"
41 35
               :disabled="startTime == '' ? true : false"
@@ -47,21 +41,14 @@
47 41
                 end: '23:00',
48 42
                 minTime: startTime,
49 43
               }"
50
-            >
51
-            </el-time-select>
44
+            ></el-time-select>
52 45
           </div>
53 46
           <div class="create-title">选择用户:</div>
54 47
           <div class="filter-center">
55
-            <el-input
56
-              placeholder="用户手机号、用户id、用户昵称、用户真实姓名"
57
-              class="search"
58
-              v-model="searchText"
59
-            >
48
+            <el-input placeholder="用户手机号、用户id、用户昵称、用户真实姓名" class="search" v-model="searchText">
60 49
               <i slot="prefix" class="el-input__icon el-icon-search"></i>
61 50
             </el-input>
62
-            <el-button @click="searchUser" type="primary" class="searchButton"
63
-              >搜索</el-button
64
-            >
51
+            <el-button @click="searchUser" type="primary" class="searchButton">搜索</el-button>
65 52
           </div>
66 53
           <div class="filter-bottom">
67 54
             <div
@@ -71,7 +58,7 @@
71 58
               @click="isSelectUser(item, index)"
72 59
             >
73 60
               <div class="left">
74
-                <img :src="item.avatar_url" alt="">
61
+                <img :src="item.avatar_url" alt />
75 62
               </div>
76 63
               <div class="right">
77 64
                 <div class="right-content">
@@ -83,11 +70,7 @@
83 70
                   <div class="phone">电话: {{ item.mobile }}</div>
84 71
                 </div>
85 72
               </div>
86
-              <img
87
-                class="radio"
88
-                :src="item.status ? select : unSelect"
89
-                alt=""
90
-              />
73
+              <img class="radio" :src="item.status ? select : unSelect" alt />
91 74
             </div>
92 75
           </div>
93 76
         </div>
@@ -120,15 +103,28 @@ export default {
120 103
         disabledDate(time) {
121 104
           let times = Date.now() - 24 * 60 * 60 * 1000;
122 105
           return time.getTime() < times;
123
-        },
106
+        }
124 107
       }, //限制只能选择今天及以后的时间
125 108
       userList: [], //查询的用户列表
126 109
       checkUserList: [], //选中的用户信息ID
127 110
       id: "", //预约记录ID
128
-      isClick: "", //是否是编辑或者直接点击加号创建的
111
+      isClick: "" //是否是编辑或者直接点击加号创建的
129 112
     };
130 113
   },
131 114
   methods: {
115
+    // 选择日期回调
116
+    changeDate(e) {
117
+      let selectDate = `${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()}`;
118
+      let date = new Date();
119
+      let nowDate = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
120
+      if(selectDate>nowDate){
121
+        this.nowTime = ''
122
+        console.log(111);
123
+      }else{
124
+        // 限制选择的时间截止到当前之后
125
+        this.nowTime = `${date.getHours() - 1}:59`;
126
+      }
127
+    },
132 128
     // 取消&&返回按钮关闭弹窗
133 129
     closeFilterPop() {
134 130
       this.$emit("update:orderShow", false);
@@ -138,12 +134,12 @@ export default {
138 134
     searchUser(keyword) {
139 135
       api
140 136
         .searchOrderUser({
141
-          keyword: this.searchText || keyword,
137
+          keyword: this.searchText || keyword
142 138
         })
143
-        .then((res) => {
139
+        .then(res => {
144 140
           if (res.code == 200) {
145 141
             // 手机号四位隐藏
146
-            res.data.list.map((item) => {
142
+            res.data.list.map(item => {
147 143
               if (item.mobile) {
148 144
                 item.mobile =
149 145
                   item.mobile.substring(0, 3) +
@@ -154,7 +150,7 @@ export default {
154 150
             });
155 151
             // 获取查询的用户
156 152
             this.userList = res.data.list;
157
-            console.log(this.userList);
153
+            // console.log(this.userList);
158 154
           }
159 155
         });
160 156
     },
@@ -163,16 +159,16 @@ export default {
163 159
       if (this.userList[index].status) {
164 160
         this.$set(this.userList, index, {
165 161
           ...this.userList[index],
166
-          status: false,
162
+          status: false
167 163
         });
168 164
       } else {
169 165
         this.$set(this.userList, index, {
170 166
           ...this.userList[index],
171
-          status: true,
167
+          status: true
172 168
         });
173 169
       }
174 170
       let checkList = [];
175
-      this.userList.forEach((item) => {
171
+      this.userList.forEach(item => {
176 172
         if (item.status) {
177 173
           checkList.push(item.id);
178 174
         }
@@ -191,34 +187,33 @@ export default {
191 187
       }
192 188
       let date = this.isClick
193 189
         ? this.value1
194
-        : `${this.value1.getFullYear()}-${
195
-            this.value1.getMonth() + 1
196
-          }-${this.value1.getDate()}`;
190
+        : `${this.value1.getFullYear()}-${this.value1.getMonth() +
191
+            1}-${this.value1.getDate()}`;
197 192
       let start_time = date + " " + this.startTime;
198 193
       let end_time = date + " " + this.endTime;
199 194
       let params = {
200 195
         user_id: this.checkUserList.toString(),
201 196
         start_time,
202 197
         end_time,
203
-        id: this.id || "",
198
+        id: this.id || ""
204 199
       };
205 200
       console.log(params);
206
-      api.createUserOrder(params).then((res) => {
201
+      api.createUserOrder(params).then(res => {
207 202
         this.$message({
208
-          message:params.id?'修改成功': "创建成功",
209
-          type: "success",
203
+          message: params.id ? "修改成功" : "创建成功",
204
+          type: "success"
210 205
         });
211 206
         this.$emit("update:orderShow", false);
212 207
         this.$emit("updateUserOrder", date);
213 208
       });
214 209
       // 清除数据
215 210
       Object.assign(this.$data, this.$options.data());
216
-    },
211
+    }
217 212
   },
218 213
   watch: {
219 214
     // 获取父组件赋值的时间
220 215
     toTime(newValue, oldValue) {
221
-      console.log(newValue);
216
+      // console.log(newValue);
222 217
       if (newValue.isClick) {
223 218
         this.isClick = newValue.isClick;
224 219
         this.startTime = newValue.start;
@@ -228,22 +223,17 @@ export default {
228 223
         if (newValue.day) {
229 224
           this.value1 = newValue.day;
230 225
         } else {
231
-          this.value1 = `${date.getFullYear()}-${
232
-            date.getMonth() + 1
233
-          }-${date.getDate()}`;
226
+          this.value1 = `${date.getFullYear()}-${date.getMonth() +
227
+            1}-${date.getDate()}`;
234 228
         }
235 229
       } else {
236 230
         this.startTime = "";
237 231
         this.endTime = "";
238 232
         this.value1 = "";
239 233
       }
240
-    },
241
-  },
242
-  created() {
243
-    let date = new Date();
244
-    // 限制选择的时间截止到当前之后
245
-    this.nowTime = `${date.getHours() - 1}:59`;
234
+    }
246 235
   },
236
+  created() {}
247 237
 };
248 238
 </script>
249 239
 
@@ -305,7 +295,7 @@ export default {
305 295
           border-radius: 8px;
306 296
           margin-right: 8px;
307 297
           overflow: hidden;
308
-          img{
298
+          img {
309 299
             width: 100%;
310 300
             height: 100%;
311 301
           }

+ 3 - 3
src/pages/revenueManage/index.vue

@@ -11,19 +11,19 @@
11 11
           <el-card>
12 12
             <div class="titleBox">
13 13
               <div class="title">销售金额:</div>
14
-              <div class="money"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E4%BA%BA%E6%B0%91%E5%B8%81.png" alt="">{{dataTotal.total_price}}</div>
14
+              <div class="money"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E4%BA%BA%E6%B0%91%E5%B8%81.png" alt="">{{dataTotal.total_price?dataTotal.total_price:0}}</div>
15 15
             </div>
16 16
           </el-card>
17 17
           <el-card>
18 18
             <div class="titleBox">
19 19
               <div class="title">消耗金额:</div>
20
-              <div class="money"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E4%BA%BA%E6%B0%91%E5%B8%81.png" alt="">{{dataTotal.card_expend_price}}</div>
20
+              <div class="money"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E4%BA%BA%E6%B0%91%E5%B8%81.png" alt="">{{dataTotal.card_expend_price?dataTotal.card_expend_price:0}}</div>
21 21
             </div>
22 22
           </el-card>
23 23
           <el-card>
24 24
             <div class="titleBox">
25 25
               <div class="title">实收金额:</div>
26
-              <div class="money"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E4%BA%BA%E6%B0%91%E5%B8%81.png" alt="">{{dataTotal.payer_price}}</div>
26
+              <div class="money"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E4%BA%BA%E6%B0%91%E5%B8%81.png" alt="">{{dataTotal.payer_price?dataTotal.payer_price:0}}</div>
27 27
             </div>
28 28
           </el-card>
29 29
         </div>