This commit is contained in:
木瓜一块八 2025-08-19 20:56:03 +08:00
parent d9647cf17e
commit 97d54661f0
2 changed files with 76 additions and 15 deletions

View File

@ -183,3 +183,21 @@ export function reqHomepageProductCategory(data){
data
})
}
//产品树更新 /product/homepage_category_tree_update.dspy
export function reqHomepageCategoryTreeUpdate(data){
return request({
url: '/product/homepage_category_tree_update.dspy',
method: 'post',
headers: { 'Content-Type': 'application/json' },
data
})
}
//产品树删除 /product/homepage_category_tree_delete.dspy
export function reqHomepageCategoryTreeDelete(data){
return request({
url: '/product/homepage_category_tree_delete.dspy',
method: 'post',
headers: { 'Content-Type': 'application/json' },
data
})
}

View File

@ -91,7 +91,7 @@
<!-- 操作按钮 -->
<el-form-item>
<el-button type="primary" @click="submitForm">保存</el-button>
<el-button type="primary" @click="submitForm">{{ isEdit ? '保存' : '新增' }}</el-button>
<el-button @click="resetForm">重置</el-button>
<el-button @click="drawer = false">取消</el-button>
</el-form-item>
@ -104,7 +104,7 @@
</div>
</template>
<script>
import { reqNcMatchMenu,reqAddProductMenu } from '@/api/ncmatch';
import { reqNcMatchMenu,reqAddProductMenu,reqHomepageCategoryTreeUpdate,reqHomepageCategoryTreeDelete } from '@/api/ncmatch';
export default {
name: 'menuMangement',
data() {
@ -116,6 +116,7 @@ export default {
direction: 'rtl',
labelPosition: 'right',
isEdit: false,
formLabelAlign: {
name: '',
icon: '',
@ -206,8 +207,16 @@ export default {
}).catch(() => {});
},
//
//
submitForm() {
// reqHomepageCategoryTreeUpdate({id:row.id,name:row.name,poriority:row.poriority,source:row.source,url_link:window.location.href}).then(res=>{
// if(res.status){
// this.$message.success('');
// this.getCategories();
// }else{
// this.$message.error(res.msg);
// }
// })
this.$refs.menuForm.validate((valid) => {
if (valid) {
// FormData
@ -243,8 +252,21 @@ export default {
console.log(`${key}:`, value);
}
// API
// API isEdit
if (this.isEdit) {
this.updateMenuData({
id: this.formLabelAlign.id,
name: this.formLabelAlign.name,
poriority: this.formLabelAlign.poriority,
source: this.formLabelAlign.source,
parentid: this.formLabelAlign.parentid,
url_link: window.location.href,
// icon
//
})
} else {
this.saveMenuData(formData);
}
} else {
this.$message.error('请检查表单信息!');
return false;
@ -252,7 +274,7 @@ export default {
});
},
//
//
saveMenuData(formData) {
// API
//
@ -274,6 +296,21 @@ export default {
// console.log('FormData');
},
//
updateMenuData(payload) {
reqHomepageCategoryTreeUpdate(payload).then(res => {
if (res.status) {
this.$message.success('保存成功!');
this.drawer = false;
this.getCategories();
} else {
this.$message.error(res.msg);
}
}).catch(error => {
this.$message.error('保存失败:' + error.message);
})
},
//
resetForm() {
this.$refs.menuForm.resetFields();
@ -283,6 +320,7 @@ export default {
addNode(row, type) {
this.drawer = true;
this.resetForm();
this.isEdit = false;
if (type === 'child') {
this.formLabelAlign.parentid = row.id;
} else if (type === 'sibling') {
@ -309,17 +347,22 @@ export default {
this.formLabelAlign = { ...row };
// iconFile
this.formLabelAlign.iconFile = null;
console.log('编辑节点:', row);
this.isEdit = true;
},
deleteNode(row) {
this.$confirm('确定要删除这个菜单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
console.log('删除节点:', row);
reqHomepageCategoryTreeDelete({id:row.id}).then(res=>{
if(res.status){
this.$message.success('删除成功!');
}).catch(() => {});
this.getCategories();
}else{
this.$message.error(res.msg);
}
})
},
buildTree(data, parentId = null) {
if (!Array.isArray(data)) {