Blame view

src/views/reservation/selectWarehouse/index.vue 6.79 KB
yuanshuhui authored
1
<template>
yuanshuhui authored
2
3
  <div class="app-container">
    <el-form ref="form" :model="form" v-if="flag == true">
yuanshuhui authored
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
      <el-row :gutter="15">
        <el-col :span="4">
          <el-form-item>
            <span class="pull-right">仓库:</span>
          </el-form-item>
        </el-col>
        <el-col :span="16">
          <el-form-item prop="warehouse">
            <el-select
              v-model="form.warehouse"
              placeholder="仓库"
              style="width: 100%"
            >
              <el-option
                v-for="item in warehouseOptions"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item>
            <el-button type="primary" @click="save">确 定</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
yuanshuhui authored
33
    <el-tabs v-model="activeName" type="card" v-if="flag == false">
yuanshuhui authored
34
35
36
37
38
39
      <el-tab-pane
        :label="item.date"
        :name="item.name.toString()"
        v-for="item in reservationList"
        :key="item.name"
      >
yuanshuhui authored
40
        <el-row :gutter="30">
yuanshuhui authored
41
42
43
44
45
46
47
48
49
50
51
52
53
          <el-col
            :xs="8"
            :sm="8"
            :lg="4"
            class="card-panel-col"
            v-for="value in item.data"
            :key="value.index"
          >
            <div
              @click="
                value.flag == true &&
                  handleUpdate(item.date, value.beginTime, value.endTime)
              "
yuanshuhui authored
54
            >
yuanshuhui authored
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
              <el-card
                :body-style="{
                  padding: '15px 20px 20px',
                  background: '#5CB87A',
                  color: '#fff',
                }"
                :class="[
                  'my-card-size',
                  { 'custom-my-card': value.flag == false },
                ]"
              >
                <div class="time">
                  {{ value.beginTime }}-{{ value.endTime }}
                </div>
                <div>预约到达时间</div>
                <div>
                  <span>当前已预约人数:{{ value.number }}</span>
                  <span class="pull-right"
                    >{{ value.number }}/{{ value.reservationsNumber }}</span
                  >
                </div>
              </el-card>
yuanshuhui authored
77
            </div>
yuanshuhui authored
78
79
80
81
          </el-col>
        </el-row>
      </el-tab-pane>
    </el-tabs>
yuanshuhui authored
82
83
84
85
86
87
88
89
    <!-- 修改预约对话框 -->
    <el-dialog title="预约" :visible.sync="open" width="500px" append-to-body>
      <el-form
        ref="reservationForm"
        :model="reservationForm"
        :rules="rules"
        label-width="80px"
      >
yuanshuhui authored
90
91
92
93
94
95
        <el-form-item label="姓名" prop="name">
          <el-input v-model="reservationForm.name" />
        </el-form-item>
        <el-form-item label="联系方式" prop="phone">
          <el-input v-model="reservationForm.phone" />
        </el-form-item>
yuanshuhui authored
96
        <el-form-item label="车型" prop="modal">
yuanshuhui authored
97
98
99
100
101
102
103
104
105
106
107
          <el-input v-model="reservationForm.modal" />
        </el-form-item>
        <el-form-item label="车牌号" prop="carPlate">
          <el-input v-model="reservationForm.carPlate" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
yuanshuhui authored
108
  </div>
