Authored by htoooth

fix

... ... @@ -3,6 +3,7 @@ import App from './pages/app';
import yohoPluginCore from './plugins/yoho-plugin-core';
import yohoPluginRouter from './plugins/yoho-plugin-router';
import yohoPluginAuth from './plugins/yoho-plugin-auth';
import yohoPluginBus from './plugins/yoho-plugin-bus';
import './filters';
import './directives';
import 'iview/dist/styles/iview.css';
... ... @@ -14,6 +15,7 @@ import 'font-awesome/css/font-awesome.css';
Vue.use(yohoPluginCore);
Vue.use(yohoPluginRouter);
Vue.use(yohoPluginAuth);
Vue.use(yohoPluginBus);
Vue.render({
el: '#app',
... ...
... ... @@ -11,6 +11,10 @@
:placeholder="filters.prodName.holder"></Input>
</FilterItem>
<FilterItem label="选择类目">
<SelectCategory :value="categoryValue" @select-change="sortChange"></SelectCategory>
</FilterItem>
<FilterItem :label="filters.prodStatus.label">
<Select v-model.trim="filters.prodStatus.model">
<Option v-for="option in filters.prodStatus.options"
... ... @@ -19,10 +23,6 @@
</Select>
</FilterItem>
<FilterItem label="选择类目">
<SelectCategory :value="categoryValue" @select-change="sortChange"></SelectCategory>
</FilterItem>
<FilterItem>
<Button type="primary" @click="filterSearch">查询</Button>
<Button @click="clearFilter">清空条件</Button>
... ... @@ -31,14 +31,10 @@
</LayoutFilter>
<LayoutAction>
<Button type="error">选择</Button>
</LayoutAction>
<LayoutList>
<Table border :context="self" :columns="tableCols" :data="tableData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
@on-change="pageChange" :page-size="pageData.pageSize" show-total></Page>
</LayoutList>
</LayoutBody>
... ... @@ -48,84 +44,131 @@
import _ from 'lodash';
import {SelectCategory} from 'components/select';
import {CellImage} from 'components/cell';
import {tableCols, tableData} from '../store';
import {tableCols, tableData, pageData} from '../store';
import methods from '../methods';
import service from 'shop-category-service';
import operator from './operator';
export default {
props: ['cid'],
data() {
return {
self: this,
tableCols: tableCols,
tableData: tableData,
categoryId: this.cid,
categoryValue: [],
pageData: {
total: 0,
current: 1
},
pageData: pageData(),
filters: {
sknCode: {
label: 'SKN',
model: '',
model: null,
holder: ''
},
prodName: {
label: '商品名称',
model: '',
model: null,
holder: ''
},
prodStatus: {
label: '上下架状态',
model: '',
model: -1,
options: [
{
value: -1,
label: '全部'
},
{
value: 1,
label: '上架'
value: 0,
label: '未上架'
},
{
value: 2,
label: '架'
label: '已上架'
}
]
}
},
maxSortId: null,
middleSortId: null,
smallSortId: null
},
}
},
mounted() {
created() {
this.productList();
this.$bus.$on('on-tab-change', this.productList);
},
methods: {
filterParams() {
let page = this.pageData.current;
let size = this.pageData.pageSize;
let productSKN = this.filters.sknCode.model;
let productName = this.filters.prodName.model;
let status = this.filters.prodStatus.model;
let maxSortId = this.filters.maxSortId;
let middleSortId = this.filters.middleSortId;
let smallSortId = this.filters.smallSortId;
let categoryId = this.categoryId;
return Promise.resolve({
page,
size,
productSKN,
productName,
status,
maxSortId,
middleSortId,
smallSortId,
categoryId
});
},
filterSearch() {
this.productList();
},
clearFilter() {
this.filters.sknCode.model = null;
this.filters.prodName.model = null;
this.filters.prodStatus.model = -1;
this.categoryValue = [];
this.filters.maxSortId = null;
this.filters.middleSortId = null;
this.filters.smallSortId = null;
this.pageData.current = 1;
this.productList();
},
productList(params) {
service.listProduct().then((result) => {
console.log(result);
if (result.code === 200) {
this.tableData = result.data.list;
}
})
productList() {
this.filterParams().then((result) => {
return service.listProduct(result).then((result) => {
if (result.code === 200) {
this.tableData = result.data.list;
this.pageData.total = result.data.total;
this.pageData.current = result.data.page;
}
})
}).catch(() => {
this.$Message.error('查询失败,请重新查询');
});
},
reloadList() {
sortChange(sort) {
this.filters.maxSortId = sort.max;
this.filters.middleSortId = sort.mid;
this.filters.smallSortId = sort.min;
},
pageChange(page) {
this.pageData.current = page;
this.productList();
},
sortChange() {
onColStatusChange() {
this.productList()
},
...methods
},
components: {
SelectCategory,
CellImage
CellImage,
operator
}
}
</script>
... ...
<template>
<div class="action-btn-row">
<Button type="warning" v-if="product.checked" @click="cancelCategory">取消选择</Button>
<Button type="success" v-else @click="addCategory">选择</Button>
</div>
</template>
<script>
import service from 'shop-category-service';
export default {
name: 'operator',
props: ['product', 'categoryId'],
methods: {
cancelCategory() {
service.deleteBindProduct(this.categoryId, this.product.productSKN)
.then((result) => {
if (result.code === 200) {
this.$emit('on-change-status');
this.$bus.$emit('on-count-change');
}
});
},
addCategory() {
service.createBindProduct(this.categoryId, this.product.productSKN)
.then((result) => {
if (result.code === 200) {
this.$emit('on-change-status');
this.$bus.$emit('on-count-change');
}
});
}
}
}
</script>
<style>
</style>
... ...
... ... @@ -11,6 +11,10 @@
:placeholder="filters.prodName.holder"></Input>
</FilterItem>
<FilterItem label="选择类目">
<SelectCategory :value="categoryValue" @select-change="sortChange"></SelectCategory>
</FilterItem>
<FilterItem :label="filters.prodStatus.label">
<Select v-model.trim="filters.prodStatus.model">
<Option v-for="option in filters.prodStatus.options"
... ... @@ -19,10 +23,6 @@
</Select>
</FilterItem>
<FilterItem label="选择类目">
<SelectCategory :value="categoryValue" @select-change="sortChange"></SelectCategory>
</FilterItem>
<FilterItem>
<Button type="primary" @click="filterSearch">查询</Button>
<Button @click="clearFilter">清空条件</Button>
... ... @@ -31,14 +31,10 @@
</LayoutFilter>
<LayoutAction>
<Button type="error">取消选择</Button>
</LayoutAction>
<LayoutList>
<Table border :context="self" :columns="tableCols" :data="tableData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
@on-change="pageChange" :page-size="pageData.pageSize" show-total></Page>
</LayoutList>
</LayoutBody>
... ... @@ -47,83 +43,132 @@
<script>
import _ from 'lodash';
import {SelectCategory} from 'components/select';
import {tableCols, tableData} from '../store'
import methods from '../methods'
import {CellImage} from 'components/cell';
import {tableCols, tableData, pageData} from '../store';
import methods from '../methods';
import service from 'shop-category-service';
import operator from './operator';
export default {
props: ['categoryId'],
props: ['cid'],
data() {
return {
self: this,
tableCols: tableCols,
tableData: tableData,
categoryId: this.cid,
categoryValue: [],
pageData: {
total: 0,
current: 1
},
pageData: pageData(),
filters: {
sknCode: {
label: 'SKN',
model: '',
model: null,
holder: ''
},
prodName: {
label: '商品名称',
model: '',
model: null,
holder: ''
},
prodStatus: {
label: '上下架状态',
model: '',
model: -1,
options: [
{
value: -1,
label: '全部'
},
{
value: 1,
label: '上架'
value: 0,
label: '未上架'
},
{
value: 2,
label: '架'
label: '已上架'
}
]
}
},
maxSortId: null,
middleSortId: null,
smallSortId: null
},
}
},
mounted() {
created() {
this.productList();
this.$bus.$on('on-tab-change', this.productList);
},
methods: {
filterParams() {
let page = this.pageData.current;
let size = this.pageData.pageSize;
let productSKN = this.filters.sknCode.model;
let productName = this.filters.prodName.model;
let status = this.filters.prodStatus.model;
let maxSortId = this.filters.maxSortId;
let middleSortId = this.filters.middleSortId;
let smallSortId = this.filters.smallSortId;
let categoryId = this.categoryId;
return Promise.resolve({
page,
size,
productSKN,
productName,
status,
maxSortId,
middleSortId,
smallSortId,
categoryId
});
},
filterSearch() {
this.productList();
},
clearFilter() {
this.filters.sknCode.model = null;
this.filters.prodName.model = null;
this.filters.prodStatus.model = -1;
this.categoryValue = [];
this.filters.maxSortId = null;
this.filters.middleSortId = null;
this.filters.smallSortId = null;
this.pageData.current = 1;
this.productList();
},
productList(params) {
service.listBindProduct(this.categoryId).then((result) => {
if (result.code === 200) {
this.tableData = result.data.list;
}
})
productList() {
this.filterParams().then((result) => {
return service.listBindProduct(result).then((result) => {
if (result.code === 200) {
this.tableData = result.data.list;
this.pageData.total = result.data.total;
this.pageData.current = result.data.page;
}
})
}).catch(() => {
this.$Message.error('查询失败,请重新查询');
});
},
reloadList() {
sortChange(sort) {
this.filters.maxSortId = sort.max;
this.filters.middleSortId = sort.mid;
this.filters.smallSortId = sort.min;
},
pageChange(page) {
this.pageData.current = page;
this.productList();
},
sortChange() {
onColStatusChange() {
this.productList()
},
...methods
},
components: {
SelectCategory
SelectCategory,
CellImage,
operator
}
}
</script>
... ...
<template>
<Tabs type="card" :animated="false">
<Tabs type="card" :animated="false" @on-click="onTabsClick">
<Tab-pane :label="'全部商品'">
<ProductList @on-count-change="onCountChange"></ProductList>
<ProductList @on-count-change="onCountChange" :cid="categoryId"></ProductList>
</Tab-pane>
<Tab-pane :label="handleCount">
<ProductSelectedList @on-count-change="onCountChange" :categoryId="categoryId"></ProductSelectedList>
<ProductSelectedList @on-count-change="onCountChange" :cid="categoryId"></ProductSelectedList>
</Tab-pane>
<Button type="ghost" size="small" slot="extra" @click="back">返回</Button>
... ... @@ -20,12 +20,13 @@ export default {
data () {
return {
count: 0,
categoryId: ''
categoryId: '',
}
},
created() {
this.categoryId = this.$route.query.categoryId;
this.getCount();
this.$bus.$on('on-count-change', this.getCount);
},
methods: {
back() {
... ... @@ -40,6 +41,9 @@ export default {
this.count = result.data
}
})
},
onTabsClick() {
this.$bus.$emit('on-tab-change');
}
},
computed: {
... ...
... ... @@ -3,21 +3,7 @@
*/
let tableCols = [
{
type: 'selection',
width: 60,
align: 'center'
},
{
title: '当前状态',
key: 'checked',
render: function(row) {
return `<div class="action-btn-row">
<Tag color="green" v-if="row.checked">已选择</Tag>
<Tag color="yellow" v-else>未选择</Tag>
</div>`;
}
},
{
title: '商品图片',
key: 'productPic',
... ... @@ -55,47 +41,33 @@ let tableCols = [
},
{
title: '商品分类',
key: 'saleCategory'
}
];
let tableData = [
{
"categoryName": "111222",
"checked": true,
"factoryCode": "",
"productName": "创建的基础商品为什么找不到_审核通过",
"productPic": "",
"productSKN": 51198397,
"productSort": "裤装-连体裤-连体裤",
"saleCategory": [
"111222",
"铁锁链孤舟"
],
"salePrice": 199,
"status": 0,
"storage": 5
key: 'saleCategory',
render: function(row) {
return `<div v-for="i in row.saleCategory">{{i}}</div>`
}
},
{
"categoryName": "铁锁链孤舟",
"checked": false,
"factoryCode": "",
"productName": "得宝笔记本测试商品,请勿购买",
"productPic": "http://img13.static.yhbimg.com/goodsimg/2015/09/14/07/0216e9186d1b41e76434457636fdb3e70c.jpg",
"productSKN": 51145654,
"productSort": "创意生活-文具-本子",
"saleCategory": [
"测试111333",
"111222",
"铁锁链孤舟"
],
"salePrice": 11,
"status": 0,
"storage": 2
title: '操作',
key: 'checked',
render: function(row) {
return `<operator :category-id="categoryId" :product="row"
@on-change-status="onColStatusChange"> </operator>`;
}
}
];
let tableData = [];
let pageData = () => {
return {
total: 0,
current: 1,
pageSize: 20
};
};
export {
tableCols,
tableData
tableData,
pageData
}
\ No newline at end of file
... ...
... ... @@ -8,7 +8,7 @@
<div style="text-align: center">
<FilterItem :label="'商品分类名称'">
<Input v-model="name"/>
<Input v-model="name" @on-enter="submit"/>
</FilterItem>
</div>
... ...
... ... @@ -9,7 +9,7 @@
<LayoutList>
<Table border :context="self" :columns="tableCols" :data="tableData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
@on-change="pageChange" :page-size="pageData.pageSize" show-total></Page>
</LayoutList>
<EditName ref="showNameEdit" @on-success="onEditSuccess"></EditName>
</LayoutBody>
... ... @@ -45,7 +45,7 @@
content: `你确定 删除 商品分类 ${row.categoryName} 么?`,
onOk() {
_this.deleteCategory(row.categoryId).then(() => {
_this.tableData.splice(_this.tableData.indexOf(row), 1)
_this.getData();
});
},
})
... ... @@ -57,11 +57,13 @@
clickCreate() {
this.$refs.showNameEdit.create()
},
pageChange() {
pageChange(num) {
this.pageData.current = num;
this.getData();
},
getData() {
return service.getCategoryList(pageData.current).then((result) => {
return service.getCategoryList(pageData.current, pageData.pageSize).then((result) => {
if (result.code === 200) {
this.pageData.total = result.data.total;
this.pageData.current = result.data.currentPage;
... ... @@ -79,7 +81,6 @@
});
},
onEditSuccess() {
console.log('ok');
this.getData();
}
},
... ...
... ... @@ -54,7 +54,8 @@ let tableData = [
let pageData = {
total: 0,
current: 1
current: 1,
pageSize: 20
};
export {
... ...
import Vue from 'vue'
const eventBus = new Vue();
const bus = {
install(vue) {
Object.defineProperty(vue.prototype, '$bus', {
get(){
return eventBus
}
});
}
};
export default bus;
\ No newline at end of file
... ...
... ... @@ -41,7 +41,7 @@ export default [
id: 31
},
{
menu_name: '可调拨库存',
menu_name: '可调拨库存(jit)',
menu_url: '/repository/jit.html',
menu_id: 'repository.jit',
status: 1,
... ...
... ... @@ -20,10 +20,11 @@ const apiUrl = {
* 获得所有分类
* @param page
*/
function getCategoryList(page = 1) {
function getCategoryList(page = 1, size = 20) {
return request.get(apiUrl.categoryList, {
params: {
page
page,
size
}
}).then(res => res.data);
}
... ... @@ -61,8 +62,8 @@ function deleteCategory(id) {
* @param page
* @param size
*/
function listProduct(page = 1, size = 20) {
return request.post(apiUrl.listProduct, { page, size } )
function listProduct(params) {
return request.post(apiUrl.listProduct, params)
.then(res => res.data);
}
... ... @@ -72,8 +73,8 @@ function listProduct(page = 1, size = 20) {
* @param page
* @param size
*/
function listBindProduct(categoryId, page = 1, size = 20) {
return request.post(apiUrl.listBindProduct, { categoryId, page, size })
function listBindProduct(params) {
return request.post(apiUrl.listBindProduct, params)
.then(res => res.data);
}
... ...