Authored by 陈峰

Merge branch 'feature/fillStore' into 'release/2.0'

supplement



See merge request !5
... ... @@ -3,6 +3,7 @@
class="in-store"
width="700"
v-model="showModal"
@on-cancel="modalCancel"
title="添加到入库单">
<div class="in-store-content">
<p class="notice">* 请选择要添加的入库单</p>
... ... @@ -10,6 +11,7 @@
ref="table"
v-if="loadingOk"
height="300"
no-data-text="正在加载..."
:data="tableData"
:columns="tableColumn"
@on-row-click="tableRowClick"></Table>
... ... @@ -86,7 +88,6 @@ export default {
show() {
this.loadingData();
this.showModal = true;
this.loadingOk = true;
},
loadingData() {
return supplierService.listOrder({
... ... @@ -134,6 +135,8 @@ export default {
.in-store-content {
.notice {
color: #f30;
font-size: 14px;
line-height: 30px;
}
}
</style>
... ...
import {CellImage, CellInfo, CellPrice} from 'components/cell'; // eslint-disable-line
import timeFormat from 'filters/time-format';
export default function() {
return {
... ... @@ -22,55 +23,15 @@ export default function() {
sknFactoryCode: '',
skuFactoryCode: '',
prodName: '',
brandId: -1,
brandId: '',
stockStatus: ''
},
pageData: {
total: 0,
current: 1,
pageNo: 1,
pageSize: 20
},
tableData: [{
id: 1,
picImgUrl: 'http://img12.static.yhbimg.com/goodsimg/2017/05/09/09/028f8f329a40386d5cdbd966a92d0aaa0a.jpg?imageView2/0/w/78/h/78',
productSkn: '123',
productName: '123',
brandName: '123',
maxSortName: '123',
middleSortName: '123',
smallSortName: '123',
retailPrice: '123',
salesPrice: '123',
saleStatus: '已上架',
stock: '123',
day: '123',
buhuo: '123',
time: 1492531200,
store: '南京1号仓库',
brandId: 248,
_checked: false,
num: 0
}, {
id: 2,
picImgUrl: 'http://img12.static.yhbimg.com/goodsimg/2017/05/09/09/028f8f329a40386d5cdbd966a92d0aaa0a.jpg?imageView2/0/w/78/h/78',
productSkn: '123',
productName: '123',
brandName: '1232',
maxSortName: '123',
middleSortName: '123',
smallSortName: '123',
retailPrice: '123',
salesPrice: '123',
saleStatus: '已上架',
stock: '123',
day: '123',
buhuo: '123',
time: 1492531200,
store: '南京1号仓库',
brandId: 249,
_checked: false,
num: 0
}],
tableData: [],
tableCols: [{
type: 'selection',
width: 60,
... ... @@ -81,14 +42,13 @@ export default function() {
align: 'center',
render: (h, params) => {
return (
<CellImage
imageSrc={params.row.picImgUrl}
productUrl={params.row.productUrl}></CellImage>
<img v-prod-img={params.row.productSkn}/>
);
}
}, {
title: '商品信息',
align: 'center',
width: '15%',
render: (h, params) => {
return (
<CellInfo items={[
... ... @@ -111,6 +71,7 @@ export default function() {
}, {
title: '价格(元)',
align: 'center',
width: '13%',
render: (h, params) => {
return (
<CellInfo items={[
... ... @@ -119,34 +80,29 @@ export default function() {
value: params.row.retailPrice
}, {
label: '销售价',
value: params.row.salesPrice
value: params.row.salePrice
}
]}></CellInfo>
);
}
}, {
title: '销售状态',
key: 'saleStatus'
}, {
title: '仓库库存',
key: 'stock'
}, {
title: '库存可售天数',
key: 'day'
key: 'saleDays'
}, {
title: '建议补货数',
key: 'buhuo'
key: 'supplementNums'
}, {
title: '最近一次补货时间',
width: 150,
render: (h, params) => {
return (
<span>{params.row.time}</span>
<span>{timeFormat(params.row.lastTime)}</span>
);
}
}, {
title: '仓库',
key: 'store'
}, {
title: '补货数',
render: (h, params) => {
return (
... ... @@ -154,6 +110,7 @@ export default function() {
max={999}
min={0}
value={params.row.num}
style={{width: '60px'}}
onInput={val => (params.row.num = val)}
onOn-change={val => (this.numChange(params.row, val))}></Input-number>
);
... ...
... ... @@ -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: {
... ...
/**
* Created by TaoHuang on 2017/5/25.
*/
import _ from 'lodash';
import request from 'axios';
const apiUrl = {
... ... @@ -18,7 +18,8 @@ const apiUrl = {
listAvailableProduct: '/erp/invoiceGoodsAvailable',
addGoods: '/erp/invoiceGoodsAdd',
updateGoods: '/erp/invoiceGoodsUpdate',
deleteGoods: 'erp/invoiceGoodsDelete'
deleteGoods: 'erp/invoiceGoodsDelete',
supplementProductList: '/erp/supplementProductList'
};
function listOrder(params) {
... ... @@ -100,6 +101,22 @@ function deleteGoods(params) {
.then(res => res.data);
}
function supplementProductList(params) {
return request.post(apiUrl.supplementProductList, params)
.then(res => {
if (res.data.code === 200) {
let records = _.get(res, 'data.data.records', []);
_.each(records, item => {
item.num = 0;
item._checked = false;
});
return res.data.data;
}
return {};
});
}
export default {
listProduct,
listOrder,
... ... @@ -114,5 +131,6 @@ export default {
listAvailableProduct,
addGoods,
updateGoods,
deleteGoods
deleteGoods,
supplementProductList
};
... ...