...
|
...
|
@@ -43,9 +43,9 @@ |
|
|
@on-selection-change="selectChange"></Table>
|
|
|
<Page
|
|
|
:total="pageData.total"
|
|
|
:current="pageData.current"
|
|
|
:current="pageData.pageNo"
|
|
|
@on-change="pageChange"
|
|
|
:page-size="20"
|
|
|
:page-size="pageData.pageSize"
|
|
|
show-total></Page>
|
|
|
</LayoutList>
|
|
|
<ModalInvoice ref="modalInvoice" @save="saveInvoice" :brand="selectBrand.brandId"></ModalInvoice>
|
...
|
...
|
@@ -56,7 +56,7 @@ |
|
|
import _ from 'lodash';
|
|
|
import {SelectBrand, SelectCategory} from 'components/select';
|
|
|
import {ModalInvoice} from './components';
|
|
|
import supplierService from 'supplier-service';
|
|
|
import invoiceService from 'invoice-service';
|
|
|
import store from './store';
|
|
|
|
|
|
export default {
|
...
|
...
|
@@ -64,19 +64,31 @@ export default { |
|
|
return store.apply(this);
|
|
|
},
|
|
|
created() {
|
|
|
return this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
search() {
|
|
|
return supplierService.supplementProductList(this.getQuery()).then(res => {
|
|
|
console.log(res);
|
|
|
this.$Loading.start();
|
|
|
return invoiceService.supplementProductList(this.getQuery()).then(res => {
|
|
|
this.$Loading.finish();
|
|
|
this.tableData = res.records;
|
|
|
this.pageData.total = res.totalCount;
|
|
|
}, () => {
|
|
|
this.$Loading.finish();
|
|
|
});
|
|
|
},
|
|
|
pageChange(page) {
|
|
|
this.pageData.pageNo = page;
|
|
|
return this.search();
|
|
|
},
|
|
|
getQuery() {
|
|
|
return Object.assign(this.query, {
|
|
|
let params = _.toPairs(Object.assign(this.query, {
|
|
|
maxSortId: _.get(this.category, '[0].value'),
|
|
|
middleSortId: _.get(this.category, '[1].value'),
|
|
|
smallSortId: _.get(this.category, '[2].value')
|
|
|
});
|
|
|
}, this.pageData));
|
|
|
|
|
|
return _.fromPairs(params.filter(item => item[1]));
|
|
|
},
|
|
|
reset() {
|
|
|
this.category = [];
|
...
|
...
|
@@ -84,26 +96,34 @@ export default { |
|
|
this.search();
|
|
|
},
|
|
|
selectChange(selection) {
|
|
|
_.each(this.tableData, row => {
|
|
|
_.each(this.$refs.table.rebuildData, row => { // 更新rebuildData不会导致页面重新刷新
|
|
|
if (_.some(selection, item => item.id === row.id)) {
|
|
|
if (row.num <= 0) {
|
|
|
row.num = 1;
|
|
|
}
|
|
|
row._checked = true;
|
|
|
} else {
|
|
|
row._checked = false;
|
|
|
row.num = 0;
|
|
|
row._checked = false;
|
|
|
}
|
|
|
});
|
|
|
this.validBrand();
|
|
|
},
|
|
|
numChange(row, num) {
|
|
|
if ((row.num > 0 && !row._checked) ||
|
|
|
(row.num === 0 && row._checked)) {
|
|
|
if (row.brandId !== this.selectBrand.brandId && this.selectBrand.brandId) { // 如果品牌不同就直接操作table的rebuilddata不会导致表格刷新
|
|
|
row.num = 0;
|
|
|
this.$Message.warning(`请选择品牌为:${this.selectBrand.brandName}的商品补货`);
|
|
|
return;
|
|
|
}
|
|
|
this.syncData();
|
|
|
row._checked = num > 0;
|
|
|
this.validBrand();
|
|
|
}
|
|
|
},
|
|
|
validBrand() {
|
|
|
let selection = _.filter(this.tableData, row => row._checked);
|
|
|
let selection = _.filter(this.$refs.table.rebuildData, row => row._checked);
|
|
|
|
|
|
if (selection.length > 0) {
|
|
|
if (!this.selectBrand.brandId) {
|
...
|
...
|
@@ -113,7 +133,12 @@ export default { |
|
|
let rmRows = _.remove(selection, row => row.brandId !== this.selectBrand.brandId);
|
|
|
|
|
|
if (rmRows.length) {
|
|
|
_.each(rmRows, row => {
|
|
|
this.syncData(); // 重新建立table的data和数据data的引用关系然后修改_checked重新渲染表格
|
|
|
let rowDatas = _.map(rmRows, row => {
|
|
|
return _.find(this.tableData, item => item.id === row.id);
|
|
|
});
|
|
|
|
|
|
_.each(rowDatas, row => {
|
|
|
row._checked = false;
|
|
|
row.num = 0;
|
|
|
});
|
...
|
...
|
@@ -135,14 +160,36 @@ export default { |
|
|
this.tableData = this.$refs.table.rebuildData;
|
|
|
},
|
|
|
saveInvoice(invoiceId) {
|
|
|
let skus = this.tableData.filter(row => row._checked).map(row => {
|
|
|
this.syncData();
|
|
|
let goodsList = this.tableData.filter(row => row._checked).map(row => {
|
|
|
return {
|
|
|
productSku: row.productSku,
|
|
|
num: row.num
|
|
|
};
|
|
|
});
|
|
|
|
|
|
console.log(skus, invoiceId);
|
|
|
if (goodsList.length && invoiceId) {
|
|
|
this.$Loading.start();
|
|
|
return invoiceService.addGoods({
|
|
|
proRequisitionFormId: invoiceId,
|
|
|
goodsList
|
|
|
}).then(res => {
|
|
|
this.$Loading.finish();
|
|
|
if (res.code === 200) {
|
|
|
this.$Notice.success({
|
|
|
title: '保存成功'
|
|
|
});
|
|
|
this.search();
|
|
|
} else {
|
|
|
this.$Notice.error({
|
|
|
title: res.message
|
|
|
});
|
|
|
}
|
|
|
}, () => {
|
|
|
this.$Loading.finish();
|
|
|
});
|
|
|
}
|
|
|
this.$Message.warning('请选择商品和入库单');
|
|
|
}
|
|
|
},
|
|
|
components: {
|
...
|
...
|
|