Merge branch 'release/1.0' of http://git.yoho.cn/fe/yoho-shop-manage into release/1.0
Showing
19 changed files
with
282 additions
and
47 deletions
@@ -2,12 +2,14 @@ | @@ -2,12 +2,14 @@ | ||
2 | <div class="cell-price"> | 2 | <div class="cell-price"> |
3 | <div v-if="canChange"> | 3 | <div v-if="canChange"> |
4 | <p>吊牌价:{{retailPrice}}</p> | 4 | <p>吊牌价:{{retailPrice}}</p> |
5 | - <p v-if="!showChange">销售价:{{salesPrice}} | 5 | + <p v-if="!showChange"> |
6 | <i-button type="info" size="small" @click="changeClick">改</i-button> | 6 | <i-button type="info" size="small" @click="changeClick">改</i-button> |
7 | + 销售价:{{salesPrice}} | ||
7 | </p> | 8 | </p> |
8 | - <p v-else>销售价:<span class="price-input"> | ||
9 | - <Input v-model.number="newPrice"></Input></span> | 9 | + <p v-else> |
10 | <i-button type="warning" size="small" @click="saveClick">存</i-button> | 10 | <i-button type="warning" size="small" @click="saveClick">存</i-button> |
11 | + 销售价:<span class="price-input"> | ||
12 | + <Input v-model.number="newPrice"></Input></span> | ||
11 | </p> | 13 | </p> |
12 | </div> | 14 | </div> |
13 | <div v-else> | 15 | <div v-else> |
@@ -16,7 +16,7 @@ export default () => { | @@ -16,7 +16,7 @@ export default () => { | ||
16 | productName: '', | 16 | productName: '', |
17 | phrase: '', | 17 | phrase: '', |
18 | factoryCode: '', | 18 | factoryCode: '', |
19 | - goodsYears: '', | 19 | + goodsYears: new Date().getFullYear().toString(), |
20 | goodsSeason: '', | 20 | goodsSeason: '', |
21 | gender: '', | 21 | gender: '', |
22 | seasons: '', | 22 | seasons: '', |
@@ -148,6 +148,11 @@ export default { | @@ -148,6 +148,11 @@ export default { | ||
148 | return api.getBrand().then((result) => { | 148 | return api.getBrand().then((result) => { |
149 | if (result.code === 200) { | 149 | if (result.code === 200) { |
150 | this.brands = result.data; | 150 | this.brands = result.data; |
151 | + | ||
152 | + if (this.brands.length === 1) { | ||
153 | + this.product.brandId = this.brands[0].brandId; | ||
154 | + this.product.brandName = this.brands[0].brandName; | ||
155 | + } | ||
151 | } | 156 | } |
152 | }); | 157 | }); |
153 | }, | 158 | }, |
@@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
44 | 44 | ||
45 | <Row> | 45 | <Row> |
46 | <Col span="8"> | 46 | <Col span="8"> |
47 | - <Form-item label="商品卖点" prop="phrase"> | 47 | + <Form-item label="商品卖点"> |
48 | <Input v-model="product.phrase" type="textarea" :rows="4" placeholder="请输入..."/> | 48 | <Input v-model="product.phrase" type="textarea" :rows="4" placeholder="请输入..."/> |
49 | </Form-item> | 49 | </Form-item> |
50 | </Col> | 50 | </Col> |
@@ -244,7 +244,9 @@ export default { | @@ -244,7 +244,9 @@ export default { | ||
244 | } | 244 | } |
245 | 245 | ||
246 | if (!Number.isInteger(value)) { | 246 | if (!Number.isInteger(value)) { |
247 | - callback(new Error('请输入数字值')); | 247 | + callback(new Error('请输入整数,不能有小数点')); |
248 | + } else if (value > 100000) { | ||
249 | + callback(new Error('价格不能大于6位')); | ||
248 | } else { | 250 | } else { |
249 | callback(); | 251 | callback(); |
250 | 252 | ||
@@ -383,9 +385,6 @@ export default { | @@ -383,9 +385,6 @@ export default { | ||
383 | productName: [ | 385 | productName: [ |
384 | { required: true, message: '商品名不能为空', trigger: 'blur'} | 386 | { required: true, message: '商品名不能为空', trigger: 'blur'} |
385 | ], | 387 | ], |
386 | - phrase: [ | ||
387 | - { required: true, message: '商品卖点不能为空', trigger: 'blur'} | ||
388 | - ], | ||
389 | goodsYears: [ | 388 | goodsYears: [ |
390 | { required: true, message: '货品年不能为空', trigger: 'change', type: 'string'} | 389 | { required: true, message: '货品年不能为空', trigger: 'change', type: 'string'} |
391 | ], | 390 | ], |
@@ -410,7 +409,8 @@ export default { | @@ -410,7 +409,8 @@ export default { | ||
410 | salesPrice: [ | 409 | salesPrice: [ |
411 | { required: true, trigger: 'blur', validator: validateMustLessRetailPrice}, | 410 | { required: true, trigger: 'blur', validator: validateMustLessRetailPrice}, |
412 | ] | 411 | ] |
413 | - } | 412 | + }, |
413 | + years: 2018 | ||
414 | }; | 414 | }; |
415 | }, | 415 | }, |
416 | mounted: function() { | 416 | mounted: function() { |
@@ -261,9 +261,9 @@ export default { | @@ -261,9 +261,9 @@ export default { | ||
261 | }, | 261 | }, |
262 | getAllAttr: function(smallSortId, maxSortId) { | 262 | getAllAttr: function(smallSortId, maxSortId) { |
263 | return api.getAllAttr(smallSortId, maxSortId).then((result) => { | 263 | return api.getAllAttr(smallSortId, maxSortId).then((result) => { |
264 | - this.render.productStandardRelationStr = result[0]; | ||
265 | - this.render.attributeProValuesOne = result[1]; | ||
266 | - this.render.attributeProValuesTwo = result[2]; | 264 | + this.render.productStandardRelationStr = service.addNoneItem(result[0]); |
265 | + this.render.attributeProValuesOne = service.addNoneItem(result[1]); | ||
266 | + this.render.attributeProValuesTwo = service.addNoneItem(result[2]); | ||
267 | this.render.productMaterial = result[3]; | 267 | this.render.productMaterial = result[3]; |
268 | }); | 268 | }); |
269 | }, | 269 | }, |
@@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
43 | 43 | ||
44 | <Row> | 44 | <Row> |
45 | <Col span="8"> | 45 | <Col span="8"> |
46 | - <Form-item label="商品卖点" prop="phrase"> | 46 | + <Form-item label="商品卖点"> |
47 | <Input v-model="product.phrase" type="textarea" :rows="4" placeholder="请输入..." style="width: 350px;"/> | 47 | <Input v-model="product.phrase" type="textarea" :rows="4" placeholder="请输入..." style="width: 350px;"/> |
48 | </Form-item> | 48 | </Form-item> |
49 | </Col> | 49 | </Col> |
@@ -620,9 +620,9 @@ export default { | @@ -620,9 +620,9 @@ export default { | ||
620 | }, | 620 | }, |
621 | getAllAttr: function(smallSortId, maxSortId) { | 621 | getAllAttr: function(smallSortId, maxSortId) { |
622 | return api.getAllAttr(smallSortId, maxSortId).then((result) => { | 622 | return api.getAllAttr(smallSortId, maxSortId).then((result) => { |
623 | - this.render.productStandardRelationStr = result[0] || []; | ||
624 | - this.render.attributeProValuesOne = result[1]; | ||
625 | - this.render.attributeProValuesTwo = result[2]; | 623 | + this.render.productStandardRelationStr = service.addNoneItem(result[0] || []); |
624 | + this.render.attributeProValuesOne = service.addNoneItem(result[1]); | ||
625 | + this.render.attributeProValuesTwo = service.addNoneItem(result[2]); | ||
626 | this.render.productMaterial = result[3]; | 626 | this.render.productMaterial = result[3]; |
627 | }).then(() => { | 627 | }).then(() => { |
628 | let relation = this.product.productStandardRelationBoList || []; | 628 | let relation = this.product.productStandardRelationBoList || []; |
@@ -695,6 +695,7 @@ export default { | @@ -695,6 +695,7 @@ export default { | ||
695 | let goodsImageList = this.product.sellerGoodsImagesList; | 695 | let goodsImageList = this.product.sellerGoodsImagesList; |
696 | 696 | ||
697 | this.table.data = _.range(goodsList.length).map((i) => { | 697 | this.table.data = _.range(goodsList.length).map((i) => { |
698 | + console.log(goodsList[i], goodsImageList[i]); | ||
698 | return this.handleItem(goodsList[i], goodsImageList[i]); | 699 | return this.handleItem(goodsList[i], goodsImageList[i]); |
699 | }); | 700 | }); |
700 | 701 | ||
@@ -772,7 +773,6 @@ export default { | @@ -772,7 +773,6 @@ export default { | ||
772 | }, | 773 | }, |
773 | beforeSave: function() { | 774 | beforeSave: function() { |
774 | let newProduct = makeSaveProduct(); | 775 | let newProduct = makeSaveProduct(); |
775 | - | ||
776 | this.refreshTable(); | 776 | this.refreshTable(); |
777 | 777 | ||
778 | newProduct.productSkn = this.product.productSkn; | 778 | newProduct.productSkn = this.product.productSkn; |
@@ -248,6 +248,11 @@ | @@ -248,6 +248,11 @@ | ||
248 | const salesPrice = newSalesPrice; | 248 | const salesPrice = newSalesPrice; |
249 | const productSkn = row.productSkn; | 249 | const productSkn = row.productSkn; |
250 | 250 | ||
251 | + if(newSalesPrice > row.salesPrice) { | ||
252 | + this.$Message.error('销售价不能大于吊牌价'); | ||
253 | + return; | ||
254 | + } | ||
255 | + | ||
251 | if(newSalesPrice === row.salesPrice) { | 256 | if(newSalesPrice === row.salesPrice) { |
252 | row.changePrice = false; | 257 | row.changePrice = false; |
253 | return; | 258 | return; |
@@ -171,6 +171,7 @@ export default () => { | @@ -171,6 +171,7 @@ export default () => { | ||
171 | { | 171 | { |
172 | title: '价格(元)', | 172 | title: '价格(元)', |
173 | key: 'price', | 173 | key: 'price', |
174 | + width: '180', | ||
174 | align: 'center', | 175 | align: 'center', |
175 | render(row, column, index) { | 176 | render(row, column, index) { |
176 | row.lineIndex = index; | 177 | row.lineIndex = index; |
@@ -231,10 +231,16 @@ | @@ -231,10 +231,16 @@ | ||
231 | row.changePrice = true; | 231 | row.changePrice = true; |
232 | }, | 232 | }, |
233 | updatePrice(row, newSalesPrice) { | 233 | updatePrice(row, newSalesPrice) { |
234 | + | ||
234 | const index = row.lineIndex; | 235 | const index = row.lineIndex; |
235 | const salesPrice = newSalesPrice; | 236 | const salesPrice = newSalesPrice; |
236 | const productSkn = row.productSkn; | 237 | const productSkn = row.productSkn; |
237 | 238 | ||
239 | + if(newSalesPrice > row.salesPrice) { | ||
240 | + this.$Message.error('销售价不能大于吊牌价'); | ||
241 | + return; | ||
242 | + } | ||
243 | + | ||
238 | if(newSalesPrice === row.salesPrice) { | 244 | if(newSalesPrice === row.salesPrice) { |
239 | row.changePrice = false; | 245 | row.changePrice = false; |
240 | return; | 246 | return; |
@@ -46,6 +46,7 @@ export default () => { | @@ -46,6 +46,7 @@ export default () => { | ||
46 | { | 46 | { |
47 | title: '价格(元)', | 47 | title: '价格(元)', |
48 | key: 'price', | 48 | key: 'price', |
49 | + width: '180', | ||
49 | align: 'center', | 50 | align: 'center', |
50 | render(row, column, index) { | 51 | render(row, column, index) { |
51 | row.lineIndex = index; | 52 | row.lineIndex = index; |
@@ -48,8 +48,9 @@ | @@ -48,8 +48,9 @@ | ||
48 | import _ from 'lodash'; | 48 | import _ from 'lodash'; |
49 | import {SelectCategory} from 'components/select'; | 49 | import {SelectCategory} from 'components/select'; |
50 | import {CellImage} from 'components/cell'; | 50 | import {CellImage} from 'components/cell'; |
51 | - import {tableCols, tableData} from '../store' | ||
52 | - import methods from '../methods' | 51 | + import {tableCols, tableData} from '../store'; |
52 | + import methods from '../methods'; | ||
53 | + import service from 'shop-category-service'; | ||
53 | 54 | ||
54 | export default { | 55 | export default { |
55 | data() { | 56 | data() { |
@@ -95,7 +96,8 @@ | @@ -95,7 +96,8 @@ | ||
95 | }, | 96 | }, |
96 | } | 97 | } |
97 | }, | 98 | }, |
98 | - created() { | 99 | + mounted() { |
100 | + this.productList(); | ||
99 | }, | 101 | }, |
100 | methods: { | 102 | methods: { |
101 | filterParams() { | 103 | filterParams() { |
@@ -105,6 +107,12 @@ | @@ -105,6 +107,12 @@ | ||
105 | clearFilter() { | 107 | clearFilter() { |
106 | }, | 108 | }, |
107 | productList(params) { | 109 | productList(params) { |
110 | + service.listProduct().then((result) => { | ||
111 | + console.log(result); | ||
112 | + if (result.code === 200) { | ||
113 | + this.tableData = result.data.list; | ||
114 | + } | ||
115 | + }) | ||
108 | }, | 116 | }, |
109 | reloadList() { | 117 | reloadList() { |
110 | }, | 118 | }, |
@@ -49,8 +49,10 @@ | @@ -49,8 +49,10 @@ | ||
49 | import {SelectCategory} from 'components/select'; | 49 | import {SelectCategory} from 'components/select'; |
50 | import {tableCols, tableData} from '../store' | 50 | import {tableCols, tableData} from '../store' |
51 | import methods from '../methods' | 51 | import methods from '../methods' |
52 | + import service from 'shop-category-service'; | ||
52 | 53 | ||
53 | export default { | 54 | export default { |
55 | + props: ['categoryId'], | ||
54 | data() { | 56 | data() { |
55 | return { | 57 | return { |
56 | self: this, | 58 | self: this, |
@@ -94,7 +96,8 @@ | @@ -94,7 +96,8 @@ | ||
94 | }, | 96 | }, |
95 | } | 97 | } |
96 | }, | 98 | }, |
97 | - created() { | 99 | + mounted() { |
100 | + this.productList(); | ||
98 | }, | 101 | }, |
99 | methods: { | 102 | methods: { |
100 | filterParams() { | 103 | filterParams() { |
@@ -104,6 +107,11 @@ | @@ -104,6 +107,11 @@ | ||
104 | clearFilter() { | 107 | clearFilter() { |
105 | }, | 108 | }, |
106 | productList(params) { | 109 | productList(params) { |
110 | + service.listBindProduct(this.categoryId).then((result) => { | ||
111 | + if (result.code === 200) { | ||
112 | + this.tableData = result.data.list; | ||
113 | + } | ||
114 | + }) | ||
107 | }, | 115 | }, |
108 | reloadList() { | 116 | reloadList() { |
109 | }, | 117 | }, |
1 | <template> | 1 | <template> |
2 | <Tabs type="card" :animated="false"> | 2 | <Tabs type="card" :animated="false"> |
3 | <Tab-pane :label="'全部商品'"> | 3 | <Tab-pane :label="'全部商品'"> |
4 | - <ProductList></ProductList> | 4 | + <ProductList @on-count-change="onCountChange"></ProductList> |
5 | </Tab-pane> | 5 | </Tab-pane> |
6 | 6 | ||
7 | <Tab-pane :label="handleCount"> | 7 | <Tab-pane :label="handleCount"> |
8 | - <ProductSelectedList></ProductSelectedList> | 8 | + <ProductSelectedList @on-count-change="onCountChange" :categoryId="categoryId"></ProductSelectedList> |
9 | </Tab-pane> | 9 | </Tab-pane> |
10 | 10 | ||
11 | <Button type="ghost" size="small" slot="extra" @click="back">返回</Button> | 11 | <Button type="ghost" size="small" slot="extra" @click="back">返回</Button> |
@@ -14,16 +14,32 @@ | @@ -14,16 +14,32 @@ | ||
14 | <script> | 14 | <script> |
15 | 15 | ||
16 | import components from './components'; | 16 | import components from './components'; |
17 | +import service from 'shop-category-service'; | ||
17 | 18 | ||
18 | export default { | 19 | export default { |
19 | data () { | 20 | data () { |
20 | return { | 21 | return { |
21 | - count: 2, | 22 | + count: 0, |
23 | + categoryId: '' | ||
22 | } | 24 | } |
23 | }, | 25 | }, |
26 | + created() { | ||
27 | + this.categoryId = this.$route.query.categoryId; | ||
28 | + this.getCount(); | ||
29 | + }, | ||
24 | methods: { | 30 | methods: { |
25 | back() { | 31 | back() { |
26 | this.$router.push({name: 'shop.category.list'}) | 32 | this.$router.push({name: 'shop.category.list'}) |
33 | + }, | ||
34 | + onCountChange() { | ||
35 | + this.getCount(); | ||
36 | + }, | ||
37 | + getCount() { | ||
38 | + service.countBindProduct(this.categoryId).then((result) => { | ||
39 | + if (result.code === 200) { | ||
40 | + this.count = result.data | ||
41 | + } | ||
42 | + }) | ||
27 | } | 43 | } |
28 | }, | 44 | }, |
29 | computed: { | 45 | computed: { |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | 8 | ||
9 | <div style="text-align: center"> | 9 | <div style="text-align: center"> |
10 | <FilterItem :label="'商品分类名称'"> | 10 | <FilterItem :label="'商品分类名称'"> |
11 | - <Input >fdsa</Input> | 11 | + <Input v-model="name"/> |
12 | </FilterItem> | 12 | </FilterItem> |
13 | </div> | 13 | </div> |
14 | 14 | ||
@@ -20,15 +20,27 @@ | @@ -20,15 +20,27 @@ | ||
20 | </template> | 20 | </template> |
21 | 21 | ||
22 | <script> | 22 | <script> |
23 | + | ||
24 | + import service from 'shop-category-service'; | ||
25 | + | ||
23 | export default { | 26 | export default { |
24 | data() { | 27 | data() { |
25 | return { | 28 | return { |
26 | model: false, | 29 | model: false, |
27 | - modal_loading: false | 30 | + modal_loading: false, |
31 | + name: '', | ||
32 | + id: '' | ||
28 | } | 33 | } |
29 | }, | 34 | }, |
30 | methods: { | 35 | methods: { |
31 | - show() { | 36 | + update(c) { |
37 | + this.reset(); | ||
38 | + this.model = true; | ||
39 | + this.id = c.categoryId; | ||
40 | + this.name = c.categoryName; | ||
41 | + }, | ||
42 | + create() { | ||
43 | + this.reset(); | ||
32 | this.model = true; | 44 | this.model = true; |
33 | }, | 45 | }, |
34 | close() { | 46 | close() { |
@@ -38,17 +50,20 @@ | @@ -38,17 +50,20 @@ | ||
38 | this.modal_loading = true; | 50 | this.modal_loading = true; |
39 | 51 | ||
40 | this.save().then(() => { | 52 | this.save().then(() => { |
41 | - setTimeout(() => { | ||
42 | - this.close(); | ||
43 | - }, 2000) | 53 | + this.modal_loading = false; |
54 | + this.$emit('on-success'); | ||
55 | + this.close(); | ||
44 | }) | 56 | }) |
45 | }, | 57 | }, |
46 | cancel(){ | 58 | cancel(){ |
47 | this.close(); | 59 | this.close(); |
48 | }, | 60 | }, |
49 | save() { | 61 | save() { |
62 | + return service.updateCategoryName(this.id, this.name); | ||
50 | }, | 63 | }, |
51 | reset() { | 64 | reset() { |
65 | + this.name = ''; | ||
66 | + this.id = ''; | ||
52 | } | 67 | } |
53 | } | 68 | } |
54 | } | 69 | } |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | <Page :total="pageData.total" :current="pageData.current" | 11 | <Page :total="pageData.total" :current="pageData.current" |
12 | @on-change="pageChange" :page-size="20" show-total></Page> | 12 | @on-change="pageChange" :page-size="20" show-total></Page> |
13 | </LayoutList> | 13 | </LayoutList> |
14 | - <EditName ref="showNameEdit"></EditName> | 14 | + <EditName ref="showNameEdit" @on-success="onEditSuccess"></EditName> |
15 | </LayoutBody> | 15 | </LayoutBody> |
16 | </template> | 16 | </template> |
17 | 17 | ||
@@ -19,30 +19,35 @@ | @@ -19,30 +19,35 @@ | ||
19 | import _ from 'lodash'; | 19 | import _ from 'lodash'; |
20 | import {tableCols, pageData, tableData} from './store'; | 20 | import {tableCols, pageData, tableData} from './store'; |
21 | import components from './components'; | 21 | import components from './components'; |
22 | + import service from 'shop-category-service'; | ||
22 | 23 | ||
23 | export default { | 24 | export default { |
24 | data() { | 25 | data() { |
25 | return { | 26 | return { |
26 | self: this, | 27 | self: this, |
27 | tableCols, | 28 | tableCols, |
28 | - tableData, | 29 | + tableData: [], |
29 | pageData, | 30 | pageData, |
30 | } | 31 | } |
31 | }, | 32 | }, |
33 | + mounted() { | ||
34 | + this.getData(); | ||
35 | + }, | ||
32 | methods: { | 36 | methods: { |
33 | clickEditName(row) { | 37 | clickEditName(row) { |
34 | - this.$refs.showNameEdit.show(row) | 38 | + this.$refs.showNameEdit.update(row) |
35 | }, | 39 | }, |
36 | clickDelete(row) { | 40 | clickDelete(row) { |
41 | + let _this = this; | ||
42 | + | ||
37 | this.$Modal.confirm({ | 43 | this.$Modal.confirm({ |
38 | title: '删除店铺商品分类', | 44 | title: '删除店铺商品分类', |
39 | - content: '你确定 删除 商品分类 test 么?', | ||
40 | - onOk: function() { | ||
41 | - | 45 | + content: `你确定 删除 商品分类 ${row.categoryName} 么?`, |
46 | + onOk() { | ||
47 | + _this.deleteCategory(row.categoryId).then(() => { | ||
48 | + _this.tableData.splice(_this.tableData.indexOf(row), 1) | ||
49 | + }); | ||
42 | }, | 50 | }, |
43 | - onCancel: function() { | ||
44 | - | ||
45 | - } | ||
46 | }) | 51 | }) |
47 | }, | 52 | }, |
48 | clickEditRelation(row) { | 53 | clickEditRelation(row) { |
@@ -50,12 +55,33 @@ | @@ -50,12 +55,33 @@ | ||
50 | this.$router.push({name: 'shop.category.edit', query: { categoryId }}) | 55 | this.$router.push({name: 'shop.category.edit', query: { categoryId }}) |
51 | }, | 56 | }, |
52 | clickCreate() { | 57 | clickCreate() { |
53 | - | 58 | + this.$refs.showNameEdit.create() |
54 | }, | 59 | }, |
55 | pageChange() { | 60 | pageChange() { |
56 | 61 | ||
57 | }, | 62 | }, |
58 | - | 63 | + getData() { |
64 | + return service.getCategoryList(pageData.current).then((result) => { | ||
65 | + if (result.code === 200) { | ||
66 | + this.pageData.total = result.data.total; | ||
67 | + this.pageData.current = result.data.currentPage; | ||
68 | + this.tableData = result.data.rows; | ||
69 | + } | ||
70 | + }); | ||
71 | + }, | ||
72 | + deleteCategory(id) { | ||
73 | + return service.deleteCategory(id).then((result) => { | ||
74 | + if (result.code === 200) { | ||
75 | + return Promise.resolve(); | ||
76 | + } else { | ||
77 | + return Promise.reject(); | ||
78 | + } | ||
79 | + }); | ||
80 | + }, | ||
81 | + onEditSuccess() { | ||
82 | + console.log('ok'); | ||
83 | + this.getData(); | ||
84 | + } | ||
59 | }, | 85 | }, |
60 | components: { | 86 | components: { |
61 | ...components | 87 | ...components |
@@ -8,10 +8,12 @@ const handleRelation = (oneValuesObj = []) => { | @@ -8,10 +8,12 @@ const handleRelation = (oneValuesObj = []) => { | ||
8 | return oneValuesObj.reduce((total, r) => { | 8 | return oneValuesObj.reduce((total, r) => { |
9 | let str = _.isArray(r.model) ? r.model.join(',') : r.model; | 9 | let str = _.isArray(r.model) ? r.model.join(',') : r.model; |
10 | 10 | ||
11 | - if (str) { | 11 | + if (+str) { |
12 | + let valObj = _.find(r.idNameList, {id: str}); | ||
13 | + | ||
12 | total.push({ | 14 | total.push({ |
13 | standardId: r.attributeId, | 15 | standardId: r.attributeId, |
14 | - standardVal: r.attributeName, | 16 | + standardVal: valObj.text || '', |
15 | parameterMakeId: str | 17 | parameterMakeId: str |
16 | }); | 18 | }); |
17 | } | 19 | } |
@@ -24,7 +26,7 @@ const handleValue = (skn, valueObj = []) => { | @@ -24,7 +26,7 @@ const handleValue = (skn, valueObj = []) => { | ||
24 | return valueObj.reduce((total, r) => { | 26 | return valueObj.reduce((total, r) => { |
25 | let str = _.isArray(r.model) ? r.model.join(',') : r.model; | 27 | let str = _.isArray(r.model) ? r.model.join(',') : r.model; |
26 | 28 | ||
27 | - if (str) { | 29 | + if (+str) { |
28 | total.push({ | 30 | total.push({ |
29 | attributeId: r.attributeId, | 31 | attributeId: r.attributeId, |
30 | productSkn: skn, | 32 | productSkn: skn, |
@@ -133,10 +133,19 @@ function getProduct(skn) { | @@ -133,10 +133,19 @@ function getProduct(skn) { | ||
133 | }); | 133 | }); |
134 | } | 134 | } |
135 | 135 | ||
136 | +function addNoneItem(objArray) { | ||
137 | + objArray.forEach(obj => { | ||
138 | + obj.idNameList && obj.idNameList.unshift({id: 0, text: '请选择' + obj.attributeName}) | ||
139 | + }); | ||
140 | + | ||
141 | + return objArray; | ||
142 | +} | ||
143 | + | ||
136 | export default { | 144 | export default { |
137 | handleGoods, | 145 | handleGoods, |
138 | handleColorImage, | 146 | handleColorImage, |
139 | handleGoodsImage, | 147 | handleGoodsImage, |
140 | handleEditColorImage, | 148 | handleEditColorImage, |
141 | - getProduct | 149 | + getProduct, |
150 | + addNoneItem | ||
142 | }; | 151 | }; |
app/services/shop-category-service.js
0 → 100644
1 | +/** | ||
2 | + * Created by TaoHuang on 2017/5/9. | ||
3 | + */ | ||
4 | + | ||
5 | +import _ from 'lodash'; | ||
6 | +import request from 'axios'; | ||
7 | + | ||
8 | +const apiUrl = { | ||
9 | + categoryList: '/platform/getShopsCategoryList', | ||
10 | + updateCategory: '/platform/addOrUpdateShopsCategory', | ||
11 | + deleteCategory: '/platform/deleteShopsCategory', | ||
12 | + listProduct: '/platform/getAllProduct', | ||
13 | + listBindProduct: '/platform/getBindProduct', | ||
14 | + countBindProduct: '/platform/getBindProductCount', | ||
15 | + createBindProduct:'/platform/addCategoryLinkProduct', | ||
16 | + deleteBindProduct:'/platform/deleteCategoryLinkProduct' | ||
17 | +}; | ||
18 | + | ||
19 | +/** | ||
20 | + * 获得所有分类 | ||
21 | + * @param page | ||
22 | + */ | ||
23 | +function getCategoryList(page = 1) { | ||
24 | + return request.get(apiUrl.categoryList, { | ||
25 | + params: { | ||
26 | + page | ||
27 | + } | ||
28 | + }).then(res => res.data); | ||
29 | +} | ||
30 | + | ||
31 | +/** | ||
32 | + * 更新或者新建分类 | ||
33 | + * @param id 有id 时是更新,没有id 是新建 | ||
34 | + * @param name | ||
35 | + */ | ||
36 | +function updateCategoryName(id, name) { | ||
37 | + let data = { | ||
38 | + categoryName: name, | ||
39 | + }; | ||
40 | + | ||
41 | + if (id) { | ||
42 | + data.categoryId = id | ||
43 | + } | ||
44 | + | ||
45 | + return request.post(apiUrl.updateCategory, data).then(res => res.data); | ||
46 | +} | ||
47 | + | ||
48 | +/** | ||
49 | + * 删除一个分类 | ||
50 | + * @param id | ||
51 | + */ | ||
52 | +function deleteCategory(id) { | ||
53 | + return request.post(apiUrl.deleteCategory, { | ||
54 | + categoryId: id | ||
55 | + }).then(res => res.data); | ||
56 | +} | ||
57 | + | ||
58 | +/** | ||
59 | + * 列出该店铺中所有的商品 | ||
60 | + * @param categoryId | ||
61 | + * @param page | ||
62 | + * @param size | ||
63 | + */ | ||
64 | +function listProduct(page = 1, size = 20) { | ||
65 | + return request.post(apiUrl.listProduct, { page, size } ) | ||
66 | + .then(res => res.data); | ||
67 | +} | ||
68 | + | ||
69 | +/** | ||
70 | + * 列出分类下所有商品 | ||
71 | + * @param categoryId | ||
72 | + * @param page | ||
73 | + * @param size | ||
74 | + */ | ||
75 | +function listBindProduct(categoryId, page = 1, size = 20) { | ||
76 | + return request.post(apiUrl.listBindProduct, { categoryId, page, size }) | ||
77 | + .then(res => res.data); | ||
78 | +} | ||
79 | + | ||
80 | +/** | ||
81 | + * 获得分类下商品的个数 | ||
82 | + * @param categoryId | ||
83 | + */ | ||
84 | +function countBindProduct(categoryId) { | ||
85 | + return request.post(apiUrl.countBindProduct, { categoryId }) | ||
86 | + .then(res => res.data); | ||
87 | +} | ||
88 | + | ||
89 | +/** | ||
90 | + * 增加类目中关联的商品 | ||
91 | + * @param categoryId {string | array} | ||
92 | + * @param productSKN | ||
93 | + */ | ||
94 | +function createBindProduct(categoryId, productSKN) { | ||
95 | + if (_.isArray(productSKN)) { | ||
96 | + | ||
97 | + } | ||
98 | + return request.post(apiUrl.createBindProduct, { | ||
99 | + categoryId, productSKN: _.isArray(productSKN) ? productSKN.join(',') : productSKN | ||
100 | + }).then(res => res.data); | ||
101 | +} | ||
102 | + | ||
103 | +/** | ||
104 | + * 删除类目中关联的商品 | ||
105 | + * @param categoryId {string | array} | ||
106 | + * @param productSKN | ||
107 | + */ | ||
108 | +function deleteBindProduct(categoryId, productSKN) { | ||
109 | + return request.post(apiUrl.deleteBindProduct, { | ||
110 | + categoryId, productSKN: _.isArray(productSKN) ? productSKN.join(',') : productSKN | ||
111 | + }).then(res => res.data); | ||
112 | +} | ||
113 | + | ||
114 | +export default { | ||
115 | + getCategoryList, | ||
116 | + updateCategoryName, | ||
117 | + deleteCategory, | ||
118 | + listProduct, | ||
119 | + listBindProduct, | ||
120 | + countBindProduct, | ||
121 | + createBindProduct, | ||
122 | + deleteBindProduct | ||
123 | +} |
@@ -30,7 +30,15 @@ let domainApis = { | @@ -30,7 +30,15 @@ let domainApis = { | ||
30 | getShopDetailById: '/SellerShopController/getShopDetailById', | 30 | getShopDetailById: '/SellerShopController/getShopDetailById', |
31 | updateShopBaseInfoById: '/SellerShopController/updateShopBaseInfoById', | 31 | updateShopBaseInfoById: '/SellerShopController/updateShopBaseInfoById', |
32 | uploads: '/fileupload/uploads', | 32 | uploads: '/fileupload/uploads', |
33 | - findBusinessShopsDecorator: '/ShopsDecoratorRest/findBusinessShopsDecorator' | 33 | + findBusinessShopsDecorator: '/ShopsDecoratorRest/findBusinessShopsDecorator', |
34 | + getShopsCategoryList: '/SellerShopController/getShopsCategoryList', | ||
35 | + addOrUpdateShopsCategory: '/SellerShopController/addOrUpdateShopsCategory', | ||
36 | + deleteShopsCategory: '/SellerShopController/deleteShopsCategory', | ||
37 | + getAllProduct: '/SellerShopController/getAllProduct', | ||
38 | + getBindProductCount: '/SellerShopController/getBindProductCount', | ||
39 | + getBindProduct: '/SellerShopController/getBindProduct', | ||
40 | + addCategoryLinkProduct: '/SellerShopController/addCategoryLinkProduct', | ||
41 | + deleteCategoryLinkProduct: '/SellerShopController/deleteCategoryLinkProduct' | ||
34 | }, | 42 | }, |
35 | shop: { | 43 | shop: { |
36 | login: '/loginInter' | 44 | login: '/loginInter' |
-
Please register or login to post a comment