Browse Source

优化预约订单创建

yuhao 1 year ago
parent
commit
812012e0e2
2 changed files with 47 additions and 57 deletions
  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
 <template>
1
 <template>
2
   <div>
2
   <div>
3
     <div class="filterPop">
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
         <span slot="title" class="slot-title">
5
         <span slot="title" class="slot-title">
11
           <i @click="closeFilterPop" class="el-icon-arrow-left"></i>
6
           <i @click="closeFilterPop" class="el-icon-arrow-left"></i>
12
           创建订单
7
           创建订单
@@ -21,8 +16,8 @@
21
               v-model="value1"
16
               v-model="value1"
22
               type="date"
17
               type="date"
23
               placeholder="选择日期"
18
               placeholder="选择日期"
24
-            >
25
-            </el-date-picker>
19
+              @change="changeDate"
20
+            ></el-date-picker>
26
             <el-time-select
21
             <el-time-select
27
               :editable="false"
22
               :editable="false"
28
               :disabled="value1 == '' ? true : false"
23
               :disabled="value1 == '' ? true : false"
@@ -34,8 +29,7 @@
34
                 end: '23:00',
29
                 end: '23:00',
35
                 minTime: this.nowTime,
30
                 minTime: this.nowTime,
36
               }"
31
               }"
37
-            >
38
-            </el-time-select>
32
+            ></el-time-select>
39
             <el-time-select
33
             <el-time-select
40
               :editable="false"
34
               :editable="false"
41
               :disabled="startTime == '' ? true : false"
35
               :disabled="startTime == '' ? true : false"
@@ -47,21 +41,14 @@
47
                 end: '23:00',
41
                 end: '23:00',
48
                 minTime: startTime,
42
                 minTime: startTime,
49
               }"
43
               }"
50
-            >
51
-            </el-time-select>
44
+            ></el-time-select>
52
           </div>
45
           </div>
53
           <div class="create-title">选择用户:</div>
46
           <div class="create-title">选择用户:</div>
54
           <div class="filter-center">
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
               <i slot="prefix" class="el-input__icon el-icon-search"></i>
49
               <i slot="prefix" class="el-input__icon el-icon-search"></i>
61
             </el-input>
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
           </div>
52
           </div>
66
           <div class="filter-bottom">
53
           <div class="filter-bottom">
67
             <div
54
             <div
@@ -71,7 +58,7 @@
71
               @click="isSelectUser(item, index)"
58
               @click="isSelectUser(item, index)"
72
             >
59
             >
73
               <div class="left">
60
               <div class="left">
74
-                <img :src="item.avatar_url" alt="">
61
+                <img :src="item.avatar_url" alt />
75
               </div>
62
               </div>
76
               <div class="right">
63
               <div class="right">
77
                 <div class="right-content">
64
                 <div class="right-content">
@@ -83,11 +70,7 @@
83
                   <div class="phone">电话: {{ item.mobile }}</div>
70
                   <div class="phone">电话: {{ item.mobile }}</div>
84
                 </div>
71
                 </div>
85
               </div>
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
             </div>
74
             </div>
92
           </div>
75
           </div>
93
         </div>
76
         </div>
@@ -120,15 +103,28 @@ export default {
120
         disabledDate(time) {
103
         disabledDate(time) {
121
           let times = Date.now() - 24 * 60 * 60 * 1000;
104
           let times = Date.now() - 24 * 60 * 60 * 1000;
122
           return time.getTime() < times;
105
           return time.getTime() < times;
123
-        },
106
+        }
124
       }, //限制只能选择今天及以后的时间
107
       }, //限制只能选择今天及以后的时间
125
       userList: [], //查询的用户列表
108
       userList: [], //查询的用户列表
126
       checkUserList: [], //选中的用户信息ID
109
       checkUserList: [], //选中的用户信息ID
127
       id: "", //预约记录ID
110
       id: "", //预约记录ID
128
-      isClick: "", //是否是编辑或者直接点击加号创建的
111
+      isClick: "" //是否是编辑或者直接点击加号创建的
129
     };
112
     };
130
   },
113
   },
