Authored by htoooth

fix

... ... @@ -8,7 +8,7 @@
<div style="text-align: center">
<FilterItem :label="'商品分类名称'">
<Input >fdsa</Input>
<Input v-model="name"/>
</FilterItem>
</div>
... ... @@ -20,15 +20,27 @@
</template>
<script>
import service from 'shop-category-service';
export default {
data() {
return {
model: false,
modal_loading: false
modal_loading: false,
name: '',
id: ''
}
},
methods: {
show() {
update(c) {
this.reset();
this.model = true;
this.id = c.categoryId;
this.name = c.categoryName;
},
create() {
this.reset();
this.model = true;
},
close() {
... ... @@ -38,17 +50,20 @@
this.modal_loading = true;
this.save().then(() => {
setTimeout(() => {
this.modal_loading = false;
this.$emit('on-success');
this.close();
}, 2000)
})
},
cancel(){
this.close();
},
save() {
return service.updateCategoryName(this.id, this.name);
},
reset() {
this.name = '';
this.id = '';
}
}
}
... ...
... ... @@ -11,7 +11,7 @@
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
</LayoutList>
<EditName ref="showNameEdit"></EditName>
<EditName ref="showNameEdit" @on-success="onEditSuccess"></EditName>
</LayoutBody>
</template>
... ... @@ -19,30 +19,35 @@
import _ from 'lodash';
import {tableCols, pageData, tableData} from './store';
import components from './components';
import service from 'shop-category-service';
export default {
data() {
return {
self: this,
tableCols,
tableData,
tableData: [],
pageData,
}
},
mounted() {
this.getData();
},
methods: {
clickEditName(row) {
this.$refs.showNameEdit.show(row)
this.$refs.showNameEdit.update(row)
},
clickDelete(row) {
let _this = this;
this.$Modal.confirm({
title: '删除店铺商品分类',
content: '你确定 删除 商品分类 test 么?',
onOk: function() {
content: `你确定 删除 商品分类 ${row.categoryName} 么?`,
onOk() {
_this.deleteCategory(row.categoryId).then(() => {
_this.tableData.splice(_this.tableData.indexOf(row), 1)
});
},
onCancel: function() {
}
})
},
clickEditRelation(row) {
... ... @@ -50,12 +55,33 @@
this.$router.push({name: 'shop.category.edit', query: { categoryId }})
},
clickCreate() {
this.$refs.showNameEdit.create()
},
pageChange() {
},
getData() {
return service.getCategoryList(pageData.current).then((result) => {
if (result.code === 200) {
this.pageData.total = result.data.total;
this.pageData.current = result.data.currentPage;
this.tableData = result.data.rows;
}
});
},
deleteCategory(id) {
return service.deleteCategory(id).then((result) => {
if (result.code === 200) {
return Promise.resolve();
} else {
return Promise.reject();
}
});
},
onEditSuccess() {
console.log('ok');
this.getData();
}
},
components: {
...components
... ...
/**
* Created by TaoHuang on 2017/5/9.
*/
import _ from 'lodash';
import request from 'axios';
const apiUrl = {
categoryList: '/platform/getShopsCategoryList',
updateCategory: '/platform/addOrUpdateShopsCategory',
deleteCategory: '/platform/deleteShopsCategory'
};
function getCategoryList(page = 1) {
return request.get(apiUrl.categoryList, {
params: {
page
}
}).then(res => res.data);
}
/**
* 更新或者新建分类
* @param id 有id 时是更新,没有id 是新建
* @param name
* @returns {Promise.<TResult>|Promise<R2|R1>|Promise<R>}
*/
function updateCategoryName(id, name) {
let data = {
categoryName: name,
};
if (id) {
data.categoryId = id
}
return request.post(apiUrl.updateCategory, data).then(res => res.data);
}
function deleteCategory(id) {
return request.post(apiUrl.deleteCategory, {
categoryId: id
}).then(res => res.data);
}
export default {
getCategoryList,
updateCategoryName,
deleteCategory
}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,10 @@ let domainApis = {
getShopDetailById: '/SellerShopController/getShopDetailById',
updateShopBaseInfoById: '/SellerShopController/updateShopBaseInfoById',
uploads: '/fileupload/uploads',
findBusinessShopsDecorator: '/ShopsDecoratorRest/findBusinessShopsDecorator'
findBusinessShopsDecorator: '/ShopsDecoratorRest/findBusinessShopsDecorator',
getShopsCategoryList: '/SellerShopController/getShopsCategoryList',
addOrUpdateShopsCategory: '/SellerShopController/addOrUpdateShopsCategory',
deleteShopsCategory: '/SellerShopController/deleteShopsCategory'
},
shop: {
login: '/loginInter'
... ...