Authored by 陈峰

Merge branch 'release/1.0' of http://git.yoho.cn/fe/yoho-shop-manage into release/1.0

<template>
<div>
<Row :gutter="24" class-name="filter-row">
<Col :span="6">
<Row>
<Col :span="fieldSort.first.labelSpan"><label class="field-label">{{fieldSort.first.label}}:</label></Col>
<Col :span="fieldSort.first.fieldSpan">
<Select v-model="_firstModel" :placeholder="fieldSort.first.holder" @on-change="firstChange" clearable>
<Option v-for="option in firstList" :value="option.sortId" :key="option.sortId">
{{option.sortName}}
</Option>
</Select>
</Col>
</Row>
</Col>
<Col :span="6" v-show="showSecond">
<Row>
<Col :span="fieldSort.second.labelSpan"><label class="field-label">{{fieldSort.second.label}}:</label></Col>
<Col :span="fieldSort.second.fieldSpan">
<Select v-model="_secondModel" :placeholder="fieldSort.second.holder" @on-change="secondChange" clearable>
<Option v-for="option in secondList" :value="option.sortId" :key="option.sortId">
{{option.sortName}}
</Option>
</Select>
</Col>
</Row>
</Col>
<Col :span="6" v-show="showThird">
<Row>
<Col :span="fieldSort.third.labelSpan"><label class="field-label">{{fieldSort.third.label}}:</label></Col>
<Col :span="fieldSort.third.fieldSpan">
<Select v-model="_thirdModel" :placeholder="fieldSort.third.holder" @on-change="thirdChange" clearable>
<Option v-for="option in thirdList" :value="option.sortId" :key="option.sortId">
{{option.sortName}}
</Option>
</Select>
</Col>
</Row>
</Col>
<slot></slot>
</Row>
<Cascader :data="categoryList" change-on-select @on-change="selectChange"></Cascader>
<slot></slot>
</div>
</template>
... ... @@ -49,87 +12,124 @@
export default {
name: 'SelcetCategory',
props: {
fieldSort: {
type: Object
},
firstModel: {
type: [String, Number]
}
},
data() {
return {
firstList: [],
secondList: [],
thirdList: [],
showSecond: false,
showThird: false,
sortId: {
first: '',
second: '',
third: ''
}
categoryList: []
}
},
computed: {
_firstModel() {
return this.fieldSort.first.model;
},
_secondModel() {
return this.fieldSort.second.model;
},
_thirdModel() {
return this.fieldSort.third.model;
}
},
created() {
this.getSortInfo({level: 1});
this.getSortInfo(1);
},
methods: {
firstChange(val) {
this.sortId.first = val;
this.getSortInfo({
level: 2,
sortId: val
});
getSortInfo(level, sortId) {
const params = {
level,
sortId
};
this.showSecond = val !== '' && val !== null;
this.$emit('on-change', this.sortId);
},
secondChange(val) {
this.sortId.second = val;
this.getSortInfo({
level: 3,
sortId: val
service.getAllSort(params)
.then((res) => {
if(res.code === 200) {
_.each(res.data, item => {
this.categoryList.push({
value: item.sortId,
label: item.sortName,
children: [{
value: -1,
label: ''
}]
});
});
};
});
this.showThird = val !== '' && val !== null;
this.$emit('on-change', this.sortId);
},
thirdChange(val) {
this.sortId.third = val;
this.$emit('on-change', this.sortId);
selectChange(val) {
const len = val.length;
const max = val[0];
const mid = val[1];
switch(len) {
case 1:
_.each(this.categoryList, item => {
if(item.value !== max) {
return;
};
this.getChildren(2, max)
.then(res => {
item.children.shift();
_.each(res, i => {
item.children.push({
value: i.value,
label: i.label,
children: [{
value: -1,
label: ''
}]
});
});
});
});
break;
case 2:
_.each(this.categoryList, maxItem => {
if(maxItem.value !== max) {
return;
}
_.each(maxItem.children, midItem => {
if(midItem.value !== mid) {
return;
}
this.getChildren(3, mid)
.then(res => {
midItem.children.shift();
_.each(res, i => {
midItem.children.push({
value: i.value,
label: i.label
})
})
});
});
});
break;
}
},
getSortInfo(params) {
const listMap = {
1: 'firstList',
2: 'secondList',
3: 'thirdList'
getChildren(level, sortId) {
const params = {
level,
sortId
};
service.getSort({
params
}).then((res) => {
let code = _.get(res, 'data.code');
return service.getAllSort(params)
.then((res) => {
let children = [];
if(code === 200) {
this[listMap[params.level]] = res.data.data;
}
if(res.code === 200) {
_.each(res.data, item => {
children.push({
value: item.sortId,
label: item.sortName
});
});
};
}, (error) => {
this.$Message.error(error.message);
return children;
});
}
},
}
}
</script>
... ...
... ... @@ -46,8 +46,6 @@
newPrice: this.salesPrice
}
},
computed: {
},
methods: {
changeClick() {
this.$emit('click-change');
... ...
<template>
<div class="onsale-list">
<Row :gutter="24" class-name="row-space">
<Col span="6">
<Row>
<Col :span="filters.sknCode.labelSpan">
<label class="field-label">{{filters.sknCode.label}}:</label>
</Col>
<Col :span="filters.sknCode.fieldSpan">
<Input v-model.trim="filters.sknCode.model" :placeholder="filters.sknCode.holder"></Input>
</Col>
</Row>
</Col>
<Col span="6">
<Row>
<Col :span="filters.prodCode.labelSpan">
<label class="field-label">{{filters.prodCode.label}}:</label>
</Col>
<Col :span="filters.prodCode.fieldSpan">
<Input v-model.trim="filters.prodCode.model" :placeholder="filters.prodCode.holder"></Input>
</Col>
</Row>
</Col>
<Col span="6">
<Row>
<Col :span="filters.prodName.labelSpan">
<label class="field-label">{{filters.prodName.label}}:</label>
</Col>
<Col :span="filters.prodName.fieldSpan">
<Input v-model.trim="filters.prodName.model" :placeholder="filters.prodName.holder"></Input>
</Col>
</Row>
</Col>
<Col span="6">
<Row>
<Col :span="filters.prodBarCode.labelSpan">
<label class="field-label">{{filters.prodBarCode.label}}:</label>
</Col>
<Col :span="filters.prodBarCode.fieldSpan">
<Input v-model.trim="filters.prodBarCode.model"
<LayoutBody>
<LayoutFilter>
<FilterItem :label="filters.sknCode.label">
<Input v-model.trim.trim="filters.sknCode.model"
:placeholder="filters.sknCode.holder"></Input>
</FilterItem>
<FilterItem :label="filters.prodCode.label">
<Input v-model.trim.trim="filters.prodCode.model"
:placeholder="filters.prodCode.holder"></Input>
</FilterItem>
<FilterItem :label="filters.prodName.label">
<Input v-model.trim.trim="filters.prodName.model"
:placeholder="filters.prodName.holder"></Input>
</FilterItem>
<FilterItem :label="filters.prodBarCode.label">
<Input v-model.trim.trim="filters.prodBarCode.model"
:placeholder="filters.prodBarCode.holder"></Input>
</Col>
</Row>
</Col>
</Row>
<Row :gutter="24" class-name="row-space">
<Col span="6">
<SelectBrand @on-change="brandChange"
:field-label="filters.brand.label"
:field-model="filters.brand.model"
:label-span="filters.brand.labelSpan"
:field-span="filters.brand.fieldSpan"
:option-list="filters.brand.options">
</SelectBrand>
</Col>
<Col span="6">
<Row>
<Col :span="filters.verifyStatus.labelSpan">
<label class="field-label">{{filters.verifyStatus.label}}:</label>
</Col>
<Col :span="filters.verifyStatus.fieldSpan">
<Select v-model.trim="filters.verifyStatus.model" clearable>
</FilterItem>
<FilterItem :label="filters.prodBarCode.label">
<Input v-model.trim.trim="filters.prodBarCode.model"
:placeholder="filters.prodBarCode.holder"></Input>
</FilterItem>
<FilterItem label="选择品牌">
<SelectBrand @on-change="brandChange"
:field-label="filters.brand.label"
:field-model="filters.brand.model"
:label-span="filters.brand.labelSpan"
:field-span="filters.brand.fieldSpan"
:option-list="filters.brand.options">
</SelectBrand>
</FilterItem>
<FilterItem :label="filters.verifyStatus.label">
<Select v-model.trim="filters.verifyStatus.model">
<Option v-for="option in filters.verifyStatus.options"
:value="option.value" :key="option.value">{{option.label}}</Option>
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</Col>
</Row>
</Col>
<Col span="6">
<Row>
<Col :span="filters.stockStatus.labelSpan">
<label class="field-label">{{filters.stockStatus.label}}:</label>
</Col>
<Col :span="filters.stockStatus.fieldSpan">
<Select v-model.trim="filters.stockStatus.model" clearable>
</FilterItem>
<FilterItem :label="filters.stockStatus.label">
<Select v-model.trim="filters.stockStatus.model">
<Option v-for="option in filters.stockStatus.options"
:value="option.value" :key="option.value">{{option.label}}</Option>
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</Col>
</Row>
</Col>
<Col span="6">
<Row>
<Col :span="filters.publishStatus.labelSpan">
<label class="field-label">{{filters.publishStatus.label}}:</label>
</Col>
<Col :span="filters.publishStatus.fieldSpan">
<Select v-model.trim="filters.publishStatus.model" clearable>
</FilterItem>
<FilterItem :label="filters.publishStatus.label">
<Select v-model.trim="filters.publishStatus.model">
<Option v-for="option in filters.publishStatus.options"
:value="option.value" :key="option.value">{{option.label}}</Option>
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</Col>
</Row>
</Col>
</Row>
<Row class-name="row-space">
<SelectCategory :field-sort="filters.sort" @on-change="sortChange"></SelectCategory>
</Row>
<Row class-name="row-space">
<Button type="primary" @click="filterSearch">筛选</Button>
<Button @click="clearFilter">清空条件</Button>
</Row>
<div class="hr row-space"></div>
<div class="batch-action row-space">
<Button type="success" @click="batchSetOnSale">上架</Button>
</div>
<div class="list-table row-space">
</FilterItem>
<FilterItem label="选择类目">
<SelectCategory :field-sort="filters.sort" @on-change="sortChange"></SelectCategory>
</FilterItem>
<FilterItem>
<Button type="primary" @click="filterSearch">筛选</Button>
<Button @click="clearFilter">清空条件</Button>
</FilterItem>
</LayoutFilter>
<LayoutAction>
<Button type="error" @click="batchSetOnSale">上架</Button>
</LayoutAction>
<LayoutList>
<Table border :context="self" :columns="tableCols" :data="tableData" @on-selection-change="selectChange"></Table>
</div>
<div class="list-page row-space">
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
</div>
</LayoutList>
<SizeEdit ref="showSizeEdit" :show="showSizeEdit"></SizeEdit>
</div>
</LayoutBody>
</template>
<script>
... ...
... ... @@ -68,6 +68,7 @@
</template>
<script>
import Vue from 'vue';
import _ from 'lodash';
import service from 'product-service';
import {SizeEdit} from 'product/size-edit';
... ... @@ -75,7 +76,6 @@
import {CellImage, CellInfo, CellPrice} from 'product/table-cell';
import {filterFields, initialFields, tableCols, tableData, pageData} from './store';
export default {
data() {
return {
... ...
... ... @@ -23,8 +23,17 @@ const productService = {
return axios.get(apiUrl.brand);
},
getSort(params) {
return axios.get(apiUrl.getSellerAllSortInfo, params);
getAllSort(params) {
return axios.get(apiUrl.getSellerAllSortInfo, {
params
})
.then(res => {
if(res.status === 200) {
return res.data;
}
return {};
});
},
productList(params) {
... ... @@ -79,7 +88,7 @@ const productService = {
},
exportProductFile(params) {
return axios.post(apiUrl.exportSellerProductList, params).then(result => {
return axios.get(apiUrl.exportSellerProductList, {params}).then(result => {
if (result.status === 200) {
return result.data;
}
... ...