131
   methods: {
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
     closeFilterPop() {
129
     closeFilterPop() {
134
       this.$emit("update:orderShow", false);
130
       this.$emit("update:orderShow", false);
@@ -138,12 +134,12 @@ export default {
138
     searchUser(keyword) {
134
     searchUser(keyword) {
139
       api
135
       api
140
         .searchOrderUser({
136
         .searchOrderUser({
141
-          keyword: this.searchText || keyword,
137
+          keyword: this.searchText || keyword
142
         })
138
         })
143
-        .then((res) => {
139
+        .then(res => {
144
           if (res.code == 200) {
140
           if (res.code == 200) {
145
             // 手机号四位隐藏
141
             // 手机号四位隐藏
146
-            res.data.list.map((item) => {
142
+            res.data.list.map(item => {
147
               if (item.mobile) {
143
               if (item.mobile) {
148
                 item.mobile =
144
                 item.mobile =
149
                   item.mobile.substring(0, 3) +
145
                   item.mobile.substring(0, 3) +
@@ -154,7 +150,7 @@ export default {
154
             });
150
             });
155
             // 获取查询的用户
151
             // 获取查询的用户
156
             this.userList = res.data.list;
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
       if (this.userList[index].status) {
159
       if (this.userList[index].status) {
164
         this.$set(this.userList, index, {
160
         this.$set(this.userList, index, {
165
           ...this.userList[index],
161
           ...this.userList[index],
166
-          status: false,
162
+          status: false
167
         });
163
         });
168
       } else {
164
       } else {
169
         this.$set(this.userList, index, {
165
         this.$set(this.userList, index, {
170
           ...this.userList[index],
166
           ...this.userList[index],
171
-          status: true,
167
+          status: true
172
         });
168
         });
173
       }
169
       }
174
       let checkList = [];
170
       let checkList = [];
175
-      this.userList.forEach((item) => {
171
+      this.userList.forEach(item => {
176
         if (item.status) {
172
         if (item.status) {
177
           checkList.push(item.id);
173
           checkList.push(item.id);
178
         }
174
         }
@@ -191,34 +187,33 @@ export default {
191
       }
187
       }
192
       let date = this.isClick
188
       let date = this.isClick
193
         ? this.value1
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
       let start_time = date + " " + this.startTime;
192
       let start_time = date + " " + this.startTime;
198
       let end_time = date + " " + this.endTime;
193
       let end_time = date + " " + this.endTime;
199
       let params = {
194
       let params = {
200
         user_id: this.checkUserList.toString(),
195
         user_id: this.checkUserList.toString(),
201
         start_time,
196
         start_time,
202
         end_time,
197
         end_time,
203
-        id: this.id || "",
198
+        id: this.id || ""
204
       };
199
       };
205
       console.log(params);
200
       console.log(params);
206
-      api.createUserOrder(params).then((res) => {
201
+      api.createUserOrder(params).then(res => {
207
         this.$message({
202
         this.$message({
208
-          message:params.id?'修改成功': "创建成功",
209
-          type: "success",
203
+          message: params.id ? "修改成功" : "创建成功",
204
+          type: "success"
210
         });
205
         });
211
         this.$emit("update:orderShow", false);
206
         this.$emit("update:orderShow", false);
212
         this.$emit("updateUserOrder", date);
207
         this.$emit("updateUserOrder", date);
213
       });
208
       });
214
       // 清除数据
209
       // 清除数据
215
       Object.assign(this.$data, this.$options.data());
210
       Object.assign(this.$data, this.$options.data());
216
-    },
211
+    }
217
   },
212
   },
218
   watch: {
213
   watch: {
219
     // 获取父组件赋值的时间
214
     // 获取父组件赋值的时间
220
     toTime(newValue, oldValue) {
215
     toTime(newValue, oldValue) {
221
-      console.log(newValue);
216
+      // console.log(newValue);
222
       if (newValue.isClick) {
217
       if (newValue.isClick) {
223
         this.isClick = newValue.isClick;
218
         this.isClick = newValue.isClick;
224
         this.startTime = newValue.start;
219
         this.startTime = newValue.start;
@@ -228,22 +223,17 @@ export default {
228
         if (newValue.day) {
223
         if (newValue.day) {
229
           this.value1 = newValue.day;
224
           this.value1 = newValue.day;
230
         } else {
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
       } else {
229
       } else {
236
         this.startTime = "";
230
         this.startTime = "";
237
         this.endTime = "";
231
         this.endTime = "";
238
         this.value1 = "";
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
 </script>
238
 </script>
249
 
239
 
@@ -305,7 +295,7 @@ export default {
305
           border-radius: 8px;
295
           border-radius: 8px;
306
           margin-right: 8px;
296
           margin-right: 8px;
307
           overflow: hidden;
297
           overflow: hidden;
308
-          img{
298
+          img {
309
             width: 100%;
299
             width: 100%;
310
             height: 100%;
300
             height: 100%;
311
           }
301
           }

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

@@ -11,19 +11,19 @@
11
           <el-card>
11
           <el-card>
12
             <div class="titleBox">
12
             <div class="titleBox">
13
               <div class="title">销售金额:</div>
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
             </div>
15
             </div>
16
           </el-card>
16
           </el-card>
17
           <el-card>
17
           <el-card>
18
             <div class="titleBox">
18
             <div class="titleBox">
19
               <div class="title">消耗金额:</div>
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
             </div>
21
             </div>
22
           </el-card>
22
           </el-card>
23
           <el-card>
23
           <el-card>
24
             <div class="titleBox">
24
             <div class="titleBox">
25
               <div class="title">实收金额:</div>
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
             </div>
27
             </div>
28
           </el-card>
28
           </el-card>
29
         </div>
29
         </div>