diff --git a/src/api/product/productAttr.js b/src/api/product/productAttr.js index e8a9cd7..91a9c15 100644 --- a/src/api/product/productAttr.js +++ b/src/api/product/productAttr.js @@ -8,6 +8,13 @@ export default { data: page }) }, + classifyUpdate(page) { + return request({ + url: `/${service_name}/mallProductClassification/update`, + method: 'post', + data: page + }) + }, classifyGetByPage(page) { // 分页查询 return request({ url: `/${service_name}/mallProductClassification/getByPage`, diff --git a/src/components/Category/edit.vue b/src/components/Category/edit.vue index cc4f317..61b7e3e 100644 --- a/src/components/Category/edit.vue +++ b/src/components/Category/edit.vue @@ -43,6 +43,7 @@ export default { }, data() { return { + model:"add", loadingBtn: false, constants: [], editPram: { @@ -83,7 +84,7 @@ export default { addTreeListLabelForCasCard(arr, child) { }, handlerSubmit() { - productApi.classifySave(this.editPram,).then((result) => { + productApi[this.model](this.editPram).then((result) => { if(result.code==20000){ this.$parent.$parent.editDialogConfig.visible=false; this.$message.success("添加成功!"); diff --git a/src/permission.js b/src/permission.js index 5a2b61b..19dfeba 100644 --- a/src/permission.js +++ b/src/permission.js @@ -35,8 +35,9 @@ router.beforeEach(async (to, from, next) => { } else { try { await store.dispatch('user/getInfo') - const accessRoutes = await store.dispatch('permission/generateRoutes') - router.addRoutes(accessRoutes) + const accessRoutes = await store.dispatch('permission/generateRoutes'); + console.log(accessRoutes,"routerrouterrouter") + router.addRoutes(accessRoutes); next({ ...to, replace: true }) } catch (error) { await store.dispatch('user/resetToken') diff --git a/src/router/index.js b/src/router/index.js index 5ba3ecf..d43ff99 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -24,7 +24,7 @@ export const constantRoutes = [{ redirect: 'productList', meta: { title: '商品', icon: 'iconkongzhitai', affix: true }, children: [ - { + { path: '/productList', component: () => import('@/views/product/productList/index'), name: 'productList', diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 8bd6614..e54f196 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -7,7 +7,7 @@ import Layout from '@/layout' * @param routes asyncRoutes * @param auths */ -export function filterAsyncRouter(asyncRouterMap) { +export function filterAsyncRouter(asyncRouterMap) { return asyncRouterMap.filter(route => { if (route.component) { // Layout组件特殊处理 @@ -40,9 +40,9 @@ const actions = { generateRoutes({ commit, dispatch }) { return new Promise(resolve => { // 向后端请求路由数据 - getRouters().then(res => { - const accessedRoutes = filterAsyncRouter([]||res.data) - accessedRoutes.push({ path: '*', redirect: '/404', hidden: true }) + getRouters().then(res => { + const accessedRoutes = filterAsyncRouter(res.data); + accessedRoutes.push({ path: '*', redirect: '/404', hidden: true }); commit('SET_ROUTES', accessedRoutes) resolve(accessedRoutes) }) diff --git a/src/views/product/productClassify/index.vue b/src/views/product/productClassify/index.vue index a424509..37f2cfe 100644 --- a/src/views/product/productClassify/index.vue +++ b/src/views/product/productClassify/index.vue @@ -52,7 +52,9 @@ 设置 - 编辑 + + 编辑 + 新增下级 @@ -147,6 +149,7 @@ export default { // 添加 addClass(parent = null) { this.editDialogConfig.visible = true; + this.$refs.edit.model = "classifySave"; // this.$nextTick(()=>{ // this.$refs.edit.parent = parent; // }); @@ -158,15 +161,16 @@ export default { } }, // 编辑 - edit(row) { - console.log(row.level); + edit(row) { this.editDialogConfig.visible = true; this.$nextTick(()=>{ - let { level, icon, showFlag, categoryName, sort, parentId } = row; + let { level, icon, showFlag, categoryName, sort, parentId,id } = row; + console.log(this.tableData.find(item=>item==parentId),"categoryName") if (row.level == 1) { - this.$refs.edit.editPram = Object.assign(this.$refs.edit.editPram, { level, icon, showFlag, categoryName, sort, parentId }) + this.$refs.edit.model = "classifyUpdate"; + this.$refs.edit.editPram = Object.assign(this.$refs.edit.editPram, { level, icon, showFlag, categoryName, sort, parentId,id }) } else { - this.$refs.edit.editPram = Object.assign(this.$refs.edit.editPram, { level, icon, showFlag,parentCategoryName:this.tableData.find(item=>item==parentId).categoryName, categoryName, sort, parentId }) + this.$refs.edit.editPram = Object.assign(this.$refs.edit.editPram, { level, icon, showFlag,parentCategoryName:this.tableData.find(item=>item==parentId).categoryName, categoryName, sort, parentId,id }) } }) },