2024-05-20 18:07:24 +08:00
|
|
|
<template>
|
|
|
|
<div class="app-container">
|
|
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
|
<el-form-item label="区域" prop="area">
|
|
|
|
<el-input
|
|
|
|
v-model="queryParams.area"
|
|
|
|
placeholder="请输入区域"
|
|
|
|
clearable
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="订单号" prop="orderNo">
|
|
|
|
<el-input
|
|
|
|
v-model="queryParams.orderNo"
|
|
|
|
placeholder="请输入订单号"
|
|
|
|
clearable
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="用户" prop="userName">
|
|
|
|
<el-input
|
|
|
|
v-model="queryParams.userName"
|
|
|
|
placeholder="请输入用户"
|
|
|
|
clearable
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
2024-06-06 22:08:03 +08:00
|
|
|
<el-form-item label="设备SN" prop="sn">
|
2024-05-20 18:07:24 +08:00
|
|
|
<el-input
|
|
|
|
v-model="queryParams.deviceMac"
|
2024-06-06 22:08:03 +08:00
|
|
|
placeholder="请输入设备SN"
|
2024-05-20 18:07:24 +08:00
|
|
|
clearable
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
|
<el-col :span="1.5">
|
|
|
|
<el-button
|
|
|
|
type="warning"
|
|
|
|
plain
|
|
|
|
icon="el-icon-download"
|
|
|
|
size="mini"
|
|
|
|
@click="handleExport"
|
|
|
|
v-hasPermi="['system:order:export']"
|
|
|
|
>导出</el-button>
|
|
|
|
</el-col>
|
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
|
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
2024-06-06 22:08:03 +08:00
|
|
|
<!-- <el-table-column label="订单id" align="center" prop="orderId" />-->
|
2024-05-20 18:07:24 +08:00
|
|
|
<el-table-column label="区域" align="center" prop="area" />
|
2024-06-06 22:08:03 +08:00
|
|
|
<el-table-column label="订单号" :show-overflow-tooltip="true" align="center" prop="orderNo" />
|
2024-05-20 18:07:24 +08:00
|
|
|
<el-table-column label="用户" align="center" prop="userName" />
|
2024-06-06 22:08:03 +08:00
|
|
|
<el-table-column label="设备SN" align="center" prop="sn" />
|
|
|
|
<el-table-column label="状态" align="center" prop="status">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<dict-tag :options="dict.type.et_order_status" :value="scope.row.status"/>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="支付时间" align="center" prop="payTime" width="150">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="开始骑行时间" align="center" prop="unlockTime" width="150">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ parseTime(scope.row.unlockTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="结束骑行时间" align="center" prop="returnTime" width="150">
|
2024-05-20 18:07:24 +08:00
|
|
|
<template slot-scope="scope">
|
2024-06-06 22:08:03 +08:00
|
|
|
<span>{{ parseTime(scope.row.returnTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="创建时间" align="center" prop="createTime" width="150">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
2024-05-20 18:07:24 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="支付方式" align="center" prop="payType">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<dict-tag :options="dict.type.et_pay_type" :value="scope.row.payType"/>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="类型" align="center" prop="type">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<dict-tag :options="dict.type.et_order_type" :value="scope.row.type"/>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2024-06-06 22:08:03 +08:00
|
|
|
<el-table-column label="金额(元)" align="center" prop="totalFee" />
|
2024-05-20 18:07:24 +08:00
|
|
|
<el-table-column label="备注" align="center" prop="mark" />
|
2024-06-06 22:08:03 +08:00
|
|
|
<el-table-column label="订单时长" align="center" prop="duration" :formatter="formatDuration"/>
|
2024-05-20 18:07:24 +08:00
|
|
|
<el-table-column label="距离" align="center" prop="distance" />
|
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
type="text"
|
|
|
|
icon="el-icon-view"
|
|
|
|
@click="handleUpdate(scope.row)"
|
|
|
|
v-hasPermi="['system:order:edit']"
|
|
|
|
>详情</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
<pagination
|
|
|
|
v-show="total>0"
|
|
|
|
:total="total"
|
|
|
|
:page.sync="queryParams.pageNum"
|
|
|
|
:limit.sync="queryParams.pageSize"
|
|
|
|
@pagination="getList"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<!-- 添加或修改订单对话框 -->
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
|
</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>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { listOrder, getOrder, delOrder, addOrder, updateOrder } from "@/api/system/order";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Order",
|
|
|
|
dicts: ['et_order_type', 'et_pay_type', 'et_order_status'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// 遮罩层
|
|
|
|
loading: true,
|
|
|
|
// 选中数组
|
|
|
|
ids: [],
|
|
|
|
// 非单个禁用
|
|
|
|
single: true,
|
|
|
|
// 非多个禁用
|
|
|
|
multiple: true,
|
|
|
|
// 显示搜索条件
|
|
|
|
showSearch: true,
|
|
|
|
// 总条数
|
|
|
|
total: 0,
|
|
|
|
// 订单表格数据
|
|
|
|
orderList: [],
|
|
|
|
// 弹出层标题
|
|
|
|
title: "",
|
|
|
|
// 是否显示弹出层
|
|
|
|
open: false,
|
|
|
|
// 查询参数
|
|
|
|
queryParams: {
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
areaId: null,
|
|
|
|
area: null,
|
|
|
|
orderNo: null,
|
|
|
|
type: "1",
|
|
|
|
userId: null,
|
|
|
|
userName: null,
|
|
|
|
deviceMac: null,
|
|
|
|
},
|
|
|
|
// 表单参数
|
|
|
|
form: {},
|
|
|
|
// 表单校验
|
|
|
|
rules: {
|
|
|
|
orderNo: [
|
|
|
|
{ required: true, message: "订单号不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
userId: [
|
|
|
|
{ required: true, message: "用户不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
payType: [
|
|
|
|
{ required: true, message: "支付方式不能为空", trigger: "change" }
|
|
|
|
],
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-06 22:08:03 +08:00
|
|
|
formatDuration(row) {
|
|
|
|
const createTime = new Date(row.createTime);
|
|
|
|
const endTime = new Date(row.returnTime);
|
|
|
|
if (!row.returnTime) {
|
|
|
|
return "未结束";
|
|
|
|
}
|
|
|
|
const durationMilliseconds = endTime - createTime;
|
|
|
|
// 计算小时、分钟和秒
|
|
|
|
const hours = Math.floor(durationMilliseconds / (1000 * 60 * 60));
|
|
|
|
const minutes = Math.floor((durationMilliseconds % (1000 * 60 * 60)) / (1000 * 60));
|
|
|
|
const seconds = Math.floor((durationMilliseconds % (1000 * 60)) / 1000); // 取整秒数
|
|
|
|
// 格式化输出
|
|
|
|
const formattedTime = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
|
|
|
return formattedTime;
|
|
|
|
},
|
2024-05-20 18:07:24 +08:00
|
|
|
/** 查询订单列表 */
|
|
|
|
getList() {
|
|
|
|
this.loading = true;
|
|
|
|
listOrder(this.queryParams).then(response => {
|
|
|
|
this.orderList = response.rows;
|
|
|
|
this.total = response.total;
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 取消按钮
|
|
|
|
cancel() {
|
|
|
|
this.open = false;
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
// 表单重置
|
|
|
|
reset() {
|
|
|
|
this.form = {
|
|
|
|
orderId: null,
|
|
|
|
areaId: null,
|
|
|
|
orderNo: null,
|
|
|
|
userId: null,
|
|
|
|
deviceMac: null,
|
|
|
|
payTime: null,
|
|
|
|
payType: null,
|
|
|
|
type: null,
|
|
|
|
totalFee: null,
|
|
|
|
mark: null,
|
|
|
|
duration: null,
|
|
|
|
distance: null,
|
|
|
|
status: null,
|
|
|
|
createTime: null
|
|
|
|
};
|
|
|
|
this.resetForm("form");
|
|
|
|
},
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
handleQuery() {
|
|
|
|
this.queryParams.pageNum = 1;
|
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
resetQuery() {
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
this.handleQuery();
|
|
|
|
},
|
|
|
|
// 多选框选中数据
|
|
|
|
handleSelectionChange(selection) {
|
|
|
|
this.ids = selection.map(item => item.orderId)
|
|
|
|
this.single = selection.length!==1
|
|
|
|
this.multiple = !selection.length
|
|
|
|
},
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
handleAdd() {
|
|
|
|
this.reset();
|
|
|
|
this.open = true;
|
|
|
|
this.title = "添加订单";
|
|
|
|
},
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
handleUpdate(row) {
|
|
|
|
this.reset();
|
|
|
|
const orderId = row.orderId || this.ids
|
|
|
|
getOrder(orderId).then(response => {
|
|
|
|
this.form = response.data;
|
|
|
|
this.open = true;
|
|
|
|
this.title = "修改订单";
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/** 提交按钮 */
|
|
|
|
submitForm() {
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
if (valid) {
|
|
|
|
if (this.form.orderId != null) {
|
|
|
|
updateOrder(this.form).then(response => {
|
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
|
this.open = false;
|
|
|
|
this.getList();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
addOrder(this.form).then(response => {
|
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
|
this.open = false;
|
|
|
|
this.getList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
handleDelete(row) {
|
|
|
|
const orderIds = row.orderId || this.ids;
|
|
|
|
this.$modal.confirm('是否确认删除订单编号为"' + orderIds + '"的数据项?').then(function() {
|
|
|
|
return delOrder(orderIds);
|
|
|
|
}).then(() => {
|
|
|
|
this.getList();
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
|
}).catch(() => {});
|
|
|
|
},
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
handleExport() {
|
|
|
|
this.download('system/order/export', {
|
|
|
|
...this.queryParams
|
|
|
|
}, `order_${new Date().getTime()}.xlsx`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|