kongdeqiang
2023-09-12 eadd5784244d98dca21e5788440004432af8e803
1
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
<template>
  <section class="content-box">
 
      <div class="form-box">
        <h1>停 车 场 车 位 管 理</h1>
        <el-form :inline="true" :model="searchForm" size="medium" >
          <el-form-item>
            <el-select v-model="searchForm.parkId" clearable>
              <el-option v-for="item in table1" :key="item.id" :label="item.name" :value="item.id" ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="small" @click="onSearch" icon="el-icon-search">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
 
      <div class="table">
        <el-table :data="table2" border height="300" style="font-size: 15px">
          <el-table-column prop="name" label="停车场名称" align="center" ></el-table-column>
          <el-table-column prop="num" label="计划车位数量" align="center" ></el-table-column>
          <el-table-column prop="carNum" label="场内泊车数量" align="center" ></el-table-column>
          <el-table-column prop="content" label="描述" align="center"></el-table-column>
          <el-table-column label="操作" fixed="right"  align="center">
            <template slot-scope="scope">
              <el-button size="mini" @click="onEdit(scope.$index, scope.row)">修改</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
 
      <el-dialog title="编辑" :visible.sync="flag" width="40%">
        <el-form :model="formData" ref="formData" label-width="130px" >
          <el-form-item label="停车场名称"  prop="name" aria-readonly="true">
            <el-input v-model="formData.name"></el-input>
          </el-form-item>
          <el-form-item label="计划车位数量" prop="num" :rules="[{ required: true, message: '请输入车位数量', trigger: 'blur'}]">
            <el-input v-model="formData.num"></el-input>
          </el-form-item>
          <el-form-item label="场内泊车数量" prop="num" :rules="[{ required: true, message: '请输入车位数量', trigger: 'blur'}]">
            <el-input v-model="formData.carNum"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="flag = false">取 消</el-button>
          <el-button type="primary" @click="onSave">确 定</el-button>
        </div>
      </el-dialog>
 
 
  </section>
</template>
 
<script>
export default {
  name: "EditCarNum",
  data: function () {
    return {
      flag:false,
      flag2:false,
      pageData: null,
      searchForm: {
        parkId: '',
      },
      formData: {
        id:null,
        parkName:'',
        num:'',
        carNum:''
      },
      urlPath:this.$systemconfig.basePath + '/ffzf/park/',
      table1:[],
      table2:[],
    }
  },
  mounted() {
    this.$byutil.postData(this, this.urlPath+'findAll', this.formData, res => {
      this.table1 = res.data;
    })
  },
  methods: {
    onSave(){
      this.$refs['formData'].validate((valid) => {
        if (valid) {
          this.$byutil.postData(this, this.urlPath+'editParkCarNum', this.formData, res => {
            this.$refs['formData'].resetFields();
            this.flag=false;
            this.$message({message: '保存成功', type: 'success'});
            this.loadData();
          })
        } else {
          return false;
        }
      });
    },
    loadData() {
      this.$byutil.postData(this, this.urlPath+'getById', this.searchForm,res => {
        this.table2 = []
        this.table2.push(res.data);
      });
    },
    onSearch() {
      this.flag2 = true
      this.loadData();
    },
    onEdit(index, row) {
      this.flag=true;
      this.formData  = row;
    },
  }
}
</script>
 
<style scoped>
.content-box{
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  position: relative;
  left: 0;
  top: 0;
}
 
h1{
  font-size: 55px;
  color: #409EFF;
  margin-bottom: 50px;
}
 
.form-box{
  width: 1000px;
  /*height: 50px;*/
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
 
/deep/ .el-input--medium .el-input__inner{
  width: 700px;
  border: 2px solid #BDE2B2FF;
  border-radius: 30px;
}
 
.table{
  width: 1000px;
  height: 500px;
}
 
</style>