Blame view

src/views/scm/doDiningList.vue 10.3 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
9d4e862a   wuxw   开发完成预约功能
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    <div class="do-dining-container">
      <el-row :gutter="20">
        <el-col :span="4" class="bg-white">
          <div class="margin-sm">{{ $t('doDining.selectGoods') }}</div>
          <div class="flex justify-start flex-wrap">
            <div v-for="reserveDining in doDiningInfo.reserveDinings" :key="reserveDining.goodsId" class="margin-right-xs margin-bottom-xs">
              <div 
                class="vc-border border-radius padding-xs cursor-pointer"
                :class="{'vc-reserve-active': doDiningInfo.goodsId == reserveDining.goodsId}"
                @click="_chooseDining(reserveDining)"
              >
                <div>
                  <el-image 
                    style="width: 60px; height: 60px; border-radius: 5px;"
                    :src="reserveDining.imgUrl || '/img/noPhoto.jpg'"
                    fit="cover"
                  ></el-image>
                </div>
                <div class="text-center margin-top-xs">
                  {{ reserveDining.goodsName }}
                </div>
              </div>
            </div>
          </div>
        </el-col>
        <el-col :span="20">
          <el-row :gutter="20">
            <el-col :span="6"></el-col>
            <el-col :span="12">
              <el-input 
                v-model="doDiningInfo.qrCode" 
                :placeholder="$t('doDining.scanQrCode')"
                @keyup.enter.native="_doDining()"
                id="qrCode"
              ></el-input>
            </el-col>
            <el-col :span="6">
              <el-button type="primary" @click="_doDining()" style="width:100%">
                {{ $t('doDining.dining') }}
              </el-button>
            </el-col>
          </el-row>
  
          <el-row class="margin-top">
            <el-col :span="24">
              <el-card>
27dcfde5   wuxw   系统全面测试完成
48
                <div slot="header" class="flex justify-between">
9d4e862a   wuxw   开发完成预约功能
49
50
51
52
53
54
                  <span>{{ $t('doDining.diningRecords') }}</span>
                </div>
                <el-row :gutter="20">
                  <el-col :span="4">
                    <el-date-picker
                      v-model="doDiningInfo.conditions.startDate"
b25b036d   wuxw   v1.9 优化日期
55
56
                      type="datetime" value-format="yyyy-MM-dd HH:mm:ss"                    :placeholder="$t('doDining.selectStartTime')"
                      style="width:100%" 
9d4e862a   wuxw   开发完成预约功能
57
58
59
60
61
                    ></el-date-picker>
                  </el-col>
                  <el-col :span="4">
                    <el-date-picker
                      v-model="doDiningInfo.conditions.endDate"
b25b036d   wuxw   v1.9 优化日期
62
63
                      type="datetime" value-format="yyyy-MM-dd HH:mm:ss"                    :placeholder="$t('doDining.selectEndTime')"
                      style="width:100%" 
