longyvfengyun
2024-03-28 e688c5abc5f87c3ce00afb094376053643fe3857
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
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
<script setup>
import {ref, onMounted, watch} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {
    allDrivesModule, changeDriveInfoModule,
    driveInfModule
} from "@/views/moudle/driveInf/driveInf";
import EditDriveParams from "@/components/params/editDriveParams.vue";
import AddDriveParams from "@/components/params/addDriveParams.vue";
const editVisible = ref(false);
const addVisible = ref(false);
const {
    page,
    pageSize,
    total,
    driveList,
    carName,
    getDriveList
} = driveInfModule();
const loading = ref(false);
const svg = `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `;
/**
 * 查询汽车列表
 * @return {Promise<void>}
 */
const searchDriveList = async ()=>{
    // 开启等待框
    loading.value = true;
 
    let res = await getDriveList();
    driveList.value = res.result;
    // 关闭等待框
    loading.value = false;
}
 
watch(carName, ()=>{
    searchDriveList();
});
 
/**
 * 每页查询个数变更
 * @param value 每页查询个数
 */
const sizeChange = (value)=>{
    pageSize.value = value;
    searchDriveList();
}
 
/**
 * 当前页个数
 * @param value 当前页页码
 */
const currentChange = (value)=>{
    page.value = value;
    searchDriveList();
}
 
const {
    allDriveList,
    getAllDriveList
} = allDrivesModule();
 
const searchAllDrives = async ()=>{
    const res = await getAllDriveList();
    console.log(res);
}
 
const {
    deleteDrive
} = changeDriveInfoModule();
const handleDeleteDrive = (row)=>{
    ElMessageBox.confirm(
        "确认删除当前车辆",
        "系统提示"
    ).then(async ()=>{
        const rs = await deleteDrive(row.id);
        if (rs.code === 1) {
            ElMessage({
                message: rs.message,
                type: "success"
            });
            searchDriveList();
        }else {
            ElMessage.error(rs.message);
        }
    }).catch(()=>{});
}
 
import useBoxListSearch from "@/views/user/hooks/useBoxListSearch";
 
// 模糊查询模块
const {loading: boxSearchLoading, selectBox, boxList, boxListSearch} = useBoxListSearch();
watch(selectBox, (name)=>{
    carName.value = name;
    console.log(carName.value);
})
 
onMounted(()=>{
    searchDriveList();
    searchAllDrives();
    boxListSearch();
});
</script>
 
<template>
    <div class="page-container">
        <div class="page-content">
            <div class="page-header">
                <div class="input-list">
<!--                    <div class="input-item">-->
<!--                        <div class="input-wrapper">-->
<!--                            <div class="input-label">车辆名称:</div>-->
<!--                            <div class="input-content">-->
<!--                                <el-select v-model="carName" filterable>-->
<!--                                    <el-option-->
<!--                                        v-for="(item, key) in allDriveList.data" :key="'key'+key"-->
<!--                                        :value="item.key" :label="item.label"></el-option>-->
<!--                                </el-select>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="input-item">
                        <el-select
                            v-model="selectBox"
                            clearable
                            filterable
                            remote
                            reserve-keyword
                            placeholder="请输入车辆名称"
                            remote-show-suffix
                            :remote-method="boxListSearch"
                            :loading="boxSearchLoading">
                            <el-option
                                v-for="(item, key) in boxList"
                                :key="'key'+key"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                        <span class="w16-block"></span>
                        <el-button type="success" icon="Plus" @click="addVisible=true">添加</el-button>
                        <el-button type="primary" icon="Search" @click="searchDriveList">查询</el-button>
                    </div>
                </div>
            </div>
            <div class="page-content">
                <el-table
                    v-loading="loading"
                    element-loading-text="数据加载中..."
                    :element-loading-spinner="svg"
                    element-loading-svg-view-box="-10, -10, 50, 50"
                    element-loading-background="rgba(122, 122, 122, 0.5)"
                    :data="driveList"
                    height="100%">
                    <el-table-column min-width="120" align="center" prop="name" label="车辆名称" />
                    <el-table-column min-width="120" align="center" prop="boxSn" label="车辆编码"></el-table-column>
                    <el-table-column align="center" prop="online" label="车辆状态">
                        <template #default="{row}">
                            <el-tag v-if="row.online" type="success">在线</el-tag>
                            <el-tag v-else type="danger">离线</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column min-width="170" align="center" prop="createTime1" label="创建日期"></el-table-column>
                    <el-table-column min-width="170" align="center" prop="onlineTime1" label="在线时间"></el-table-column>
                    <el-table-column min-width="170" align="center" prop="updateTime1" label="数据更新日期"></el-table-column>
                    <el-table-column align="center" fixed="right" label="操作" width="120">
                        <template #default="{row}">
<!--                            <el-button link type="primary" size="small" @click="editVisible = true">编辑</el-button>-->
                            <el-button link type="primary" size="small" @click="handleDeleteDrive(row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="page-footer">
                <div class="el-pagination-container">
                    <el-pagination
                        background
                        layout="total, sizes, prev, pager, next, jumper"
                        @size-change="sizeChange"
                        @current-change="currentChange"
                        :total="total"></el-pagination>
                </div>
            </div>
        </div>
    </div>
    <el-dialog
        v-model="editVisible"
        title="车辆信息编辑"
        width="auto"
        draggable
        destroy-on-close
        align-center>
        <edit-drive-params v-model:visible="editVisible"></edit-drive-params>
    </el-dialog>
 
    <el-dialog
        v-model="addVisible"
        title="车辆信息添加"
        width="auto"
        draggable
        destroy-on-close
        align-center>
        <add-drive-params v-model:visible="addVisible" @success="searchDriveList"></add-drive-params>
    </el-dialog>
</template>
 
<style scoped lang="less">
.page-container {
    height: 100%;
    padding: 12px;
    .page-content {
        display: flex;
        height: 100%;
        border-radius: 4px;
        box-shadow: 0 0 12px rgba(0, 0, 0, .16);
        flex-direction: column;
        .page-header {
            padding: 8px;
        }
        .page-content {
            flex: 1;
            overflow-y: auto;
        }
        .page-footer {
            padding: 8px 0;
            text-align: center;
            .el-pagination-container {
                display: inline-block;
            }
        }
    }
}
 
.input-list {
    .input-item {
        display: inline-block;
        margin-left: 8px;
        vertical-align: top;
    }
}
.input-wrapper {
    display: flex;
    .input-content {
        width: 160px;
    }
    .input-label {
        font-size: 14px;
        line-height: 32px;
        vertical-align: bottom;
        margin-right: 8px;
    }
}
span.w16-block {
    display: inline-block;
    width: 16px;
}
</style>