|
@@ -1,16 +1,32 @@
|
|
|
<template>
|
|
|
<div id="once">
|
|
|
+ <alert :content="['请手动选择条件查询']"></alert>
|
|
|
<animates>
|
|
|
- <data-table height="600px" :select="true" :fields="fields" :data="list" :opera="opera" :total="total" @handleSelect="toSelect" v-if="!dialog">
|
|
|
+ <data-table
|
|
|
+ height="600px"
|
|
|
+ :select="true"
|
|
|
+ :fields="fields"
|
|
|
+ :data="list"
|
|
|
+ :opera="opera"
|
|
|
+ :total="total"
|
|
|
+ @query="search"
|
|
|
+ @handleSelect="toSelect"
|
|
|
+ v-if="!dialog"
|
|
|
+ >
|
|
|
<template #options="{item}">
|
|
|
- <template v-if="item.model == 'car_no'">
|
|
|
- <el-option v-for="(i, index) in carList" :key="`car-${index}`" :label="i.name" :value="i._id"></el-option>
|
|
|
+ <template v-if="item.model == 'car'">
|
|
|
+ <el-option v-for="(i, index) in carList" :key="`car-${index}`" :label="i.car_no" :value="i._id"></el-option>
|
|
|
</template>
|
|
|
</template>
|
|
|
<template #filterEnd>
|
|
|
<el-button v-if="selected.length <= 0" type="primary" :disabled="true">未选择任何运输单</el-button>
|
|
|
<el-button v-else type="primary" @click="toResult">查看选中的结果</el-button>
|
|
|
</template>
|
|
|
+ <template #custom="{item,row}">
|
|
|
+ <template v-if="item.model === 'goods'">
|
|
|
+ {{ getGoods(row) }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
</data-table>
|
|
|
<cardRL v-else>
|
|
|
<template #header>
|
|
@@ -49,6 +65,8 @@
|
|
|
const _ = require('lodash');
|
|
|
import cardRL from '@f/layouts/cardRL.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: car } = createNamespacedHelpers('car');
|
|
|
+const { mapActions: transport } = createNamespacedHelpers('transport');
|
|
|
export default {
|
|
|
name: 'once',
|
|
|
props: {},
|
|
@@ -58,37 +76,15 @@ export default {
|
|
|
dialog: false,
|
|
|
opera: [],
|
|
|
fields: [
|
|
|
- { label: '车号', model: 'car_no', filter: 'select' },
|
|
|
- { label: '运输单号', model: 'transport_no' },
|
|
|
+ { label: '车号', model: 'car', filter: 'select', notable: true },
|
|
|
+ { label: '运输单号', model: 'no' },
|
|
|
+ { label: '线路', model: 'route' },
|
|
|
{ label: '发货时间', model: 'send_time', filter: 'date' },
|
|
|
- // { label: '货物', model: 'goods' },
|
|
|
+ { label: '签收时间', model: 'sign_time', filter: 'date' },
|
|
|
+ { label: '货物', model: 'goods', custom: true },
|
|
|
],
|
|
|
carList: [], // 查车列表
|
|
|
- list: [
|
|
|
- {
|
|
|
- id: '1',
|
|
|
- car_no: 1,
|
|
|
- order_no: 'or30928',
|
|
|
- transport_no: 'tran-0987',
|
|
|
- money: 100,
|
|
|
- cost: [
|
|
|
- { item: '罚款', money: 200 },
|
|
|
- { item: '过桥费', money: 100 },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- id: '2',
|
|
|
- car_no: 2,
|
|
|
- order_no: 'or30lsi',
|
|
|
- transport_no: 'tran-0928',
|
|
|
- money: 400,
|
|
|
- cost: [
|
|
|
- { item: '罚款', money: 500, remark: '第一次' },
|
|
|
- { item: '罚款', money: 200, remark: '第二次' },
|
|
|
- { item: '过桥费', money: 100 },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
+ list: [],
|
|
|
total: 0,
|
|
|
selected: [],
|
|
|
form: {},
|
|
@@ -96,14 +92,14 @@ export default {
|
|
|
inList: [],
|
|
|
inFields: [
|
|
|
{ label: '订单号', model: 'order_no' },
|
|
|
- { label: '运输单号', model: 'transport_no' },
|
|
|
- // { label: '发货时间', model: 'send_time', filter: 'date' },
|
|
|
- { label: '收入金额', model: 'money' },
|
|
|
+ { label: '运输单号', model: 'no' },
|
|
|
+ { label: '货物', model: 'name' },
|
|
|
+ { label: '收入金额', model: 'sh_ys' },
|
|
|
],
|
|
|
outList: [],
|
|
|
outFields: [
|
|
|
- { label: '订单号', model: 'order_no' },
|
|
|
- { label: '运输单号', model: 'transport_no' },
|
|
|
+ { label: '运输单号', model: 'no' },
|
|
|
+ { label: '支出项目', model: 'item' },
|
|
|
{ label: '支出金额', model: 'money' },
|
|
|
{ label: '备注', model: 'remark' },
|
|
|
],
|
|
@@ -111,24 +107,33 @@ export default {
|
|
|
count: {},
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.getOhterList();
|
|
|
+ },
|
|
|
methods: {
|
|
|
- async search({ skip = 0, limit = 10 }) {},
|
|
|
+ ...transport(['query', 'update', 'calculate']),
|
|
|
+ ...car({ getCarList: 'query' }),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ const res = await this.query({ skip, limit, ...info, supply_type: '0' });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ const { data, total } = res;
|
|
|
+ this.$set(this, `list`, data);
|
|
|
+ this.$set(this, `total`, total);
|
|
|
+ }
|
|
|
+ },
|
|
|
toSelect(data) {
|
|
|
- console.log(data);
|
|
|
this.selected = data;
|
|
|
},
|
|
|
- toResult() {
|
|
|
- this.dialog = true;
|
|
|
- // 整理数据,将被选择的所有运输单收入和支出分成2部分
|
|
|
- // 收入,直接拿来就行,就是显示的不一样
|
|
|
- const inList = _.cloneDeep(this.selected);
|
|
|
- this.$set(this, `inList`, inList);
|
|
|
- // 获取支出列表
|
|
|
- const outList = this.getOutList();
|
|
|
- this.$set(this, `outList`, outList);
|
|
|
- // 计算合计部分
|
|
|
- this.getCount();
|
|
|
+ async toResult() {
|
|
|
+ const ids = this.selected.map(i => i._id);
|
|
|
+ const res = await this.calculate({ ids, type: 'once' });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ const { inBill, outBill, count } = res;
|
|
|
+ this.$set(this, `inList`, inBill);
|
|
|
+ this.$set(this, `outList`, outBill);
|
|
|
+ this.$set(this, `count`, count);
|
|
|
+ this.dialog = true;
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 获取支出列表
|
|
@@ -151,27 +156,6 @@ export default {
|
|
|
/**
|
|
|
* 获取合计
|
|
|
*/
|
|
|
- getCount() {
|
|
|
- let inList = _.cloneDeep(this.inList);
|
|
|
- let outList = _.cloneDeep(this.outList);
|
|
|
- let im = 0;
|
|
|
- let om = 0;
|
|
|
- console.log(inList);
|
|
|
- console.log(outList);
|
|
|
- if (_.isArray(inList))
|
|
|
- im = _.round(
|
|
|
- inList.reduce((p, n) => p + (n.money || 0), 0),
|
|
|
- 2
|
|
|
- );
|
|
|
- if (_.isArray(outList))
|
|
|
- om = _.round(
|
|
|
- outList.reduce((p, n) => p + (n.money || 0), 0),
|
|
|
- 2
|
|
|
- );
|
|
|
- console.log(im, om);
|
|
|
- let total = _.round(im - om, 2);
|
|
|
- this.$set(this, `count`, { im, om, total });
|
|
|
- },
|
|
|
toExport() {
|
|
|
// TODO 导出excel
|
|
|
let msg = this.$message({ message: '正在导出,请稍后', duration: 0 });
|
|
@@ -181,6 +165,17 @@ export default {
|
|
|
this.dialog = false;
|
|
|
this.selected = [];
|
|
|
},
|
|
|
+ async getOhterList() {
|
|
|
+ const cres = await this.getCarList();
|
|
|
+ if (this.$checkRes(cres)) this.$set(this, `carList`, cres.data);
|
|
|
+ },
|
|
|
+ getGoods(data) {
|
|
|
+ let goods = _.get(data, 'goods', []);
|
|
|
+ if (goods && _.isArray(goods) && goods.length > 0) {
|
|
|
+ goods = goods.map(i => i.name);
|
|
|
+ return goods.join(';');
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user', 'menuParams']),
|