diff --git a/src/api/commodity.ts b/src/api/commodity.ts
index 77509dc..cf89f0a 100644
--- a/src/api/commodity.ts
+++ b/src/api/commodity.ts
@@ -16,6 +16,9 @@ const login = {
*/
getCategoryPropertyList: ['/category/property/list'], // 获取类目属性列表
updateCategoryProperty: ['/category/property/insertOrUpdate'], // 更新类目属性
+ deleteCategoryProperty: ['/category/property/delete'], // 删除类目属性
+ updateCategoryPropertyValue: ['/category/property/value/insertOrUpdate'], // 更新类目属性值
+ deleteCategoryPropertyValue: ['/category/property/value/delete'], // 删除类目属性值
/**
* app类目管理
*/
diff --git a/src/views/goods/category/index.vue b/src/views/goods/category/index.vue
index d3392f0..a83df88 100644
--- a/src/views/goods/category/index.vue
+++ b/src/views/goods/category/index.vue
@@ -46,7 +46,7 @@
@@ -56,7 +56,7 @@
size="small"
class="ml-2 !text-white"
@click="visibleProperty[data.id] = true"
- >新增属性新增属性值
@@ -78,7 +78,7 @@
size="small"
class="ml-2 !text-white"
@click="visiblePropertyType[data.id] = true"
- >新增属性类型新增属性
+ 删除属性
@@ -108,6 +115,7 @@
import { ElButton, ElMessage } from 'element-plus'
import type { RenderContentContext } from 'element-plus'
import { handleDragStart, handleDropFinish } from './use-drag'
+import { handleMessageBox } from '@/utils/page'
interface Tree {
id: number
@@ -230,42 +238,55 @@ 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
- })
+ await api.commodity.deleteCategoryPropertyValue.post!({ id })
data.vvPropertyValueList.splice(i, 1)
+ ElMessage.success('删除成功')
}
-// 新增回车确认
+// 新增属性值回车确认
const onAddPropertyValue = async (data: any = {}) => {
if (inputPropertyValue.value) {
- const params = {
+ const res = await api.commodity.updateCategoryPropertyValue.post!({
+ categoryPropertyId: data.id,
categoryPropertyValue: inputPropertyValue.value
- }
- const res = await api.commodity.updateCategoryProperty.post!({
- ...params
})
// testzc 将新增的数据返回到页面中
- data.vvPropertyValueList.push(params)
+ data.vvPropertyValueList.push(res.data)
}
visibleProperty.value[data.id] = false
inputPropertyValue.value = ''
+ ElMessage.success('新增成功')
}
+// 新增属性类型
const onAddPropertyType = async (data: any = {}) => {
+ console.warn('----- my data is data111: ', data)
if (inputPropertyTypeValue.value) {
- const params = {
- categoryPropertyName: inputPropertyTypeValue.value,
- vvCategoryPropertyDTOList: []
- }
const res = await api.commodity.updateCategoryProperty.post!({
- ...params
+ categoryId: data.categoryId,
+ categoryName: data.categoryName,
+ categoryPropertyName: inputPropertyTypeValue.value
})
+ console.warn('----- my data is data.id: ', data.id)
+ res.data.vvPropertyValueList = []
+ const newData = res.data
+ // testzc把新的数据塞到树里去
visiblePropertyType.value[data.id] = false
inputPropertyTypeValue.value = ''
+ ElMessage.success('新增成功')
}
}
+
+// 删除属性
+const onDeleteProperty = async (id: number) => {
+ handleMessageBox({
+ msg: `是否删除属性?`,
+ success: api.commodity.deleteCategoryProperty.post!,
+ data: { id }
+ }).then(() => {
+ // testzc 删除成功后,删除树中的数据
+ })
+}