diff --git a/src/api/pms/attribute.ts b/src/api/pms/attribute.ts new file mode 100644 index 00000000..e81db3dc --- /dev/null +++ b/src/api/pms/attribute.ts @@ -0,0 +1,30 @@ +import request from '@/utils/request' + +/** + * 获取商品属性列表 + * + * @param params + */ +export function listAttributes(params:object) { + return request({ + url: '/mall-pms/api/v1/attributes', + method: 'get', + params: params + }) +} + + +/** + * 批量修改商品属性 + * + * @param data + */ +export function saveAttributeBatch(data:object) { + return request({ + url: '/mall-pms/api/v1/attributes/batch', + method: 'post', + data: data + }) +} + + diff --git a/src/views/pms/category/components/Attribute.vue b/src/views/pms/category/components/Attribute.vue index 0b479830..978fa9f2 100644 --- a/src/views/pms/category/components/Attribute.vue +++ b/src/views/pms/category/components/Attribute.vue @@ -1,13 +1,166 @@ - \ No newline at end of file + diff --git a/src/views/pms/category/components/Category.vue b/src/views/pms/category/components/Category.vue index 0893b7a8..47bd9e30 100644 --- a/src/views/pms/category/components/Category.vue +++ b/src/views/pms/category/components/Category.vue @@ -13,19 +13,24 @@ :accordion="true" @node-click="handleNodeClick" > - @@ -65,6 +70,7 @@ ref="dataFormRef" :model="formData" :rules="rules" + label-width="100px" > @@ -109,13 +115,13 @@ import {ElForm, ElMessage, ElMessageBox, ElTree} from "element-plus"; const emit = defineEmits(['categoryClick']) -const categoryTreeRef=ref(ElTree) -const dataFormRef=ref(ElForm) +const categoryTreeRef = ref(ElTree) +const dataFormRef = ref(ElForm) const state = reactive({ // 遮罩层 loading: true, - ids:[], + ids: [], queryParam: {}, categoryOptions: [] as Array, formData: { @@ -143,8 +149,7 @@ const state = reactive({ current: {} }) -const {loading, categoryOptions, formData, rules, dialog} = toRefs(state) - +const {loading, categoryOptions, formData, rules, dialog, parent} = toRefs(state) function handleQuery() { state.loading = true @@ -161,8 +166,8 @@ function handleQuery() { } -function handleNodeClick(row:any) { - const categoryTree=unref(categoryTreeRef) +function handleNodeClick(row: any) { + const categoryTree = unref(categoryTreeRef) const parentNode = categoryTree.getNode(row.parentId) state.parent = { @@ -197,7 +202,7 @@ function handleUpdate(row: any) { title: '修改商品分类', visible: true } - Object.assign( state.formData ,state.current) + Object.assign(state.formData, state.current) } function submitForm() { @@ -211,7 +216,12 @@ function submitForm() { handleQuery() }) } else { - addCategory(state.formData).then(response => { + const parentCategory= state.parent as any + console.log('parent',parentCategory) + state.formData.parentId = parentCategory.id + state.formData.level = parentCategory.level+1 + + addCategory(state.formData).then(() => { ElMessage.success('新增成功') state.dialog.visible = false handleQuery() @@ -232,10 +242,9 @@ function handleDelete(row: any) { ElMessage.success('删除成功') handleQuery() }) - }).catch(() => - ElMessage.info('已取消删除') - ) + }) } + function resetForm() { state.formData = { id: undefined, @@ -259,6 +268,10 @@ onMounted(() => {