|
@@ -3,7 +3,14 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="container">
|
|
|
<el-col :span="24" class="search">
|
|
|
- <search-bar :nameList="nameList"></search-bar>
|
|
|
+ <el-row type="flex">
|
|
|
+ <el-col :span="20">
|
|
|
+ <search-bar v-model="sform" :clientList="clientList" :userList="userList"></search-bar>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" @click="search">查询</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="info">
|
|
|
<el-row :gutter="20">
|
|
@@ -16,7 +23,8 @@
|
|
|
</el-row>
|
|
|
</div>
|
|
|
<!-- <data-table height="200px" :fields="fields" :data="item.split" :usePage="false" :opera="opera" @splice="splice"> </data-table> -->
|
|
|
- <el-table :data="item.split" style="width: 100%" @row-click="clickTable(index)">
|
|
|
+ <!-- <el-table :data="item.split" style="width: 100%" @row-click="clickTable(index)"> -->
|
|
|
+ <el-table :data="item.split" style="width: 100%" height="200px">
|
|
|
<el-table-column prop="name" label="货物名"></el-table-column>
|
|
|
<el-table-column prop="number" label="数量"></el-table-column>
|
|
|
<el-table-column prop="weight" label="重量"></el-table-column>
|
|
@@ -24,7 +32,7 @@
|
|
|
<el-table-column prop="remark" label="备注"></el-table-column>
|
|
|
<el-table-column label="操作">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button size="mini" @click="splice(index, scope.row)">拆分</el-button>
|
|
|
+ <el-button size="mini" @click="splice(index, scope.row, scope.$index)">拆分</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -113,7 +121,7 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" @click="add(splitList)">拆分订单</el-button>
|
|
|
+ <el-button type="primary" @click="add(splitList, orderForm)">拆分订单</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -122,6 +130,9 @@
|
|
|
<script>
|
|
|
const { mapActions: client } = createNamespacedHelpers('client');
|
|
|
const { mapActions: order } = createNamespacedHelpers('order');
|
|
|
+const { mapActions: user } = createNamespacedHelpers('user');
|
|
|
+const { mapActions: split } = createNamespacedHelpers('split');
|
|
|
+
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
import searchBar from './index-parts/search-bar.vue';
|
|
|
export default {
|
|
@@ -154,14 +165,18 @@ export default {
|
|
|
//项目列表
|
|
|
projectList: [{ name: '项目一' }, { name: '项目二' }],
|
|
|
//客戶列表
|
|
|
- nameList: [],
|
|
|
+ clientList: [],
|
|
|
+ //用户列表
|
|
|
+ userList: [],
|
|
|
+ sform: {},
|
|
|
// name: [],
|
|
|
- num: 1,
|
|
|
+ num: 0,
|
|
|
number: 0,
|
|
|
max: 0,
|
|
|
weight: 0,
|
|
|
volume: 0,
|
|
|
tableNumber: 0,
|
|
|
+ spiteIndex: 0,
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
@@ -169,10 +184,20 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
...client({ clientQuery: 'query' }),
|
|
|
- ...order(['query', 'create', 'update', 'delete', 'fetch']),
|
|
|
- async search({ skip = 0, limit = 8, ...info } = {}) {
|
|
|
+ ...order(['query']),
|
|
|
+ ...split({ getSplit: 'split', getQuery: 'query' }),
|
|
|
+ ...user({ getUserList: 'query' }),
|
|
|
+ async search({ skip = 0, limit = 8 } = {}) {
|
|
|
//查订单
|
|
|
- const res = await this.query({ skip, limit, ...info });
|
|
|
+ let duplicate = _.cloneDeep(this.sform);
|
|
|
+ let { date, ...info } = duplicate;
|
|
|
+ let querys = { skip, limit, ...info };
|
|
|
+ if (date && date.length === 2) {
|
|
|
+ querys[`rq_send_time@start`] = date[0];
|
|
|
+ querys[`rq_send_time@end`] = date[1];
|
|
|
+ }
|
|
|
+ if (this.user.role !== '0') querys.principal = this.user.id;
|
|
|
+ const res = await this.query(querys);
|
|
|
if (this.$checkRes(res)) {
|
|
|
const { data, total } = res;
|
|
|
this.$set(this, `list`, data);
|
|
@@ -182,7 +207,13 @@ export default {
|
|
|
const res1 = await this.clientQuery({ type: '客户' });
|
|
|
if (this.$checkRes(res1)) {
|
|
|
const { data, total } = res1;
|
|
|
- this.$set(this, `nameList`, data);
|
|
|
+ this.$set(this, `clientList`, data);
|
|
|
+ }
|
|
|
+ //查用户
|
|
|
+ const res2 = await this.getUserList();
|
|
|
+ if (this.$checkRes(res2)) {
|
|
|
+ const { data, total } = res2;
|
|
|
+ this.$set(this, `userList`, data);
|
|
|
}
|
|
|
},
|
|
|
//关闭
|
|
@@ -194,17 +225,25 @@ export default {
|
|
|
console.log(data);
|
|
|
},
|
|
|
//卡片上面的拆分
|
|
|
- splice(index, data) {
|
|
|
- this.$set(this, `orderForm`, _.cloneDeep(data));
|
|
|
+ splice(tableIndex, data, index) {
|
|
|
+ let newList = this.list[tableIndex].split;
|
|
|
+ this.$set(this, `orderForm`, data);
|
|
|
+ let arr = newList.filter(function(i) {
|
|
|
+ return i.pid === newList[index]._id;
|
|
|
+ });
|
|
|
+ this.num = arr.length;
|
|
|
this.dialog = true;
|
|
|
this.number = this.orderForm.number;
|
|
|
this.weight = this.orderForm.weight;
|
|
|
this.volume = this.orderForm.volume;
|
|
|
+ this.tableNumber = tableIndex;
|
|
|
+ this.spiteIndex = index;
|
|
|
},
|
|
|
//真的拆分订单
|
|
|
splite() {
|
|
|
let origin = this.orderForm;
|
|
|
- this.splitList.push({ type: 1, name: `${this.orderForm.name}-${this.num++}`, number: 0, weight: 0, volume: 0, pid: origin.pid });
|
|
|
+ let n = ++this.num;
|
|
|
+ this.splitList.push({ type: 1, name: `${this.orderForm.name}-${n}`, number: 0, weight: 0, volume: 0, pid: origin._id });
|
|
|
},
|
|
|
//数量改变
|
|
|
changeNumber(index, currentValue, oldValue) {
|
|
@@ -285,32 +324,28 @@ export default {
|
|
|
this.orderForm.volume += this.splitList[index].volume;
|
|
|
this.splitList.splice(index, 1);
|
|
|
},
|
|
|
- choose(client) {
|
|
|
- const obj = this.nameList.find(i => i.id === client);
|
|
|
- if (obj) return obj.name;
|
|
|
- },
|
|
|
- //保存拆分订单 ???修改不上 search栏怎么弄
|
|
|
- async add(data) {
|
|
|
- let splitList = this.list[this.tableNumber].split;
|
|
|
- // console.log(splitList);
|
|
|
- let newList = [];
|
|
|
- newList.push(splitList[0]);
|
|
|
- for (let item of data) {
|
|
|
- newList.push(item);
|
|
|
+ //保存拆分订单
|
|
|
+ async add(splitList, orderForm) {
|
|
|
+ // 复制一份数据在orderSplite;
|
|
|
+ let orderSplite = _.cloneDeep(this.list[this.tableNumber].split);
|
|
|
+ // 从orderSplite删除拆分的数据;
|
|
|
+ orderSplite.splice(this.spiteIndex, 1);
|
|
|
+ orderSplite.unshift(orderForm);
|
|
|
+ for (let item of splitList) {
|
|
|
+ orderSplite.push(item);
|
|
|
}
|
|
|
- this.$set(this.list[this.tableNumber], `split`, newList);
|
|
|
+ this.$set(this.list[this.tableNumber], `split`, orderSplite);
|
|
|
let newData = this.list[this.tableNumber];
|
|
|
- let owner = this.user.id;
|
|
|
- const res = await this.update(this.list);
|
|
|
+ const res = await this.getSplit(newData);
|
|
|
if (this.$checkRes(res, '拆分成功', res.errmsg || '拆分失败')) {
|
|
|
this.search();
|
|
|
- this.orderForm = {};
|
|
|
+ this.splitList = [];
|
|
|
this.dialog = false;
|
|
|
}
|
|
|
},
|
|
|
- clickTable(index) {
|
|
|
- console.log(index);
|
|
|
- this.tableNumber = index;
|
|
|
+ choose(client) {
|
|
|
+ const obj = this.clientList.find(i => i.id === client);
|
|
|
+ if (obj) return obj.name;
|
|
|
},
|
|
|
},
|
|
|
computed: {
|