diff --git a/src/api/commodity.ts b/src/api/commodity.ts
index 4cd0ba0..77509dc 100644
--- a/src/api/commodity.ts
+++ b/src/api/commodity.ts
@@ -10,6 +10,12 @@ const login = {
getCategoryList: ['/category/list'], // 获取类目列表
sortCategory: ['/category/sort'], // 排序
updateCategory: ['/category/insertOrUpdate'], // 插入或更新
+
+ /**
+ * 类目属性接口
+ */
+ getCategoryPropertyList: ['/category/property/list'], // 获取类目属性列表
+ updateCategoryProperty: ['/category/property/insertOrUpdate'], // 更新类目属性
/**
* app类目管理
*/
diff --git a/src/api/login.ts b/src/api/login.ts
index e4859e0..450215e 100644
--- a/src/api/login.ts
+++ b/src/api/login.ts
@@ -1,7 +1,7 @@
const login = {
apiGetUserRoleInfo: ['/user/getRoleUserInfo'], // 获取用户信息及权限
apiLogout: ['/login/out'], // 退出登录
- login: ['/admin/login'] // 登录
+ login: ['/login'] // 登录
}
export default login
diff --git a/src/permission.ts b/src/permission.ts
index b87b08a..d8714d5 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -17,7 +17,6 @@ router.beforeEach(async (to, from, next) => {
// 登录成功,跳转到首页
if (to.path === '/login') {
loaded = false
- router.removeRoute('errorpage')
next()
NProgress.done()
} else {
@@ -46,12 +45,10 @@ router.beforeEach(async (to, from, next) => {
if (whiteList.indexOf(to.path) !== -1) {
if (to.path === '/login') {
loaded = false
- router.removeRoute('errorpage')
}
next()
} else {
loaded = false
- router.removeRoute('errorpage')
next(`/login?redirect=${to.path}`)
NProgress.done()
}
diff --git a/src/views/goods/category/index.vue b/src/views/goods/category/index.vue
index 3937636..d3392f0 100644
--- a/src/views/goods/category/index.vue
+++ b/src/views/goods/category/index.vue
@@ -3,7 +3,6 @@
类目展示:
-
{{ data.name }}
-
+
+
{{ data.name }}
+
+
+
+ - {{ data.categoryPropertyName }}:
+ -
+
+ {{ child.categoryPropertyValue }}
+
+
+
+ 新增属性
+
+
+
+
+
+ 新增属性类型
+
+
+
+
+
+
+
编辑
添加
@@ -139,19 +201,70 @@ const defaultProps = {
// 获取类目列表
const handleLoadNode = (node, resolve) => {
- api.commodity.getCategoryList.post!
({ parentId: node.data.id || 0 }).then((res) => {
+ if (node.data.vvCategoryPropertyDTOList?.length) {
resolve(
- res.data.map((item: any) => ({
+ node.data.vvCategoryPropertyDTOList.map((item: any) => ({
...item,
- children: item.hasChild ? [] : undefined
+ hasChild: 0,
+ isProperty: 1
}))
)
- })
+ } else {
+ api.commodity.getCategoryList.post!({ parentId: node.data.id || 0 }).then((res) => {
+ resolve(
+ res.data.map((item: any) => ({
+ ...item,
+ hasChild: item.hasChild || !!item.vvCategoryPropertyDTOList?.length,
+ children: item.hasChild ? [] : undefined
+ }))
+ )
+ })
+ }
}
-// 点击类目
-const handleNodeClick = (node: Node, data: Data) => {
- console.log('click', node, data)
+const visibleProperty = ref>({})
+const inputPropertyValue = ref('')
+const visiblePropertyType = ref>({})
+const inputPropertyTypeValue = ref('')
+
+// 删除类目的属性
+const onClosePropertyValue = async (id: number, data: any) => {
+ const i = data.vvPropertyValueList.findIndex((item: any) => item.id === id)
+ await api.commodity.updateCategoryProperty.post!({
+ ...data.vvPropertyValueList[i],
+ isDelete: 1
+ })
+ data.vvPropertyValueList.splice(i, 1)
+}
+
+// 新增回车确认
+const onAddPropertyValue = async (data: any = {}) => {
+ if (inputPropertyValue.value) {
+ const params = {
+ categoryPropertyValue: inputPropertyValue.value
+ }
+ const res = await api.commodity.updateCategoryProperty.post!({
+ ...params
+ })
+ // testzc 将新增的数据返回到页面中
+ data.vvPropertyValueList.push(params)
+ }
+ visibleProperty.value[data.id] = false
+ inputPropertyValue.value = ''
+}
+
+const onAddPropertyType = async (data: any = {}) => {
+ if (inputPropertyTypeValue.value) {
+ const params = {
+ categoryPropertyName: inputPropertyTypeValue.value,
+ vvCategoryPropertyDTOList: []
+ }
+ const res = await api.commodity.updateCategoryProperty.post!({
+ ...params
+ })
+ visiblePropertyType.value[data.id] = false
+ inputPropertyTypeValue.value = ''
+ }
}
@@ -165,5 +278,10 @@ const handleNodeClick = (node: Node, data: Data) => {
font-size: 14px;
padding-right: 8px;
}
+ :deep(.el-tree) {
+ .el-tree-node__content {
+ height: auto;
+ }
+ }
}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index bcf4c2e..2db979b 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -19,13 +19,17 @@ const loginRules = reactive({
const handleLogin = () => {
loginFormRef.value.validate((valid) => {
if (valid) {
- user.onLogin(loginData).then((res) => {
- if (res.code === 200) {
+ api.login.login
+ .post(loginData)
+ .then((res) => {
+ if (res.code === 200) {
+ router.push({ path: '/home' })
+ }
+ })
+ .finally(() => {
+ user.onLogin({ tokenValue: '123', tokenName: '123' })
router.push({ path: '/home' })
- } else if (res.code === 6005) {
- dialogPasswordVisible.value = true
- }
- })
+ })
} else {
return false
}