9d4e862a   wuxw   开发完成预约功能
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
                    ></el-date-picker>
                  </el-col>
                  <el-col :span="4">
                    <el-input
                      v-model="doDiningInfo.conditions.nameLike"
                      :placeholder="$t('doDining.enterOwnerName')"
                    ></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-input
                      v-model="doDiningInfo.conditions.dinerName"
                      :placeholder="$t('doDining.enterDinerName')"
                    ></el-input>
                  </el-col>
                  <el-col :span="4">
                    <el-button type="primary" @click="_queryData()">
                      <i class="el-icon-search"></i>
                      {{ $t('common.search') }}
                    </el-button>
                    <el-button @click="_exportExcel()">
                      <i class="el-icon-download"></i>
                      {{ $t('common.export') }}
                    </el-button>
                  </el-col>
                </el-row>
  
                <el-table
                  :data="doDiningInfo.orders"
                  style="width: 100%"
                  border
                  class="margin-top"
                >
                  <el-table-column
                    prop="createTime"
                    :label="$t('doDining.diningTime')"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="goodsName"
                    :label="$t('doDining.goods')"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="ownerName"
                    :label="$t('doDining.owner')"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="personName"
                    :label="$t('doDining.diner')"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="personTel"
                    :label="$t('doDining.dinerPhone')"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="orderId"
                    :label="$t('doDining.orderNo')"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    prop="remark"
                    :label="$t('doDining.remark')"
                    align="center"
                  ></el-table-column>
                </el-table>
  
                <el-pagination
                  :current-page.sync="page.current"
                  :page-sizes="[10, 20, 30, 50]"
                  :page-size="page.size"
                  :total="page.total"
                  layout="total, sizes, prev, pager, next, jumper"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  class="margin-top"
                ></el-pagination>
              </el-card>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
  
      <add-reserve-dining-person ref="addReserveDiningPerson"></add-reserve-dining-person>
      <delete-reserve-dining ref="deleteReserveDining"></delete-reserve-dining>
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { 
    listReserveGoods,
    queryOwnerDining,
    exportData,
    doDining
  } from '@/api/scm/doDiningApi'
  import AddReserveDiningPerson from '@/components/scm/addReserveDiningPerson'
  import DeleteReserveDining from '@/components/scm/deleteReserveDining'
  
  export default {
    name: 'DoDiningList',
    components: {
      AddReserveDiningPerson,
      DeleteReserveDining
    },
    data() {
      return {
        communityId: '',
        doDiningInfo: {
          reserveDinings: [],
          orders: [],
          total: 0,
          records: 1,
          goodsId: '',
          moreCondition: false,
          qrCode: '',
          conditions: {
            goodsName: '',
            startDate: '',
            endDate: '',
            ownerName: '',
            dinerName: '',
            communityId: ''
          }
        },
        page: {
          current: 1,
          size: 10,
          total: 0
        },
        focusInterval: null
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.doDiningInfo.conditions.communityId = this.communityId
      this._listReserveDinings(1, 200)
      this._listReserveConfirms(this.page.current, this.page.size)
    },
    mounted() {
      document.getElementById("qrCode").focus()
      this.focusInterval = setInterval(() => {
        document.getElementById("qrCode").focus()
      }, 5000)
    },
    beforeDestroy() {
      if (this.focusInterval) {
        clearInterval(this.focusInterval)
      }
    },
    methods: {
      _listReserveDinings(_page, _rows) {
        const params = {
          page: _page,
          row: _rows,
          communityId: this.communityId
        }
        listReserveGoods(params)
          .then(response => {
            this.doDiningInfo.reserveDinings = response.data
          })
          .catch(error => {
            console.error('请求失败:', error)
          })
      },
      _chooseDining(_dining) {
        this.doDiningInfo.goodsId = _dining.goodsId
        document.getElementById("qrCode").focus()
      },
      _doDining() {
        const data = {
          communityId: this.communityId,
          goodsId: this.doDiningInfo.goodsId,
          qrCode: this.doDiningInfo.qrCode
        }
  
        doDining(data)
          .then(response => {
            this.doDiningInfo.qrCode = ''
            if (response.code !== 0) {
              this.$message.error(response.msg)
              return
            }
            this._listReserveConfirms(this.page.current, this.page.size)
          })
          .catch(error => {
            console.error('请求失败:', error)
            this.doDiningInfo.qrCode = ''
          })
      },
      _listReserveConfirms(_page, _rows) {
        const params = {
          page: _page,
          row: _rows,
          ...this.doDiningInfo.conditions
        }
        queryOwnerDining(params)
          .then(response => {
            this.doDiningInfo.total = response.total
            this.doDiningInfo.records = response.records
            this.doDiningInfo.orders = response.data
f9f29297   wuxw   v1.9 分页 record 传给...
267
            this.page.total = response.total
9d4e862a   wuxw   开发完成预约功能
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
          })
          .catch(error => {
            console.error('请求失败:', error)
          })
      },
      _queryData() {
        this.page.current = 1
        this._listReserveConfirms(this.page.current, this.page.size)
      },
      _exportExcel() {
        const params = {
          ...this.doDiningInfo.conditions,
          pagePath: 'doDining'
        }
        exportData(params)
          .then(response => {
            if (response.code === 0) {
              this.$router.push('/pages/property/downloadTempFile?tab=下载中心')
            }
          })
          .catch(error => {
            console.error('请求失败:', error)
          })
      },
      handleSizeChange(val) {
        this.page.size = val
        this._listReserveConfirms(this.page.current, val)
      },
      handleCurrentChange(val) {
        this.page.current = val
        this._listReserveConfirms(val, this.page.size)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .do-dining-container {
    padding: 20px;
    .vc-reserve-active {
      border: 1px solid #409EFF;
      background-color: #f5f7fa;
    }
    .margin-sm {
      margin: 10px 0;
    }
    .margin-top {
      margin-top: 20px;
    }
    .margin-right-xs {
      margin-right: 5px;
    }
    .margin-bottom-xs {
      margin-bottom: 5px;
    }
    .padding-xs {
      padding: 5px;
    }
    .border-radius {
      border-radius: 4px;
    }
    .vc-border {
      border: 1px solid #ebeef5;
    }
    .text-center {
      text-align: center;
    }
    .flex {
      display: flex;
    }
    .justify-start {
      justify-content: flex-start;
    }
    .flex-wrap {
      flex-wrap: wrap;
    }
    .bg-white {
      background-color: #fff;
      padding: 10px;
      border-radius: 4px;
    }
    .cursor-pointer {
      cursor: pointer;
    }
  }
  </style>