<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="订单号" prop="orderNumber">
<el-input
v-model="queryParams.orderNumber"
placeholder="请输入订单号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</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 label="订单号" align="center" prop="orderNumber" />
<el-table-column label="金额" align="center" prop="price" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" >
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-search"
@click="queryBONAndWON(scope.row)"
>查看</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-t"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</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-item label="订单号" prop="orderNumber">
<el-input v-model="form.orderNumber" placeholder="请输入订单号" />
</el-form-item>
<el-form-item label="金额" prop="price">
<el-input v-model="form.price" placeholder="请输入金额" />
</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>
<!--
查看对应的B订单和W订单
title: 弹窗标题
visible.sync: 控制是否展示
-->
<el-dialog :titleBAW="B订单和W订单" :visible.sync="openBAW" width="500px" append-to-body>
<div>
<p>T信息</p>
<el-table :data="fromB">
<el-table-column label="装箱单号" align="center" prop="businessNumber" />
<el-table-column label="毛重" align="center" prop="grossWeight" />
<el-table-column label="净重" align="center" prop="netWeight" />
<el-table-column label="单位" align="center" prop="uom" />
<el-table-column label="运输工具车牌号" align="center" prop="equipmentNumber" />
<el-table-column label="港车车牌" align="center" prop="bookingReferenceNumber" />
<el-table-column label="封条号" align="center" prop="sealNumber" />
<el-table-column label="柜号" align="center" prop="containerNumber" />
</el-table>
</div>
<div>
<p>W信息</p>
<el-table :data="fromW">
<el-table-column label="装箱单号" align="center" prop="businessNumber" />
<el-table-column label="毛重" align="center" prop="grossWeight" />
<el-table-column label="净重" align="center" prop="netWeight" />
<el-table-column label="单位" align="center" prop="uom" />
<el-table-column label="运输工具车牌号" align="center" prop="equipmentNumber" />
<el-table-column label="港车车牌" align="center" prop="bookingReferenceNumber" />
<el-table-column label="封条号" align="center" prop="sealNumber" />
<el-table-column label="柜号" align="center" prop="containerNumber" />
</el-table>
</div>
</el-dialog>
</div>
</template>
<script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder, queryBAWO } from "@/api/order";
export default {
name: "order",
data() {
return {
loading: true,
ids: [],
single: true,
multiple: true,
showSearch: true,
total: 0,
orderList: [],
title: "",
open: false,
titleBAW: "",
openBAW: false,
queryParams: {
pageNum: 1,
pageSize: 10,
orderNumber: null,
price: null,
},
form: {},
rules: {
orderNumber: [
{ required: true, message: "订单不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
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();
},
cancelBAW() {
this.openBAW = false;
},
reset() {
this.form = {
orderNumber: null,
price: 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.orderNumber)
this.single = selection.length!==1
this.multiple = !selection.length
},
handleAdd() {
this.reset();
this.open = true;
this.title = "添加订单";
},
handleUpdate(row) {
this.reset();
const ecpoId = row.ecpoId || this.ids
getOrder(ecpoId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改订单";
});
},
queryBAWO(row) {
this.titleBAW = "BAW信息";
const bOrderNumber = "00001"
const wOrderNumber = "00002"
queryBAWO(bOrderNumber).then(response => {
let res = [];
res.push(response.data);
this.fromB = res;
});
queryBAWO(wOrderNumber).then(response => {
let resW = [];
resW.push(response.data);
this.fromW = resW;
console.log(this.fromW)
});
this.openBAW = true;
},
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.ecpoId != 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 ecpoIds = row.ecpoId || this.ids;
this.$modal.confirm('是否确认删除订单编号为"' + orderNumber + '"的数据项?').then(function() {
return delOrder(orderNumber);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
handleExport() {
this.download('order/export', {
...this.queryParams
}, `order.xlsx`)
}
}
};
</script>
|