yuanshuhui authored
109
110
</template>
<script>
yuanshuhui authored
111
import { listWarehouse } from "@/api/system/warehouse";
yuanshuhui authored
112
import { reservation, addReservation } from "@/api/reservation";
yuanshuhui authored
113
114
115
export default {
  data() {
    return {
yuanshuhui authored
116
      activeName: "0",
yuanshuhui authored
117
      form: {
yuanshuhui authored
118
        warehouse: undefined,
yuanshuhui authored
119
      },
yuanshuhui authored
120
      queryParams: {},
yuanshuhui authored
121
122
      warehouseOptions: [],
      flag: true,
yuanshuhui authored
123
      reservationList: [],
yuanshuhui authored
124
      // 是否显示弹出层
yuanshuhui authored
125
      open: false,
yuanshuhui authored
126
      // 表单参数
yuanshuhui authored
127
      reservationForm: {},
yuanshuhui authored
128
      // 表单校验
yuanshuhui authored
129
      rules: {
yuanshuhui authored
130
131
132
133
134
135
136
        name: [
          {
            required: true,
            message: "姓名不能为空",
            trigger: ["blur", "change"],
          },
        ],
yuanshuhui authored
137
        phone: [
yuanshuhui authored
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
          {
            required: true,
            message: "联系方式不能为空",
            trigger: ["blur", "change"],
          },
          {
            pattern: /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/,
            message: "号码格式有误",
            trigger: ["blur", "change"],
          },
        ],
        modal: [
          {
            required: true,
            message: "车型不能为空",
            trigger: ["blur", "change"],
          },
yuanshuhui authored
155
156
        ],
        carPlate: [
yuanshuhui authored
157
158
159
160
161
162
163
164
165
166
          {
            required: true,
            message: "车牌号不能为空",
            trigger: ["blur", "change"],
          },
          {
            pattern: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
            message: "车牌号格式有误",
            trigger: ["blur", "change"],
          },
yuanshuhui authored
167
168
        ],
      },
yuanshuhui authored
169
170
171
    };
  },
  created() {
yuanshuhui authored
172
    this.getWarehouseList();
yuanshuhui authored
173
174
  },
  methods: {
yuanshuhui authored
175
    getWarehouseList() {
yuanshuhui authored
176
177
178
179
      listWarehouse().then((response) => {
        this.warehouseOptions = response.rows;
        this.form.warehouse = response.rows[0].code;
      });
yuanshuhui authored
180
    },
yuanshuhui authored
181
    save() {
yuanshuhui authored
182
      this.flag = false;
yuanshuhui authored
183
184
      this.queryParams = {
        warehouseCode: this.form.warehouse,
yuanshuhui authored
185
      };
yuanshuhui authored
186
187
188
      reservation(this.queryParams).then((response) => {
        this.reservationList = response.data;
      });
yuanshuhui authored
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.reservationForm = {
        name: undefined,
        phone: undefined,
        carPlate: undefined,
        beginTime: undefined,
        endTime: undefined,
        modal: undefined,
        warehouseCode: undefined,
      };
      this.resetForm("reservationForm");
    },
yuanshuhui authored
208
209
210
211
212
    handleUpdate(date, val1, val2) {
      this.reservationForm.beginTime = date + " " + val1;
      this.reservationForm.endTime = date + " " + val2;
      this.reservationForm.warehouseCode = this.form.warehouse;
      this.open = true;
yuanshuhui authored
213
    },
yuanshuhui authored
214
    /** 提交按钮 */
yuanshuhui authored
215
216
217
218
219
220
221
222
223
224
    submitForm: function () {
      this.$refs["reservationForm"].validate((valid) => {
        if (valid) {
          addReservation(this.reservationForm).then((response) => {
            this.msgSuccess("预约成功");
            this.cancel();
            this.save();
          });
        }
      });
yuanshuhui authored
225
    },
yuanshuhui authored
226
227
228
  },
};
</script>
yuanshuhui authored
229
230
231
232
233
<style lang="scss">
.my-card-size {
  font-size: 14px;
  cursor: pointer;
}
yuanshuhui authored
234
235
236
237
.custom-my-card {
  .el-card__body {
    background: #f58383 !important;
    cursor: not-allowed;
yuanshuhui authored
238
  }
yuanshuhui authored
239
}
yuanshuhui authored
240
</style>
yuanshuhui authored
241
242
243
<style lang="scss" scoped>
.card-panel-col {
  margin-bottom: 25px;
yuanshuhui authored
244
yuanshuhui authored
245
246
247
248
249
  .time {
    margin-bottom: 10px;
  }
}
</style>